#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/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"
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;
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;
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));
+ partition_get_p part = calloc(1, sizeof(partition_get_t));
/*
* Validate arguments
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;
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));
+ 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) {
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));
+ 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;
}
}
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));
+ 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;
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));
+ volume_get_p entry = calloc(1, sizeof(volume_get_t));
/*
* Validate arguments