#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
-RCSID
- ("$Header$");
+#include <roken.h>
-#include <afs/stds.h>
-#include <stdio.h>
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
#include <ctype.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#include <io.h>
-#else
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#endif
-#include "afs_vosAdmin.h"
-#include "../adminutil/afs_AdminInternal.h"
-#include <afs/afs_utilAdmin.h>
+
#include <afs/vlserver.h>
+#include <afs/afsint.h>
#include <afs/volser.h>
#include <afs/volint.h>
+
+#include "afs_vosAdmin.h"
+#include "../adminutil/afs_AdminInternal.h"
+
+/* File descriptors are HANDLE's on NT. The following typedef helps catch
+ * type errors. Duplicated from vol/ihandle.h
+ */
+#ifdef AFS_NT40_ENV
+typedef HANDLE FD_t;
+#else
+typedef int FD_t;
+#endif
+#define INVALID_FD ((FD_t)-1)
+
#include <afs/partition.h>
#include <rx/rx.h>
+#include <rx/rxstat.h>
+#include <afs/afs_utilAdmin.h>
#include "vosutils.h"
#include "vsprocs.h"
#include "lockprocs.h"
-extern int VL_GetAddrsU();
-
typedef struct file_server {
int begin_magic;
int is_valid;
size_t prefix_len = 0;
nbulkentries arrayEntries;
afs_int32 nentries = 0;
- register struct nvldbentry *entry;
+ struct nvldbentry *entry;
int i;
afs_int32 rw_volid, rw_server, rw_partition;
int previdx;
int equal = 0;
char backbuf[1024];
- memset((void *)&attr, 0, sizeof(attr));
+ memset(&attr, 0, sizeof(attr));
+ memset(&arrayEntries, 0, sizeof(arrayEntries));
/*
* Validate arguments
prefix_len = strlen(volumePrefix);
}
- memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
-
/*
* Get a list of all the volumes in the cell
*/
if (tst) {
goto fail_vos_PartitionGet;
}
- strcpy(partitionP->name, part_info.name);
- strcpy(partitionP->deviceName, part_info.devName);
+ strncpy(partitionP->name, part_info.name, VOS_MAX_PARTITION_NAME_LEN);
+ partitionP->name[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
+ strncpy(partitionP->deviceName, part_info.devName, VOS_MAX_PARTITION_NAME_LEN);
+ partitionP->deviceName[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
partitionP->lockFileDescriptor = part_info.lock_fd;
partitionP->totalSpace = part_info.minFree;
partitionP->totalFreeSpace = part_info.free;
int rc = 0;
afs_status_t tst = 0;
file_server_p f_server = (file_server_p) serverHandle;
- afs_admin_iterator_p iter =
- (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
- partition_get_p part =
- (partition_get_p) calloc(1, sizeof(partition_get_t));
+ afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
+ partition_get_p part = calloc(1, sizeof(partition_get_t));
/*
* Validate arguments
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
- file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
+ file_server_p f_server = malloc(sizeof(file_server_t));
int server_address;
struct rx_securityClass *sc[3];
int scIndex;
int ADMINAPI
vos_FileServerAddressChange(const void *cellHandle,
- vos_MessageCallBack_t callBack, int oldAddress,
- int newAddress, afs_status_p st)
+ vos_MessageCallBack_t callBack,
+ unsigned int oldAddress,
+ unsigned int newAddress, afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
}
tst =
- ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, oldAddress,
- newAddress);
+ ubik_VL_ChangeAddr(c_handle->vos, 0, oldAddress, newAddress);
if (tst) {
goto fail_vos_FileServerAddressChange;
}
int ADMINAPI
vos_FileServerAddressRemove(const void *cellHandle,
- vos_MessageCallBack_t callBack, int serverAddress,
+ vos_MessageCallBack_t callBack,
+ unsigned int serverAddress,
afs_status_p st)
{
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
- int dummyAddress = 0xffffffff;
+ unsigned int dummyAddress = 0xffffffff;
/*
* Validate arguments
}
tst =
- ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0, dummyAddress,
+ ubik_VL_ChangeAddr(c_handle->vos, 0, dummyAddress,
serverAddress);
if (tst) {
goto fail_vos_FileServerAddressRemove;
addr_multi.bulkaddrs_val = 0;
addr_multi.bulkaddrs_len = 0;
tst =
- ubik_Call(VL_GetAddrsU, serv->vldb, 0, &m_attrs, &m_uuid,
+ ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
&m_unique, &total_multi, &addr_multi);
if (tst) {
goto fail_GetServerRPC;
int rc = 0;
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
- afs_admin_iterator_p iter =
- (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
- server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
+ afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
+ server_get_p serv = calloc(1, sizeof(server_get_t));
struct VLCallBack unused;
serv->vldb = c_handle->vos;
tst =
- ubik_Call_New(VL_GetAddrs, c_handle->vos, 0, 0, 0, &unused,
+ ubik_VL_GetAddrs(c_handle->vos, 0, 0, 0, &unused,
&serv->total_addresses, &serv->addresses);
if (tst) {
int rc = 0;
afs_status_t tst = 0;
file_server_p f_server = (file_server_p) serverHandle;
- afs_admin_iterator_p iter =
- (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
- transaction_get_p tran =
- (transaction_get_p) calloc(1, sizeof(transaction_get_t));
+ afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
+ transaction_get_p tran = calloc(1, sizeof(transaction_get_t));
/*
dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
}
- strcpy(dest->name, source->name);
+ strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
+ dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
dest->volumeSites[i].serverAddress = source->serverNumber[i];
dest->volumeSites[i].serverPartition = source->serverPartition[i];
int ADMINAPI
vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
- const unsigned int *volumeId, const char *volumeName,
+ const unsigned int *volumeId, char *volumeName,
vos_vldbEntry_p vldbEntry, afs_status_p st)
{
int rc = 0;
if (!ValidateVolumeName(volumeName, &tst)) {
goto fail_vos_VLDBGet;
}
- if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
+ if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
goto fail_vos_VLDBGet;
}
} else {
- if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
+ if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
goto fail_vos_VLDBGet;
}
}
afs_status_t tst = 0;
afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
file_server_p f_server = (file_server_p) serverHandle;
- afs_admin_iterator_p iter =
- (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
- vldb_entry_get_p entry =
- (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
+ afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
+ vldb_entry_get_p entry = calloc(1, sizeof(vldb_entry_get_t));
struct VldbListByAttributes attr;
attr.Mask = 0;
*/
if (volumeId != NULL) {
- tst = ubik_Call(VL_DeleteEntry, c_handle->vos, 0, *volumeId, -1);
+ tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
if (tst != 0) {
goto fail_vos_VLDBEntryRemove;
}
}
for (i = 0; i < nentries; i++) {
- ubik_Call(VL_DeleteEntry, c_handle->vos, 0,
- entries.nbulkentries_val[i].volumeId[RWVOL]);
+ ubik_VL_DeleteEntry(c_handle->vos, 0,
+ entries.nbulkentries_val[i].volumeId[RWVOL], -1);
}
rc = 1;
goto fail_vos_VLDBEntryLock;
}
- tst = ubik_Call(VL_SetLock, c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
+ tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
if (tst != 0) {
goto fail_vos_VLDBEntryLock;
}
tst =
- ubik_Call(VL_ReleaseLock, c_handle->vos, 0, volumeId, -1,
+ ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
if (tst != 0) {
goto fail_vos_VLDBEntryUnlock;
int ADMINAPI
vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
vos_MessageCallBack_t callBack, unsigned int partition,
- const char *volumeName, unsigned int quota,
+ char *volumeName, unsigned int quota,
unsigned int *volumeId, afs_status_p st)
{
int rc = 0;
* Check that the volume doesn't already exist
*/
- if (VLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
+ if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
tst = ADMVOSVOLUMENAMEDUP;
goto fail_vos_VolumeCreate;
}
int ADMINAPI
vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
- unsigned int readWriteVolumeId, const char *newVolumeName,
+ unsigned int readWriteVolumeId, char *newVolumeName,
afs_status_p st)
{
int rc = 0;
* Retrieve the entry
*/
- if (!VLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
+ if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
goto fail_vos_VolumeRename;
}
int ADMINAPI
vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
vos_MessageCallBack_t callBack, unsigned int partition,
- unsigned int *volumeId, const char *volumeName,
+ unsigned int *volumeId, char *volumeName,
const char *dumpFile, vos_volumeRestoreType_t dumpType,
afs_status_p st)
{
*/
if (volumeId != NULL) {
- if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
+ if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
goto fail_vos_VolumeRestore;
}
volid = *volumeId;
close(fd);
}
- if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
+ if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
restoreflags = RV_FULLRST;
} else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
restoreflags = RV_FULLRST;
* user from seeing stale data from a previous call
*/
- memset(dest, 0, sizeof(dest));
+ memset(dest, 0, sizeof(*dest));
switch (source->status) {
case VOK:
*/
if (dest->status == VOS_OK) {
- strcpy(dest->name, source->name);
+ strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
+ dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
dest->id = source->volid;
if (source->type == 0) {
dest->type = VOS_READ_WRITE_VOLUME;
int rc = 0;
afs_status_t tst = 0;
file_server_p f_server = (file_server_p) serverHandle;
- afs_admin_iterator_p iter =
- (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
- volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
+ afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
+ volume_get_p entry = calloc(1, sizeof(volume_get_t));
/*
* Validate arguments
memset((void *)&tstatus, 0, sizeof(tstatus));
tstatus.dayUse = -1;
+ tstatus.spare2 = -1;
tstatus.maxquota = volumeQuota;
+
tst =
AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
if (tst) {
}
return rc;
}
+/*
+ * vos_VolumeGet2 - get information about a particular volume.
+ *
+ * PARAMETERS
+ *
+ * IN cellHandle - a previously opened cellHandle that corresponds
+ * to the cell where the volume exists.
+ *
+ * IN serverHandle - a previously opened serverHandle that corresponds
+ * to the server where the volume exists.
+ *
+ * IN callBack - a call back function pointer that may be called to report
+ * status information. Can be null.
+ *
+ * IN partition - the partition where the volume exists.
+ *
+ * IN volumeId - the volume id of the volume to be retrieved.
+ *
+ * OUT pinfo - upon successful completion, contains the information about the
+ * specified volume.
+ *
+ * LOCKS
+ *
+ * No locks are obtained or released by this function
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ */
+
+int ADMINAPI
+vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
+ vos_MessageCallBack_t callBack, unsigned int partition,
+ unsigned int volumeId, volintInfo* pinfo,
+ afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ file_server_p f_server = (file_server_p) serverHandle;
+ volintInfo *pinfo_=0;
+
+ /*
+ * Validate arguments
+ */
+
+ if (!IsValidServerHandle(f_server, &tst)) {
+ goto fail_vos_VolumeGet2;
+ }
+
+ if (partition > VOLMAXPARTS) {
+ tst = ADMVOSPARTITIONIDTOOLARGE;
+ goto fail_vos_VolumeGet2;
+ }
+
+ if (pinfo == NULL) {
+ tst = ADMVOSVOLUMEPNULL;
+ goto fail_vos_VolumeGet2;
+ }
+
+ /*
+ * Retrieve the information for the volume
+ */
+
+ if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
+ goto fail_vos_VolumeGet2;
+ }
+
+
+ rc = 1;
+
+ fail_vos_VolumeGet2:
+
+ if (pinfo_ != NULL) {
+ memcpy(pinfo,pinfo_,sizeof(volintInfo));
+ free(pinfo_);
+ }
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+
+/*
+ * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
+ *
+ * PARAMETERS
+ *
+ * IN cellHandle - a previously opened cellHandle that corresponds
+ * to the cell where the volume exists.
+ *
+ * IN serverHandle - a previously opened serverHandle that corresponds
+ * to the server where the volume exists.
+ *
+ * IN partition - the partition where the volume exists.
+ *
+ * IN volumeId - the volume id of the volume to be retrieved.
+ *
+ * LOCKS
+ *
+ * No locks are obtained or released by this function
+ *
+ * RETURN CODES
+ *
+ * Returns != 0 upon successful completion.
+ */
+
+int ADMINAPI
+vos_ClearVolUpdateCounter(const void *cellHandle,
+ const void *serverHandle,
+ unsigned int partition,
+ unsigned int volumeId,
+ afs_status_p st)
+{
+ int rc = 0;
+ afs_status_t tst = 0;
+ afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
+ file_server_p f_server = (file_server_p) serverHandle;
+ int ttid = 0;
+ int rcode = 0;
+ struct volintInfo tstatus;
+ int active_trans = 0;
+
+ /*
+ * Verify that the cellHandle is capable of making vos rpc's
+ */
+
+ if (!IsValidCellHandle(c_handle, &tst)) {
+ goto fail_vos_ClearVolUpdateCounter;
+ }
+
+ if (!IsValidServerHandle(f_server, &tst)) {
+ goto fail_vos_ClearVolUpdateCounter;
+ }
+
+ memset((void *)&tstatus, 0, sizeof(tstatus));
+ tstatus.maxquota = -1;
+ tstatus.dayUse = -1;
+ tstatus.creationDate = -1;
+ tstatus.updateDate = -1;
+ tstatus.flags = -1;
+ tstatus.spare0 = -1;
+ tstatus.spare1 = -1;
+ tstatus.spare2 = 0;
+ tstatus.spare3 = -1;
+
+ tst =
+ AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
+ if (tst) {
+ goto fail_vos_ClearVolUpdateCounter;
+ }
+ active_trans = 1;
+
+ tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
+ if (tst) {
+ goto fail_vos_ClearVolUpdateCounter;
+ }
+ rc = 1;
+
+ fail_vos_ClearVolUpdateCounter:
+
+ if (active_trans) {
+ afs_status_t tst2 = 0;
+ tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
+ if (tst2) {
+ if (tst == 0) {
+ tst = tst2;
+ rc = 0;
+ }
+ }
+ if (rcode) {
+ if (tst == 0) {
+ tst = rcode;
+ rc = 0;
+ }
+ }
+ }
+
+ if (st != NULL) {
+ *st = tst;
+ }
+ return rc;
+}
+