/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <afs/stds.h>
#include <sys/types.h>
-#include <stdio.h>
#ifdef AFS_NT40_ENV
#include <winsock2.h>
#else
#include <afs/bubasics.h>
#include "bc.h"
#include "error_macros.h"
+#include "bucoord_internal.h"
+#include "bucoord_prototypes.h"
/* code to manage volumesets
* specific to the ubik database implementation
*/
-afs_int32 bc_UpdateVolumeSet();
extern struct bc_config *bc_globalConfig;
extern struct udbHandleS udbHandle;
extern char *whoami;
-extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cf,
- char *name);
+
+static int ListVolSet(struct bc_volumeSet *aset);
/* ------------------------------------
* command level routines
* parm 3 is volume regexp
*/
-bc_AddVolEntryCmd(as, arock)
- struct cmd_syndesc *as;
- char *arock;
+int
+bc_AddVolEntryCmd(struct cmd_syndesc *as, void *arock)
{
- register afs_int32 code;
+ int code;
char *volSetName, *serverName, *partitionName, *volRegExp;
udbClientTextP ctPtr;
struct bc_volumeSet *tset;
- afs_int32 flags;
volSetName = as->parms[0].items->data;
serverName = as->parms[1].items->data;
code = bc_UpdateVolumeSet();
if (code) {
- com_err(whoami, code, "; Can't retrieve volume sets");
+ afs_com_err(whoami, code, "; Can't retrieve volume sets");
return (code);
}
tset = bc_FindVolumeSet(bc_globalConfig, volSetName);
if (!tset) {
- com_err(whoami, code, "; Volume entry not added");
+ afs_com_err(whoami, code, "; Volume entry not added");
ERROR(code);
}
code = bc_UpdateVolumeSet();
if (code) {
- com_err(whoami, code, "; Can't retrieve volume sets");
+ afs_com_err(whoami, code, "; Can't retrieve volume sets");
return (code);
}
bc_AddVolumeItem(bc_globalConfig, volSetName, serverName,
partitionName, volRegExp);
if (code) {
- com_err(whoami, code, "; Volume entry not added");
+ afs_com_err(whoami, code, "; Volume entry not added");
ERROR(code);
}
if (!(tset->flags & VSFLAG_TEMPORARY)) {
code = bc_SaveVolumeSet();
if (code) {
- com_err(whoami, code, "Cannot save volume set file");
- com_err(whoami, 0,
+ afs_com_err(whoami, code, "Cannot save volume set file");
+ afs_com_err(whoami, 0,
"Changes are temporary - for this session only");
}
}
* name of new volume set
*/
-afs_int32
-bc_AddVolSetCmd(as, arock)
- struct cmd_syndesc *as;
- char *arock;
+int
+bc_AddVolSetCmd(struct cmd_syndesc *as, void *arock)
{
/* parm 0 is vol set name */
- register afs_int32 code;
- register struct cmd_item *ti;
+ int code;
+ struct cmd_item *ti;
udbClientTextP ctPtr;
afs_int32 flags;
code = bc_UpdateVolumeSet();
if (code) {
- com_err(whoami, code, "; Can't retrieve volume sets");
+ afs_com_err(whoami, code, "; Can't retrieve volume sets");
return (code);
}
flags);
if (code) {
if (code == -1)
- com_err(whoami, 0, "Volume set '%s' already exists", ti->data);
+ afs_com_err(whoami, 0, "Volume set '%s' already exists", ti->data);
else
- com_err(whoami, 0, "Unknown problem");
+ afs_com_err(whoami, 0, "Unknown problem");
} else if (!(flags & VSFLAG_TEMPORARY)) {
code = bc_SaveVolumeSet();
if (code) {
- com_err(whoami, code, "Cannot save new volume set file");
- com_err(whoami, 0,
+ afs_com_err(whoami, code, "Cannot save new volume set file");
+ afs_com_err(whoami, 0,
"Changes are temporary - for this session only");
}
}
* parm 1 is entry # (integer, 1 based)
*/
-afs_int32
-bc_DeleteVolEntryCmd(as, arock)
- struct cmd_syndesc *as;
- char *arock;
+int
+bc_DeleteVolEntryCmd(struct cmd_syndesc *as, void *arock)
{
- register afs_int32 code;
+ int code;
afs_int32 entry;
char *vsname;
udbClientTextP ctPtr;
code = bc_UpdateVolumeSet();
if (code) {
- com_err(whoami, code, "; Can't retrieve volume sets");
+ afs_com_err(whoami, code, "; Can't retrieve volume sets");
return (code);
}
tset = bc_FindVolumeSet(bc_globalConfig, vsname);
if (!tset) {
- com_err(whoami, 0, "No such volume set as '%s'", vsname);
+ afs_com_err(whoami, 0, "No such volume set as '%s'", vsname);
ERROR(code);
}
code = bc_UpdateVolumeSet();
if (code) {
- com_err(whoami, code, "; Can't retrieve volume sets");
+ afs_com_err(whoami, code, "; Can't retrieve volume sets");
return (code);
}
entry = bc_SafeATOI(as->parms[1].items->data);
if (entry < 0) {
- com_err(whoami, 0, "Can't parse entry number '%s' as decimal integer",
+ afs_com_err(whoami, 0, "Can't parse entry number '%s' as decimal integer",
as->parms[1].items->data);
ERROR(BC_BADARG);
}
code = bc_DeleteVolumeItem(bc_globalConfig, vsname, entry);
if (code) {
if (code == -1) {
- com_err(whoami, 0, "No such volume set as '%s'", vsname);
+ afs_com_err(whoami, 0, "No such volume set as '%s'", vsname);
} else if (code == -2) {
- com_err(whoami, 0,
+ afs_com_err(whoami, 0,
"There aren't %d volume items for this volume set",
entry);
- com_err(whoami, 0,
+ afs_com_err(whoami, 0,
"Use the 'listvolsets' command to examine the volume set");
}
ERROR(code);
printf("backup: deleted volume entry %d from volume set %s\n",
entry, vsname);
} else {
- com_err(whoami, code, "Cannot save volume set file");
- com_err(whoami, 0,
+ afs_com_err(whoami, code, "Cannot save volume set file");
+ afs_com_err(whoami, 0,
"Deletion is temporary - for this session only");
}
}
* name of volumeset to delete
*/
-afs_int32
-bc_DeleteVolSetCmd(as, arock)
- struct cmd_syndesc *as;
- char *arock;
+int
+bc_DeleteVolSetCmd(struct cmd_syndesc *as, void *arock)
{
/* parm 0 is vol set name */
- register afs_int32 code;
- register struct cmd_item *ti;
+ int code;
+ struct cmd_item *ti;
udbClientTextP ctPtr;
afs_int32 c;
afs_int32 flags, tosave = 0;
code = bc_UpdateVolumeSet();
if (code) {
- com_err(whoami, code, "; Can't retrieve volume sets");
+ afs_com_err(whoami, code, "; Can't retrieve volume sets");
return (code);
}
code = bc_DeleteVolumeSet(bc_globalConfig, ti->data, &flags);
if (code) {
if (code == -1)
- com_err(whoami, 0, "Can't find volume set '%s'", ti->data);
+ afs_com_err(whoami, 0, "Can't find volume set '%s'", ti->data);
else
- com_err(whoami, code,
+ afs_com_err(whoami, code,
"; Unknown problem deleting volume set '%s'",
ti->data);
} else {
if (c) {
if (!code)
code = c;
- com_err(whoami, c, "Cannot save updated volume set file");
- com_err(whoami, 0, "Deletion effective for this session only");
+ afs_com_err(whoami, c, "Cannot save updated volume set file");
+ afs_com_err(whoami, 0, "Deletion effective for this session only");
}
}
}
+static int
+ListVolSet(struct bc_volumeSet *aset)
+{
+ struct bc_volumeEntry *tentry;
+ int i;
+
+ printf("Volume set %s", aset->name);
+ if (aset->flags & VSFLAG_TEMPORARY)
+ printf(" (temporary)");
+ printf(":\n");
+ i = 1;
+ for (tentry = aset->ventries; tentry; tentry = tentry->next, i++) {
+ printf(" Entry %3d: server %s, partition %s, volumes: %s\n", i,
+ tentry->serverName, tentry->partname, tentry->name);
+ }
+ return 0;
+}
+
/* bc_ListVolSetCmd
* list out all the information (?) about a volumeset or about all
* volumesets
* optional parameter specifies a volumeset name
*/
-afs_int32
-bc_ListVolSetCmd(as, arock)
- struct cmd_syndesc *as;
- char *arock;
+int
+bc_ListVolSetCmd(struct cmd_syndesc *as, void *arock)
{
/* parm 0 is optional volume set to display */
- register struct bc_volumeSet *tset;
- register struct cmd_item *ti;
- afs_int32 code = 0;
+ struct bc_volumeSet *tset;
+ struct cmd_item *ti;
+ int code = 0;
code = bc_UpdateVolumeSet();
if (code) {
- com_err(whoami, code, "; Can't retrieve volume sets");
+ afs_com_err(whoami, code, "; Can't retrieve volume sets");
return (code);
}
/* figure out volume set to list */
- if (ti = as->parms[0].items) {
+ if ((ti = as->parms[0].items)) {
/* for each volume set in the command item list */
for (; ti; ti = ti->next) {
tset = bc_FindVolumeSet(bc_globalConfig, ti->data);
ListVolSet(tset);
printf("\n");
} else {
- com_err(whoami, 0, "Can't find volume set '%s'", ti->data);
+ afs_com_err(whoami, 0, "Can't find volume set '%s'", ti->data);
code = 1;
}
}
* ------------------------------------
*/
-bc_ClearVolumeSets()
+int
+bc_ClearVolumeSets(void)
{
- udbClientTextP ctPtr;
- struct udbHandleS *uhptr = &udbHandle;
struct bc_volumeSet *vsPtr, *vsNextPtr, **vsPrev;
- struct bc_volumeEntry *vePtr, *veNextPtr;
- afs_int32 code;
extern struct bc_config *bc_globalConfig;
return (0);
}
-static
-ListVolSet(aset)
- struct bc_volumeSet *aset;
-{
- struct bc_volumeEntry *tentry;
- int i;
-
- printf("Volume set %s", aset->name);
- if (aset->flags & VSFLAG_TEMPORARY)
- printf(" (temporary)");
- printf(":\n");
- i = 1;
- for (tentry = aset->ventries; tentry; tentry = tentry->next, i++) {
- printf(" Entry %3d: server %s, partition %s, volumes: %s\n", i,
- tentry->serverName, tentry->partname, tentry->name);
- }
- return 0;
-}
-
-
/* bc_ParseVolumeSet
* Open up the volume set configuration file as specified in our argument,
* then parse the file to set up our internal representation.
*/
int
-bc_ParseVolumeSet()
+bc_ParseVolumeSet(void)
{
- static char rn[] = "bc_ParseVolumeSet"; /*Routine name */
char tbuffer[1024]; /*Buffer for reading config file */
char vsname[256]; /*Volume set name */
char serverName[256]; /*Server name */
char partName[256]; /*Partition name */
- register struct bc_volumeEntry *tve; /*Ptr to generated volume spec struct */
- register struct bc_volumeSet *tvs; /*Ptr to volume set struct */
+ struct bc_volumeEntry *tve; /*Ptr to generated volume spec struct */
+ struct bc_volumeSet *tvs = NULL; /*Ptr to volume set struct */
struct bc_volumeEntry **ppve, *pve;
struct bc_volumeSet **ppvs, *pvs;
- register afs_int32 code; /*Generalized return code */
+ afs_int32 code; /*Generalized return code */
char *tp; /*Result of fgets(), malloc() */
int readHeader; /*Is next thing to read a volume set hdr? */
udbClientTextP ctPtr;
- register FILE *stream;
- struct bc_config *configPtr;
+ FILE *stream;
extern struct bc_config *bc_globalConfig;
ctPtr = &bc_globalConfig->configText[TB_VOLUMESET];
stream = ctPtr->textStream;
- configPtr = bc_globalConfig;
/*
* Open up the volume set configuration file, fail if it can't be done.
if ((code != 2)
|| (strcmp(serverName, "volumeset") != 0)
) {
- com_err(whoami, 0, "Bad volume header line: '%s'", tbuffer);
+ afs_com_err(whoami, 0, "Bad volume header line: '%s'", tbuffer);
return (-1);
}
tvs->next = (struct bc_volumeSet *)0;
} /*r */
else { /*e */
- /* Scan a volume name entry, which contains the server name,
+ /* Scan a volume name entry, which contains the server name,
* partition pattern, and volume pattern.
*/
code = sscanf(tbuffer, "%s %s %s", serverName, partName, vsname);
continue;
}
- /* The line just read in is a volume spec. Create a new volume
- * spec record, then get the rest of the information regarding
+ /* The line just read in is a volume spec. Create a new volume
+ * spec record, then get the rest of the information regarding
* the host, and stuff everything into place.
*/
tve = (struct bc_volumeEntry *)
malloc(sizeof(struct bc_volumeEntry));
if (!tve) {
- com_err(whoami, 0,
+ afs_com_err(whoami, 0,
"Can't malloc() a new volume spec record!");
return (-1);
}
memset(tve, 0, sizeof(*tve));
if (bc_ParseHost(serverName, &(tve->server)))
- com_err(whoami, 0, "Can't get required info on host '%s'",
+ afs_com_err(whoami, 0, "Can't get required info on host '%s'",
serverName);
/* The above code has filled in the server sockaddr, now fill in
*/
tve->serverName = (char *)malloc(strlen(serverName) + 1);
if (!tve->serverName) {
- com_err(whoami, 0,
+ afs_com_err(whoami, 0,
"Can't malloc() a new volume spec server name field!");
return (-1);
}
strcpy(tve->serverName, serverName);
tve->partname = (char *)malloc(strlen(partName) + 1);
if (!tve->partname) {
- com_err(whoami, 0,
+ afs_com_err(whoami, 0,
"Can't malloc() a new volume spec partition pattern field!");
return (-1);
}
strcpy(tve->partname, partName);
code = bc_GetPartitionID(partName, &tve->partition);
if (code) {
- com_err(whoami, 0, "Can't parse partition '%s'", partName);
+ afs_com_err(whoami, 0, "Can't parse partition '%s'", partName);
return -1;
}
tp = (char *)malloc(strlen(vsname) + 1);
if (!tp) {
- com_err(whoami, 0,
+ afs_com_err(whoami, 0,
"Can't malloc() a new volume spec volume pattern field!");
return (-1);
}
}
} /*forever loop */
- /* If we hit an EOF in the middle of a volume set record, we bitch and
+ /* If we hit an EOF in the middle of a volume set record, we bitch and
* moan.
*/
if (!readHeader)
* save the current volume set information to disk
*/
-bc_SaveVolumeSet()
+int
+bc_SaveVolumeSet(void)
{
- register afs_int32 code = 0;
- register struct bc_volumeSet *tset;
- register struct bc_volumeEntry *tentry;
+ afs_int32 code = 0;
+ struct bc_volumeSet *tset;
+ struct bc_volumeEntry *tentry;
udbClientTextP ctPtr;
- register FILE *stream;
- struct bc_config *configPtr;
+ FILE *stream;
extern struct bc_config *bc_globalConfig;
ctPtr = &bc_globalConfig->configText[TB_VOLUMESET];
stream = ctPtr->textStream;
- configPtr = bc_globalConfig;
/* must be locked */
if (ctPtr->lockHandle == 0)
}
afs_int32
-bc_UpdateVolumeSet()
+bc_UpdateVolumeSet(void)
{
- struct bc_dumpSchedule *dumpPtr, *nextDumpPtr;
struct udbHandleS *uhptr = &udbHandle;
udbClientTextP ctPtr;
afs_int32 code;
/* fetch the version number */
code =
- ubik_Call(BUDB_GetTextVersion, uhptr->uh_client, 0, ctPtr->textType,
+ ubik_BUDB_GetTextVersion(uhptr->uh_client, 0, ctPtr->textType,
&ctPtr->textVersion);
if (code)
ERROR(code);