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>
14 #include <sys/types.h>
31 #endif /* AFS_NT40_ENV */
33 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
34 #include <afs/afsutil.h>
36 #include "bosprototypes.h"
38 static int emergency = 0;
40 /* if this file exists, then we have to salvage the file system */
41 #define SALFILE "SALVAGE."
43 #define POLLTIME 20 /* for handling below */
44 #define SDTIME 60 /* time in seconds given to a process to evaporate */
47 Normal operation involves having the file server and the vol server both running.
49 If the vol server terminates, it can simply be restarted.
51 If the file server terminates, the disk must salvaged before the file server
52 can be restarted. In order to restart either the file server or the salvager,
53 the vol server must be shut down.
55 If the file server terminates *normally* (exits after receiving a SIGQUIT)
56 then we don't have to salvage it.
58 The needsSalvage flag is set when the file server is started. It is cleared
59 if the file server exits when fileSDW is true but fileKillSent is false,
60 indicating that it exited after receiving a quit, but before we sent it a kill.
62 The needsSalvage flag is cleared when the salvager exits.
67 afs_int32 timeSDStarted; /* time shutdown operation started */
68 char *filecmd; /* command to start primary file server */
69 char *volcmd; /* command to start secondary vol server */
70 char *salsrvcmd; /* command to start salvageserver (demand attach fs) */
71 char *salcmd; /* command to start salvager */
72 char *scancmd; /* command to start scanner (MR-AFS) */
73 struct bnode_proc *fileProc; /* process for file server */
74 struct bnode_proc *volProc; /* process for vol server */
75 struct bnode_proc *salsrvProc; /* process for salvageserver (demand attach fs) */
76 struct bnode_proc *salProc; /* process for salvager */
77 struct bnode_proc *scanProc; /* process for scanner (MR-AFS) */
78 afs_int32 lastFileStart; /* last start for file */
79 afs_int32 lastVolStart; /* last start for vol */
80 afs_int32 lastSalsrvStart; /* last start for salvageserver (demand attach fs) */
81 afs_int32 lastScanStart; /* last start for scanner (MR-AFS) */
82 char fileRunning; /* file process is running */
83 char volRunning; /* volser is running */
84 char salsrvRunning; /* salvageserver is running (demand attach fs) */
85 char salRunning; /* salvager is running */
86 char scanRunning; /* scanner is running (MR_AFS) */
87 char fileSDW; /* file shutdown wait */
88 char volSDW; /* vol shutdown wait */
89 char salsrvSDW; /* salvageserver shutdown wait (demand attach fs) */
90 char salSDW; /* waiting for the salvager to shutdown */
91 char scanSDW; /* scanner shutdown wait (MR_AFS) */
92 char fileKillSent; /* kill signal has been sent */
94 char salsrvKillSent; /* kill signal has been sent (demand attach fs) */
96 char scanKillSent; /* kill signal has been sent (MR_AFS) */
97 char needsSalvage; /* salvage before running */
98 char needsClock; /* do we need clock ticks */
101 struct bnode * fs_create(char *ainstance, char *afilecmd, char *avolcmd,
102 char *asalcmd, char *ascancmd, char *dummy);
103 struct bnode * dafs_create(char *ainstance, char *afilecmd, char *avolcmd,
104 char * asalsrvcmd, char *asalcmd, char *ascancmd);
106 static int fs_hascore(struct bnode *abnode);
107 static int fs_restartp(struct bnode *abnode);
108 static int fs_delete(struct bnode *abnode);
109 static int fs_timeout(struct bnode *abnode);
110 static int fs_getstat(struct bnode *abnode, afs_int32 * astatus);
111 static int fs_setstat(struct bnode *abnode, afs_int32 astatus);
112 static int fs_procexit(struct bnode *abnode, struct bnode_proc *aproc);
113 static int fs_getstring(struct bnode *abnode, char *abuffer, afs_int32 alen);
114 static int fs_getparm(struct bnode *abnode, afs_int32 aindex,
115 char *abuffer, afs_int32 alen);
116 static int dafs_getparm(struct bnode *abnode, afs_int32 aindex,
117 char *abuffer, afs_int32 alen);
119 static int SetSalFlag(struct fsbnode *abnode, int aflag);
120 static int RestoreSalFlag(struct fsbnode *abnode);
121 static void SetNeedsClock(struct fsbnode *);
122 static int NudgeProcs(struct fsbnode *);
125 static void AppendExecutableExtension(char *cmd);
127 #define AppendExecutableExtension(x)
130 struct bnode_ops fsbnode_ops = {
143 /* demand attach fs bnode ops */
144 struct bnode_ops dafsbnode_ops = {
157 /* Quick inline function to safely convert a fsbnode to a bnode without
158 * dropping type information
161 static_inline struct bnode *
162 fsbnode2bnode(struct fsbnode *abnode) {
163 return (struct bnode *) abnode;
166 /* Function to tell whether this bnode has a core file or not. You might
167 * think that this could be in bnode.c, and decide what core files to check
168 * for based on the bnode's coreName property, but that doesn't work because
169 * there may not be an active process for a bnode that dumped core at the
170 * time the query is done.
173 fs_hascore(struct bnode *abnode)
177 /* see if file server has a core file */
178 bnode_CoreName(abnode, "file", tbuffer);
179 if (access(tbuffer, 0) == 0)
182 /* see if volserver has a core file */
183 bnode_CoreName(abnode, "vol", tbuffer);
184 if (access(tbuffer, 0) == 0)
187 /* see if salvageserver left a core file */
188 bnode_CoreName(abnode, "salsrv", tbuffer);
189 if (access(tbuffer, 0) == 0)
192 /* see if salvager left a core file */
193 bnode_CoreName(abnode, "salv", tbuffer);
194 if (access(tbuffer, 0) == 0)
197 /* see if scanner left a core file (MR-AFS) */
198 bnode_CoreName(abnode, "scan", tbuffer);
199 if (access(tbuffer, 0) == 0)
202 /* no one left a core file */
207 fs_restartp(struct bnode *bn)
209 struct fsbnode *abnode = (struct fsbnode *)bn;
210 struct bnode_token *tt;
214 code = bnode_ParseLine(abnode->filecmd, &tt);
219 code = stat(tt->key, &tstat);
221 bnode_FreeTokens(tt);
224 if (tstat.st_ctime > abnode->lastFileStart)
228 bnode_FreeTokens(tt);
232 /* now do same for volcmd */
233 code = bnode_ParseLine(abnode->volcmd, &tt);
238 code = stat(tt->key, &tstat);
240 bnode_FreeTokens(tt);
243 if (tstat.st_ctime > abnode->lastVolStart)
247 bnode_FreeTokens(tt);
251 if (abnode->salsrvcmd) { /* only in demand attach fs */
252 /* now do same for salsrvcmd (demand attach fs) */
253 code = bnode_ParseLine(abnode->salsrvcmd, &tt);
258 code = stat(tt->key, &tstat);
260 bnode_FreeTokens(tt);
263 if (tstat.st_ctime > abnode->lastSalsrvStart)
267 bnode_FreeTokens(tt);
270 if (abnode->scancmd) { /* Only in MR-AFS */
271 /* now do same for scancmd (MR-AFS) */
272 code = bnode_ParseLine(abnode->scancmd, &tt);
277 code = stat(tt->key, &tstat);
279 bnode_FreeTokens(tt);
282 if (tstat.st_ctime > abnode->lastScanStart)
286 bnode_FreeTokens(tt);
292 /* set needsSalvage flag, creating file SALVAGE.<instancename> if
293 we need to salvage the file system (so we can tell over panic reboots */
295 SetSalFlag(struct fsbnode *abnode, int aflag)
297 char tbuffer[AFSDIR_PATH_MAX];
300 /* don't use the salvage flag for demand attach fs */
301 if (abnode->salsrvcmd == NULL) {
302 abnode->needsSalvage = aflag;
303 strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
304 SALFILE, abnode->b.name, NULL);
306 fd = open(tbuffer, O_CREAT | O_TRUNC | O_RDWR, 0666);
315 /* set the needsSalvage flag according to the existence of the salvage file */
317 RestoreSalFlag(struct fsbnode *abnode)
319 char tbuffer[AFSDIR_PATH_MAX];
321 /* never set needs salvage flag for demand attach fs */
322 if (abnode->salsrvcmd != NULL) {
323 abnode->needsSalvage = 0;
325 strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/",
326 SALFILE, abnode->b.name, NULL);
327 if (access(tbuffer, 0) == 0) {
328 /* file exists, so need to salvage */
329 abnode->needsSalvage = 1;
331 abnode->needsSalvage = 0;
341 b = (char *)malloc(strlen(a) + 1);
347 fs_delete(struct bnode *bn)
349 struct fsbnode *abnode = (struct fsbnode *)bn;
351 free(abnode->filecmd);
352 free(abnode->volcmd);
353 free(abnode->salcmd);
354 if (abnode->salsrvcmd)
355 free(abnode->salsrvcmd);
357 free(abnode->scancmd);
365 AppendExecutableExtension(char *cmd)
367 char cmdext[_MAX_EXT];
369 _splitpath(cmd, NULL, NULL, NULL, cmdext);
370 if (*cmdext == '\0') {
371 /* no filename extension supplied for cmd; append .exe */
375 #endif /* AFS_NT40_ENV */
379 fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd,
380 char *ascancmd, char *dummy)
384 char cmdname[AFSDIR_PATH_MAX];
385 char *fileCmdpath, *volCmdpath, *salCmdpath, *scanCmdpath;
388 fileCmdpath = volCmdpath = salCmdpath = scanCmdpath = NULL;
391 /* construct local paths from canonical (wire-format) paths */
392 if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) {
393 bozo_Log("BNODE: command path invalid '%s'\n", afilecmd);
397 if (ConstructLocalBinPath(avolcmd, &volCmdpath)) {
398 bozo_Log("BNODE: command path invalid '%s'\n", avolcmd);
402 if (ConstructLocalBinPath(asalcmd, &salCmdpath)) {
403 bozo_Log("BNODE: command path invalid '%s'\n", asalcmd);
408 if (ascancmd && strlen(ascancmd)) {
409 if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
410 bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
417 sscanf(fileCmdpath, "%s", cmdname);
418 AppendExecutableExtension(cmdname);
419 if (stat(cmdname, &tstat)) {
420 bozo_Log("BNODE: file server binary '%s' not found\n", cmdname);
425 sscanf(volCmdpath, "%s", cmdname);
426 AppendExecutableExtension(cmdname);
427 if (stat(cmdname, &tstat)) {
428 bozo_Log("BNODE: volume server binary '%s' not found\n", cmdname);
433 sscanf(salCmdpath, "%s", cmdname);
434 AppendExecutableExtension(cmdname);
435 if (stat(cmdname, &tstat)) {
436 bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
441 if (ascancmd && strlen(ascancmd)) {
442 sscanf(scanCmdpath, "%s", cmdname);
443 AppendExecutableExtension(cmdname);
444 if (stat(cmdname, &tstat)) {
445 bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
452 te = (struct fsbnode *)malloc(sizeof(struct fsbnode));
457 memset(te, 0, sizeof(struct fsbnode));
458 te->filecmd = fileCmdpath;
459 te->volcmd = volCmdpath;
460 te->salsrvcmd = NULL;
461 te->salcmd = salCmdpath;
462 if (ascancmd && strlen(ascancmd))
463 te->scancmd = scanCmdpath;
466 if (bnode_InitBnode(fsbnode2bnode(te), &fsbnode_ops, ainstance) != 0) {
470 bnode_SetTimeout(fsbnode2bnode(te), POLLTIME);
471 /* 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 fsbnode2bnode(te);
493 /* create a demand attach fs bnode */
495 dafs_create(char *ainstance, char *afilecmd, char *avolcmd,
496 char * asalsrvcmd, char *asalcmd, char *ascancmd)
500 char cmdname[AFSDIR_PATH_MAX];
501 char *fileCmdpath, *volCmdpath, *salsrvCmdpath, *salCmdpath, *scanCmdpath;
504 fileCmdpath = volCmdpath = salsrvCmdpath = salCmdpath = scanCmdpath = NULL;
507 /* construct local paths from canonical (wire-format) paths */
508 if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) {
509 bozo_Log("BNODE: command path invalid '%s'\n", afilecmd);
513 if (ConstructLocalBinPath(avolcmd, &volCmdpath)) {
514 bozo_Log("BNODE: command path invalid '%s'\n", avolcmd);
518 if (ConstructLocalBinPath(asalsrvcmd, &salsrvCmdpath)) {
519 bozo_Log("BNODE: command path invalid '%s'\n", asalsrvcmd);
523 if (ConstructLocalBinPath(asalcmd, &salCmdpath)) {
524 bozo_Log("BNODE: command path invalid '%s'\n", asalcmd);
529 if (ascancmd && strlen(ascancmd)) {
530 if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
531 bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
538 sscanf(fileCmdpath, "%s", cmdname);
539 AppendExecutableExtension(cmdname);
540 if (stat(cmdname, &tstat)) {
541 bozo_Log("BNODE: file server binary '%s' not found\n", cmdname);
546 sscanf(volCmdpath, "%s", cmdname);
547 AppendExecutableExtension(cmdname);
548 if (stat(cmdname, &tstat)) {
549 bozo_Log("BNODE: volume server binary '%s' not found\n", cmdname);
554 sscanf(salsrvCmdpath, "%s", cmdname);
555 AppendExecutableExtension(cmdname);
556 if (stat(cmdname, &tstat)) {
557 bozo_Log("BNODE: salvageserver binary '%s' not found\n", cmdname);
562 sscanf(salCmdpath, "%s", cmdname);
563 AppendExecutableExtension(cmdname);
564 if (stat(cmdname, &tstat)) {
565 bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
570 if (ascancmd && strlen(ascancmd)) {
571 sscanf(scanCmdpath, "%s", cmdname);
572 AppendExecutableExtension(cmdname);
573 if (stat(cmdname, &tstat)) {
574 bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
581 te = (struct fsbnode *)malloc(sizeof(struct fsbnode));
586 memset(te, 0, sizeof(struct fsbnode));
587 te->filecmd = fileCmdpath;
588 te->volcmd = volCmdpath;
589 te->salsrvcmd = salsrvCmdpath;
590 te->salcmd = salCmdpath;
591 if (ascancmd && strlen(ascancmd))
592 te->scancmd = scanCmdpath;
595 if (bnode_InitBnode(fsbnode2bnode(te), &dafsbnode_ops, ainstance) != 0) {
599 bnode_SetTimeout(fsbnode2bnode(te), POLLTIME);
600 /* ask for timeout activations every 10 seconds */
601 RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */
602 SetNeedsClock(te); /* compute needsClock field */
621 return fsbnode2bnode(te);
624 /* called to SIGKILL a process if it doesn't terminate normally */
626 fs_timeout(struct bnode *bn)
628 struct fsbnode *abnode = (struct fsbnode *)bn;
632 now = FT_ApproxTime();
634 if (abnode->volSDW) {
635 if (!abnode->volKillSent && now - abnode->timeSDStarted > SDTIME) {
636 bnode_StopProc(abnode->volProc, SIGKILL);
637 abnode->volKillSent = 1;
639 ("bos shutdown: volserver failed to shutdown within %d seconds\n",
643 if (abnode->salSDW) {
644 if (!abnode->salKillSent && now - abnode->timeSDStarted > SDTIME) {
645 bnode_StopProc(abnode->salProc, SIGKILL);
646 abnode->salKillSent = 1;
648 ("bos shutdown: salvager failed to shutdown within %d seconds\n",
652 if (abnode->fileSDW) {
653 if (!abnode->fileKillSent && now - abnode->timeSDStarted > FSSDTIME) {
654 bnode_StopProc(abnode->fileProc, SIGKILL);
655 abnode->fileKillSent = 1;
657 ("bos shutdown: fileserver failed to shutdown within %d seconds\n",
661 if (abnode->salsrvSDW) {
662 if (!abnode->salsrvKillSent && now - abnode->timeSDStarted > SDTIME) {
663 bnode_StopProc(abnode->salsrvProc, SIGKILL);
664 abnode->salsrvKillSent = 1;
666 ("bos shutdown: salvageserver failed to shutdown within %d seconds\n",
670 if (abnode->scanSDW) {
671 if (!abnode->scanKillSent && now - abnode->timeSDStarted > SDTIME) {
672 bnode_StopProc(abnode->scanProc, SIGKILL);
673 abnode->scanKillSent = 1;
675 ("bos shutdown: scanner failed to shutdown within %d seconds\n",
679 SetNeedsClock(abnode);
684 fs_getstat(struct bnode *bn, afs_int32 * astatus)
686 struct fsbnode *abnode = (struct fsbnode *) bn;
689 if (abnode->volSDW || abnode->fileSDW || abnode->salSDW
690 || abnode->scanSDW || abnode->salsrvSDW)
691 temp = BSTAT_SHUTTINGDOWN;
692 else if (abnode->salRunning)
694 else if (abnode->volRunning && abnode->fileRunning
695 && (!abnode->scancmd || abnode->scanRunning)
696 && (!abnode->salsrvcmd || abnode->salsrvRunning))
698 else if (!abnode->salRunning && !abnode->volRunning
699 && !abnode->fileRunning && !abnode->scanRunning
700 && !abnode->salsrvRunning)
701 temp = BSTAT_SHUTDOWN;
703 temp = BSTAT_STARTINGUP;
709 fs_setstat(struct bnode *abnode, afs_int32 astatus)
711 return NudgeProcs((struct fsbnode *) abnode);
715 fs_procexit(struct bnode *bn, struct bnode_proc *aproc)
717 struct fsbnode *abnode = (struct fsbnode *)bn;
719 /* process has exited */
721 if (aproc == abnode->volProc) {
723 abnode->volRunning = 0;
725 abnode->volKillSent = 0;
726 } else if (aproc == abnode->fileProc) {
727 /* if we were expecting a shutdown and we didn't send a kill signal
728 * and exited (didn't have a signal termination), then we assume that
729 * the file server exited after putting the appropriate volumes safely
730 * offline, and don't salvage next time.
732 if (abnode->fileSDW && !abnode->fileKillSent
733 && aproc->lastSignal == 0)
734 SetSalFlag(abnode, 0); /* shut down normally */
735 abnode->fileProc = 0;
736 abnode->fileRunning = 0;
738 abnode->fileKillSent = 0;
739 } else if (aproc == abnode->salProc) {
740 /* if we didn't shutdown the salvager, then assume it exited ok, and thus
741 * that we don't have to salvage again */
743 SetSalFlag(abnode, 0); /* salvage just completed */
745 abnode->salRunning = 0;
747 abnode->salKillSent = 0;
748 } else if (aproc == abnode->scanProc) {
749 abnode->scanProc = 0;
750 abnode->scanRunning = 0;
752 abnode->scanKillSent = 0;
753 } else if (aproc == abnode->salsrvProc) {
754 abnode->salsrvProc = 0;
755 abnode->salsrvRunning = 0;
756 abnode->salsrvSDW = 0;
757 abnode->salsrvKillSent = 0;
760 /* now restart anyone who needs to restart */
761 return NudgeProcs(abnode);
764 /* make sure we're periodically checking the state if we need to */
766 SetNeedsClock(struct fsbnode *ab)
768 if (ab->b.goal == 1 && ab->fileRunning && ab->volRunning
769 && (!ab->scancmd || ab->scanRunning)
770 && (!ab->salsrvcmd || ab->salsrvRunning))
771 ab->needsClock = 0; /* running normally */
772 else if (ab->b.goal == 0 && !ab->fileRunning && !ab->volRunning
773 && !ab->salRunning && !ab->scanRunning && !ab->salsrvRunning)
774 ab->needsClock = 0; /* halted normally */
776 ab->needsClock = 1; /* other */
777 if (ab->needsClock && !bnode_PendingTimeout(fsbnode2bnode(ab)))
778 bnode_SetTimeout(fsbnode2bnode(ab), POLLTIME);
780 bnode_SetTimeout(fsbnode2bnode(ab), 0);
784 NudgeProcs(struct fsbnode *abnode)
786 struct bnode_proc *tp; /* not register */
790 now = FT_ApproxTime();
791 if (abnode->b.goal == 1) {
792 /* we're trying to run the system. If the file server is running, then we
793 * are trying to start up the system. If it is not running, then needsSalvage
794 * tells us if we need to run the salvager or not */
795 if (abnode->fileRunning) {
796 if (abnode->salRunning) {
797 bozo_Log("Salvager running along with file server!\n");
798 bozo_Log("Emergency shutdown\n");
800 bnode_SetGoal(fsbnode2bnode(abnode), BSTAT_SHUTDOWN);
801 bnode_StopProc(abnode->salProc, SIGKILL);
802 SetNeedsClock(abnode);
805 if (!abnode->volRunning) {
806 abnode->lastVolStart = FT_ApproxTime();
807 code = bnode_NewProc(fsbnode2bnode(abnode), abnode->volcmd, "vol", &tp);
809 abnode->volProc = tp;
810 abnode->volRunning = 1;
813 if (abnode->salsrvcmd) {
814 if (!abnode->salsrvRunning) {
815 abnode->lastSalsrvStart = FT_ApproxTime();
817 bnode_NewProc(fsbnode2bnode(abnode), abnode->salsrvcmd, "salsrv",
820 abnode->salsrvProc = tp;
821 abnode->salsrvRunning = 1;
825 if (abnode->scancmd) {
826 if (!abnode->scanRunning) {
827 abnode->lastScanStart = FT_ApproxTime();
829 bnode_NewProc(fsbnode2bnode(abnode), abnode->scancmd, "scanner",
832 abnode->scanProc = tp;
833 abnode->scanRunning = 1;
837 } else { /* file is not running */
838 /* see how to start */
839 /* for demand attach fs, needsSalvage flag is ignored */
840 if (!abnode->needsSalvage || abnode->salsrvcmd) {
841 /* no crash apparent, just start up normally */
842 if (!abnode->fileRunning) {
843 abnode->lastFileStart = FT_ApproxTime();
845 bnode_NewProc(fsbnode2bnode(abnode), abnode->filecmd, "file", &tp);
847 abnode->fileProc = tp;
848 abnode->fileRunning = 1;
849 SetSalFlag(abnode, 1);
852 if (!abnode->volRunning) {
853 abnode->lastVolStart = FT_ApproxTime();
854 code = bnode_NewProc(fsbnode2bnode(abnode), abnode->volcmd, "vol", &tp);
856 abnode->volProc = tp;
857 abnode->volRunning = 1;
860 if (abnode->salsrvcmd && !abnode->salsrvRunning) {
861 abnode->lastSalsrvStart = FT_ApproxTime();
863 bnode_NewProc(fsbnode2bnode(abnode), abnode->salsrvcmd, "salsrv",
866 abnode->salsrvProc = tp;
867 abnode->salsrvRunning = 1;
870 if (abnode->scancmd && !abnode->scanRunning) {
871 abnode->lastScanStart = FT_ApproxTime();
873 bnode_NewProc(fsbnode2bnode(abnode), abnode->scancmd, "scanner",
876 abnode->scanProc = tp;
877 abnode->scanRunning = 1;
880 } else { /* needs to be salvaged */
881 /* make sure file server and volser are gone */
882 if (abnode->volRunning) {
883 bnode_StopProc(abnode->volProc, SIGTERM);
885 abnode->timeSDStarted = now;
888 if (abnode->fileRunning) {
889 bnode_StopProc(abnode->fileProc, SIGQUIT);
890 if (!abnode->fileSDW)
891 abnode->timeSDStarted = now;
894 if (abnode->scanRunning) {
895 bnode_StopProc(abnode->scanProc, SIGTERM);
896 if (!abnode->scanSDW)
897 abnode->timeSDStarted = now;
900 if (abnode->volRunning || abnode->fileRunning
901 || abnode->scanRunning)
903 /* otherwise, it is safe to start salvager */
904 if (!abnode->salRunning) {
905 code = bnode_NewProc(fsbnode2bnode(abnode), abnode->salcmd, "salv", &tp);
907 abnode->salProc = tp;
908 abnode->salRunning = 1;
913 } else { /* goal is 0, we're shutting down */
914 /* trying to shutdown */
915 if (abnode->salRunning && !abnode->salSDW) {
916 bnode_StopProc(abnode->salProc, SIGTERM);
918 abnode->timeSDStarted = now;
920 if (abnode->fileRunning && !abnode->fileSDW) {
921 bnode_StopProc(abnode->fileProc, SIGQUIT);
923 abnode->timeSDStarted = now;
925 if (abnode->volRunning && !abnode->volSDW) {
926 bnode_StopProc(abnode->volProc, SIGTERM);
928 abnode->timeSDStarted = now;
930 if (abnode->salsrvRunning && !abnode->salsrvSDW) {
931 bnode_StopProc(abnode->salsrvProc, SIGTERM);
932 abnode->salsrvSDW = 1;
933 abnode->timeSDStarted = now;
935 if (abnode->scanRunning && !abnode->scanSDW) {
936 bnode_StopProc(abnode->scanProc, SIGTERM);
938 abnode->timeSDStarted = now;
941 SetNeedsClock(abnode);
946 fs_getstring(struct bnode *bn, char *abuffer, afs_int32 alen)
948 struct fsbnode *abnode = (struct fsbnode *)bn;
952 if (abnode->b.goal == 1) {
953 if (abnode->fileRunning) {
955 strcpy(abuffer, "file server shutting down");
956 else if (abnode->scancmd) {
957 if (!abnode->volRunning && !abnode->scanRunning)
959 "file server up; volser and scanner down");
960 else if (abnode->volRunning && !abnode->scanRunning)
962 "file server up; volser up; scanner down");
963 else if (!abnode->volRunning && abnode->scanRunning)
965 "file server up; volser down; scanner up");
968 strcpy(abuffer, "file server running");
969 } else if (!abnode->volRunning)
970 strcpy(abuffer, "file server up; volser down");
972 strcpy(abuffer, "file server running");
973 } else if (abnode->salRunning) {
974 strcpy(abuffer, "salvaging file system");
976 strcpy(abuffer, "starting file server");
979 if (abnode->fileRunning || abnode->volRunning || abnode->scanRunning) {
980 strcpy(abuffer, "file server shutting down");
981 } else if (abnode->salRunning)
982 strcpy(abuffer, "salvager shutting down");
984 strcpy(abuffer, "file server shut down");
990 fs_getparm(struct bnode *bn, afs_int32 aindex, char *abuffer,
993 struct fsbnode *abnode = (struct fsbnode *)bn;
996 strcpy(abuffer, abnode->filecmd);
997 else if (aindex == 1)
998 strcpy(abuffer, abnode->volcmd);
999 else if (aindex == 2)
1000 strcpy(abuffer, abnode->salcmd);
1001 else if (aindex == 3 && abnode->scancmd)
1002 strcpy(abuffer, abnode->scancmd);
1009 dafs_getparm(struct bnode *bn, afs_int32 aindex, char *abuffer,
1012 struct fsbnode *abnode = (struct fsbnode *)bn;
1015 strcpy(abuffer, abnode->filecmd);
1016 else if (aindex == 1)
1017 strcpy(abuffer, abnode->volcmd);
1018 else if (aindex == 2)
1019 strcpy(abuffer, abnode->salsrvcmd);
1020 else if (aindex == 3)
1021 strcpy(abuffer, abnode->salcmd);
1022 else if (aindex == 4 && abnode->scancmd)
1023 strcpy(abuffer, abnode->scancmd);