From 2a2e9b82681047239fd0fe84d0cef144411a1e9d Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Wed, 21 Aug 2002 19:58:18 +0000 Subject: [PATCH] modernize-bozo-20020821 convert to protoized declarations in the bosserver deal with InitBnode malloc failures --- src/bozo/bnode.c | 192 +++++++++++++++++----------------------- src/bozo/bosserver.c | 55 +++++------- src/bozo/cronbnodeops.c | 58 +++++------- src/bozo/ezbnodeops.c | 54 +++++------ src/bozo/fsbnodeops.c | 76 +++++++--------- 5 files changed, 183 insertions(+), 252 deletions(-) diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c index 4116ed484..2b522411f 100644 --- a/src/bozo/bnode.c +++ b/src/bozo/bnode.c @@ -68,8 +68,8 @@ extern char **environ; /* env structure */ #endif /* Remember the name of the process, if any, that failed last */ -static void RememberProcName(ap) -register struct bnode_proc *ap; { +static void RememberProcName(register struct bnode_proc *ap) +{ register struct bnode *tbnodep; tbnodep = ap->bnode; @@ -86,10 +86,9 @@ register struct bnode_proc *ap; { /* utility for use by BOP_HASCORE functions to determine where a core file might * be stored. */ -bnode_CoreName(abnode, acoreName, abuffer) -register struct bnode *abnode; -char *acoreName; -char *abuffer; { +int bnode_CoreName(register struct bnode *abnode, char *acoreName, + char *abuffer) +{ strcpy(abuffer, AFSDIR_SERVER_CORELOG_FILEPATH); if (acoreName) { strcat(abuffer, acoreName); @@ -100,9 +99,9 @@ char *abuffer; { } /* save core file, if any */ -static void SaveCore(abnode, aproc) -register struct bnode_proc *aproc; -register struct bnode *abnode; { +static void SaveCore(register struct bnode *abnode, register struct bnode_proc + *aproc) +{ char tbuffer[256]; struct stat tstat; register afs_int32 code; @@ -128,34 +127,30 @@ register struct bnode *abnode; { code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer); } -bnode_GetString(abnode, abuffer, alen) -register struct bnode *abnode; -register char *abuffer; -register afs_int32 alen;{ +int bnode_GetString(register struct bnode *abnode, register char *abuffer, +register afs_int32 alen) +{ return BOP_GETSTRING(abnode, abuffer, alen); } -bnode_GetParm(abnode, aindex, abuffer, alen) -register struct bnode *abnode; -register afs_int32 aindex; -register char *abuffer; -afs_int32 alen; { +int bnode_GetParm(register struct bnode *abnode, register afs_int32 aindex, + register char *abuffer, afs_int32 alen) +{ return BOP_GETPARM(abnode, aindex, abuffer, alen); } -bnode_GetStat(abnode, astatus) -register struct bnode *abnode; -register afs_int32 *astatus; { +int bnode_GetStat(register struct bnode *abnode, register afs_int32 *astatus) +{ return BOP_GETSTAT(abnode, astatus); } -bnode_RestartP(abnode) -register struct bnode *abnode; { +int bnode_RestartP(register struct bnode *abnode) +{ return BOP_RESTARTP(abnode); } -static bnode_Check(abnode) -register struct bnode *abnode; { +static int bnode_Check(register struct bnode *abnode) +{ if (abnode->flags & BNODE_WAIT) { abnode->flags &= ~BNODE_WAIT; LWP_NoYieldSignal(abnode); @@ -164,13 +159,13 @@ register struct bnode *abnode; { } /* tell if an instance has a core file */ -bnode_HasCore(abnode) -register struct bnode *abnode; { +int bnode_HasCore(register struct bnode *abnode) +{ return BOP_HASCORE(abnode); } /* wait for all bnodes to stabilize */ -bnode_WaitAll() { +int bnode_WaitAll() { register struct bnode *tb; register afs_int32 code; afs_int32 stat; @@ -195,9 +190,8 @@ bnode_WaitAll() { } /* wait until bnode status is correct */ -bnode_WaitStatus(abnode, astatus) -int astatus; -register struct bnode *abnode; { +int bnode_WaitStatus(register struct bnode *abnode, int astatus) +{ register afs_int32 code; afs_int32 stat; @@ -222,9 +216,8 @@ register struct bnode *abnode; { } } -bnode_SetStat(abnode, agoal) -register struct bnode *abnode; -register int agoal; { +int bnode_SetStat(register struct bnode *abnode, register int agoal) +{ abnode->goal = agoal; bnode_Check(abnode); BOP_SETSTAT(abnode, agoal); @@ -232,17 +225,15 @@ register int agoal; { return 0; } -bnode_SetGoal(abnode, agoal) -register struct bnode *abnode; -register int agoal; { +int bnode_SetGoal(register struct bnode *abnode, register int agoal) +{ abnode->goal = agoal; bnode_Check(abnode); return 0; } -bnode_SetFileGoal(abnode, agoal) -register struct bnode *abnode; -register int agoal; { +int bnode_SetFileGoal(register struct bnode *abnode, register int agoal) +{ if (abnode->fileGoal == agoal) return 0; /* already done */ abnode->fileGoal = agoal; WriteBozoFile(0); @@ -250,9 +241,8 @@ register int agoal; { } /* apply a function to all bnodes in the system */ -int bnode_ApplyInstance(aproc, arock) -int (*aproc)(); -char *arock; { +int bnode_ApplyInstance(int (*aproc)(), char *arock) +{ register struct bnode *tb, *nb; register afs_int32 code; @@ -264,8 +254,8 @@ char *arock; { return 0; } -struct bnode *bnode_FindInstance (aname) -register char *aname; { +struct bnode *bnode_FindInstance(register char *aname) +{ register struct bnode *tb; for(tb=allBnodes;tb;tb=tb->next) { @@ -274,8 +264,8 @@ register char *aname; { return NULL; } -static struct bnode_type *FindType(aname) -register char *aname; { +static struct bnode_type *FindType(register char *aname) +{ register struct bnode_type *tt; for(tt=allTypes;tt;tt=tt->next) { @@ -284,10 +274,8 @@ register char *aname; { return (struct bnode_type *) 0; } -bnode_Register(atype, aprocs, anparms) -char *atype; -int anparms; /* number of parms to create */ -struct bnode_ops *aprocs; { +int bnode_Register(char *atype, struct bnode_ops *aprocs, int anparms) +{ register struct bnode_type *tt; for(tt=allTypes;tt;tt=tt->next) { @@ -304,12 +292,10 @@ struct bnode_ops *aprocs; { return 0; } -afs_int32 bnode_Create(atype, ainstance, abp, ap1, ap2, ap3, ap4, ap5, notifier,fileGoal) -char *atype; -char *ainstance; -struct bnode **abp; -char *ap1, *ap2, *ap3, *ap4, *ap5, *notifier; -int fileGoal;{ +afs_int32 bnode_Create(char *atype, char *ainstance, struct bnode **abp, + char *ap1, char *ap2, char *ap3, char *ap4, + char *ap5, char *notifier, int fileGoal) +{ struct bnode_type *type; struct bnode *tb; char *notifierpath = NULL; @@ -351,8 +337,8 @@ int fileGoal;{ return 0; } -int bnode_DeleteName(ainstance) -char *ainstance; { +int bnode_DeleteName(char *ainstance) +{ register struct bnode *tb; tb = bnode_FindInstance(ainstance); @@ -361,14 +347,14 @@ char *ainstance; { return bnode_Delete(tb); } -bnode_Hold(abnode) -register struct bnode *abnode; { +int bnode_Hold(register struct bnode *abnode) +{ abnode->refCount++; return 0; } -bnode_Release(abnode) -register struct bnode *abnode; { +int bnode_Release(register struct bnode *abnode) +{ abnode->refCount--; if (abnode->refCount == 0 && abnode->flags & BNODE_DELETE) { abnode->flags &= ~BNODE_DELETE; /* we're going for it */ @@ -377,8 +363,8 @@ register struct bnode *abnode; { return 0; } -int bnode_Delete(abnode) -register struct bnode *abnode; { +int bnode_Delete(register struct bnode *abnode) +{ register afs_int32 code; register struct bnode **lb, *ub; afs_int32 temp; @@ -410,15 +396,14 @@ register struct bnode *abnode; { } /* function to tell if there's a timeout coming up */ -int bnode_PendingTimeout(abnode) -register struct bnode *abnode; { +int bnode_PendingTimeout(register struct bnode *abnode) +{ return (abnode->flags & BNODE_NEEDTIMEOUT); } /* function called to set / clear periodic bnode wakeup times */ -int bnode_SetTimeout(abnode, atimeout) -register struct bnode *abnode; -afs_int32 atimeout; { +int bnode_SetTimeout(register struct bnode *abnode, afs_int32 atimeout) +{ if (atimeout != 0) { abnode->nextTimeout = FT_ApproxTime() + atimeout; abnode->flags |= BNODE_NEEDTIMEOUT; @@ -432,16 +417,17 @@ afs_int32 atimeout; { } /* used by new bnode creation code to format bnode header */ -int bnode_InitBnode (abnode, abnodeops, aname) -register struct bnode *abnode; -char *aname; -struct bnode_ops *abnodeops; { +int bnode_InitBnode (register struct bnode *abnode, + struct bnode_ops *abnodeops, char *aname) +{ struct bnode **lb, *nb; /* format the bnode properly */ memset(abnode, 0, sizeof(struct bnode)); abnode->ops = abnodeops; abnode->name = (char *) malloc(strlen(aname)+1); + if (!abnode->name) + return ENOMEM; strcpy(abnode->name, aname); abnode->flags = BNODE_ACTIVE; abnode->fileGoal = BSTAT_NORMAL; @@ -598,19 +584,7 @@ static int bproc() { } -#ifdef notdef -sigcatch() -{ - signal(SIGPIPE, SIG_IGN); - bozo_Log("Notifier aborted prematurely"); - exit(0); -} -#endif - - - -hdl_notifier(tp) - struct bnode_proc *tp; +int hdl_notifier(struct bnode_proc *tp) { #ifndef AFS_NT40_ENV /* NT notifier callout not yet implemented */ int code, pid, status; @@ -652,9 +626,8 @@ hdl_notifier(tp) } -static afs_int32 SendNotifierData(fd, tp) - register int fd; - register struct bnode_proc *tp; +static afs_int32 SendNotifierData(register int fd, + register struct bnode_proc *tp) { register struct bnode *tb = tp->bnode; char buffer[1000], *bufp = buffer, *buf1; @@ -730,7 +703,7 @@ static afs_int32 SendNotifierData(fd, tp) /* Called by IOMGR at low priority on IOMGR's stack shortly after a SIGCHLD * occurs. Wakes up bproc do redo things */ -bnode_SoftInt(int asignal) +int bnode_SoftInt(int asignal) { IOMGR_Cancel(bproc_pid); return 0; @@ -739,8 +712,7 @@ bnode_SoftInt(int asignal) /* Called at signal interrupt level; queues function to be called * when IOMGR runs again. */ -void -bnode_Int(int asignal) +void bnode_Int(int asignal) { extern void bozo_ShutdownAndExit(); @@ -777,8 +749,8 @@ int bnode_Init() { } /* free token list returned by parseLine */ -bnode_FreeTokens(alist) - register struct bnode_token *alist; { +int bnode_FreeTokens(register struct bnode_token *alist) +{ register struct bnode_token *nlist; for(; alist; alist = nlist) { nlist = alist->next; @@ -788,15 +760,14 @@ bnode_FreeTokens(alist) return 0; } -static space(x) -int x; { +static int space(int x) +{ if (x == 0 || x == ' ' || x == '\t' || x== '\n') return 1; else return 0; } -bnode_ParseLine(aline, alist) - char *aline; - struct bnode_token **alist; { +int bnode_ParseLine(char *aline, struct bnode_token **alist) +{ char tbuffer[256]; register char *tptr; int inToken; @@ -844,11 +815,9 @@ bnode_ParseLine(aline, alist) } #define MAXVARGS 128 -int bnode_NewProc(abnode, aexecString, coreName, aproc) -struct bnode_proc **aproc; -char *coreName; -struct bnode *abnode; -char *aexecString; { +int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, + struct bnode_proc **aproc) +{ struct bnode_token *tlist, *tt; afs_int32 code; struct bnode_proc *tp; @@ -893,9 +862,8 @@ char *aexecString; { return 0; } -int bnode_StopProc(aproc, asignal) -register struct bnode_proc *aproc; -int asignal; { +int bnode_StopProc(register struct bnode_proc *aproc, int asignal) +{ register int code; if (!(aproc->flags & BPROC_STARTED) || (aproc->flags & BPROC_EXITED)) return BZNOTACTIVE; @@ -907,8 +875,8 @@ int asignal; { return code; } -int bnode_Deactivate(abnode) -register struct bnode *abnode; { +int bnode_Deactivate(register struct bnode *abnode) +{ register struct bnode **pb, *tb; struct bnode *nb; if (!(abnode->flags & BNODE_ACTIVE)) return BZNOTACTIVE; @@ -923,8 +891,8 @@ register struct bnode *abnode; { return BZNOENT; } -static int DeleteProc(abproc) -register struct bnode_proc *abproc; { +static int DeleteProc(register struct bnode_proc *abproc) +{ register struct bnode_proc **pb, *tb; struct bnode_proc *nb; diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index a30ebbdd7..522574d54 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -89,14 +89,14 @@ struct bztemp { }; /* check whether caller is authorized to manage RX statistics */ -int bozo_rxstat_userok(call) - struct rx_call *call; +int bozo_rxstat_userok(struct rx_call *call) { return afsconf_SuperUser(bozo_confdir, call, NULL); } /* restart bozo process */ -bozo_ReBozo() { +int bozo_ReBozo() +{ #ifdef AFS_NT40_ENV /* exit with restart code; SCM integrator process will restart bosserver */ int status = BOSEXIT_RESTART; @@ -157,8 +157,8 @@ bozo_ReBozo() { } /* make sure a dir exists */ -static MakeDir(adir) -register char *adir; { +static int MakeDir(register char *adir) +{ struct stat tstat; register afs_int32 code; if (stat(adir, &tstat) < 0 || (tstat.st_mode & S_IFMT) != S_IFDIR) { @@ -178,8 +178,8 @@ register char *adir; { } /* create all the bozo dirs */ -static CreateDirs() { - +static int CreateDirs() +{ MakeDir(AFSDIR_USR_DIRPATH); MakeDir(AFSDIR_SERVER_AFS_DIRPATH); MakeDir(AFSDIR_SERVER_BIN_DIRPATH); @@ -198,8 +198,8 @@ static CreateDirs() { } /* strip the \\n from the end of the line, if it is present */ -static StripLine(abuffer) -register char *abuffer; { +static int StripLine(register char *abuffer) +{ register char *tp; tp = abuffer + strlen(abuffer); /* starts off pointing at the null */ @@ -210,9 +210,8 @@ register char *abuffer; { } /* write one bnode's worth of entry into the file */ -static bzwrite(abnode, at) -register struct bnode *abnode; -register struct bztemp *at; { +static bzwrite(register struct bnode *abnode, register struct bztemp *at) +{ register int i; char tbuffer[BOZO_BSSIZE]; register afs_int32 code; @@ -235,8 +234,8 @@ register struct bztemp *at; { } #define MAXPARMS 20 -ReadBozoFile(aname) -char *aname; { +int ReadBozoFile(char *aname) +{ register FILE *tfile; char tbuffer[BOZO_BSSIZE]; register char *tp; @@ -403,8 +402,8 @@ fail: } /* write a new bozo file */ -WriteBozoFile(aname) -char *aname; { +int WriteBozoFile(char *aname) +{ register FILE *tfile; char tbuffer[AFSDIR_PATH_MAX]; register afs_int32 code; @@ -444,9 +443,8 @@ char *aname; { return 0; } -static bdrestart(abnode, arock) -register struct bnode *abnode; -char *arock; { +static int bdrestart(register struct bnode *abnode, char *arock) +{ register afs_int32 code; if (abnode->fileGoal != BSTAT_NORMAL || abnode->goal != BSTAT_NORMAL) @@ -465,7 +463,8 @@ char *arock; { #define BOZO_MINSKIP 3600 /* minimum to advance clock */ /* lwp to handle system restarts */ -static BozoDaemon() { +static int BozoDaemon() +{ register afs_int32 now; /* now initialize the values */ @@ -502,7 +501,7 @@ static BozoDaemon() { } #ifdef AFS_AIX32_ENV -static tweak_config() +static int tweak_config() { FILE *f; char c[80]; @@ -561,8 +560,7 @@ static tweak_config() */ #ifndef AFS_NT40_ENV -static void -background(void) +static void background(void) { /* * A process is a process group leader if its process ID @@ -657,11 +655,7 @@ background(void) #include "AFS_component_version_number.c" - -main (argc, argv,envp) -int argc; -char **argv; -char **envp; +int main (int argc, char **argv, char **envp) { struct rx_service *tservice; register afs_int32 code; @@ -927,9 +921,8 @@ char **envp; rx_StartServer(1); /* donate this process */ } -void -bozo_Log(a,b,c,d,e,f) -char *a, *b, *c, *d, *e, *f; { +void bozo_Log(char *a, char *b, char *c, char *d, char *e, char *f) +{ char tdate[26]; time_t myTime; diff --git a/src/bozo/cronbnodeops.c b/src/bozo/cronbnodeops.c index e55324c9d..b9aab0b73 100644 --- a/src/bozo/cronbnodeops.c +++ b/src/bozo/cronbnodeops.c @@ -73,8 +73,7 @@ struct cronbnode { char killSent; /* have we tried sigkill signal? */ }; -static int cron_hascore(abnode) -register struct ezbnode *abnode; { +static int cron_hascore(register struct ezbnode *abnode) { char tbuffer[256]; bnode_CoreName(abnode, NULL, tbuffer); @@ -86,8 +85,8 @@ register struct ezbnode *abnode; { one shot run) or when we should run again. Sleeps until we should run again. Note that the computation of when we should run again is made in procexit and/or create procs. This guy only schedules the sleep */ -ScheduleCronBnode(abnode) -register struct cronbnode *abnode; { +int ScheduleCronBnode(register struct cronbnode *abnode) +{ register afs_int32 code; register afs_int32 temp; struct bnode_proc *tp; @@ -133,23 +132,21 @@ register struct cronbnode *abnode; { return 0; } -static int cron_restartp (abnode) -register struct cronbnode *abnode; { +static int cron_restartp (register struct cronbnode *abnode) +{ return 0; } -static int cron_delete(abnode) -struct cronbnode *abnode; { +static int cron_delete(struct cronbnode *abnode) +{ free(abnode->command); free(abnode->whenString); free(abnode); return 0; } -struct bnode *cron_create(ainstance, acommand, awhen) -char *ainstance; -char *awhen; -char *acommand; { +struct bnode *cron_create(char *ainstance, char *acommand, char *awhen) +{ struct cronbnode *te; afs_int32 code; char *cmdpath; @@ -164,12 +161,11 @@ char *acommand; { te = (struct cronbnode *) malloc(sizeof(struct cronbnode)); memset(te, 0, sizeof(struct cronbnode)); code = ktime_ParsePeriodic(awhen, &te->whenToRun); - if (code < 0) { + if ((code < 0) || (bnode_InitBnode(te, &cronbnode_ops, ainstance) != 0)) { free(te); free(cmdpath); return NULL; } - bnode_InitBnode(te, &cronbnode_ops, ainstance); te->when = ktime_next(&te->whenToRun, 0); te->command = cmdpath; te->whenString = copystr(awhen); @@ -178,8 +174,8 @@ char *acommand; { /* 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(abnode) -struct cronbnode *abnode; { +static int cron_timeout(struct cronbnode *abnode) +{ register afs_int32 temp; register afs_int32 code; struct bnode_proc *tp; @@ -217,9 +213,8 @@ struct cronbnode *abnode; { return 0; } -static int cron_getstat(abnode, astatus) -struct cronbnode *abnode; -afs_int32 *astatus; { +static int cron_getstat(struct cronbnode *abnode, afs_int32 *astatus) +{ register afs_int32 temp; if (abnode->waitingForShutdown) temp = BSTAT_SHUTTINGDOWN; else if (abnode->b.goal == 0) temp = BSTAT_SHUTDOWN; @@ -234,10 +229,8 @@ afs_int32 *astatus; { return 0; } -static int cron_setstat(abnode, astatus) -register struct cronbnode *abnode; -afs_int32 astatus; { - +static int cron_setstat(register struct cronbnode *abnode, afs_int32 astatus) +{ if (abnode->waitingForShutdown) return BZBUSY; if (astatus == BSTAT_SHUTDOWN) { if (abnode->running) { @@ -264,9 +257,8 @@ afs_int32 astatus; { return 0; } -static int cron_procexit(abnode, aproc) -struct cronbnode *abnode; -struct bnode_proc *aproc; { +static int cron_procexit(struct cronbnode *abnode, struct bnode_proc *aproc) +{ /* process has exited */ /* log interesting errors for folks */ @@ -288,21 +280,17 @@ struct bnode_proc *aproc; { return 0; } -static int cron_getstring(abnode, abuffer, alen) -struct cronbnode *abnode; -char *abuffer; -afs_int32 alen;{ +static int cron_getstring(struct cronbnode *abnode, char *abuffer, + afs_int32 alen) +{ if (abnode->running) strcpy(abuffer, "running now"); else if (abnode->when==0) strcpy(abuffer, "waiting to run once"); else sprintf(abuffer, "run next at %s", ktime_DateOf(abnode->when)); return 0; } -static cron_getparm(abnode, aindex, abuffer, alen) -struct cronbnode *abnode; -afs_int32 aindex; -char *abuffer; -afs_int32 alen; { +static int cron_getparm(struct cronbnode *abnode, afs_int32 aindex, char *abuffer, afs_int32 alen) +{ if (aindex == 0) strcpy(abuffer, abnode->command); else if (aindex == 1) { strcpy(abuffer, abnode->whenString); diff --git a/src/bozo/ezbnodeops.c b/src/bozo/ezbnodeops.c index 520a362ad..4921b25cb 100644 --- a/src/bozo/ezbnodeops.c +++ b/src/bozo/ezbnodeops.c @@ -53,8 +53,8 @@ struct bnode_ops ezbnode_ops = { ez_hascore, }; -static int ez_hascore(abnode) -register struct ezbnode *abnode; { +static int ez_hascore(register struct ezbnode *abnode) +{ char tbuffer[256]; bnode_CoreName(abnode, NULL, tbuffer); @@ -62,8 +62,8 @@ register struct ezbnode *abnode; { else return 0; } -static int ez_restartp (abnode) -register struct ezbnode *abnode; { +static int ez_restartp (register struct ezbnode *abnode) +{ struct bnode_token *tt; register afs_int32 code; struct stat tstat; @@ -82,16 +82,15 @@ register struct ezbnode *abnode; { return code; } -static int ez_delete(abnode) -struct ezbnode *abnode; { +static int ez_delete(struct ezbnode *abnode) +{ free(abnode->command); free(abnode); return 0; } -struct bnode *ez_create(ainstance, acommand) -char *ainstance; -char *acommand; { +struct bnode *ez_create(char *ainstance, char *acommand) +{ struct ezbnode *te; char *cmdpath; @@ -102,14 +101,17 @@ char *acommand; { te = (struct ezbnode *) malloc(sizeof(struct ezbnode)); memset(te, 0, sizeof(struct ezbnode)); - bnode_InitBnode(te, &ezbnode_ops, ainstance); + if (bnode_InitBnode(te, &ezbnode_ops, ainstance) != 0) { + free(te); + return NULL; + } te->command = cmdpath; return (struct bnode *) te; } /* called to SIGKILL a process if it doesn't terminate normally */ -static int ez_timeout(abnode) -struct ezbnode *abnode; { +static int ez_timeout(struct ezbnode *abnode) +{ if (!abnode->waitingForShutdown) return 0; /* spurious */ /* send kill and turn off timer */ bnode_StopProc(abnode->proc, SIGKILL); @@ -118,9 +120,8 @@ struct ezbnode *abnode; { return 0; } -static int ez_getstat(abnode, astatus) -struct ezbnode *abnode; -afs_int32 *astatus; { +static int ez_getstat(struct ezbnode *abnode, afs_int32 *astatus) +{ register afs_int32 temp; if (abnode->waitingForShutdown) temp = BSTAT_SHUTTINGDOWN; else if (abnode->running) temp = BSTAT_NORMAL; @@ -129,9 +130,8 @@ afs_int32 *astatus; { return 0; } -static int ez_setstat(abnode, astatus) -register struct ezbnode *abnode; -afs_int32 astatus; { +static int ez_setstat(register struct ezbnode *abnode, afs_int32 astatus) +{ struct bnode_proc *tp; register afs_int32 code; @@ -155,9 +155,8 @@ afs_int32 astatus; { return 0; } -static int ez_procexit(abnode, aproc) -struct ezbnode *abnode; -struct bnode_proc *aproc; { +static int ez_procexit(struct ezbnode *abnode, struct bnode_proc *aproc) +{ /* process has exited */ register afs_int32 code; @@ -172,18 +171,13 @@ struct bnode_proc *aproc; { return code; } -static int ez_getstring(abnode, abuffer, alen) -struct ezbnode *abnode; -char *abuffer; -afs_int32 alen;{ +static int ez_getstring(struct ezbnode *abnode, char *abuffer, afs_int32 alen) +{ return -1; /* don't have much to add */ } -static ez_getparm(abnode, aindex, abuffer, alen) -struct ezbnode *abnode; -afs_int32 aindex; -char *abuffer; -afs_int32 alen; { +static ez_getparm(struct ezbnode *abnode, afs_int32 aindex, char *abuffer, afs_int32 alen) +{ if (aindex > 0) return BZDOM; strcpy(abuffer, abnode->command); return 0; diff --git a/src/bozo/fsbnodeops.c b/src/bozo/fsbnodeops.c index 6b6a32d16..74676ada4 100644 --- a/src/bozo/fsbnodeops.c +++ b/src/bozo/fsbnodeops.c @@ -125,8 +125,8 @@ struct fsbnode { * there may not be an active process for a bnode that dumped core at the * time the query is done. */ -static int fs_hascore(abnode) -register struct ezbnode *abnode; { +static int fs_hascore(register struct ezbnode *abnode) +{ char tbuffer[256]; /* see if file server has a core file */ @@ -149,8 +149,8 @@ register struct ezbnode *abnode; { return 0; } -static int fs_restartp (abnode) -register struct fsbnode *abnode; { +static int fs_restartp (register struct fsbnode *abnode) +{ struct bnode_token *tt; register afs_int32 code; struct stat tstat; @@ -202,9 +202,8 @@ register struct fsbnode *abnode; { /* set needsSalvage flag, creating file SALVAGE. if we need to salvage the file system (so we can tell over panic reboots */ -static SetSalFlag(abnode, aflag) -register struct fsbnode *abnode; -register int aflag; { +static int SetSalFlag(register struct fsbnode *abnode, register int aflag) +{ char tbuffer[AFSDIR_PATH_MAX]; int fd; @@ -222,8 +221,7 @@ register int aflag; { } /* set the needsSalvage flag according to the existence of the salvage file */ -static RestoreSalFlag(abnode) -register struct fsbnode *abnode; { +static int RestoreSalFlag(register struct fsbnode *abnode) { char tbuffer[AFSDIR_PATH_MAX]; strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/", SALFILE, @@ -238,16 +236,15 @@ register struct fsbnode *abnode; { return 0; } -char *copystr(a) -register char *a; { +char *copystr(register char *a) +{ register char *b; b = (char *) malloc(strlen(a)+1); strcpy(b, a); return b; } -static int fs_delete(abnode) -struct fsbnode *abnode; { +static int fs_delete(struct fsbnode *abnode) { free(abnode->filecmd); free(abnode->volcmd); free(abnode->salcmd); @@ -271,12 +268,8 @@ static void AppendExecutableExtension(char *cmd) #endif /* AFS_NT40_ENV */ -struct bnode *fs_create(ainstance, afilecmd, avolcmd, asalcmd, ascancmd) -char *ainstance; -char *afilecmd; -char *avolcmd; -char *asalcmd; -char *ascancmd; { +struct bnode *fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd, char *ascancmd) +{ struct stat tstat; register struct fsbnode *te; char cmdname[AFSDIR_PATH_MAX]; @@ -360,7 +353,11 @@ char *ascancmd; { te->scancmd = scanCmdpath; else te->scancmd = NULL; - bnode_InitBnode(te, &fsbnode_ops, ainstance); + if (bnode_InitBnode(te, &fsbnode_ops, ainstance) != 0) { + free(te); + free(fileCmdpath); free(volCmdpath); free(salCmdpath); + return NULL; + } bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */ RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */ SetNeedsClock(te); /* compute needsClock field */ @@ -368,8 +365,7 @@ char *ascancmd; { } /* called to SIGKILL a process if it doesn't terminate normally */ -static int fs_timeout(abnode) -struct fsbnode *abnode; { +static int fs_timeout(struct fsbnode *abnode) { register afs_int32 now; now = FT_ApproxTime(); @@ -410,9 +406,8 @@ struct fsbnode *abnode; { return 0; } -static int fs_getstat(abnode, astatus) -struct fsbnode *abnode; -afs_int32 *astatus; { +static int fs_getstat(struct fsbnode *abnode, afs_int32 *astatus) +{ register afs_int32 temp; if (abnode->volSDW || abnode->fileSDW || abnode->salSDW || abnode->scanSDW) temp = BSTAT_SHUTTINGDOWN; @@ -426,15 +421,13 @@ afs_int32 *astatus; { return 0; } -static int fs_setstat(abnode, astatus) -register struct fsbnode *abnode; -afs_int32 astatus; { +static int fs_setstat(register struct fsbnode *abnode, afs_int32 astatus) +{ return NudgeProcs(abnode); } -static int fs_procexit(abnode, aproc) -struct fsbnode *abnode; -struct bnode_proc *aproc; { +static int fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc) +{ /* process has exited */ if (aproc == abnode->volProc) { @@ -478,8 +471,7 @@ struct bnode_proc *aproc; { } /* make sure we're periodically checking the state if we need to */ -static SetNeedsClock(ab) - register struct fsbnode *ab; +static int SetNeedsClock(register struct fsbnode *ab) { if (ab->b.goal == 1 && ab->fileRunning && ab->volRunning && (!ab->scancmd || ab->scanRunning)) @@ -493,8 +485,8 @@ static SetNeedsClock(ab) if (!ab->needsClock) bnode_SetTimeout(ab, 0); } -static NudgeProcs(abnode) -register struct fsbnode *abnode; { +static int NudgeProcs(register struct fsbnode *abnode) +{ struct bnode_proc *tp; /* not register */ register afs_int32 code; afs_int32 now; @@ -621,10 +613,8 @@ register struct fsbnode *abnode; { return 0; } -static int fs_getstring(abnode, abuffer, alen) -struct fsbnode *abnode; -char *abuffer; -afs_int32 alen;{ +static int fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen) +{ if (alen < 40) return -1; if (abnode->b.goal == 1) { if (abnode->fileRunning) { @@ -660,11 +650,9 @@ afs_int32 alen;{ return 0; } -static fs_getparm(abnode, aindex, abuffer, alen) -struct fsbnode *abnode; -afs_int32 aindex; -char *abuffer; -afs_int32 alen; { +static int fs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer, + afs_int32 alen) +{ if (aindex == 0) strcpy(abuffer, abnode->filecmd); else if (aindex == 1) -- 2.39.5