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>
38 #endif /* AFS_NT40_ENV */
40 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
41 #include <afs/afsutil.h>
45 static int emergency = 0;
47 /* if this file exists, then we have to salvage the file system */
48 #define SALFILE "SALVAGE."
50 #define POLLTIME 20 /* for handling below */
51 #define SDTIME 60 /* time in seconds given to a process to evaporate */
54 Normal operation involves having the file server and the vol server both running.
56 If the vol server terminates, it can simply be restarted.
58 If the file server terminates, the disk must salvaged before the file server
59 can be restarted. In order to restart either the file server or the salvager,
60 the vol server must be shut down.
62 If the file server terminates *normally* (exits after receiving a SIGQUIT)
63 then we don't have to salvage it.
65 The needsSalvage flag is set when the file server is started. It is cleared
66 if the file server exits when fileSDW is true but fileKillSent is false,
67 indicating that it exited after receiving a quit, but before we sent it a kill.
69 The needsSalvage flag is cleared when the salvager exits.
74 afs_int32 timeSDStarted; /* time shutdown operation started */
75 char *filecmd; /* command to start primary file server */
76 char *volcmd; /* command to start secondary vol server */
77 char *salsrvcmd; /* command to start salvageserver (demand attach fs) */
78 char *salcmd; /* command to start salvager */
79 char *scancmd; /* command to start scanner (MR-AFS) */
80 struct bnode_proc *fileProc; /* process for file server */
81 struct bnode_proc *volProc; /* process for vol server */
82 struct bnode_proc *salsrvProc; /* process for salvageserver (demand attach fs) */
83 struct bnode_proc *salProc; /* process for salvager */
84 struct bnode_proc *scanProc; /* process for scanner (MR-AFS) */
85 afs_int32 lastFileStart; /* last start for file */
86 afs_int32 lastVolStart; /* last start for vol */
87 afs_int32 lastSalsrvStart; /* last start for salvageserver (demand attach fs) */
88 afs_int32 lastScanStart; /* last start for scanner (MR-AFS) */
89 char fileRunning; /* file process is running */
90 char volRunning; /* volser is running */
91 char salsrvRunning; /* salvageserver is running (demand attach fs) */
92 char salRunning; /* salvager is running */
93 char scanRunning; /* scanner is running (MR_AFS) */
94 char fileSDW; /* file shutdown wait */
95 char volSDW; /* vol shutdown wait */
96 char salsrvSDW; /* salvageserver shutdown wait (demand attach fs) */
97 char salSDW; /* waiting for the salvager to shutdown */
98 char scanSDW; /* scanner shutdown wait (MR_AFS) */
99 char fileKillSent; /* kill signal has been sent */
101 char salsrvKillSent; /* kill signal has been sent (demand attach fs) */
103 char scanKillSent; /* kill signal has been sent (MR_AFS) */
104 char needsSalvage; /* salvage before running */
105 char needsClock; /* do we need clock ticks */
110 struct bnode * fs_create(char *ainstance, char *afilecmd, char *avolcmd,
111 char *asalcmd, char *ascancmd);
112 struct bnode * dafs_create(char *ainstance, char *afilecmd, char *avolcmd,
113 char * asalsrvcmd, char *asalcmd, char *ascancmd);
115 static int fs_hascore(register struct ezbnode *abnode);
116 static int fs_restartp(register struct fsbnode *abnode);
117 static int SetSalFlag(register struct fsbnode *abnode, register int aflag);
118 static int RestoreSalFlag(register struct fsbnode *abnode);
119 static int fs_delete(struct fsbnode *abnode);
120 static int fs_timeout(struct fsbnode *abnode);
121 static int fs_getstat(struct fsbnode *abnode, afs_int32 * astatus);
122 static int fs_setstat(register struct fsbnode *abnode, afs_int32 astatus);
123 static int fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc);
124 static int fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen);
127 static int fs_getparm(struct fsbnode *abnode, afs_int32 aindex,
128 char *abuffer, afs_int32 alen);
129 static int dafs_getparm(struct fsbnode *abnode, afs_int32 aindex,
130 char *abuffer, afs_int32 alen);
133 static void AppendExecutableExtension(char *cmd);
135 #define AppendExecutableExtension(x)
138 static void SetNeedsClock(register struct fsbnode *ab);
139 static int NudgeProcs(register struct fsbnode *abnode);
143 struct bnode_ops fsbnode_ops = {
156 /* demand attach fs bnode ops */
157 struct bnode_ops dafsbnode_ops = {
171 /* Function to tell whether this bnode has a core file or not. You might
172 * think that this could be in bnode.c, and decide what core files to check
173 * for based on the bnode's coreName property, but that doesn't work because
174 * there may not be an active process for a bnode that dumped core at the
175 * time the query is done.
178 fs_hascore(register struct ezbnode *abnode)
182 /* see if file server has a core file */
183 bnode_CoreName(abnode, "file", tbuffer);
184 if (access(tbuffer, 0) == 0)
187 /* see if volserver has a core file */
188 bnode_CoreName(abnode, "vol", tbuffer);
189 if (access(tbuffer, 0) == 0)
192 /* see if salvageserver left a core file */
193 bnode_CoreName(abnode, "salsrv", tbuffer);
194 if (access(tbuffer, 0) == 0)
197 /* see if salvager left a core file */
198 bnode_CoreName(abnode, "salv", tbuffer);
199 if (access(tbuffer, 0) == 0)
202 /* see if scanner left a core file (MR-AFS) */
203 bnode_CoreName(abnode, "scan", tbuffer);
204 if (access(tbuffer, 0) == 0)
207 /* no one left a core file */
212 fs_restartp(register struct fsbnode *abnode)
214 struct bnode_token *tt;
215 register afs_int32 code;
218 code = bnode_ParseLine(abnode->filecmd, &tt);
223 code = stat(tt->key, &tstat);
225 bnode_FreeTokens(tt);
228 if (tstat.st_ctime > abnode->lastFileStart)
232 bnode_FreeTokens(tt);
236 /* now do same for volcmd */
237 code = bnode_ParseLine(abnode->volcmd, &tt);
242 code = stat(tt->key, &tstat);
244 bnode_FreeTokens(tt);
247 if (tstat.st_ctime > abnode->lastVolStart)
251 bnode_FreeTokens(tt);
255 if (abnode->salsrvcmd) { /* only in demand attach fs */
256 /* now do same for salsrvcmd (demand attach fs) */
257 code = bnode_ParseLine(abnode->salsrvcmd, &tt);
262 code = stat(tt->key, &tstat);
264 bnode_FreeTokens(tt);
267 if (tstat.st_ctime > abnode->lastScanStart)
271 bnode_FreeTokens(tt);
274 if (abnode->scancmd) { /* Only in MR-AFS */
275 /* now do same for scancmd (MR-AFS) */
276 code = bnode_ParseLine(abnode->scancmd, &tt);
281 code = stat(tt->key, &tstat);
283 bnode_FreeTokens(tt);
286 if (tstat.st_ctime > abnode->lastScanStart)
290 bnode_FreeTokens(tt);
296 /* set needsSalvage flag, creating file SALVAGE.<instancename> if
297 we need to salvage the file system (so we can tell over panic reboots */
299 SetSalFlag(register struct fsbnode *abnode, register int aflag)
301 char tbuffer[AFSDIR_PATH_MAX];
304 /* don't use the salvage flag for demand attach fs */
305 if (abnode->salsrvcmd == NULL) {
306 abnode->needsSalvage = aflag;
307 strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
308 SALFILE, abnode->b.name, NULL);
310 fd = open(tbuffer, O_CREAT | O_TRUNC | O_RDWR, 0666);
319 /* set the needsSalvage flag according to the existence of the salvage file */
321 RestoreSalFlag(register struct fsbnode *abnode)
323 char tbuffer[AFSDIR_PATH_MAX];
325 /* never set needs salvage flag for demand attach fs */
326 if (abnode->salsrvcmd != NULL) {
327 abnode->needsSalvage = 0;
329 strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
330 SALFILE, abnode->b.name, NULL);
331 if (access(tbuffer, 0) == 0) {
332 /* file exists, so need to salvage */
333 abnode->needsSalvage = 1;
335 abnode->needsSalvage = 0;
342 copystr(register char *a)
345 b = (char *)malloc(strlen(a) + 1);
351 fs_delete(struct fsbnode *abnode)
353 free(abnode->filecmd);
354 free(abnode->volcmd);
355 free(abnode->salcmd);
356 if (abnode->salsrvcmd)
357 free(abnode->salsrvcmd);
359 free(abnode->scancmd);
367 AppendExecutableExtension(char *cmd)
369 char cmdext[_MAX_EXT];
371 _splitpath(cmd, NULL, NULL, NULL, cmdext);
372 if (*cmdext == '\0') {
373 /* no filename extension supplied for cmd; append .exe */
377 #endif /* AFS_NT40_ENV */
381 fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd,
385 register struct fsbnode *te;
386 char cmdname[AFSDIR_PATH_MAX];
387 char *fileCmdpath, *volCmdpath, *salCmdpath, *scanCmdpath;
390 te = fileCmdpath = volCmdpath = salCmdpath = scanCmdpath = NULL;
392 /* construct local paths from canonical (wire-format) paths */
393 if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) {
394 bozo_Log("BNODE: command path invalid '%s'\n", afilecmd);
398 if (ConstructLocalBinPath(avolcmd, &volCmdpath)) {
399 bozo_Log("BNODE: command path invalid '%s'\n", avolcmd);
403 if (ConstructLocalBinPath(asalcmd, &salCmdpath)) {
404 bozo_Log("BNODE: command path invalid '%s'\n", asalcmd);
409 if (ascancmd && strlen(ascancmd)) {
410 if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
411 bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
418 sscanf(fileCmdpath, "%s", cmdname);
419 AppendExecutableExtension(cmdname);
420 if (stat(cmdname, &tstat)) {
421 bozo_Log("BNODE: file server binary '%s' not found\n", cmdname);
426 sscanf(volCmdpath, "%s", cmdname);
427 AppendExecutableExtension(cmdname);
428 if (stat(cmdname, &tstat)) {
429 bozo_Log("BNODE: volume server binary '%s' not found\n", cmdname);
434 sscanf(salCmdpath, "%s", cmdname);
435 AppendExecutableExtension(cmdname);
436 if (stat(cmdname, &tstat)) {
437 bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
442 if (ascancmd && strlen(ascancmd)) {
443 sscanf(scanCmdpath, "%s", cmdname);
444 AppendExecutableExtension(cmdname);
445 if (stat(cmdname, &tstat)) {
446 bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
453 te = (struct fsbnode *)malloc(sizeof(struct fsbnode));
458 memset(te, 0, sizeof(struct fsbnode));
459 te->filecmd = fileCmdpath;
460 te->volcmd = volCmdpath;
461 te->salsrvcmd = NULL;
462 te->salcmd = salCmdpath;
463 if (ascancmd && strlen(ascancmd))
464 te->scancmd = scanCmdpath;
467 if (bnode_InitBnode(te, &fsbnode_ops, ainstance) != 0) {
471 bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */
472 RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */
473 SetNeedsClock(te); /* compute needsClock field */
490 return (struct bnode *)te;
493 /* create a demand attach fs bnode */
495 dafs_create(char *ainstance, char *afilecmd, char *avolcmd,
496 char * asalsrvcmd, char *asalcmd, char *ascancmd)
499 register struct fsbnode *te;
500 char cmdname[AFSDIR_PATH_MAX];
501 char *fileCmdpath, *volCmdpath, *salsrvCmdpath, *salCmdpath, *scanCmdpath;
504 te = fileCmdpath = volCmdpath = salsrvCmdpath = salCmdpath = scanCmdpath = NULL;
506 /* construct local paths from canonical (wire-format) paths */
507 if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) {
508 bozo_Log("BNODE: command path invalid '%s'\n", afilecmd);
512 if (ConstructLocalBinPath(avolcmd, &volCmdpath)) {
513 bozo_Log("BNODE: command path invalid '%s'\n", avolcmd);
517 if (ConstructLocalBinPath(asalsrvcmd, &salsrvCmdpath)) {
518 bozo_Log("BNODE: command path invalid '%s'\n", asalsrvcmd);
522 if (ConstructLocalBinPath(asalcmd, &salCmdpath)) {
523 bozo_Log("BNODE: command path invalid '%s'\n", asalcmd);
528 if (ascancmd && strlen(ascancmd)) {
529 if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
530 bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
537 sscanf(fileCmdpath, "%s", cmdname);
538 AppendExecutableExtension(cmdname);
539 if (stat(cmdname, &tstat)) {
540 bozo_Log("BNODE: file server binary '%s' not found\n", cmdname);
545 sscanf(volCmdpath, "%s", cmdname);
546 AppendExecutableExtension(cmdname);
547 if (stat(cmdname, &tstat)) {
548 bozo_Log("BNODE: volume server binary '%s' not found\n", cmdname);
553 sscanf(salsrvCmdpath, "%s", cmdname);
554 AppendExecutableExtension(cmdname);
555 if (stat(cmdname, &tstat)) {
556 bozo_Log("BNODE: salvageserver binary '%s' not found\n", cmdname);
561 sscanf(salCmdpath, "%s", cmdname);
562 AppendExecutableExtension(cmdname);
563 if (stat(cmdname, &tstat)) {
564 bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
569 if (ascancmd && strlen(ascancmd)) {
570 sscanf(scanCmdpath, "%s", cmdname);
571 AppendExecutableExtension(cmdname);
572 if (stat(cmdname, &tstat)) {
573 bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
580 te = (struct fsbnode *)malloc(sizeof(struct fsbnode));
585 memset(te, 0, sizeof(struct fsbnode));
586 te->filecmd = fileCmdpath;
587 te->volcmd = volCmdpath;
588 te->salsrvcmd = salsrvCmdpath;
589 te->salcmd = salCmdpath;
590 if (ascancmd && strlen(ascancmd))
591 te->scancmd = scanCmdpath;
594 if (bnode_InitBnode(te, &dafsbnode_ops, ainstance) != 0) {
598 bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */
599 RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */
600 SetNeedsClock(te); /* compute needsClock field */
619 return (struct bnode *)te;
622 /* called to SIGKILL a process if it doesn't terminate normally */
624 fs_timeout(struct fsbnode *abnode)
626 register afs_int32 now;
628 now = FT_ApproxTime();
630 if (abnode->volSDW) {
631 if (!abnode->volKillSent && now - abnode->timeSDStarted > SDTIME) {
632 bnode_StopProc(abnode->volProc, SIGKILL);
633 abnode->volKillSent = 1;
635 ("bos shutdown: volserver failed to shutdown within %d seconds\n",
639 if (abnode->salSDW) {
640 if (!abnode->salKillSent && now - abnode->timeSDStarted > SDTIME) {
641 bnode_StopProc(abnode->salProc, SIGKILL);
642 abnode->salKillSent = 1;
644 ("bos shutdown: salvager failed to shutdown within %d seconds\n",
648 if (abnode->fileSDW) {
649 if (!abnode->fileKillSent && now - abnode->timeSDStarted > FSSDTIME) {
650 bnode_StopProc(abnode->fileProc, SIGKILL);
651 abnode->fileKillSent = 1;
653 ("bos shutdown: fileserver failed to shutdown within %d seconds\n",
657 if (abnode->salsrvSDW) {
658 if (!abnode->salsrvKillSent && now - abnode->timeSDStarted > SDTIME) {
659 bnode_StopProc(abnode->salsrvProc, SIGKILL);
660 abnode->salsrvKillSent = 1;
662 ("bos shutdown: salvageserver failed to shutdown within %d seconds\n",
666 if (abnode->scanSDW) {
667 if (!abnode->scanKillSent && now - abnode->timeSDStarted > SDTIME) {
668 bnode_StopProc(abnode->scanProc, SIGKILL);
669 abnode->scanKillSent = 1;
671 ("bos shutdown: scanner failed to shutdown within %d seconds\n",
675 SetNeedsClock(abnode);
680 fs_getstat(struct fsbnode *abnode, afs_int32 * astatus)
682 register afs_int32 temp;
683 if (abnode->volSDW || abnode->fileSDW || abnode->salSDW
684 || abnode->scanSDW || abnode->salsrvSDW)
685 temp = BSTAT_SHUTTINGDOWN;
686 else if (abnode->salRunning)
688 else if (abnode->volRunning && abnode->fileRunning
689 && (!abnode->scancmd || abnode->scanRunning)
690 && (!abnode->salsrvcmd || abnode->salsrvRunning))
692 else if (!abnode->salRunning && !abnode->volRunning
693 && !abnode->fileRunning && !abnode->scanRunning
694 && !abnode->salsrvRunning)
695 temp = BSTAT_SHUTDOWN;
697 temp = BSTAT_STARTINGUP;
703 fs_setstat(register struct fsbnode *abnode, afs_int32 astatus)
705 return NudgeProcs(abnode);
709 fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc)
711 /* process has exited */
713 if (aproc == abnode->volProc) {
715 abnode->volRunning = 0;
717 abnode->volKillSent = 0;
718 } else if (aproc == abnode->fileProc) {
719 /* if we were expecting a shutdown and we didn't send a kill signal
720 * and exited (didn't have a signal termination), then we assume that
721 * the file server exited after putting the appropriate volumes safely
722 * offline, and don't salvage next time.
724 if (abnode->fileSDW && !abnode->fileKillSent
725 && aproc->lastSignal == 0)
726 SetSalFlag(abnode, 0); /* shut down normally */
727 abnode->fileProc = 0;
728 abnode->fileRunning = 0;
730 abnode->fileKillSent = 0;
731 } else if (aproc == abnode->salProc) {
732 /* if we didn't shutdown the salvager, then assume it exited ok, and thus
733 * that we don't have to salvage again */
735 SetSalFlag(abnode, 0); /* salvage just completed */
737 abnode->salRunning = 0;
739 abnode->salKillSent = 0;
740 } else if (aproc == abnode->scanProc) {
741 abnode->scanProc = 0;
742 abnode->scanRunning = 0;
744 abnode->scanKillSent = 0;
745 } else if (aproc == abnode->salsrvProc) {
746 abnode->salsrvProc = 0;
747 abnode->salsrvRunning = 0;
748 abnode->salsrvSDW = 0;
749 abnode->salsrvKillSent = 0;
752 /* now restart anyone who needs to restart */
753 return NudgeProcs(abnode);
756 /* make sure we're periodically checking the state if we need to */
758 SetNeedsClock(register struct fsbnode *ab)
760 if (ab->b.goal == 1 && ab->fileRunning && ab->volRunning
761 && (!ab->scancmd || ab->scanRunning)
762 && (!ab->salsrvcmd || ab->salsrvRunning))
763 ab->needsClock = 0; /* running normally */
764 else if (ab->b.goal == 0 && !ab->fileRunning && !ab->volRunning
765 && !ab->salRunning && !ab->scanRunning && !ab->salsrvRunning)
766 ab->needsClock = 0; /* halted normally */
768 ab->needsClock = 1; /* other */
769 if (ab->needsClock && !bnode_PendingTimeout(ab))
770 bnode_SetTimeout(ab, POLLTIME);
772 bnode_SetTimeout(ab, 0);
776 NudgeProcs(register struct fsbnode *abnode)
778 struct bnode_proc *tp; /* not register */
779 register afs_int32 code;
782 now = FT_ApproxTime();
783 if (abnode->b.goal == 1) {
784 /* we're trying to run the system. If the file server is running, then we
785 * are trying to start up the system. If it is not running, then needsSalvage
786 * tells us if we need to run the salvager or not */
787 if (abnode->fileRunning) {
788 if (abnode->salRunning) {
789 bozo_Log("Salvager running along with file server!\n");
790 bozo_Log("Emergency shutdown\n");
792 bnode_SetGoal(abnode, BSTAT_SHUTDOWN);
793 bnode_StopProc(abnode->salProc, SIGKILL);
794 SetNeedsClock(abnode);
797 if (!abnode->volRunning) {
798 abnode->lastVolStart = FT_ApproxTime();
799 code = bnode_NewProc(abnode, abnode->volcmd, "vol", &tp);
801 abnode->volProc = tp;
802 abnode->volRunning = 1;
805 if (abnode->salsrvcmd) {
806 if (!abnode->salsrvRunning) {
807 abnode->lastSalsrvStart = FT_ApproxTime();
809 bnode_NewProc(abnode, abnode->salsrvcmd, "salsrv",
812 abnode->salsrvProc = tp;
813 abnode->salsrvRunning = 1;
817 if (abnode->scancmd) {
818 if (!abnode->scanRunning) {
819 abnode->lastScanStart = FT_ApproxTime();
821 bnode_NewProc(abnode, abnode->scancmd, "scanner",
824 abnode->scanProc = tp;
825 abnode->scanRunning = 1;
829 } else { /* file is not running */
830 /* see how to start */
831 /* for demand attach fs, needsSalvage flag is ignored */
832 if (!abnode->needsSalvage || abnode->salsrvcmd) {
833 /* no crash apparent, just start up normally */
834 if (!abnode->fileRunning) {
835 abnode->lastFileStart = FT_ApproxTime();
837 bnode_NewProc(abnode, abnode->filecmd, "file", &tp);
839 abnode->fileProc = tp;
840 abnode->fileRunning = 1;
841 SetSalFlag(abnode, 1);
844 if (!abnode->volRunning) {
845 abnode->lastVolStart = FT_ApproxTime();
846 code = bnode_NewProc(abnode, abnode->volcmd, "vol", &tp);
848 abnode->volProc = tp;
849 abnode->volRunning = 1;
852 if (abnode->salsrvcmd && !abnode->salsrvRunning) {
853 abnode->lastSalsrvStart = FT_ApproxTime();
855 bnode_NewProc(abnode, abnode->salsrvcmd, "salsrv",
858 abnode->salsrvProc = tp;
859 abnode->salsrvRunning = 1;
862 if (abnode->scancmd && !abnode->scanRunning) {
863 abnode->lastScanStart = FT_ApproxTime();
865 bnode_NewProc(abnode, abnode->scancmd, "scanner",
868 abnode->scanProc = tp;
869 abnode->scanRunning = 1;
872 } else { /* needs to be salvaged */
873 /* make sure file server and volser are gone */
874 if (abnode->volRunning) {
875 bnode_StopProc(abnode->volProc, SIGTERM);
877 abnode->timeSDStarted = now;
880 if (abnode->fileRunning) {
881 bnode_StopProc(abnode->fileProc, SIGQUIT);
882 if (!abnode->fileSDW)
883 abnode->timeSDStarted = now;
886 if (abnode->scanRunning) {
887 bnode_StopProc(abnode->scanProc, SIGTERM);
888 if (!abnode->scanSDW)
889 abnode->timeSDStarted = now;
892 if (abnode->volRunning || abnode->fileRunning
893 || abnode->scanRunning)
895 /* otherwise, it is safe to start salvager */
896 if (!abnode->salRunning) {
897 code = bnode_NewProc(abnode, abnode->salcmd, "salv", &tp);
899 abnode->salProc = tp;
900 abnode->salRunning = 1;
905 } else { /* goal is 0, we're shutting down */
906 /* trying to shutdown */
907 if (abnode->salRunning && !abnode->salSDW) {
908 bnode_StopProc(abnode->salProc, SIGTERM);
910 abnode->timeSDStarted = now;
912 if (abnode->fileRunning && !abnode->fileSDW) {
913 bnode_StopProc(abnode->fileProc, SIGQUIT);
915 abnode->timeSDStarted = now;
917 if (abnode->volRunning && !abnode->volSDW) {
918 bnode_StopProc(abnode->volProc, SIGTERM);
920 abnode->timeSDStarted = now;
922 if (abnode->salsrvRunning && !abnode->salsrvSDW) {
923 bnode_StopProc(abnode->salsrvProc, SIGTERM);
924 abnode->salsrvSDW = 1;
925 abnode->timeSDStarted = now;
927 if (abnode->scanRunning && !abnode->scanSDW) {
928 bnode_StopProc(abnode->scanProc, SIGTERM);
930 abnode->timeSDStarted = now;
933 SetNeedsClock(abnode);
938 fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen)
942 if (abnode->b.goal == 1) {
943 if (abnode->fileRunning) {
945 strcpy(abuffer, "file server shutting down");
946 else if (abnode->scancmd) {
947 if (!abnode->volRunning && !abnode->scanRunning)
949 "file server up; volser and scanner down");
950 else if (abnode->volRunning && !abnode->scanRunning)
952 "file server up; volser up; scanner down");
953 else if (!abnode->volRunning && abnode->scanRunning)
955 "file server up; volser down; scanner up");
958 strcpy(abuffer, "file server running");
959 } else if (!abnode->volRunning)
960 strcpy(abuffer, "file server up; volser down");
962 strcpy(abuffer, "file server running");
963 } else if (abnode->salRunning) {
964 strcpy(abuffer, "salvaging file system");
966 strcpy(abuffer, "starting file server");
969 if (abnode->fileRunning || abnode->volRunning || abnode->scanRunning) {
970 strcpy(abuffer, "file server shutting down");
971 } else if (abnode->salRunning)
972 strcpy(abuffer, "salvager shutting down");
974 strcpy(abuffer, "file server shut down");
980 fs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer,
984 strcpy(abuffer, abnode->filecmd);
985 else if (aindex == 1)
986 strcpy(abuffer, abnode->volcmd);
987 else if (aindex == 2)
988 strcpy(abuffer, abnode->salcmd);
989 else if (aindex == 3 && abnode->scancmd)
990 strcpy(abuffer, abnode->scancmd);
997 dafs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer,
1001 strcpy(abuffer, abnode->filecmd);
1002 else if (aindex == 1)
1003 strcpy(abuffer, abnode->volcmd);
1004 else if (aindex == 2)
1005 strcpy(abuffer, abnode->salsrvcmd);
1006 else if (aindex == 3)
1007 strcpy(abuffer, abnode->salcmd);
1008 else if (aindex == 4 && abnode->scancmd)
1009 strcpy(abuffer, abnode->scancmd);