2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <sys/types.h>
32 #endif /* AFS_NT40_ENV */
34 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
35 #include <afs/afsutil.h>
39 static int emergency = 0;
41 /* if this file exists, then we have to salvage the file system */
42 #define SALFILE "SALVAGE."
44 #define POLLTIME 20 /* for handling below */
45 #define SDTIME 60 /* time in seconds given to a process to evaporate */
48 Normal operation involves having the file server and the vol server both running.
50 If the vol server terminates, it can simply be restarted.
52 If the file server terminates, the disk must salvaged before the file server
53 can be restarted. In order to restart either the file server or the salvager,
54 the vol server must be shut down.
56 If the file server terminates *normally* (exits after receiving a SIGQUIT)
57 then we don't have to salvage it.
59 The needsSalvage flag is set when the file server is started. It is cleared
60 if the file server exits when fileSDW is true but fileKillSent is false,
61 indicating that it exited after receiving a quit, but before we sent it a kill.
63 The needsSalvage flag is cleared when the salvager exits.
68 afs_int32 timeSDStarted; /* time shutdown operation started */
69 char *filecmd; /* command to start primary file server */
70 char *volcmd; /* command to start secondary vol server */
71 char *salsrvcmd; /* command to start salvageserver (demand attach fs) */
72 char *salcmd; /* command to start salvager */
73 char *scancmd; /* command to start scanner (MR-AFS) */
74 struct bnode_proc *fileProc; /* process for file server */
75 struct bnode_proc *volProc; /* process for vol server */
76 struct bnode_proc *salsrvProc; /* process for salvageserver (demand attach fs) */
77 struct bnode_proc *salProc; /* process for salvager */
78 struct bnode_proc *scanProc; /* process for scanner (MR-AFS) */
79 afs_int32 lastFileStart; /* last start for file */
80 afs_int32 lastVolStart; /* last start for vol */
81 afs_int32 lastSalsrvStart; /* last start for salvageserver (demand attach fs) */
82 afs_int32 lastScanStart; /* last start for scanner (MR-AFS) */
83 char fileRunning; /* file process is running */
84 char volRunning; /* volser is running */
85 char salsrvRunning; /* salvageserver is running (demand attach fs) */
86 char salRunning; /* salvager is running */
87 char scanRunning; /* scanner is running (MR_AFS) */
88 char fileSDW; /* file shutdown wait */
89 char volSDW; /* vol shutdown wait */
90 char salsrvSDW; /* salvageserver shutdown wait (demand attach fs) */
91 char salSDW; /* waiting for the salvager to shutdown */
92 char scanSDW; /* scanner shutdown wait (MR_AFS) */
93 char fileKillSent; /* kill signal has been sent */
95 char salsrvKillSent; /* kill signal has been sent (demand attach fs) */
97 char scanKillSent; /* kill signal has been sent (MR_AFS) */
98 char needsSalvage; /* salvage before running */
99 char needsClock; /* do we need clock ticks */
104 struct bnode * fs_create(char *ainstance, char *afilecmd, char *avolcmd,
105 char *asalcmd, char *ascancmd);
106 struct bnode * dafs_create(char *ainstance, char *afilecmd, char *avolcmd,
107 char * asalsrvcmd, char *asalcmd, char *ascancmd);
109 static int fs_hascore(register struct ezbnode *abnode);
110 static int fs_restartp(register struct fsbnode *abnode);
111 static int SetSalFlag(register struct fsbnode *abnode, register int aflag);
112 static int RestoreSalFlag(register struct fsbnode *abnode);
113 static int fs_delete(struct fsbnode *abnode);
114 static int fs_timeout(struct fsbnode *abnode);
115 static int fs_getstat(struct fsbnode *abnode, afs_int32 * astatus);
116 static int fs_setstat(register struct fsbnode *abnode, afs_int32 astatus);
117 static int fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc);
118 static int fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen);
121 static int fs_getparm(struct fsbnode *abnode, afs_int32 aindex,
122 char *abuffer, afs_int32 alen);
123 static int dafs_getparm(struct fsbnode *abnode, afs_int32 aindex,
124 char *abuffer, afs_int32 alen);
127 static void AppendExecutableExtension(char *cmd);
129 #define AppendExecutableExtension(x)
132 static void SetNeedsClock(register struct fsbnode *ab);
133 static int NudgeProcs(register struct fsbnode *abnode);
137 struct bnode_ops fsbnode_ops = {
150 /* demand attach fs bnode ops */
151 struct bnode_ops dafsbnode_ops = {
165 /* Function to tell whether this bnode has a core file or not. You might
166 * think that this could be in bnode.c, and decide what core files to check
167 * for based on the bnode's coreName property, but that doesn't work because
168 * there may not be an active process for a bnode that dumped core at the
169 * time the query is done.
172 fs_hascore(register struct ezbnode *abnode)
176 /* see if file server has a core file */
177 bnode_CoreName(abnode, "file", tbuffer);
178 if (access(tbuffer, 0) == 0)
181 /* see if volserver has a core file */
182 bnode_CoreName(abnode, "vol", tbuffer);
183 if (access(tbuffer, 0) == 0)
186 /* see if salvageserver left a core file */
187 bnode_CoreName(abnode, "salsrv", tbuffer);
188 if (access(tbuffer, 0) == 0)
191 /* see if salvager left a core file */
192 bnode_CoreName(abnode, "salv", tbuffer);
193 if (access(tbuffer, 0) == 0)
196 /* see if scanner left a core file (MR-AFS) */
197 bnode_CoreName(abnode, "scan", tbuffer);
198 if (access(tbuffer, 0) == 0)
201 /* no one left a core file */
206 fs_restartp(register struct fsbnode *abnode)
208 struct bnode_token *tt;
209 register afs_int32 code;
212 code = bnode_ParseLine(abnode->filecmd, &tt);
217 code = stat(tt->key, &tstat);
219 bnode_FreeTokens(tt);
222 if (tstat.st_ctime > abnode->lastFileStart)
226 bnode_FreeTokens(tt);
230 /* now do same for volcmd */
231 code = bnode_ParseLine(abnode->volcmd, &tt);
236 code = stat(tt->key, &tstat);
238 bnode_FreeTokens(tt);
241 if (tstat.st_ctime > abnode->lastVolStart)
245 bnode_FreeTokens(tt);
249 if (abnode->salsrvcmd) { /* only in demand attach fs */
250 /* now do same for salsrvcmd (demand attach fs) */
251 code = bnode_ParseLine(abnode->salsrvcmd, &tt);
256 code = stat(tt->key, &tstat);
258 bnode_FreeTokens(tt);
261 if (tstat.st_ctime > abnode->lastScanStart)
265 bnode_FreeTokens(tt);
268 if (abnode->scancmd) { /* Only in MR-AFS */
269 /* now do same for scancmd (MR-AFS) */
270 code = bnode_ParseLine(abnode->scancmd, &tt);
275 code = stat(tt->key, &tstat);
277 bnode_FreeTokens(tt);
280 if (tstat.st_ctime > abnode->lastScanStart)
284 bnode_FreeTokens(tt);
290 /* set needsSalvage flag, creating file SALVAGE.<instancename> if
291 we need to salvage the file system (so we can tell over panic reboots */
293 SetSalFlag(register struct fsbnode *abnode, register int aflag)
295 char tbuffer[AFSDIR_PATH_MAX];
298 /* don't use the salvage flag for demand attach fs */
299 if (abnode->salsrvcmd == NULL) {
300 abnode->needsSalvage = aflag;
301 strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
302 SALFILE, abnode->b.name, NULL);
304 fd = open(tbuffer, O_CREAT | O_TRUNC | O_RDWR, 0666);
313 /* set the needsSalvage flag according to the existence of the salvage file */
315 RestoreSalFlag(register struct fsbnode *abnode)
317 char tbuffer[AFSDIR_PATH_MAX];
319 /* never set needs salvage flag for demand attach fs */
320 if (abnode->salsrvcmd != NULL) {
321 abnode->needsSalvage = 0;
323 strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
324 SALFILE, abnode->b.name, NULL);
325 if (access(tbuffer, 0) == 0) {
326 /* file exists, so need to salvage */
327 abnode->needsSalvage = 1;
329 abnode->needsSalvage = 0;
336 copystr(register char *a)
339 b = (char *)malloc(strlen(a) + 1);
345 fs_delete(struct fsbnode *abnode)
347 free(abnode->filecmd);
348 free(abnode->volcmd);
349 free(abnode->salcmd);
350 if (abnode->salsrvcmd)
351 free(abnode->salsrvcmd);
353 free(abnode->scancmd);
361 AppendExecutableExtension(char *cmd)
363 char cmdext[_MAX_EXT];
365 _splitpath(cmd, NULL, NULL, NULL, cmdext);
366 if (*cmdext == '\0') {
367 /* no filename extension supplied for cmd; append .exe */
371 #endif /* AFS_NT40_ENV */
375 fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd,
379 register struct fsbnode *te;
380 char cmdname[AFSDIR_PATH_MAX];
381 char *fileCmdpath, *volCmdpath, *salCmdpath, *scanCmdpath;
384 te = fileCmdpath = volCmdpath = salCmdpath = scanCmdpath = NULL;
386 /* construct local paths from canonical (wire-format) paths */
387 if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) {
388 bozo_Log("BNODE: command path invalid '%s'\n", afilecmd);
392 if (ConstructLocalBinPath(avolcmd, &volCmdpath)) {
393 bozo_Log("BNODE: command path invalid '%s'\n", avolcmd);
397 if (ConstructLocalBinPath(asalcmd, &salCmdpath)) {
398 bozo_Log("BNODE: command path invalid '%s'\n", asalcmd);
403 if (ascancmd && strlen(ascancmd)) {
404 if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
405 bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
412 sscanf(fileCmdpath, "%s", cmdname);
413 AppendExecutableExtension(cmdname);
414 if (stat(cmdname, &tstat)) {
415 bozo_Log("BNODE: file server binary '%s' not found\n", cmdname);
420 sscanf(volCmdpath, "%s", cmdname);
421 AppendExecutableExtension(cmdname);
422 if (stat(cmdname, &tstat)) {
423 bozo_Log("BNODE: volume server binary '%s' not found\n", cmdname);
428 sscanf(salCmdpath, "%s", cmdname);
429 AppendExecutableExtension(cmdname);
430 if (stat(cmdname, &tstat)) {
431 bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
436 if (ascancmd && strlen(ascancmd)) {
437 sscanf(scanCmdpath, "%s", cmdname);
438 AppendExecutableExtension(cmdname);
439 if (stat(cmdname, &tstat)) {
440 bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
447 te = (struct fsbnode *)malloc(sizeof(struct fsbnode));
452 memset(te, 0, sizeof(struct fsbnode));
453 te->filecmd = fileCmdpath;
454 te->volcmd = volCmdpath;
455 te->salsrvcmd = NULL;
456 te->salcmd = salCmdpath;
457 if (ascancmd && strlen(ascancmd))
458 te->scancmd = scanCmdpath;
461 if (bnode_InitBnode(te, &fsbnode_ops, ainstance) != 0) {
465 bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */
466 RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */
467 SetNeedsClock(te); /* compute needsClock field */
484 return (struct bnode *)te;
487 /* create a demand attach fs bnode */
489 dafs_create(char *ainstance, char *afilecmd, char *avolcmd,
490 char * asalsrvcmd, char *asalcmd, char *ascancmd)
493 register struct fsbnode *te;
494 char cmdname[AFSDIR_PATH_MAX];
495 char *fileCmdpath, *volCmdpath, *salsrvCmdpath, *salCmdpath, *scanCmdpath;
498 te = fileCmdpath = volCmdpath = salsrvCmdpath = salCmdpath = scanCmdpath = NULL;
500 /* construct local paths from canonical (wire-format) paths */
501 if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) {
502 bozo_Log("BNODE: command path invalid '%s'\n", afilecmd);
506 if (ConstructLocalBinPath(avolcmd, &volCmdpath)) {
507 bozo_Log("BNODE: command path invalid '%s'\n", avolcmd);
511 if (ConstructLocalBinPath(asalsrvcmd, &salsrvCmdpath)) {
512 bozo_Log("BNODE: command path invalid '%s'\n", asalsrvcmd);
516 if (ConstructLocalBinPath(asalcmd, &salCmdpath)) {
517 bozo_Log("BNODE: command path invalid '%s'\n", asalcmd);
522 if (ascancmd && strlen(ascancmd)) {
523 if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
524 bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
531 sscanf(fileCmdpath, "%s", cmdname);
532 AppendExecutableExtension(cmdname);
533 if (stat(cmdname, &tstat)) {
534 bozo_Log("BNODE: file server binary '%s' not found\n", cmdname);
539 sscanf(volCmdpath, "%s", cmdname);
540 AppendExecutableExtension(cmdname);
541 if (stat(cmdname, &tstat)) {
542 bozo_Log("BNODE: volume server binary '%s' not found\n", cmdname);
547 sscanf(salsrvCmdpath, "%s", cmdname);
548 AppendExecutableExtension(cmdname);
549 if (stat(cmdname, &tstat)) {
550 bozo_Log("BNODE: salvageserver binary '%s' not found\n", cmdname);
555 sscanf(salCmdpath, "%s", cmdname);
556 AppendExecutableExtension(cmdname);
557 if (stat(cmdname, &tstat)) {
558 bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
563 if (ascancmd && strlen(ascancmd)) {
564 sscanf(scanCmdpath, "%s", cmdname);
565 AppendExecutableExtension(cmdname);
566 if (stat(cmdname, &tstat)) {
567 bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
574 te = (struct fsbnode *)malloc(sizeof(struct fsbnode));
579 memset(te, 0, sizeof(struct fsbnode));
580 te->filecmd = fileCmdpath;
581 te->volcmd = volCmdpath;
582 te->salsrvcmd = salsrvCmdpath;
583 te->salcmd = salCmdpath;
584 if (ascancmd && strlen(ascancmd))
585 te->scancmd = scanCmdpath;
588 if (bnode_InitBnode(te, &dafsbnode_ops, ainstance) != 0) {
592 bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */
593 RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */
594 SetNeedsClock(te); /* compute needsClock field */
613 return (struct bnode *)te;
616 /* called to SIGKILL a process if it doesn't terminate normally */
618 fs_timeout(struct fsbnode *abnode)
620 register afs_int32 now;
622 now = FT_ApproxTime();
624 if (abnode->volSDW) {
625 if (!abnode->volKillSent && now - abnode->timeSDStarted > SDTIME) {
626 bnode_StopProc(abnode->volProc, SIGKILL);
627 abnode->volKillSent = 1;
629 ("bos shutdown: volserver failed to shutdown within %d seconds\n",
633 if (abnode->salSDW) {
634 if (!abnode->salKillSent && now - abnode->timeSDStarted > SDTIME) {
635 bnode_StopProc(abnode->salProc, SIGKILL);
636 abnode->salKillSent = 1;
638 ("bos shutdown: salvager failed to shutdown within %d seconds\n",
642 if (abnode->fileSDW) {
643 if (!abnode->fileKillSent && now - abnode->timeSDStarted > FSSDTIME) {
644 bnode_StopProc(abnode->fileProc, SIGKILL);
645 abnode->fileKillSent = 1;
647 ("bos shutdown: fileserver failed to shutdown within %d seconds\n",
651 if (abnode->salsrvSDW) {
652 if (!abnode->salsrvKillSent && now - abnode->timeSDStarted > SDTIME) {
653 bnode_StopProc(abnode->salsrvProc, SIGKILL);
654 abnode->salsrvKillSent = 1;
656 ("bos shutdown: salvageserver failed to shutdown within %d seconds\n",
660 if (abnode->scanSDW) {
661 if (!abnode->scanKillSent && now - abnode->timeSDStarted > SDTIME) {
662 bnode_StopProc(abnode->scanProc, SIGKILL);
663 abnode->scanKillSent = 1;
665 ("bos shutdown: scanner failed to shutdown within %d seconds\n",
669 SetNeedsClock(abnode);
674 fs_getstat(struct fsbnode *abnode, afs_int32 * astatus)
676 register afs_int32 temp;
677 if (abnode->volSDW || abnode->fileSDW || abnode->salSDW
678 || abnode->scanSDW || abnode->salsrvSDW)
679 temp = BSTAT_SHUTTINGDOWN;
680 else if (abnode->salRunning)
682 else if (abnode->volRunning && abnode->fileRunning
683 && (!abnode->scancmd || abnode->scanRunning)
684 && (!abnode->salsrvcmd || abnode->salsrvRunning))
686 else if (!abnode->salRunning && !abnode->volRunning
687 && !abnode->fileRunning && !abnode->scanRunning
688 && !abnode->salsrvRunning)
689 temp = BSTAT_SHUTDOWN;
691 temp = BSTAT_STARTINGUP;
697 fs_setstat(register struct fsbnode *abnode, afs_int32 astatus)
699 return NudgeProcs(abnode);
703 fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc)
705 /* process has exited */
707 if (aproc == abnode->volProc) {
709 abnode->volRunning = 0;
711 abnode->volKillSent = 0;
712 } else if (aproc == abnode->fileProc) {
713 /* if we were expecting a shutdown and we didn't send a kill signal
714 * and exited (didn't have a signal termination), then we assume that
715 * the file server exited after putting the appropriate volumes safely
716 * offline, and don't salvage next time.
718 if (abnode->fileSDW && !abnode->fileKillSent
719 && aproc->lastSignal == 0)
720 SetSalFlag(abnode, 0); /* shut down normally */
721 abnode->fileProc = 0;
722 abnode->fileRunning = 0;
724 abnode->fileKillSent = 0;
725 } else if (aproc == abnode->salProc) {
726 /* if we didn't shutdown the salvager, then assume it exited ok, and thus
727 * that we don't have to salvage again */
729 SetSalFlag(abnode, 0); /* salvage just completed */
731 abnode->salRunning = 0;
733 abnode->salKillSent = 0;
734 } else if (aproc == abnode->scanProc) {
735 abnode->scanProc = 0;
736 abnode->scanRunning = 0;
738 abnode->scanKillSent = 0;
739 } else if (aproc == abnode->salsrvProc) {
740 abnode->salsrvProc = 0;
741 abnode->salsrvRunning = 0;
742 abnode->salsrvSDW = 0;
743 abnode->salsrvKillSent = 0;
746 /* now restart anyone who needs to restart */
747 return NudgeProcs(abnode);
750 /* make sure we're periodically checking the state if we need to */
752 SetNeedsClock(register struct fsbnode *ab)
754 if (ab->b.goal == 1 && ab->fileRunning && ab->volRunning
755 && (!ab->scancmd || ab->scanRunning)
756 && (!ab->salsrvcmd || ab->salsrvRunning))
757 ab->needsClock = 0; /* running normally */
758 else if (ab->b.goal == 0 && !ab->fileRunning && !ab->volRunning
759 && !ab->salRunning && !ab->scanRunning && !ab->salsrvRunning)
760 ab->needsClock = 0; /* halted normally */
762 ab->needsClock = 1; /* other */
763 if (ab->needsClock && !bnode_PendingTimeout(ab))
764 bnode_SetTimeout(ab, POLLTIME);
766 bnode_SetTimeout(ab, 0);
770 NudgeProcs(register struct fsbnode *abnode)
772 struct bnode_proc *tp; /* not register */
773 register afs_int32 code;
776 now = FT_ApproxTime();
777 if (abnode->b.goal == 1) {
778 /* we're trying to run the system. If the file server is running, then we
779 * are trying to start up the system. If it is not running, then needsSalvage
780 * tells us if we need to run the salvager or not */
781 if (abnode->fileRunning) {
782 if (abnode->salRunning) {
783 bozo_Log("Salvager running along with file server!\n");
784 bozo_Log("Emergency shutdown\n");
786 bnode_SetGoal(abnode, BSTAT_SHUTDOWN);
787 bnode_StopProc(abnode->salProc, SIGKILL);
788 SetNeedsClock(abnode);
791 if (!abnode->volRunning) {
792 abnode->lastVolStart = FT_ApproxTime();
793 code = bnode_NewProc(abnode, abnode->volcmd, "vol", &tp);
795 abnode->volProc = tp;
796 abnode->volRunning = 1;
799 if (abnode->salsrvcmd) {
800 if (!abnode->salsrvRunning) {
801 abnode->lastSalsrvStart = FT_ApproxTime();
803 bnode_NewProc(abnode, abnode->salsrvcmd, "salsrv",
806 abnode->salsrvProc = tp;
807 abnode->salsrvRunning = 1;
811 if (abnode->scancmd) {
812 if (!abnode->scanRunning) {
813 abnode->lastScanStart = FT_ApproxTime();
815 bnode_NewProc(abnode, abnode->scancmd, "scanner",
818 abnode->scanProc = tp;
819 abnode->scanRunning = 1;
823 } else { /* file is not running */
824 /* see how to start */
825 /* for demand attach fs, needsSalvage flag is ignored */
826 if (!abnode->needsSalvage || abnode->salsrvcmd) {
827 /* no crash apparent, just start up normally */
828 if (!abnode->fileRunning) {
829 abnode->lastFileStart = FT_ApproxTime();
831 bnode_NewProc(abnode, abnode->filecmd, "file", &tp);
833 abnode->fileProc = tp;
834 abnode->fileRunning = 1;
835 SetSalFlag(abnode, 1);
838 if (!abnode->volRunning) {
839 abnode->lastVolStart = FT_ApproxTime();
840 code = bnode_NewProc(abnode, abnode->volcmd, "vol", &tp);
842 abnode->volProc = tp;
843 abnode->volRunning = 1;
846 if (abnode->salsrvcmd && !abnode->salsrvRunning) {
847 abnode->lastSalsrvStart = FT_ApproxTime();
849 bnode_NewProc(abnode, abnode->salsrvcmd, "salsrv",
852 abnode->salsrvProc = tp;
853 abnode->salsrvRunning = 1;
856 if (abnode->scancmd && !abnode->scanRunning) {
857 abnode->lastScanStart = FT_ApproxTime();
859 bnode_NewProc(abnode, abnode->scancmd, "scanner",
862 abnode->scanProc = tp;
863 abnode->scanRunning = 1;
866 } else { /* needs to be salvaged */
867 /* make sure file server and volser are gone */
868 if (abnode->volRunning) {
869 bnode_StopProc(abnode->volProc, SIGTERM);
871 abnode->timeSDStarted = now;
874 if (abnode->fileRunning) {
875 bnode_StopProc(abnode->fileProc, SIGQUIT);
876 if (!abnode->fileSDW)
877 abnode->timeSDStarted = now;
880 if (abnode->scanRunning) {
881 bnode_StopProc(abnode->scanProc, SIGTERM);
882 if (!abnode->scanSDW)
883 abnode->timeSDStarted = now;
886 if (abnode->volRunning || abnode->fileRunning
887 || abnode->scanRunning)
889 /* otherwise, it is safe to start salvager */
890 if (!abnode->salRunning) {
891 code = bnode_NewProc(abnode, abnode->salcmd, "salv", &tp);
893 abnode->salProc = tp;
894 abnode->salRunning = 1;
899 } else { /* goal is 0, we're shutting down */
900 /* trying to shutdown */
901 if (abnode->salRunning && !abnode->salSDW) {
902 bnode_StopProc(abnode->salProc, SIGTERM);
904 abnode->timeSDStarted = now;
906 if (abnode->fileRunning && !abnode->fileSDW) {
907 bnode_StopProc(abnode->fileProc, SIGQUIT);
909 abnode->timeSDStarted = now;
911 if (abnode->volRunning && !abnode->volSDW) {
912 bnode_StopProc(abnode->volProc, SIGTERM);
914 abnode->timeSDStarted = now;
916 if (abnode->salsrvRunning && !abnode->salsrvSDW) {
917 bnode_StopProc(abnode->salsrvProc, SIGTERM);
918 abnode->salsrvSDW = 1;
919 abnode->timeSDStarted = now;
921 if (abnode->scanRunning && !abnode->scanSDW) {
922 bnode_StopProc(abnode->scanProc, SIGTERM);
924 abnode->timeSDStarted = now;
927 SetNeedsClock(abnode);
932 fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen)
936 if (abnode->b.goal == 1) {
937 if (abnode->fileRunning) {
939 strcpy(abuffer, "file server shutting down");
940 else if (abnode->scancmd) {
941 if (!abnode->volRunning && !abnode->scanRunning)
943 "file server up; volser and scanner down");
944 else if (abnode->volRunning && !abnode->scanRunning)
946 "file server up; volser up; scanner down");
947 else if (!abnode->volRunning && abnode->scanRunning)
949 "file server up; volser down; scanner up");
952 strcpy(abuffer, "file server running");
953 } else if (!abnode->volRunning)
954 strcpy(abuffer, "file server up; volser down");
956 strcpy(abuffer, "file server running");
957 } else if (abnode->salRunning) {
958 strcpy(abuffer, "salvaging file system");
960 strcpy(abuffer, "starting file server");
963 if (abnode->fileRunning || abnode->volRunning || abnode->scanRunning) {
964 strcpy(abuffer, "file server shutting down");
965 } else if (abnode->salRunning)
966 strcpy(abuffer, "salvager shutting down");
968 strcpy(abuffer, "file server shut down");
974 fs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer,
978 strcpy(abuffer, abnode->filecmd);
979 else if (aindex == 1)
980 strcpy(abuffer, abnode->volcmd);
981 else if (aindex == 2)
982 strcpy(abuffer, abnode->salcmd);
983 else if (aindex == 3 && abnode->scancmd)
984 strcpy(abuffer, abnode->scancmd);
991 dafs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer,
995 strcpy(abuffer, abnode->filecmd);
996 else if (aindex == 1)
997 strcpy(abuffer, abnode->volcmd);
998 else if (aindex == 2)
999 strcpy(abuffer, abnode->salsrvcmd);
1000 else if (aindex == 3)
1001 strcpy(abuffer, abnode->salcmd);
1002 else if (aindex == 4 && abnode->scancmd)
1003 strcpy(abuffer, abnode->scancmd);