From 0dcdbf6dcda0814a5f24e84d4ef98ffc2279eff1 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Mon, 16 Mar 2009 13:19:47 +0000 Subject: [PATCH] bozo-prototypes-20090316 LICENSE IPL10 FIXES 124236 prototype the bozo directory --- src/bozo/bnode.c | 42 ++++--- src/bozo/bnode.p.h | 23 ++-- src/bozo/bos.c | 93 +++++++-------- src/bozo/bos_util.c | 8 +- src/bozo/bosoprocs.c | 242 ++++++++++++--------------------------- src/bozo/bosprototypes.h | 42 +++++++ src/bozo/bosserver.c | 25 ++-- src/bozo/cronbnodeops.c | 65 ++++++----- src/bozo/ezbnodeops.c | 65 +++++++---- src/bozo/fsbnodeops.c | 129 ++++++++++++--------- 10 files changed, 371 insertions(+), 363 deletions(-) diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c index 9d326847f..a68e3d023 100644 --- a/src/bozo/bnode.c +++ b/src/bozo/bnode.c @@ -33,6 +33,7 @@ RCSID #include /* signal(), kill(), wait(), etc. */ #include +#include #include #include #include @@ -60,6 +61,8 @@ static struct bnode_stats { extern char **environ; /* env structure */ #endif +int hdl_notifier(struct bnode_proc *tp); + /* Remember the name of the process, if any, that failed last */ static void RememberProcName(register struct bnode_proc *ap) @@ -113,7 +116,6 @@ SaveCore(register struct bnode *abnode, register struct bnode_proc if (code) { DIR *logdir; struct dirent *file; - char *p; size_t length; unsigned long pid; @@ -204,7 +206,7 @@ bnode_HasCore(register struct bnode *abnode) /* wait for all bnodes to stabilize */ int -bnode_WaitAll() +bnode_WaitAll(void) { register struct bnode *tb; register afs_int32 code; @@ -288,7 +290,7 @@ bnode_SetFileGoal(register struct bnode *abnode, register int agoal) /* apply a function to all bnodes in the system */ int -bnode_ApplyInstance(int (*aproc) (), char *arock) +bnode_ApplyInstance(int (*aproc) (struct bnode *tb, void *), void *arock) { register struct bnode *tb, *nb; register afs_int32 code; @@ -700,15 +702,15 @@ SendNotifierData(register int fd, register struct bnode_proc *tp) buf1 = "(null)"; (void)sprintf(bufp, "coreName: %s\n", buf1); bufp += strlen(bufp); - (void)sprintf(bufp, "pid: %ld\n", tp->pid); + (void)sprintf(bufp, "pid: %ld\n", (long int)tp->pid); bufp += strlen(bufp); - (void)sprintf(bufp, "lastExit: %ld\n", tp->lastExit); + (void)sprintf(bufp, "lastExit: %ld\n", (long int)tp->lastExit); bufp += strlen(bufp); #ifdef notdef - (void)sprintf(bufp, "lastSignal: %ld\n", tp->lastSignal); + (void)sprintf(bufp, "lastSignal: %ld\n", (long int)tp->lastSignal); bufp += strlen(bufp); #endif - (void)sprintf(bufp, "flags: %ld\n", tp->flags); + (void)sprintf(bufp, "flags: %ld\n", (long int)tp->flags); bufp += strlen(bufp); (void)sprintf(bufp, "END bnode_proc\n"); bufp += strlen(bufp); @@ -725,21 +727,21 @@ SendNotifierData(register int fd, register struct bnode_proc *tp) bufp += strlen(bufp); (void)sprintf(bufp, "name: %s\n", tb->name); bufp += strlen(bufp); - (void)sprintf(bufp, "rsTime: %ld\n", tb->rsTime); + (void)sprintf(bufp, "rsTime: %ld\n", (long int)tb->rsTime); bufp += strlen(bufp); - (void)sprintf(bufp, "rsCount: %ld\n", tb->rsCount); + (void)sprintf(bufp, "rsCount: %ld\n", (long int)tb->rsCount); bufp += strlen(bufp); - (void)sprintf(bufp, "procStartTime: %ld\n", tb->procStartTime); + (void)sprintf(bufp, "procStartTime: %ld\n", (long int)tb->procStartTime); bufp += strlen(bufp); - (void)sprintf(bufp, "procStarts: %ld\n", tb->procStarts); + (void)sprintf(bufp, "procStarts: %ld\n", (long int)tb->procStarts); bufp += strlen(bufp); - (void)sprintf(bufp, "lastAnyExit: %ld\n", tb->lastAnyExit); + (void)sprintf(bufp, "lastAnyExit: %ld\n", (long int)tb->lastAnyExit); bufp += strlen(bufp); - (void)sprintf(bufp, "lastErrorExit: %ld\n", tb->lastErrorExit); + (void)sprintf(bufp, "lastErrorExit: %ld\n", (long int)tb->lastErrorExit); bufp += strlen(bufp); - (void)sprintf(bufp, "errorCode: %ld\n", tb->errorCode); + (void)sprintf(bufp, "errorCode: %ld\n", (long int)tb->errorCode); bufp += strlen(bufp); - (void)sprintf(bufp, "errorSignal: %ld\n", tb->errorSignal); + (void)sprintf(bufp, "errorSignal: %ld\n", (long int)tb->errorSignal); bufp += strlen(bufp); /* (void) sprintf(bufp, "lastErrorName: %s\n", tb->lastErrorName); @@ -753,13 +755,14 @@ SendNotifierData(register int fd, register struct bnode_proc *tp) if (write(fd, buffer, len) < 0) { return -1; } + return 0; } int hdl_notifier(struct bnode_proc *tp) { #ifndef AFS_NT40_ENV /* NT notifier callout not yet implemented */ - int code, pid, status; + int code, pid; struct stat tstat; if (stat(tp->bnode->notifier, &tstat)) { @@ -827,12 +830,12 @@ bnode_Int(int asignal) /* intialize the whole system */ int -bnode_Init() +bnode_Init(void) { PROCESS junk; register afs_int32 code; struct sigaction newaction; - static initDone = 0; + static int initDone = 0; if (initDone) return 0; @@ -882,7 +885,7 @@ int bnode_ParseLine(char *aline, struct bnode_token **alist) { char tbuffer[256]; - register char *tptr; + register char *tptr = NULL; int inToken; struct bnode_token *first, *last; register struct bnode_token *ttok; @@ -928,6 +931,7 @@ bnode_ParseLine(char *aline, struct bnode_token **alist) return 0; } } + return 0; } #define MAXVARGS 128 diff --git a/src/bozo/bnode.p.h b/src/bozo/bnode.p.h index cb6246937..adbea7f3d 100644 --- a/src/bozo/bnode.p.h +++ b/src/bozo/bnode.p.h @@ -17,17 +17,20 @@ #define BOP_RESTARTP(bnode) ((*(bnode)->ops->restartp)((bnode))) #define BOP_HASCORE(bnode) ((*(bnode)->ops->hascore)((bnode))) +struct bnode_proc; + struct bnode_ops { - struct bnode *(*create) ( /* variable args */ ); - int (*timeout) ( /* bnode */ ); - int (*getstat) ( /* bnode, status */ ); - int (*setstat) ( /* bnode, status */ ); - int (*delete) ( /* bnode */ ); - int (*procexit) ( /* bnode, proc */ ); - int (*getstring) ( /* bnode, buffer, bufLen */ ); - int (*getparm) ( /* bnode, parmIndex, buffer, bufLen */ ); - int (*restartp) ( /* bnode */ ); - int (*hascore) ( /* bnode */ ); + struct bnode *(*create) ( char *, char *, char *, char *, char *, char *); + int (*timeout) ( struct bnode * ); + int (*getstat) ( struct bnode *, afs_int32 * ); + int (*setstat) ( struct bnode *, afs_int32 ); + int (*delete) ( struct bnode * ); + int (*procexit) ( struct bnode *, struct bnode_proc * ); + int (*getstring) ( struct bnode *, char *abuffer, afs_int32 alen ); + int (*getparm) ( struct bnode *, afs_int32 aindex, char *abuffer, + afs_int32 alen); + int (*restartp) ( struct bnode *); + int (*hascore) ( struct bnode *); }; struct bnode_type { diff --git a/src/bozo/bos.c b/src/bozo/bos.c index 5ecd8e85a..f3a63f963 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -45,9 +45,14 @@ RCSID #include #include #include +#include +#include +#include +#include -static IStatServer(); -static DoStat(); +static int IStatServer(register struct cmd_syndesc *as, int int32p); +static int DoStat(char *aname, register struct rx_connection *aconn, + int aint32p, int firstTime); #include "bosint.h" @@ -79,15 +84,14 @@ struct MRAFSSalvageParms { /* dummy routine for the audit work. It should do nothing since audits */ /* occur at the server level and bos is not a server. */ -osi_audit() +int osi_audit(void ) { return 0; } /* keep those lines small */ static char * -em(acode) - afs_int32 acode; +em(afs_int32 acode) { if (acode == -1) return "communications failure (-1)"; @@ -98,9 +102,10 @@ em(acode) } /* get partition id from a name */ +/* XXX - unused code - could be removed? */ +#if 0 static afs_int32 -GetPartitionID(aname) - char *aname; +GetPartitionID(char *aname) { register char tc; char ascii[3]; @@ -138,11 +143,11 @@ GetPartitionID(aname) return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26; } } +#endif /* make ctime easier to use */ static char * -DateOf(atime) - afs_int32 atime; +DateOf(afs_int32 atime) { static char tbuffer[30]; register char *tp; @@ -164,9 +169,7 @@ static int scIndex; * aencrypt is set if we want to encrypt the data on the wire. */ static struct rx_connection * -GetConn(as, aencrypt) - int aencrypt; - struct cmd_syndesc *as; +GetConn(struct cmd_syndesc *as, int aencrypt) { struct hostent *th; char *hostname; @@ -306,10 +309,8 @@ SetAuth(struct cmd_syndesc *as, void *arock) /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct * /usr/afs/bin/bar */ -static -ComputeDestDir(aname, adir, aresult, alen) - char *aname, *adir, *aresult; - afs_int32 alen; +static int +ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen) { register char *tp; @@ -327,10 +328,8 @@ ComputeDestDir(aname, adir, aresult, alen) } /* copy data from fd afd to rx call acall */ -static -CopyBytes(afd, acall) - int afd; - register struct rx_call *acall; +static int +CopyBytes(int afd, register struct rx_call *acall) { register afs_int32 code; register afs_int32 len; @@ -469,9 +468,7 @@ UnInstall(register struct cmd_syndesc *as, void *arock) } static afs_int32 -GetServerGoal(aconn, aname) - char *aname; - struct rx_connection *aconn; +GetServerGoal(struct rx_connection *aconn, char *aname) { char buffer[500]; char *tp; @@ -622,13 +619,13 @@ GetRestartCmd(struct cmd_syndesc *as, void *arock) hostp = as->parms[0].items->data; /* host name for messages */ tconn = GetConn(as, 0); - code = BOZO_GetRestartTime(tconn, 1, &generalTime); + code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime); if (code) { printf("bos: failed to retrieve restart information (%s)\n", em(code)); return code; } - code = BOZO_GetRestartTime(tconn, 2, &newBinaryTime); + code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime); if (code) { printf("bos: failed to retrieve restart information (%s)\n", em(code)); @@ -656,10 +653,10 @@ GetRestartCmd(struct cmd_syndesc *as, void *arock) static int SetRestartCmd(struct cmd_syndesc *as, void *arock) { - afs_int32 count; + afs_int32 count = 0; register afs_int32 code; struct ktime restartTime; - afs_int32 type; + afs_int32 type = 0 ; struct rx_connection *tconn; count = 0; @@ -679,13 +676,13 @@ SetRestartCmd(struct cmd_syndesc *as, void *arock) if (count == 0) type = 1; /* by default set general restart time */ - if (code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime)) { + if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) { printf("bos: failed to parse '%s' as periodic restart time(%s)\n", as->parms[1].items->data, em(code)); return code; } - code = BOZO_SetRestartTime(tconn, type, &restartTime); + code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime); if (code) { printf("bos: failed to set restart time at server (%s)\n", em(code)); return code; @@ -1113,7 +1110,7 @@ CreateServer(register struct cmd_syndesc *as, void *arock) } name = as->parms[1].items->data; type = as->parms[2].items->data; - if (ti = as->parms[4].items) { + if ((ti = as->parms[4].items)) { notifier = ti->data; } code = @@ -1360,13 +1357,14 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, if (mrafsParm->OptDontAskFS) strcat(tbuffer, " -DontAskFS"); if (mrafsParm->OptLogLevel) { - sprintf(pbuffer, " -LogLevel %ld", mrafsParm->OptLogLevel); + sprintf(pbuffer, " -LogLevel %ld", (long int) mrafsParm->OptLogLevel); strcat(tbuffer, pbuffer); } if (mrafsParm->OptRxDebug) strcat(tbuffer, " -rxdebug"); if (mrafsParm->OptResidencies) { - sprintf(pbuffer, " -Residencies %lu", mrafsParm->OptResidencies); + sprintf(pbuffer, " -Residencies %lu", + (long unsigned int) mrafsParm->OptResidencies); strcat(tbuffer, pbuffer); } } @@ -1489,18 +1487,18 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) tp = &tname[0]; /* find out whether fileserver is running demand attach fs */ - if (code = BOZO_GetInstanceParm(tconn, "dafs", 0, &tp) == 0) { + if ((code = BOZO_GetInstanceParm(tconn, "dafs", 0, &tp) == 0)) { dafs = 1; serviceName = "dafs"; /* Find out whether fileserver is running MR-AFS (has a scanner instance) */ /* XXX this should really be done some other way, potentially by RPC */ - if (code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0) + if ((code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0)) mrafs = 1; } else { serviceName = "fs"; /* Find out whether fileserver is running MR-AFS (has a scanner instance) */ /* XXX this should really be done some other way, potentially by RPC */ - if (code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0) + if ((code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0)) mrafs = 1; } @@ -1744,10 +1742,8 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) return 0; } -static -IStatServer(as, int32p) - int int32p; - register struct cmd_syndesc *as; +static int +IStatServer(register struct cmd_syndesc *as, int int32p) { register struct rx_connection *tconn; register struct cmd_item *ti; @@ -1761,12 +1757,11 @@ IStatServer(as, int32p) return 0; } -static -DoStat(aname, aconn, aint32p, firstTime) - IN char *aname; - IN register struct rx_connection *aconn; - IN int aint32p; - IN int firstTime; /* true iff first instance in cmd */ +static int +DoStat(IN char *aname, + IN register struct rx_connection *aconn, + IN int aint32p, + IN int firstTime) /* true iff first instance in cmd */ { afs_int32 temp; char buffer[500]; @@ -1913,8 +1908,7 @@ SetRestrict(struct cmd_syndesc *as, void *arock) #endif static void -add_std_args(ts) - register struct cmd_syndesc *ts; +add_std_args(register struct cmd_syndesc *ts) { cmd_Seek(ts, ADDPARMOFFSET); /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name"); @@ -1926,9 +1920,8 @@ add_std_args(ts) #include "AFS_component_version_number.c" -main(argc, argv) - int argc; - char **argv; +int +main(int argc, char **argv) { register afs_int32 code; register struct cmd_syndesc *ts; diff --git a/src/bozo/bos_util.c b/src/bozo/bos_util.c index c29b79790..1f2125acc 100644 --- a/src/bozo/bos_util.c +++ b/src/bozo/bos_util.c @@ -35,6 +35,9 @@ RCSID #include #include #include +#include +#include +#include int main(int argc, char **argv) @@ -99,7 +102,6 @@ main(int argc, char **argv) int kvno; register afs_int32 code; char buf[BUFSIZ], ver[BUFSIZ]; - char *tcell = NULL; if (argc != 3) { printf("bos_util adddes: usage is 'bos_util adddes \n"); @@ -167,7 +169,7 @@ main(int argc, char **argv) kvno = atoi(argv[2]); code = afsconf_DeleteKey(tdir, kvno); if (code) { - printf("bos_util: failed to delete key %d, (code %d)\n", kvno, + printf("bos_util: failed to delete key %ld, (code %d)\n", kvno, code); exit(1); } @@ -188,7 +190,7 @@ main(int argc, char **argv) memcpy(tbuffer, tkeys.key[i].key, 8); tbuffer[8] = 0; printf("kvno %4d: key is '%s' '", tkeys.key[i].kvno, tbuffer); - strcpy(x, (char *)tbuffer); + strcpy((char *)x, (char *)tbuffer); for (count = 0; count < 8; count++) printf("\\%03o", x[count]); printf("'\n"); diff --git a/src/bozo/bosoprocs.c b/src/bozo/bosoprocs.c index c1466da2b..63460c665 100644 --- a/src/bozo/bosoprocs.c +++ b/src/bozo/bosoprocs.c @@ -37,6 +37,7 @@ RCSID #include #include #include +#include #include #include "bnode.h" @@ -53,10 +54,7 @@ extern int bozo_isrestricted; #endif afs_int32 -SBOZO_GetRestartTime(acall, atype, aktime) - struct rx_call *acall; - afs_int32 atype; - struct bozo_netKTime *aktime; +SBOZO_GetRestartTime(struct rx_call *acall, afs_int32 atype, struct bozo_netKTime *aktime) { register afs_int32 code; @@ -79,10 +77,7 @@ SBOZO_GetRestartTime(acall, atype, aktime) } afs_int32 -SBOZO_SetRestartTime(acall, atype, aktime) - struct rx_call *acall; - afs_int32 atype; - struct bozo_netKTime *aktime; +SBOZO_SetRestartTime(struct rx_call *acall, afs_int32 atype, struct bozo_netKTime *aktime) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -122,9 +117,7 @@ SBOZO_SetRestartTime(acall, atype, aktime) } afs_int32 -SBOZO_Exec(acall, acmd) - struct rx_call *acall; - char *acmd; +SBOZO_Exec(struct rx_call *acall, char *acmd) { char caller[MAXKTCNAMELEN]; @@ -153,10 +146,8 @@ SBOZO_Exec(acall, acmd) } afs_int32 -SBOZO_GetDates(acall, aname, atime, abakTime, aoldTime) - struct rx_call *acall; - char *aname; - afs_int32 *atime, *abakTime, *aoldTime; +SBOZO_GetDates(struct rx_call *acall, char *aname, afs_int32 *atime, + afs_int32 *abakTime, afs_int32 *aoldTime) { struct stat tstat; char *strp; @@ -190,9 +181,7 @@ SBOZO_GetDates(acall, aname, atime, abakTime, aoldTime) } afs_int32 -SBOZO_UnInstall(acall, aname) - struct rx_call *acall; - register char *aname; +SBOZO_UnInstall(struct rx_call *acall, register char *aname) { char *filepath; char fpOld[AFSDIR_PATH_MAX], fpBak[AFSDIR_PATH_MAX]; @@ -288,12 +277,7 @@ SaveOldFiles(char *aname) } afs_int32 -SBOZO_Install(acall, aname, asize, mode, amtime) - struct rx_call *acall; - char *aname; - afs_int32 asize; - afs_int32 amtime; - afs_int32 mode; +SBOZO_Install(struct rx_call *acall, char *aname, afs_int32 asize, afs_int32 mode, afs_int32 amtime) { afs_int32 code; int fd; @@ -384,9 +368,7 @@ SBOZO_Install(acall, aname, asize, mode, amtime) } afs_int32 -SBOZO_SetCellName(acall, aname) - struct rx_call *acall; - char *aname; +SBOZO_SetCellName(struct rx_call *acall, char *aname) { struct afsconf_cell tcell; register afs_int32 code; @@ -426,9 +408,7 @@ SBOZO_SetCellName(acall, aname) } afs_int32 -SBOZO_GetCellName(acall, aname) - struct rx_call *acall; - char **aname; +SBOZO_GetCellName(struct rx_call *acall, char **aname) { register afs_int32 code; char tname[MAXCELLCHARS]; @@ -447,10 +427,7 @@ SBOZO_GetCellName(acall, aname) } afs_int32 -SBOZO_GetCellHost(acall, awhich, aname) - struct rx_call *acall; - afs_uint32 awhich; - char **aname; +SBOZO_GetCellHost(struct rx_call *acall, afs_uint32 awhich, char **aname) { register afs_int32 code; struct afsconf_cell tcell; @@ -487,9 +464,7 @@ SBOZO_GetCellHost(acall, awhich, aname) } afs_int32 -SBOZO_DeleteCellHost(acall, aname) - struct rx_call *acall; - char *aname; +SBOZO_DeleteCellHost(struct rx_call *acall, char *aname) { register afs_int32 code; struct afsconf_cell tcell; @@ -536,9 +511,7 @@ SBOZO_DeleteCellHost(acall, aname) } afs_int32 -SBOZO_AddCellHost(acall, aname) - struct rx_call *acall; - char *aname; +SBOZO_AddCellHost(struct rx_call *acall, char *aname) { register afs_int32 code; struct afsconf_cell tcell; @@ -619,17 +592,13 @@ SBOZO_AddCellHost(acall, aname) } afs_int32 -SBOZO_ListKeys(acall, an, akvno, akey, akeyinfo) - struct rx_call *acall; - afs_int32 an; - afs_int32 *akvno; - struct bozo_keyInfo *akeyinfo; - struct bozo_key *akey; +SBOZO_ListKeys(struct rx_call *acall, afs_int32 an, afs_int32 *akvno, + struct bozo_key *akey, struct bozo_keyInfo *akeyinfo) { struct afsconf_keys tkeys; register afs_int32 code; struct stat tstat; - int noauth; + int noauth = 0; char caller[MAXKTCNAMELEN]; rxkad_level enc_level = rxkad_clear; @@ -677,10 +646,7 @@ SBOZO_ListKeys(acall, an, akvno, akey, akeyinfo) } afs_int32 -SBOZO_AddKey(acall, an, akey) - struct rx_call *acall; - afs_int32 an; - struct bozo_key *akey; +SBOZO_AddKey(struct rx_call *acall, afs_int32 an, struct bozo_key *akey) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -709,9 +675,7 @@ SBOZO_AddKey(acall, an, akey) } afs_int32 -SBOZO_SetNoAuthFlag(acall, aflag) - register struct rx_call *acall; - afs_int32 aflag; +SBOZO_SetNoAuthFlag(register struct rx_call *acall, afs_int32 aflag) { register afs_int32 code = 0; char caller[MAXKTCNAMELEN]; @@ -731,9 +695,7 @@ SBOZO_SetNoAuthFlag(acall, aflag) } afs_int32 -SBOZO_DeleteKey(acall, an) - struct rx_call *acall; - afs_int32 an; +SBOZO_DeleteKey(struct rx_call *acall, afs_int32 an) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -754,10 +716,7 @@ SBOZO_DeleteKey(acall, an) afs_int32 -SBOZO_ListSUsers(acall, an, aname) - struct rx_call *acall; - afs_int32 an; - register char **aname; +SBOZO_ListSUsers(struct rx_call *acall, afs_int32 an, register char **aname) { register afs_int32 code; register char *tp; @@ -772,9 +731,7 @@ SBOZO_ListSUsers(acall, an, aname) } afs_int32 -SBOZO_AddSUser(acall, aname) - struct rx_call *acall; - char *aname; +SBOZO_AddSUser(struct rx_call *acall, char *aname) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -794,9 +751,7 @@ SBOZO_AddSUser(acall, aname) } afs_int32 -SBOZO_DeleteSUser(acall, aname) - struct rx_call *acall; - char *aname; +SBOZO_DeleteSUser(struct rx_call *acall, char *aname) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -817,12 +772,9 @@ SBOZO_DeleteSUser(acall, aname) } afs_int32 -SBOZO_CreateBnode(acall, atype, ainstance, ap1, ap2, ap3, ap4, ap5, notifier) - struct rx_call *acall; - char *atype; - char *ainstance; - char *ap1, *ap2, *ap3, *ap4, *ap5; - char *notifier; +SBOZO_CreateBnode(struct rx_call *acall, char *atype, char *ainstance, + char *ap1, char *ap2, char *ap3, char *ap4, char *ap5, + char *notifier) { struct bnode *tb; afs_int32 code; @@ -856,8 +808,7 @@ SBOZO_CreateBnode(acall, atype, ainstance, ap1, ap2, ap3, ap4, ap5, notifier) } afs_int32 -SBOZO_WaitAll(acall) - register struct rx_call *acall; +SBOZO_WaitAll(register struct rx_call *acall) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -878,9 +829,7 @@ SBOZO_WaitAll(acall) } afs_int32 -SBOZO_DeleteBnode(acall, ainstance) - struct rx_call *acall; - char *ainstance; +SBOZO_DeleteBnode(struct rx_call *acall, char *ainstance) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -906,10 +855,8 @@ SBOZO_DeleteBnode(acall, ainstance) return code; } -static -swproc(abnode, arock) - register struct bnode *abnode; - char *arock; +static int +swproc(register struct bnode *abnode, void *arock) { if (abnode->goal == BSTAT_NORMAL) return 0; /* this one's not shutting down */ @@ -920,10 +867,8 @@ swproc(abnode, arock) return 0; /* don't stop apply function early, no matter what */ } -static -stproc(abnode, arock) - struct bnode *abnode; - char *arock; +static int +stproc(struct bnode *abnode, void *arock) { if (abnode->fileGoal == BSTAT_SHUTDOWN) return 0; /* don't do these guys */ @@ -934,10 +879,8 @@ stproc(abnode, arock) return 0; } -static -sdproc(abnode, arock) - struct bnode *abnode; - char *arock; +static int +sdproc(struct bnode *abnode, void *arock) { bnode_Hold(abnode); bnode_SetStat(abnode, BSTAT_SHUTDOWN); @@ -947,8 +890,7 @@ sdproc(abnode, arock) /* shutdown and leave down */ afs_int32 -SBOZO_ShutdownAll(acall) - struct rx_call *acall; +SBOZO_ShutdownAll(struct rx_call *acall) { /* iterate over all bnodes, setting the status to temporarily disabled */ register afs_int32 code; @@ -971,8 +913,7 @@ SBOZO_ShutdownAll(acall) /* shutdown and restart */ afs_int32 -SBOZO_RestartAll(acall) - struct rx_call *acall; +SBOZO_RestartAll(struct rx_call *acall) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -1003,8 +944,7 @@ SBOZO_RestartAll(acall) } afs_int32 -SBOZO_ReBozo(acall) - register struct rx_call *acall; +SBOZO_ReBozo(struct rx_call *acall) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -1048,8 +988,7 @@ SBOZO_ReBozo(acall) /* make sure all are running */ afs_int32 -SBOZO_StartupAll(acall) - struct rx_call *acall; +SBOZO_StartupAll(struct rx_call *acall) { register afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -1068,9 +1007,7 @@ SBOZO_StartupAll(acall) } afs_int32 -SBOZO_Restart(acall, ainstance) - struct rx_call *acall; - register char *ainstance; +SBOZO_Restart(struct rx_call *acall, register char *ainstance) { register struct bnode *tb; register afs_int32 code; @@ -1105,10 +1042,7 @@ SBOZO_Restart(acall, ainstance) /* set temp status */ afs_int32 -SBOZO_SetTStatus(acall, ainstance, astatus) - struct rx_call *acall; - char *ainstance; - afs_int32 astatus; +SBOZO_SetTStatus(struct rx_call *acall, char *ainstance, afs_int32 astatus) { register struct bnode *tb; register afs_int32 code; @@ -1137,10 +1071,7 @@ SBOZO_SetTStatus(acall, ainstance, astatus) } afs_int32 -SBOZO_SetStatus(acall, ainstance, astatus) - struct rx_call *acall; - char *ainstance; - afs_int32 astatus; +SBOZO_SetStatus(struct rx_call *acall, char *ainstance, afs_int32 astatus) { register struct bnode *tb; register afs_int32 code; @@ -1170,11 +1101,8 @@ SBOZO_SetStatus(acall, ainstance, astatus) } afs_int32 -SBOZO_GetStatus(acall, ainstance, astat, astatDescr) - struct rx_call *acall; - char *ainstance; - afs_int32 *astat; - char **astatDescr; +SBOZO_GetStatus(struct rx_call *acall, char *ainstance, afs_int32 *astat, + char **astatDescr) { register struct bnode *tb; register afs_int32 code; @@ -1210,11 +1138,11 @@ struct eidata { int counter; }; -static -eifunc(abnode, arock) - struct bnode *abnode; - struct eidata *arock; +static int +eifunc(struct bnode *abnode, void *param) { + struct eidata *arock = (struct eidata *)param; + if (arock->counter-- == 0) { /* done */ strcpy(arock->iname, abnode->name); @@ -1225,22 +1153,18 @@ eifunc(abnode, arock) } } -static -ZapFile(adir, aname) - register char *adir; - register char *aname; +static int +ZapFile(const char *adir, const char *aname) { char tbuffer[256]; - strcpy(tbuffer, adir); - strcat(tbuffer, "/"); - strcat(tbuffer, aname); - return unlink(tbuffer); + if (snprintf(tbuffer, 256, "%s/%s", adir, aname)<256) + return unlink(tbuffer); + else + return -1; } afs_int32 -SBOZO_Prune(acall, aflags) - struct rx_call *acall; - afs_int32 aflags; +SBOZO_Prune(struct rx_call *acall, afs_int32 aflags) { register afs_int32 code; DIR *dirp; @@ -1297,10 +1221,8 @@ SBOZO_Prune(acall, aflags) } afs_int32 -SBOZO_EnumerateInstance(acall, anum, ainstance) - struct rx_call *acall; - afs_int32 anum; - char **ainstance; +SBOZO_EnumerateInstance(struct rx_call *acall, afs_int32 anum, + char **ainstance) { struct eidata tdata; @@ -1337,7 +1259,7 @@ int bozo_nbosEntryStats = * The other fields in the struct are however, statically initialized. */ int -initBosEntryStats() +initBosEntryStats(void) { bozo_bosEntryStats[0].path = AFSDIR_SERVER_AFS_DIRPATH; bozo_bosEntryStats[1].path = AFSDIR_SERVER_ETC_DIRPATH; @@ -1357,8 +1279,7 @@ initBosEntryStats() * read. */ static int -StatEachEntry(stats) - IN struct bozo_bosEntryStats *stats; +StatEachEntry(IN struct bozo_bosEntryStats *stats) { struct stat info; if (stat(stats->path, &info)) { @@ -1385,7 +1306,7 @@ StatEachEntry(stats) * this check more often than every 5 seconds. */ int -DirAccessOK() +DirAccessOK(void) { #ifdef AFS_NT40_ENV /* underlying filesystem may not support directory protection */ @@ -1425,8 +1346,7 @@ DirAccessOK() } int -GetRequiredDirPerm(path) - IN char *path; +GetRequiredDirPerm(const char *path) { int i; for (i = 0; i < bozo_nbosEntryStats; i++) @@ -1436,11 +1356,10 @@ GetRequiredDirPerm(path) } afs_int32 -SBOZO_GetInstanceInfo(acall, ainstance, atype, astatus) - IN struct rx_call *acall; - IN char *ainstance; - OUT char **atype; - OUT struct bozo_status *astatus; +SBOZO_GetInstanceInfo(IN struct rx_call *acall, + IN char *ainstance, + OUT char **atype, + OUT struct bozo_status *astatus) { register struct bnode *tb; @@ -1472,11 +1391,10 @@ SBOZO_GetInstanceInfo(acall, ainstance, atype, astatus) } afs_int32 -SBOZO_GetInstanceParm(acall, ainstance, anum, aparm) - struct rx_call *acall; - char *ainstance; - afs_int32 anum; - char **aparm; +SBOZO_GetInstanceParm(struct rx_call *acall, + char *ainstance, + afs_int32 anum, + char **aparm) { register struct bnode *tb; register char *tp; @@ -1504,9 +1422,7 @@ SBOZO_GetInstanceParm(acall, ainstance, anum, aparm) } afs_int32 -SBOZO_GetLog(acall, aname) - register struct rx_call *acall; - char *aname; +SBOZO_GetLog(register struct rx_call *acall, char *aname) { register afs_int32 code; FILE *tfile; @@ -1572,10 +1488,8 @@ SBOZO_GetLog(acall, aname) } afs_int32 -SBOZO_GetInstanceStrings(acall, abnodeName, as1, as2, as3, as4) - struct rx_call *acall; - char *abnodeName; - char **as1, **as2, **as3, **as4; +SBOZO_GetInstanceStrings(struct rx_call *acall, char *abnodeName, + char **as1, char **as2, char **as3, char **as4) { register struct bnode *tb; @@ -1607,18 +1521,14 @@ SBOZO_GetInstanceStrings(acall, abnodeName, as1, as2, as3, as4) #ifdef BOS_RESTRICTED_MODE afs_int32 -SBOZO_GetRestrictedMode(acall, arestmode) - struct rx_call *acall; - afs_int32 *arestmode; +SBOZO_GetRestrictedMode(struct rx_call *acall, afs_int32 *arestmode) { *arestmode = bozo_isrestricted; return 0; } afs_int32 -SBOZO_SetRestrictedMode(acall, arestmode) - struct rx_call *acall; - afs_int32 arestmode; +SBOZO_SetRestrictedMode(struct rx_call *acall, afs_int32 arestmode) { afs_int32 code; char caller[MAXKTCNAMELEN]; @@ -1639,17 +1549,13 @@ SBOZO_SetRestrictedMode(acall, arestmode) } #else afs_int32 -SBOZO_GetRestrictedMode(acall, arestmode) - struct rx_call *acall; - afs_int32 *arestmode; +SBOZO_GetRestrictedMode(struct rx_call *acall, afs_int32 *arestmode) { return RXGEN_OPCODE; } afs_int32 -SBOZO_SetRestrictedMode(acall, arestmode) - struct rx_call *acall; - afs_int32 arestmode; +SBOZO_SetRestrictedMode(struct rx_call *acall, afs_int32 arestmode) { return RXGEN_OPCODE; } diff --git a/src/bozo/bosprototypes.h b/src/bozo/bosprototypes.h index 7275737f8..15abe3c5b 100644 --- a/src/bozo/bosprototypes.h +++ b/src/bozo/bosprototypes.h @@ -10,8 +10,50 @@ #ifndef _BOSPROTOTYPES_H_ #define _BOSPROTOTYPES_H_ +/* bnode.c */ +int bnode_CoreName(struct bnode *abnode, char *acoreName, char *abuffer); +int bnode_GetString(struct bnode *abnode, char *abuffer, afs_int32 alen); +int bnode_GetParm(struct bnode *abnode, afs_int32 aindex, char *abuffer, + afs_int32 alen); +int bnode_GetStat(struct bnode *abnode, afs_int32 * astatus); +int bnode_RestartP(struct bnode *abnode); +int bnode_HasCore(struct bnode *abnode); +int bnode_WaitAll(void); +int bnode_SetGoal(struct bnode *abnode, int agoal); +int bnode_SetFileGoal(struct bnode *abnode, int agoal); +int bnode_ApplyInstance(int (*aproc)(struct bnode *, void *), void *arock); +int bnode_Register(char *, struct bnode_ops *, int); +int bnode_DeleteName(char *); +int bnode_Hold(struct bnode *); +int bnode_Release(struct bnode *); +int bnode_Delete(struct bnode *); +int bnode_PendingTimeout(struct bnode *abnode); +void bnode_Int(int asignal); +int bnode_Init(void); +int bnode_FreeTokens(struct bnode_token *alist); +int bnode_ParseLine(char *aline, struct bnode_token **alist); +int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, + struct bnode_proc **aproc); +int bnode_StopProc(struct bnode_proc *aproc, int asignal); +int bnode_Deactivate(struct bnode *abnode); + +/* bosint.ss.c */ +struct rx_call; +int BOZO_ExecuteRequest(register struct rx_call *z_call); + /* bosserver.c */ void bozo_Log(char *format, ... ); +int bozo_ReBozo(void); +int WriteBozoFile(char *aname); + +/* bosoprocs.c */ +int GetRequiredDirPerm(const char *path); +void *bozo_ShutdownAndExit(void *arock /* really int asignal */); +int initBosEntryStats(void); +int DirAccessOK(void); + +/* fsbnodeops.c */ +char *copystr(char *a); /* bosoprocs.c */ void *bozo_ShutdownAndExit(void *arock /* really int asignal */); diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index 91ddf1783..554c58ff5 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -40,18 +40,20 @@ RCSID #include "bnode.h" #include "bosprototypes.h" #include +#include +#include #include #include #include #include #include /* signal(), kill(), wait(), etc. */ +#include +#include #if defined(AFS_SGI_ENV) #include #endif #define BOZO_LWP_STACKSIZE 16000 -extern int BOZO_ExecuteRequest(); -extern int RXSTATS_ExecuteRequest(); extern struct bnode_ops fsbnode_ops, dafsbnode_ops, ezbnode_ops, cronbnode_ops; struct afsconf_dir *bozo_confdir = 0; /* bozo configuration dir */ @@ -102,7 +104,7 @@ bozo_rxstat_userok(struct rx_call *call) /* restart bozo process */ int -bozo_ReBozo() +bozo_ReBozo(void) { #ifdef AFS_NT40_ENV /* exit with restart code; SCM integrator process will restart bosserver */ @@ -187,7 +189,7 @@ MakeDir(const char *adir) /* create all the bozo dirs */ static int -CreateDirs() +CreateDirs(void) { if ((!strncmp (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH, @@ -239,9 +241,10 @@ StripLine(register char *abuffer) } /* write one bnode's worth of entry into the file */ -static -bzwrite(register struct bnode *abnode, register struct bztemp *at) +static int +bzwrite(register struct bnode *abnode, void *arock) { + register struct bztemp *at = (struct bztemp *)arock; register int i; char tbuffer[BOZO_BSSIZE]; register afs_int32 code; @@ -494,7 +497,7 @@ WriteBozoFile(char *aname) } static int -bdrestart(register struct bnode *abnode, char *arock) +bdrestart(register struct bnode *abnode, void *arock) { register afs_int32 code; @@ -555,7 +558,7 @@ BozoDaemon(void *unused) #ifdef AFS_AIX32_ENV static int -tweak_config() +tweak_config(void) { FILE *f; char c[80]; @@ -833,7 +836,7 @@ main(int argc, char **argv, char **envp) rxMaxMTU = atoi(argv[++code]); if ((rxMaxMTU < RX_MIN_PACKET_SIZE) || (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) { - printf("rxMaxMTU %d invalid; must be between %d-%d\n", + printf("rxMaxMTU %d invalid; must be between %d-%lu\n", rxMaxMTU, RX_MIN_PACKET_SIZE, RX_MAX_PACKET_DATA_SIZE); exit(1); @@ -946,7 +949,7 @@ main(int argc, char **argv, char **envp) } code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1, - (void *) /*parm */ 0, "bozo-the-clown", + /* param */ NULL , "bozo-the-clown", &bozo_pid); /* try to read the key from the config file */ @@ -985,7 +988,7 @@ main(int argc, char **argv, char **envp) } /* read init file, starting up programs */ - if (code = ReadBozoFile(0)) { + if ((code = ReadBozoFile(0))) { bozo_Log ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n", code, AFSDIR_SERVER_BOZCONF_FILEPATH); diff --git a/src/bozo/cronbnodeops.c b/src/bozo/cronbnodeops.c index 6c80b7184..d93b40b5b 100644 --- a/src/bozo/cronbnodeops.c +++ b/src/bozo/cronbnodeops.c @@ -32,10 +32,16 @@ RCSID #include "bnode.h" #include "bosprototypes.h" -static int cron_timeout(), cron_getstat(), cron_setstat(), cron_delete(); -static int cron_procexit(), cron_getstring(), cron_getparm(), cron_restartp(); -static int cron_hascore(); -struct bnode *cron_create(); +struct bnode *cron_create(char *, char *, char *, char *, char *, char *); +static int cron_hascore(struct bnode *bnode); +static int cron_restartp(struct bnode *bnode); +static int cron_delete(struct bnode *bnode); +static int cron_timeout(struct bnode *bnode); +static int cron_getstat(struct bnode *bnode, afs_int32 *status); +static int cron_setstat(struct bnode *bnode, afs_int32 status); +static int cron_procexit(struct bnode *bnode, struct bnode_proc *proc); +static int cron_getstring(struct bnode *bnode, char *abuffer, afs_int32 alen); +static int cron_getparm(struct bnode *bnode, afs_int32, char *, afs_int32); #define SDTIME 60 /* time in seconds given to a process to evaporate */ @@ -69,7 +75,7 @@ struct cronbnode { }; static int -cron_hascore(register struct ezbnode *abnode) +cron_hascore(struct bnode *abnode) { char tbuffer[256]; @@ -93,7 +99,7 @@ ScheduleCronBnode(register struct cronbnode *abnode) /* If this proc is shutdown, tell bproc() to no longer run this job */ if (abnode->b.goal == BSTAT_SHUTDOWN) { - bnode_SetTimeout(abnode, 0); + bnode_SetTimeout((struct bnode *)abnode, 0); return 0; } @@ -102,14 +108,14 @@ ScheduleCronBnode(register struct cronbnode *abnode) /* one shot */ if (abnode->everRun) { /* once is enough */ - bnode_Delete(abnode); + bnode_Delete((struct bnode *)abnode); return 0; } /* otherwise start it */ if (!abnode->running) { /* start up */ abnode->lastStart = FT_ApproxTime(); - code = bnode_NewProc(abnode, abnode->command, NULL, &tp); + code = bnode_NewProc((struct bnode *)abnode, abnode->command, NULL, &tp); if (code) { bozo_Log("cron bnode %s failed to start (code %d)\n", abnode->b.name, code); @@ -128,20 +134,21 @@ ScheduleCronBnode(register struct cronbnode *abnode) temp = abnode->when - FT_ApproxTime(); if (temp < 1) temp = 1; /* temp is when to start dude */ - bnode_SetTimeout(abnode, temp); + bnode_SetTimeout((struct bnode *)abnode, temp); } return 0; } static int -cron_restartp(register struct cronbnode *abnode) +cron_restartp(struct bnode *abnode) { return 0; } static int -cron_delete(struct cronbnode *abnode) +cron_delete(struct bnode *bn) { + struct cronbnode *abnode = (struct cronbnode *)bn; free(abnode->command); free(abnode->whenString); free(abnode); @@ -149,12 +156,12 @@ cron_delete(struct cronbnode *abnode) } struct bnode * -cron_create(char *ainstance, char *acommand, char *awhen) +cron_create(char *ainstance, char *acommand, char *awhen, + char *unused1, char *unused2, char *unused3) { struct cronbnode *te; afs_int32 code; char *cmdpath; - extern char *copystr(); /* construct local path from canonical (wire-format) path */ if (ConstructLocalBinPath(acommand, &cmdpath)) { @@ -165,7 +172,7 @@ cron_create(char *ainstance, char *acommand, char *awhen) te = (struct cronbnode *)malloc(sizeof(struct cronbnode)); memset(te, 0, sizeof(struct cronbnode)); code = ktime_ParsePeriodic(awhen, &te->whenToRun); - if ((code < 0) || (bnode_InitBnode(te, &cronbnode_ops, ainstance) != 0)) { + if ((code < 0) || (bnode_InitBnode((struct bnode *)te, &cronbnode_ops, ainstance) != 0)) { free(te); free(cmdpath); return NULL; @@ -179,8 +186,9 @@ cron_create(char *ainstance, char *acommand, char *awhen) /* called to SIGKILL a process if it doesn't terminate normally. In cron, also start up a process if it is time and not already running */ static int -cron_timeout(struct cronbnode *abnode) +cron_timeout(struct bnode *bn) { + struct cronbnode *abnode = (struct cronbnode *)bn; register afs_int32 temp; register afs_int32 code; struct bnode_proc *tp; @@ -191,8 +199,8 @@ cron_timeout(struct cronbnode *abnode) /* not running, perhaps we should start it */ if (FT_ApproxTime() >= abnode->when) { abnode->lastStart = FT_ApproxTime(); - bnode_SetTimeout(abnode, 0); - code = bnode_NewProc(abnode, abnode->command, NULL, &tp); + bnode_SetTimeout((struct bnode *)abnode, 0); + code = bnode_NewProc((struct bnode *)abnode, abnode->command, NULL, &tp); if (code) { bozo_Log("cron failed to start bnode %s (code %d)\n", abnode->b.name, code); @@ -206,7 +214,7 @@ cron_timeout(struct cronbnode *abnode) temp = abnode->when - FT_ApproxTime(); if (temp < 1) temp = 1; - bnode_SetTimeout(abnode, temp); + bnode_SetTimeout((struct bnode *)abnode, temp); } } else { if (!abnode->waitingForShutdown) @@ -214,14 +222,15 @@ cron_timeout(struct cronbnode *abnode) /* send kill and turn off timer */ bnode_StopProc(abnode->proc, SIGKILL); abnode->killSent = 1; - bnode_SetTimeout(abnode, 0); + bnode_SetTimeout((struct bnode *)abnode, 0); } return 0; } static int -cron_getstat(struct cronbnode *abnode, afs_int32 * astatus) +cron_getstat(struct bnode *bn, afs_int32 * astatus) { + struct cronbnode *abnode = (struct cronbnode *)bn; register afs_int32 temp; if (abnode->waitingForShutdown) temp = BSTAT_SHUTTINGDOWN; @@ -239,8 +248,9 @@ cron_getstat(struct cronbnode *abnode, afs_int32 * astatus) } static int -cron_setstat(register struct cronbnode *abnode, afs_int32 astatus) +cron_setstat(struct bnode *bn, afs_int32 astatus) { + struct cronbnode *abnode = (struct cronbnode *)bn; if (abnode->waitingForShutdown) return BZBUSY; if (astatus == BSTAT_SHUTDOWN) { @@ -248,14 +258,14 @@ cron_setstat(register struct cronbnode *abnode, afs_int32 astatus) /* start shutdown */ bnode_StopProc(abnode->proc, SIGTERM); abnode->waitingForShutdown = 1; - bnode_SetTimeout(abnode, SDTIME); + bnode_SetTimeout((struct bnode *)abnode, SDTIME); /* When shutdown is complete, bproc() calls BOP_PROCEXIT() * [cron_procexit()] which will tell bproc() to no longer * run this cron job. */ } else { /* Tell bproc() to no longer run this cron job */ - bnode_SetTimeout(abnode, 0); + bnode_SetTimeout((struct bnode *)abnode, 0); } } else if (astatus == BSTAT_NORMAL) { /* start the cron job @@ -268,8 +278,9 @@ cron_setstat(register struct cronbnode *abnode, afs_int32 astatus) } static int -cron_procexit(struct cronbnode *abnode, struct bnode_proc *aproc) +cron_procexit(struct bnode *bn, struct bnode_proc *aproc) { + struct cronbnode *abnode = (struct cronbnode *) bn; /* process has exited */ /* log interesting errors for folks */ @@ -292,8 +303,9 @@ cron_procexit(struct cronbnode *abnode, struct bnode_proc *aproc) } static int -cron_getstring(struct cronbnode *abnode, char *abuffer, afs_int32 alen) +cron_getstring(struct bnode *bn, char *abuffer, afs_int32 alen) { + struct cronbnode *abnode = (struct cronbnode *)bn; if (abnode->running) strcpy(abuffer, "running now"); else if (abnode->when == 0) @@ -304,9 +316,10 @@ cron_getstring(struct cronbnode *abnode, char *abuffer, afs_int32 alen) } static int -cron_getparm(struct cronbnode *abnode, afs_int32 aindex, char *abuffer, +cron_getparm(struct bnode *bn, afs_int32 aindex, char *abuffer, afs_int32 alen) { + struct cronbnode *abnode = (struct cronbnode *)bn; if (aindex == 0) strcpy(abuffer, abnode->command); else if (aindex == 1) { diff --git a/src/bozo/ezbnodeops.c b/src/bozo/ezbnodeops.c index 681e59a71..ce441221d 100644 --- a/src/bozo/ezbnodeops.c +++ b/src/bozo/ezbnodeops.c @@ -17,6 +17,7 @@ RCSID #include #include #include +#include #ifdef AFS_NT40_ENV #include #endif @@ -29,10 +30,17 @@ RCSID #include "bnode.h" #include "bosprototypes.h" -static int ez_timeout(), ez_getstat(), ez_setstat(), ez_delete(); -static int ez_procexit(), ez_getstring(), ez_getparm(), ez_restartp(); -static int ez_hascore(); -struct bnode *ez_create(); + +struct bnode *ez_create(char *, char *, char *, char *, char *, char *); +static int ez_hascore(struct bnode *bnode); +static int ez_restartp(struct bnode *bnode); +static int ez_delete(struct bnode *bnode); +static int ez_timeout(struct bnode *bnode); +static int ez_getstat(struct bnode *bnode, afs_int32 *status); +static int ez_setstat(struct bnode *bnode, afs_int32 status); +static int ez_procexit(struct bnode *bnode, struct bnode_proc *proc); +static int ez_getstring(struct bnode *bnode, char *abuffer, afs_int32 alen); +static int ez_getparm(struct bnode *bnode, afs_int32, char *, afs_int32); #define SDTIME 60 /* time in seconds given to a process to evaporate */ @@ -50,7 +58,7 @@ struct bnode_ops ezbnode_ops = { }; static int -ez_hascore(register struct ezbnode *abnode) +ez_hascore(struct bnode *abnode) { char tbuffer[256]; @@ -62,8 +70,9 @@ ez_hascore(register struct ezbnode *abnode) } static int -ez_restartp(register struct ezbnode *abnode) +ez_restartp(struct bnode *bn) { + struct ezbnode *abnode = (struct ezbnode *)bn; struct bnode_token *tt; register afs_int32 code; struct stat tstat; @@ -87,15 +96,18 @@ ez_restartp(register struct ezbnode *abnode) } static int -ez_delete(struct ezbnode *abnode) +ez_delete(struct bnode *bn) { + struct ezbnode *abnode = (struct ezbnode *)bn; + free(abnode->command); free(abnode); return 0; } struct bnode * -ez_create(char *ainstance, char *acommand) +ez_create(char *ainstance, char *acommand, char *unused1, char *unused2, + char *unused3, char *unused4) { struct ezbnode *te; char *cmdpath; @@ -107,7 +119,7 @@ ez_create(char *ainstance, char *acommand) te = (struct ezbnode *)malloc(sizeof(struct ezbnode)); memset(te, 0, sizeof(struct ezbnode)); - if (bnode_InitBnode(te, &ezbnode_ops, ainstance) != 0) { + if (bnode_InitBnode((struct bnode *)te, &ezbnode_ops, ainstance) != 0) { free(te); return NULL; } @@ -117,20 +129,24 @@ ez_create(char *ainstance, char *acommand) /* called to SIGKILL a process if it doesn't terminate normally */ static int -ez_timeout(struct ezbnode *abnode) +ez_timeout(struct bnode *bn) { + struct ezbnode *abnode = (struct ezbnode *)bn; + if (!abnode->waitingForShutdown) return 0; /* spurious */ /* send kill and turn off timer */ bnode_StopProc(abnode->proc, SIGKILL); abnode->killSent = 1; - bnode_SetTimeout(abnode, 0); + bnode_SetTimeout((struct bnode *)abnode, 0); return 0; } static int -ez_getstat(struct ezbnode *abnode, afs_int32 * astatus) +ez_getstat(struct bnode *bn, afs_int32 * astatus) { + struct ezbnode *abnode = (struct ezbnode *)bn; + register afs_int32 temp; if (abnode->waitingForShutdown) temp = BSTAT_SHUTTINGDOWN; @@ -143,8 +159,10 @@ ez_getstat(struct ezbnode *abnode, afs_int32 * astatus) } static int -ez_setstat(register struct ezbnode *abnode, afs_int32 astatus) +ez_setstat(struct bnode *bn, afs_int32 astatus) { + struct ezbnode *abnode = (struct ezbnode *)bn; + struct bnode_proc *tp; register afs_int32 code; @@ -153,7 +171,7 @@ ez_setstat(register struct ezbnode *abnode, afs_int32 astatus) if (astatus == BSTAT_NORMAL && !abnode->running) { /* start up */ abnode->lastStart = FT_ApproxTime(); - code = bnode_NewProc(abnode, abnode->command, NULL, &tp); + code = bnode_NewProc((struct bnode *)abnode, abnode->command, NULL, &tp); if (code) return code; abnode->running = 1; @@ -163,40 +181,43 @@ ez_setstat(register struct ezbnode *abnode, afs_int32 astatus) /* start shutdown */ bnode_StopProc(abnode->proc, SIGTERM); abnode->waitingForShutdown = 1; - bnode_SetTimeout(abnode, SDTIME); + bnode_SetTimeout((struct bnode *)abnode, SDTIME); return 0; } return 0; } static int -ez_procexit(struct ezbnode *abnode, struct bnode_proc *aproc) +ez_procexit(struct bnode *bn, struct bnode_proc *aproc) { + struct ezbnode *abnode = (struct ezbnode *)bn; + /* process has exited */ register afs_int32 code; abnode->waitingForShutdown = 0; abnode->running = 0; abnode->killSent = 0; - abnode->proc = (struct bnode_proc *)0; - bnode_SetTimeout(abnode, 0); /* clear timer */ + abnode->proc = NULL; + bnode_SetTimeout((struct bnode *) abnode, 0); /* clear timer */ if (abnode->b.goal) - code = ez_setstat(abnode, BSTAT_NORMAL); + code = ez_setstat((struct bnode *) abnode, BSTAT_NORMAL); else code = 0; return code; } static int -ez_getstring(struct ezbnode *abnode, char *abuffer, afs_int32 alen) +ez_getstring(struct bnode *abnode, char *abuffer, afs_int32 alen) { return -1; /* don't have much to add */ } -static -ez_getparm(struct ezbnode *abnode, afs_int32 aindex, char *abuffer, +static int +ez_getparm(struct bnode *bn, afs_int32 aindex, char *abuffer, afs_int32 alen) { + struct ezbnode *abnode = (struct ezbnode *) bn; if (aindex > 0) return BZDOM; strcpy(abuffer, abnode->command); diff --git a/src/bozo/fsbnodeops.c b/src/bozo/fsbnodeops.c index 07ddef200..c05a10945 100644 --- a/src/bozo/fsbnodeops.c +++ b/src/bozo/fsbnodeops.c @@ -15,6 +15,7 @@ RCSID #include #include +#include #include #include #ifdef AFS_SUN5_ENV @@ -99,41 +100,35 @@ struct fsbnode { char needsClock; /* do we need clock ticks */ }; - - struct bnode * fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd, char *ascancmd); struct bnode * dafs_create(char *ainstance, char *afilecmd, char *avolcmd, char * asalsrvcmd, char *asalcmd, char *ascancmd); -static int fs_hascore(register struct ezbnode *abnode); -static int fs_restartp(register struct fsbnode *abnode); -static int SetSalFlag(register struct fsbnode *abnode, register int aflag); -static int RestoreSalFlag(register struct fsbnode *abnode); -static int fs_delete(struct fsbnode *abnode); -static int fs_timeout(struct fsbnode *abnode); -static int fs_getstat(struct fsbnode *abnode, afs_int32 * astatus); -static int fs_setstat(register struct fsbnode *abnode, afs_int32 astatus); -static int fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc); -static int fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen); - - -static int fs_getparm(struct fsbnode *abnode, afs_int32 aindex, +static int fs_hascore(struct bnode *abnode); +static int fs_restartp(struct bnode *abnode); +static int fs_delete(struct bnode *abnode); +static int fs_timeout(struct bnode *abnode); +static int fs_getstat(struct bnode *abnode, afs_int32 * astatus); +static int fs_setstat(struct bnode *abnode, afs_int32 astatus); +static int fs_procexit(struct bnode *abnode, struct bnode_proc *aproc); +static int fs_getstring(struct bnode *abnode, char *abuffer, afs_int32 alen); +static int fs_getparm(struct bnode *abnode, afs_int32 aindex, char *abuffer, afs_int32 alen); -static int dafs_getparm(struct fsbnode *abnode, afs_int32 aindex, +static int dafs_getparm(struct bnode *abnode, afs_int32 aindex, char *abuffer, afs_int32 alen); +static int SetSalFlag(struct fsbnode *abnode, int aflag); +static int RestoreSalFlag(struct fsbnode *abnode); +static void SetNeedsClock(struct fsbnode *); +static int NudgeProcs(struct fsbnode *); + #ifdef AFS_NT40_ENV static void AppendExecutableExtension(char *cmd); #else #define AppendExecutableExtension(x) #endif -static void SetNeedsClock(register struct fsbnode *ab); -static int NudgeProcs(register struct fsbnode *abnode); - - - struct bnode_ops fsbnode_ops = { fs_create, fs_timeout, @@ -161,6 +156,13 @@ struct bnode_ops dafsbnode_ops = { fs_hascore, }; +/* Quick inline function to safely convert a fsbnode to a bnode without + * dropping type information + */ + +inline struct bnode * fsbnode2bnode(struct fsbnode *abnode) { + return (struct bnode *) abnode; +} /* Function to tell whether this bnode has a core file or not. You might * think that this could be in bnode.c, and decide what core files to check @@ -169,7 +171,7 @@ struct bnode_ops dafsbnode_ops = { * time the query is done. */ static int -fs_hascore(register struct ezbnode *abnode) +fs_hascore(struct bnode *abnode) { char tbuffer[256]; @@ -203,8 +205,9 @@ fs_hascore(register struct ezbnode *abnode) } static int -fs_restartp(register struct fsbnode *abnode) +fs_restartp(struct bnode *bn) { + struct fsbnode *abnode = (struct fsbnode *)bn; struct bnode_token *tt; register afs_int32 code; struct stat tstat; @@ -342,8 +345,10 @@ copystr(register char *a) } static int -fs_delete(struct fsbnode *abnode) +fs_delete(struct bnode *bn) { + struct fsbnode *abnode = (struct fsbnode *)bn; + free(abnode->filecmd); free(abnode->volcmd); free(abnode->salcmd); @@ -381,8 +386,9 @@ fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd, char *fileCmdpath, *volCmdpath, *salCmdpath, *scanCmdpath; int bailout = 0; - te = fileCmdpath = volCmdpath = salCmdpath = scanCmdpath = NULL; - + fileCmdpath = volCmdpath = salCmdpath = scanCmdpath = NULL; + te = NULL; + /* construct local paths from canonical (wire-format) paths */ if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) { bozo_Log("BNODE: command path invalid '%s'\n", afilecmd); @@ -458,11 +464,12 @@ fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd, te->scancmd = scanCmdpath; else te->scancmd = NULL; - if (bnode_InitBnode(te, &fsbnode_ops, ainstance) != 0) { + if (bnode_InitBnode(fsbnode2bnode(te), &fsbnode_ops, ainstance) != 0) { bailout = 1; goto done; } - bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */ + bnode_SetTimeout(fsbnode2bnode(te), POLLTIME); + /* ask for timeout activations every 10 seconds */ RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */ SetNeedsClock(te); /* compute needsClock field */ @@ -481,7 +488,7 @@ fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd, return NULL; } - return (struct bnode *)te; + return fsbnode2bnode(te); } /* create a demand attach fs bnode */ @@ -495,8 +502,9 @@ dafs_create(char *ainstance, char *afilecmd, char *avolcmd, char *fileCmdpath, *volCmdpath, *salsrvCmdpath, *salCmdpath, *scanCmdpath; int bailout = 0; - te = fileCmdpath = volCmdpath = salsrvCmdpath = salCmdpath = scanCmdpath = NULL; - + fileCmdpath = volCmdpath = salsrvCmdpath = salCmdpath = scanCmdpath = NULL; + te = NULL; + /* construct local paths from canonical (wire-format) paths */ if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) { bozo_Log("BNODE: command path invalid '%s'\n", afilecmd); @@ -585,11 +593,12 @@ dafs_create(char *ainstance, char *afilecmd, char *avolcmd, te->scancmd = scanCmdpath; else te->scancmd = NULL; - if (bnode_InitBnode(te, &dafsbnode_ops, ainstance) != 0) { + if (bnode_InitBnode(fsbnode2bnode(te), &dafsbnode_ops, ainstance) != 0) { bailout = 1; goto done; } - bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */ + bnode_SetTimeout(fsbnode2bnode(te), POLLTIME); + /* ask for timeout activations every 10 seconds */ RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */ SetNeedsClock(te); /* compute needsClock field */ @@ -610,13 +619,15 @@ dafs_create(char *ainstance, char *afilecmd, char *avolcmd, return NULL; } - return (struct bnode *)te; + return fsbnode2bnode(te); } /* called to SIGKILL a process if it doesn't terminate normally */ static int -fs_timeout(struct fsbnode *abnode) +fs_timeout(struct bnode *bn) { + struct fsbnode *abnode = (struct fsbnode *)bn; + register afs_int32 now; now = FT_ApproxTime(); @@ -671,8 +682,10 @@ fs_timeout(struct fsbnode *abnode) } static int -fs_getstat(struct fsbnode *abnode, afs_int32 * astatus) +fs_getstat(struct bnode *bn, afs_int32 * astatus) { + struct fsbnode *abnode = (struct fsbnode *) bn; + register afs_int32 temp; if (abnode->volSDW || abnode->fileSDW || abnode->salSDW || abnode->scanSDW || abnode->salsrvSDW) @@ -694,14 +707,16 @@ fs_getstat(struct fsbnode *abnode, afs_int32 * astatus) } static int -fs_setstat(register struct fsbnode *abnode, afs_int32 astatus) +fs_setstat(struct bnode *abnode, afs_int32 astatus) { - return NudgeProcs(abnode); + return NudgeProcs((struct fsbnode *) abnode); } static int -fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc) +fs_procexit(struct bnode *bn, struct bnode_proc *aproc) { + struct fsbnode *abnode = (struct fsbnode *)bn; + /* process has exited */ if (aproc == abnode->volProc) { @@ -760,10 +775,10 @@ SetNeedsClock(register struct fsbnode *ab) ab->needsClock = 0; /* halted normally */ else ab->needsClock = 1; /* other */ - if (ab->needsClock && !bnode_PendingTimeout(ab)) - bnode_SetTimeout(ab, POLLTIME); + if (ab->needsClock && !bnode_PendingTimeout(fsbnode2bnode(ab))) + bnode_SetTimeout(fsbnode2bnode(ab), POLLTIME); if (!ab->needsClock) - bnode_SetTimeout(ab, 0); + bnode_SetTimeout(fsbnode2bnode(ab), 0); } static int @@ -783,14 +798,14 @@ NudgeProcs(register struct fsbnode *abnode) bozo_Log("Salvager running along with file server!\n"); bozo_Log("Emergency shutdown\n"); emergency = 1; - bnode_SetGoal(abnode, BSTAT_SHUTDOWN); + bnode_SetGoal(fsbnode2bnode(abnode), BSTAT_SHUTDOWN); bnode_StopProc(abnode->salProc, SIGKILL); SetNeedsClock(abnode); return -1; } if (!abnode->volRunning) { abnode->lastVolStart = FT_ApproxTime(); - code = bnode_NewProc(abnode, abnode->volcmd, "vol", &tp); + code = bnode_NewProc(fsbnode2bnode(abnode), abnode->volcmd, "vol", &tp); if (code == 0) { abnode->volProc = tp; abnode->volRunning = 1; @@ -800,7 +815,7 @@ NudgeProcs(register struct fsbnode *abnode) if (!abnode->salsrvRunning) { abnode->lastSalsrvStart = FT_ApproxTime(); code = - bnode_NewProc(abnode, abnode->salsrvcmd, "salsrv", + bnode_NewProc(fsbnode2bnode(abnode), abnode->salsrvcmd, "salsrv", &tp); if (code == 0) { abnode->salsrvProc = tp; @@ -812,7 +827,7 @@ NudgeProcs(register struct fsbnode *abnode) if (!abnode->scanRunning) { abnode->lastScanStart = FT_ApproxTime(); code = - bnode_NewProc(abnode, abnode->scancmd, "scanner", + bnode_NewProc(fsbnode2bnode(abnode), abnode->scancmd, "scanner", &tp); if (code == 0) { abnode->scanProc = tp; @@ -828,7 +843,7 @@ NudgeProcs(register struct fsbnode *abnode) if (!abnode->fileRunning) { abnode->lastFileStart = FT_ApproxTime(); code = - bnode_NewProc(abnode, abnode->filecmd, "file", &tp); + bnode_NewProc(fsbnode2bnode(abnode), abnode->filecmd, "file", &tp); if (code == 0) { abnode->fileProc = tp; abnode->fileRunning = 1; @@ -837,7 +852,7 @@ NudgeProcs(register struct fsbnode *abnode) } if (!abnode->volRunning) { abnode->lastVolStart = FT_ApproxTime(); - code = bnode_NewProc(abnode, abnode->volcmd, "vol", &tp); + code = bnode_NewProc(fsbnode2bnode(abnode), abnode->volcmd, "vol", &tp); if (code == 0) { abnode->volProc = tp; abnode->volRunning = 1; @@ -846,7 +861,7 @@ NudgeProcs(register struct fsbnode *abnode) if (abnode->salsrvcmd && !abnode->salsrvRunning) { abnode->lastSalsrvStart = FT_ApproxTime(); code = - bnode_NewProc(abnode, abnode->salsrvcmd, "salsrv", + bnode_NewProc(fsbnode2bnode(abnode), abnode->salsrvcmd, "salsrv", &tp); if (code == 0) { abnode->salsrvProc = tp; @@ -856,7 +871,7 @@ NudgeProcs(register struct fsbnode *abnode) if (abnode->scancmd && !abnode->scanRunning) { abnode->lastScanStart = FT_ApproxTime(); code = - bnode_NewProc(abnode, abnode->scancmd, "scanner", + bnode_NewProc(fsbnode2bnode(abnode), abnode->scancmd, "scanner", &tp); if (code == 0) { abnode->scanProc = tp; @@ -888,7 +903,7 @@ NudgeProcs(register struct fsbnode *abnode) return 0; /* otherwise, it is safe to start salvager */ if (!abnode->salRunning) { - code = bnode_NewProc(abnode, abnode->salcmd, "salv", &tp); + code = bnode_NewProc(fsbnode2bnode(abnode), abnode->salcmd, "salv", &tp); if (code == 0) { abnode->salProc = tp; abnode->salRunning = 1; @@ -929,8 +944,10 @@ NudgeProcs(register struct fsbnode *abnode) } static int -fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen) +fs_getstring(struct bnode *bn, char *abuffer, afs_int32 alen) { + struct fsbnode *abnode = (struct fsbnode *)bn; + if (alen < 40) return -1; if (abnode->b.goal == 1) { @@ -971,9 +988,11 @@ fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen) } static int -fs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer, +fs_getparm(struct bnode *bn, afs_int32 aindex, char *abuffer, afs_int32 alen) { + struct fsbnode *abnode = (struct fsbnode *)bn; + if (aindex == 0) strcpy(abuffer, abnode->filecmd); else if (aindex == 1) @@ -988,9 +1007,11 @@ fs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer, } static int -dafs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer, +dafs_getparm(struct bnode *bn, afs_int32 aindex, char *abuffer, afs_int32 alen) { + struct fsbnode *abnode = (struct fsbnode *)bn; + if (aindex == 0) strcpy(abuffer, abnode->filecmd); else if (aindex == 1) -- 2.39.5