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 /* viced.c - File Server main loop */
14 /* Function - This routine has the initialization code for */
17 /* ********************************************************************** */
19 #include <afsconfig.h>
20 #include <afs/param.h>
28 #include <sys/types.h>
29 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
35 #include <WINNT/afsevent.h>
38 #include <netinet/in.h>
40 #include <unistd.h> /* sysconf() */
52 #endif /* ITIMER_REAL */
53 #include <sys/resource.h>
54 #endif /* AFS_NT40_ENV */
59 #ifdef AFS_PTHREAD_ENV
61 #else /* AFS_PTHREAD_ENV */
62 #include <afs/assert.h>
63 #endif /* AFS_PTHREAD_ENV */
66 #include <afs/ptclient.h>
67 #include <afs/afsint.h>
68 #include <afs/vldbint.h>
69 #include <afs/errors.h>
70 #include <afs/ihandle.h>
71 #include <afs/vnode.h>
72 #include <afs/volume.h>
74 #include <afs/cellconfig.h>
76 #include <afs/prs_fs.h>
80 #include <afs/afs_args.h>
81 #include <afs/vlserver.h>
82 #include <afs/afsutil.h>
83 #include <afs/fileutil.h>
85 #include <afs/netutils.h>
89 #ifdef AFS_PTHREAD_ENV
92 #if defined(AFS_SGI_ENV)
93 #include "sys/schedctl.h"
96 #include <rx/rx_globals.h>
99 extern int BreakVolumeCallBacks(), InitCallBack();
100 extern int BreakVolumeCallBacks(), InitCallBack(), BreakLaterCallBacks();
101 extern int BreakVolumeCallBacksLater();
102 extern int LogLevel, etext;
103 extern afs_int32 BlocksSpare, PctSpare;
106 static void ClearXStatValues(), NewParms(), PrintCounters();
107 static void ResetCheckDescriptors(void), ResetCheckSignal(void);
108 static void CheckSignal(void);
109 extern int GetKeysFromToken();
110 extern int RXAFS_ExecuteRequest();
111 extern int RXSTATS_ExecuteRequest();
112 afs_int32 Do_VLRegisterRPC();
114 int eventlog = 0, rxlog = 0;
116 FILE *console = NULL;
118 #ifdef AFS_PTHREAD_ENV
119 pthread_mutex_t fsync_glock_mutex;
120 pthread_cond_t fsync_cond;
123 #endif /* AFS_PTHREAD_ENV */
126 #define AFS_QUIETFS_ENV 1
127 #define NT_OPEN_MAX 1024 /* This is an arbitrary no. we came up with for
128 * now. We hope this will be replaced by a more
129 * intelligent estimate later. */
132 int SystemId; /* ViceID of "Administrators" */
133 int SystemAnyUser; /* Viceid of "System:AnyUser" */
134 prlist SystemAnyUserCPS; /* CPS for "system:AnyUser */
135 int AnonymousID = 0; /* ViceId of "Anonymous" */
136 prlist AnonCPS; /* CPS for "Anonymous" */
138 struct afsconf_dir *confDir; /* Configuration dir object */
140 int restartMode = RESTART_ORDINARY;
142 int Testing = 0; /* for ListViceInodes */
145 * Home for the performance statistics.
147 struct afs_PerfStats afs_perfstats;
150 extern int Statistics;
158 int rxJumbograms = 1; /* default is to send and receive jumbograms. */
159 afs_int32 implicitAdminRights = PRSFS_LOOKUP; /* The ADMINISTER right is
161 afs_int32 readonlyServer = 0;
164 int stackSize = 24000;
165 int fiveminutes = 300; /* 5 minutes. Change this for debugging only */
166 int CurrentConnections = 0;
167 int hostaclRefresh = 7200; /* refresh host clients' acls every 2 hrs */
168 #if defined(AFS_SGI_ENV)
173 int rxpackets = 150; /* 100 */
174 int nSmallVns = 400; /* 200 */
175 int large = 400; /* 200 */
176 int volcache = 400; /* 400 */
177 int numberofcbs = 60000; /* 60000 */
178 int lwps = 9; /* 6 */
179 int buffs = 90; /* 70 */
180 int novbc = 0; /* Enable Volume Break calls */
181 int busy_threshold = 600;
182 int abort_threshold = 10;
183 int udpBufSize = 0; /* UDP buffer size for receive */
184 int sendBufSize = 16384; /* send buffer size */
189 * FileServer's name and IP address, both network byte order and
192 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
194 char FS_HostName[128] = "localhost";
195 afs_uint32 FS_HostAddr_NBO;
196 afs_uint32 FS_HostAddr_HBO;
197 afs_uint32 FS_HostAddrs[ADDRSPERSITE], FS_HostAddr_cnt = 0, FS_registered = 0;
198 /* All addresses in FS_HostAddrs are in NBO */
201 static void FlagMsg();
204 * Home for the performance statistics.
213 register int tsize = getdtablesize();
215 for (i = 0; i < tsize; i++) {
216 if (fstat(i, &status) != -1) {
217 printf("%d: dev %x, inode %u, length %u, type/mode %x\n", i,
218 status.st_dev, status.st_ino, status.st_size,
223 ResetCheckDescriptors();
225 } /*CheckDescriptors */
228 #ifdef AFS_PTHREAD_ENV
230 CheckSignal_Signal(x)
242 CheckDescriptors_Signal(x)
246 #else /* AFS_PTHREAD_ENV */
248 CheckSignal_Signal(x)
250 IOMGR_SoftSig(CheckSignal, 0);
256 IOMGR_SoftSig(ShutDown, 0);
260 CheckDescriptors_Signal(x)
262 IOMGR_SoftSig(CheckDescriptors, 0);
264 #endif /* AFS_PTHREAD_ENV */
266 /* check whether caller is authorized to manage RX statistics */
268 fs_rxstat_userok(struct rx_call *call)
270 return afsconf_SuperUser(confDir, call, NULL);
274 ResetCheckSignal(void)
278 #if defined(AFS_HPUX_ENV)
281 #if defined(AFS_NT40_ENV)
288 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
289 softsig_signal(signo, CheckSignal_Signal);
291 signal(signo, CheckSignal_Signal);
296 ResetCheckDescriptors(void)
299 #if defined(AFS_PTHREAD_ENV)
300 softsig_signal(SIGTERM, CheckDescriptors_Signal);
302 signal(SIGTERM, CheckDescriptors_Signal);
308 /* proc called by rxkad module to get a key */
310 get_key(char *arock, register afs_int32 akvno, char *akey)
313 static struct afsconf_key tkey;
314 register afs_int32 code;
317 ViceLog(0, ("conf dir not open\n"));
320 code = afsconf_GetKey(confDir, akvno, tkey.key);
323 memcpy(akey, tkey.key, sizeof(tkey.key));
330 viced_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
335 #ifndef AFS_LINUX20_ENV
336 old = (void (*)())signal(SIGSYS, SIG_IGN);
338 rcode = syscall(AFS_SYSCALL, 28 /* AFSCALL_CALL */ , a3, a4, a5);
339 #ifndef AFS_LINUX20_ENV
347 #if !defined(AFS_NT40_ENV)
348 #include "AFS_component_version_number.c"
349 #endif /* !AFS_NT40_ENV */
351 #define MAXADMINNAME 64
352 char adminName[MAXADMINNAME];
360 if ((stat("/AdminName", &status)) || /* if file does not exist */
361 (status.st_size <= 0) || /* or it is too short */
362 (status.st_size >= (MAXADMINNAME)) || /* or it is too long */
363 !(fd = open("/AdminName", O_RDONLY, 0))) { /* or the open fails */
364 strcpy(adminName, "System:Administrators"); /* use the default name */
366 (void)read(fd, adminName, status.st_size); /* use name from the file */
369 close(fd); /* close fd if it was opened */
371 } /*CheckAdminName */
377 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
378 /* set our 'thread-id' so that the host hold table works */
379 MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */
381 pthread_setspecific(rx_thread_id_key, (void *)rxi_pthread_hinum);
382 MUTEX_EXIT(&rx_stats_mutex);
384 ("Set thread id %d for '%s'\n",
385 pthread_getspecific(rx_thread_id_key), s));
389 /* This LWP does things roughly every 5 minutes */
396 ViceLog(1, ("Starting five minute check process\n"));
397 setThreadId("FiveMinuteCheckLWP");
399 #ifdef AFS_PTHREAD_ENV
401 #else /* AFS_PTHREAD_ENV */
402 IOMGR_Sleep(fiveminutes);
403 #endif /* AFS_PTHREAD_ENV */
405 /* close the log so it can be removed */
406 ReOpenLog(AFSDIR_SERVER_FILELOG_FILEPATH); /* don't trunc, just append */
407 ViceLog(2, ("Cleaning up timed out callbacks\n"));
408 if (CleanupTimedOutCallBacks())
409 ViceLog(5, ("Timed out callbacks deleted\n"));
410 ViceLog(2, ("Set disk usage statistics\n"));
412 if (FS_registered == 1)
414 /* Force wakeup in case we missed something; pthreads does timedwait */
415 #ifndef AFS_PTHREAD_ENV
416 LWP_NoYieldSignal(&fsync_wait);
418 if (printBanner && (++msg & 1)) { /* Every 10 minutes */
419 time_t now = FT_ApproxTime();
420 if (console != NULL) {
421 #ifndef AFS_QUIETFS_ENV
422 fprintf(console, "File server is running at %s\r",
423 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
424 #endif /* AFS_QUIETFS_ENV */
426 ("File server is running at %s\n",
427 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
431 } /*FiveMinuteCheckLWP */
434 /* This LWP does host checks every 5 minutes: it should not be used for
435 * other 5 minute activities because it may be delayed by timeouts when
436 * it probes the workstations
441 ViceLog(1, ("Starting Host check process\n"));
442 setThreadId("HostCheckLWP");
444 #ifdef AFS_PTHREAD_ENV
446 #else /* AFS_PTHREAD_ENV */
447 IOMGR_Sleep(fiveminutes);
448 #endif /* AFS_PTHREAD_ENV */
449 ViceLog(2, ("Checking for dead venii & clients\n"));
454 /* This LWP does fsync checks every 5 minutes: it should not be used for
455 * other 5 minute activities because it may be delayed by timeouts when
456 * it probes the workstations
462 #ifdef AFS_PTHREAD_ENV
463 struct timespec fsync_next;
465 ViceLog(1, ("Starting fsync check process\n"));
467 setThreadId("FsyncCheckLWP");
469 #ifdef AFS_PTHREAD_ENV
470 assert(pthread_cond_init(&fsync_cond, NULL) == 0);
471 assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0);
476 #ifdef AFS_PTHREAD_ENV
477 /* rounding is fine */
478 fsync_next.tv_nsec = 0;
479 fsync_next.tv_sec = time(0) + fiveminutes;
482 pthread_cond_timedwait(&fsync_cond, &fsync_glock_mutex,
484 if (code != 0 && code != ETIMEDOUT)
485 ViceLog(0, ("pthread_cond_timedwait returned %d\n", code));
486 #else /* AFS_PTHREAD_ENV */
487 if ((code = LWP_WaitProcess(&fsync_wait)) != LWP_SUCCESS)
488 ViceLog(0, ("LWP_WaitProcess returned %d\n", code));
489 #endif /* AFS_PTHREAD_ENV */
490 ViceLog(2, ("Checking for fsync events\n"));
492 code = BreakLaterCallBacks();
497 /*------------------------------------------------------------------------
498 * PRIVATE ClearXStatValues
501 * Initialize all of the values collected via the xstat
511 * Must be called during File Server initialization.
515 *------------------------------------------------------------------------*/
519 { /*ClearXStatValues */
521 struct fs_stats_opTimingData *opTimeP; /*Ptr to timing struct */
522 struct fs_stats_xferData *opXferP; /*Ptr to xfer struct */
523 int i; /*Loop counter */
526 * Zero all xstat-related structures.
528 memset((char *)(&afs_perfstats), 0, sizeof(struct afs_PerfStats));
529 #if FS_STATS_DETAILED
530 memset((char *)(&afs_FullPerfStats), 0,
531 sizeof(struct fs_stats_FullPerfStats));
534 * That's not enough. We have to set reasonable minima for
535 * time and xfer values in the detailed stats.
537 opTimeP = &(afs_FullPerfStats.det.rpcOpTimes[0]);
538 for (i = 0; i < FS_STATS_NUM_RPC_OPS; i++, opTimeP++)
539 opTimeP->minTime.tv_sec = 999999;
541 opXferP = &(afs_FullPerfStats.det.xferOpTimes[0]);
542 for (i = 0; i < FS_STATS_NUM_XFER_OPS; i++, opXferP++) {
543 opXferP->minTime.tv_sec = 999999;
544 opXferP->minBytes = 999999999;
548 * There's more. We have to set our unique system identifier, as
549 * declared in param.h. If such a thing is not defined, we bitch
550 * and declare ourselves to be an unknown system type.
553 afs_perfstats.sysname_ID = SYS_NAME_ID;
556 ViceLog(0, ("Sys name ID constant not defined in param.h!!\n"));
557 ViceLog(0, ("[Choosing ``undefined'' sys name ID.\n"));
559 afs_perfstats.sysname_ID = SYS_NAME_ID_UNDEFINED;
560 #endif /* SYS_NAME_ID */
563 } /*ClearXStatValues */
569 int dirbuff, dircall, dirio;
571 int workstations, activeworkstations, delworkstations;
575 TM_GetTimeOfDay(&tpl, 0);
578 ("Vice was last started at %s\n",
579 afs_ctime(&StartTime, tbuffer, sizeof(tbuffer))));
583 DStat(&dirbuff, &dircall, &dirio);
585 ("With %d directory buffers; %d reads resulted in %d read I/Os\n",
586 dirbuff, dircall, dirio));
587 rx_PrintStats(stderr);
589 PrintCallBackStats();
591 processSize = -1; /* TODO: */
593 processSize = (int)((long)sbrk(0) >> 10);
596 ("There are %d connections, process size %d\n",
597 CurrentConnections, processSize));
598 h_GetWorkStats(&workstations, &activeworkstations, &delworkstations,
599 tpl.tv_sec - 15 * 60);
601 ("There are %d workstations, %d are active (req in < 15 mins), %d marked \"down\"\n",
602 workstations, activeworkstations, delworkstations));
612 if (FS_registered > 0) {
614 * We have proper ip addresses; tell the vlserver what we got; the following
615 * routine will do the proper reporting for us
628 ShutDownAndCore(int dopanic)
630 time_t now = time(0);
635 ("Shutting down file server at %s",
636 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
638 ViceLog(0, ("ABNORMAL SHUTDOWN, see core file.\n"));
639 #ifndef AFS_QUIETFS_ENV
640 if (console != NULL) {
641 fprintf(console, "File server restart/shutdown received at %s\r",
642 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
649 /* do not allows new reqests to be served from now on, all new requests
650 * are returned with an error code of RX_RESTARTING ( transient failure ) */
651 rx_SetRxTranquil(); /* dhruba */
655 rx_PrintStats(debugFile);
658 if (console != NULL) {
661 #ifndef AFS_QUIETFS_ENV
662 fprintf(console, "File server has terminated abnormally at %s\r",
663 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
666 ("File server has terminated abnormally at %s\n",
667 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
669 #ifndef AFS_QUIETFS_ENV
670 fprintf(console, "File server has terminated normally at %s\r",
671 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
674 ("File server has terminated normally at %s\n",
675 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
685 { /* backward compatibility */
686 ShutDownAndCore(DONTPANIC);
695 /* default supports help flag */
697 strcpy(buffer, "Usage: fileserver ");
698 strcat(buffer, "[-d <debug level>] ");
699 strcat(buffer, "[-p <number of processes>] ");
700 strcat(buffer, "[-spare <number of spare blocks>] ");
701 strcat(buffer, "[-pctspare <percentage spare>] ");
702 strcat(buffer, "[-b <buffers>] ");
703 strcat(buffer, "[-l <large vnodes>] ");
704 strcat(buffer, "[-s <small vnodes>] ");
705 strcat(buffer, "[-vc <volume cachesize>] ");
706 strcat(buffer, "[-w <call back wait interval>] ");
707 strcat(buffer, "[-cb <number of call backs>] ");
708 strcat(buffer, "[-banner (print banner every 10 minutes)] ");
709 strcat(buffer, "[-novbc (whole volume cbs disabled)] ");
710 strcat(buffer, "[-implicit <admin mode bits: rlidwka>] ");
711 strcat(buffer, "[-readonly (read-only file server)] ");
713 "[-hr <number of hours between refreshing the host cps>] ");
714 strcat(buffer, "[-busyat <redirect clients when queue > n>] ");
715 strcat(buffer, "[-nobusy <no VBUSY before a volume is attached>] ");
716 strcat(buffer, "[-rxpck <number of rx extra packets>] ");
717 strcat(buffer, "[-rxdbg (enable rx debugging)] ");
718 strcat(buffer, "[-rxdbge (enable rxevent debugging)] ");
720 strcat(buffer, "[-m <min percentage spare in partition>] ");
722 #if defined(AFS_SGI_ENV)
723 strcat(buffer, "[-lock (keep fileserver from swapping)] ");
725 strcat(buffer, "[-L (large server conf)] ");
726 strcat(buffer, "[-S (small server conf)] ");
727 strcat(buffer, "[-k <stack size>] ");
728 strcat(buffer, "[-realm <Kerberos realm name>] ");
729 strcat(buffer, "[-udpsize <size of socket buffer in bytes>] ");
730 strcat(buffer, "[-sendsize <size of send buffer in bytes>] ");
731 /* strcat(buffer, "[-enable_peer_stats] "); */
732 /* strcat(buffer, "[-enable_process_stats] "); */
733 strcat(buffer, "[-help]\n");
735 ViceLog(0, ("%s", buffer));
738 printf("%s", buffer);
745 ParseRights(char *arights)
751 if (!arights || !strcmp(arights, "")) {
752 printf("Missing list of mode bits on -implicit option\n");
755 if (!strcmp(arights, "none"))
757 else if (!strcmp(arights, "read"))
758 mode = PRSFS_READ | PRSFS_LOOKUP;
759 else if (!strcmp(arights, "write"))
761 PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
762 PRSFS_WRITE | PRSFS_LOCK;
763 else if (!strcmp(arights, "all"))
765 PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
766 PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
768 len = strlen(arights);
769 for (i = 0; i < len; i++) {
774 mode |= PRSFS_LOOKUP;
776 mode |= PRSFS_INSERT;
778 mode |= PRSFS_DELETE;
784 mode |= PRSFS_ADMINISTER;
802 printf("Illegal -implicit rights character '%c'.\n", tc);
811 * Limit MAX_FILESERVER_THREAD by the system limit on the number of
812 * pthreads (sysconf(_SC_THREAD_THREADS_MAX)), if applicable and
815 * AIX: sysconf() limit is real
816 * HP-UX: sysconf() limit is real
817 * IRIX: sysconf() limit is apparently NOT real -- too small
818 * DUX: sysconf() limit is apparently NOT real -- too big
819 * Linux: sysconf() limit is apparently NOT real -- too big
820 * Solaris: no sysconf() limit
823 max_fileserver_thread(void)
825 #if defined(AFS_PTHREAD_ENV)
826 #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV)
829 ans = sysconf(_SC_THREAD_THREADS_MAX);
830 if (0 < ans && ans < MAX_FILESERVER_THREAD)
833 #endif /* defined(AFS_PTHREAD_ENV) */
834 return MAX_FILESERVER_THREAD;
838 ParseArgs(int argc, char *argv[])
840 int SawL = 0, SawS = 0, SawVC = 0;
841 int Sawrxpck = 0, Sawsmall = 0, Sawlarge = 0, Sawcbs = 0, Sawlwps =
845 int bufSize = 0; /* temp variable to read in udp socket buf size */
847 for (i = 1; i < argc; i++) {
848 if (!strcmp(argv[i], "-d")) {
849 debuglevel = atoi(argv[++i]);
850 LogLevel = debuglevel;
851 } else if (!strcmp(argv[i], "-banner")) {
853 } else if (!strcmp(argv[i], "-implicit")) {
854 implicitAdminRights = ParseRights(argv[++i]);
855 if (implicitAdminRights < 0)
856 return implicitAdminRights;
857 } else if (!strcmp(argv[i], "-readonly")) {
859 } else if (!strcmp(argv[i], "-L")) {
861 } else if (!strcmp(argv[i], "-S")) {
863 } else if (!strcmp(argv[i], "-p")) {
865 max_fileserver_thread() - FILESERVER_HELPER_THREADS;
867 lwps = atoi(argv[++i]);
872 } else if (!strcmp(argv[i], "-b")) {
874 buffs = atoi(argv[++i]);
875 } else if (!strcmp(argv[i], "-l")) {
877 large = atoi(argv[++i]);
878 } else if (!strcmp(argv[i], "-vc")) {
880 volcache = atoi(argv[++i]);
881 } else if (!strcmp(argv[i], "-novbc")) {
883 } else if (!strcmp(argv[i], "-rxpck")) {
885 rxpackets = atoi(argv[++i]);
886 } else if (!strcmp(argv[i], "-s")) {
888 nSmallVns = atoi(argv[++i]);
889 } else if (!strcmp(argv[i], "-abortthreshold")) {
890 abort_threshold = atoi(argv[++i]);
891 } else if (!strcmp(argv[i], "-k"))
892 stack = atoi(argv[++i]);
893 #if defined(AFS_SGI_ENV)
894 else if (!strcmp(argv[i], "-lock")) {
898 else if (!strcmp(argv[i], "-spare")) {
899 BlocksSpare = atoi(argv[++i]);
901 } else if (!strcmp(argv[i], "-pctspare")) {
902 PctSpare = atoi(argv[++i]);
903 BlocksSpare = 0; /* has non-zero default */
905 } else if (!strcmp(argv[i], "-w"))
906 fiveminutes = atoi(argv[++i]);
907 else if (!strcmp(argv[i], "-hr")) {
908 int hr = atoi(argv[++i]);
909 if ((hr < 1) || (hr > 36)) {
911 ("host acl refresh interval of %d hours is invalid; hours must be between 1 and 36\n\n",
915 hostaclRefresh = hr * 60 * 60;
916 } else if (!strcmp(argv[i], "-rxdbg"))
918 else if (!strcmp(argv[i], "-rxdbge"))
920 else if (!strcmp(argv[i], "-cb")) {
922 numberofcbs = atoi(argv[++i]);
923 if ((numberofcbs < 10000) || (numberofcbs > 2147483647)) {
925 ("number of cbs %d invalid; must be between 10000 and 2147483647\n",
929 } else if (!strcmp(argv[i], "-busyat")) {
931 busy_threshold = atoi(argv[++i]);
932 if (busy_threshold < 10) {
934 ("Busy threshold %d is too low, will compute default.\n",
938 } else if (!strcmp(argv[i], "-nobusy"))
941 else if (!strcmp(argv[i], "-m")) {
942 extern int aixlow_water;
943 aixlow_water = atoi(argv[++i]);
944 if ((aixlow_water < 0) || (aixlow_water > 30)) {
945 printf("space reserved %d% invalid; must be between 0-30%\n",
951 else if (!strcmp(argv[i], "-nojumbo")) {
953 } else if (!strcmp(argv[i], "-realm")) {
954 extern char local_realm[AFS_REALM_SZ];
955 if (strlen(argv[++i]) >= AFS_REALM_SZ) {
957 ("-realm argument must contain fewer than %d characters.\n",
961 strncpy(local_realm, argv[i], AFS_REALM_SZ);
962 } else if (!strcmp(argv[i], "-udpsize")) {
963 if ((i + 1) >= argc) {
964 printf("You have to specify -udpsize <integer value>\n");
967 bufSize = atoi(argv[++i]);
968 if (bufSize < rx_GetMinUdpBufSize())
970 ("Warning:udpsize %d is less than minimum %d; ignoring\n",
971 bufSize, rx_GetMinUdpBufSize());
973 udpBufSize = bufSize;
974 } else if (!strcmp(argv[i], "-sendsize")) {
975 if ((i + 1) >= argc) {
976 printf("You have to specify -sendsize <integer value>\n");
979 bufSize = atoi(argv[++i]);
982 ("Warning:sendsize %d is less than minimum %d; ignoring\n",
985 sendBufSize = bufSize;
986 } else if (!strcmp(argv[i], "-enable_peer_stats")) {
987 rx_enablePeerRPCStats();
988 } else if (!strcmp(argv[i], "-enable_process_stats")) {
989 rx_enableProcessRPCStats();
992 else if (strcmp(argv[i], "-syslog") == 0) {
993 /* set syslog logging flag */
995 } else if (strncmp(argv[i], "-syslog=", 8) == 0) {
997 serverLogSyslogFacility = atoi(argv[i] + 8);
1005 printf("Only one of -L, or -S must be specified\n");
1016 numberofcbs = 20000;
1032 numberofcbs = 64000;
1041 busy_threshold = 3 * rxpackets / 2;
1051 NewParms(int initializing)
1053 static struct stat sbuf;
1056 char *argv[MAXPARMS];
1059 if (!(stat("/vice/file/parms", &sbuf))) {
1060 parms = (char *)malloc(sbuf.st_size);
1063 fd = open("parms", O_RDONLY, 0666);
1065 ViceLog(0, ("Open for parms failed with errno = %d\n", errno));
1069 i = read(fd, parms, sbuf.st_size);
1071 if (i != sbuf.st_size) {
1073 ViceLog(0, ("Read on parms failed with errno = %d\n", errno));
1076 ("Read on parms failed; expected %d bytes but read %d\n",
1083 for (i = 0; i < MAXPARMS; argv[i++] = 0);
1085 for (argc = i = 0; i < sbuf.st_size; i++) {
1086 if ((*(parms + i) != ' ') && (*(parms + i) != '\n')) {
1087 if (argv[argc] == 0)
1088 argv[argc] = (parms + i);
1090 *(parms + i) = '\0';
1091 if (argv[argc] != 0) {
1092 if (++argc == MAXPARMS)
1095 while ((*(parms + i + 1) == ' ')
1096 || (*(parms + i + 1) == '\n'))
1100 if (ParseArgs(argc, argv) == 0) {
1101 ViceLog(0, ("Change parameters to:"));
1103 ViceLog(0, ("Invalid parameter in:"));
1105 for (i = 0; i < argc; i++) {
1106 ViceLog(0, (" %s", argv[i]));
1110 } else if (!initializing)
1112 ("Received request to change parms but no parms file exists\n"));
1117 /* Miscellaneous routines */
1121 ViceLog(0, ("%s\n", msg));
1133 * If this fails, it's because something major is wrong, and is not
1134 * likely to be time dependent.
1136 code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
1139 ("Couldn't initialize protection library; code=%d.\n", code));
1142 SystemId = SYSADMINID;
1143 SystemAnyUser = ANYUSERID;
1144 SystemAnyUserCPS.prlist_len = 0;
1145 SystemAnyUserCPS.prlist_val = NULL;
1146 AnonCPS.prlist_len = 0;
1147 AnonCPS.prlist_val = NULL;
1149 code = pr_GetCPS(SystemAnyUser, &SystemAnyUserCPS);
1152 ("Couldn't get CPS for AnyUser, will try again in 30 seconds; code=%d.\n",
1156 code = pr_GetCPS(ANONYMOUSID, &AnonCPS);
1159 ("Couldn't get Anonymous CPS, exiting; code=%d.\n",
1163 AnonymousID = ANONYMOUSID;
1166 #ifdef AFS_PTHREAD_ENV
1168 #else /* AFS_PTHREAD_ENV */
1170 #endif /* AFS_PTHREAD_ENV */
1174 struct rx_connection *serverconns[MAXSERVERS];
1175 struct ubik_client *cstruct;
1178 vl_Initialize(char *confDir)
1180 afs_int32 code, scIndex = 0, i;
1181 struct afsconf_dir *tdir;
1182 struct rx_securityClass *sc;
1183 struct afsconf_cell info;
1185 tdir = afsconf_Open(confDir);
1188 ("Could not open configuration directory (%s).\n", confDir));
1191 code = afsconf_ClientAuth(tdir, &sc, &scIndex);
1193 ViceLog(0, ("Could not get security object for localAuth\n"));
1196 code = afsconf_GetCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info);
1197 if (info.numServers > MAXSERVERS) {
1199 ("vl_Initialize: info.numServers=%d (> MAXSERVERS=%d)\n",
1200 info.numServers, MAXSERVERS));
1203 for (i = 0; i < info.numServers; i++)
1205 rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
1206 info.hostAddr[i].sin_port, USER_SERVICE_ID, sc,
1208 code = ubik_ClientInit(serverconns, &cstruct);
1210 ViceLog(0, ("vl_Initialize: ubik client init failed.\n"));
1216 #define SYSIDMAGIC 0x88aabbcc
1217 #define SYSIDVERSION 1
1222 afs_int32 fd, nentries, i;
1223 struct versionStamp vsn;
1227 if ((stat(AFSDIR_SERVER_SYSID_FILEPATH, &status))
1228 || (status.st_size <= 0)) {
1229 ViceLog(0, ("%s: doesn't exist\n", AFSDIR_SERVER_SYSID_FILEPATH));
1232 if (!(fd = open(AFSDIR_SERVER_SYSID_FILEPATH, O_RDONLY, 0))) {
1234 ("%s: can't open (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1238 if ((i = read(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1240 ("%s: Read failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1244 if (vsn.magic != SYSIDMAGIC) {
1246 ("%s: wrong magic %x (we support %x)\n",
1247 AFSDIR_SERVER_SYSID_FILEPATH, vsn.magic, SYSIDMAGIC));
1250 if (vsn.version != SYSIDVERSION) {
1252 ("%s: wrong version %d (we support %d)\n",
1253 AFSDIR_SERVER_SYSID_FILEPATH, vsn.version, SYSIDVERSION));
1257 read(fd, (char *)&uuid,
1258 sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1260 ("%s: read of uuid failed (%d)\n",
1261 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1264 afs_ntohuuid(&uuid);
1267 read(fd, (char *)&nentries,
1268 sizeof(afs_int32))) != sizeof(afs_int32)) {
1270 ("%s: Read of entries failed (%d)\n",
1271 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1274 if (nentries <= 0 || nentries > ADDRSPERSITE) {
1276 ("%s: invalid num of interfaces: %d\n",
1277 AFSDIR_SERVER_SYSID_FILEPATH, nentries));
1280 FS_HostAddr_cnt = nentries;
1281 for (i = 0; i < nentries; i++) {
1282 if (read(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1283 sizeof(afs_int32)) {
1285 ("%s: Read of addresses failed (%d)\n",
1286 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1287 FS_HostAddr_cnt = 0; /* reset it */
1298 afs_int32 fd, nentries, i;
1299 struct versionStamp vsn;
1303 if (!stat(AFSDIR_SERVER_SYSID_FILEPATH, &status)) {
1305 * File exists; keep the old one around
1307 renamefile(AFSDIR_SERVER_SYSID_FILEPATH,
1308 AFSDIR_SERVER_OLDSYSID_FILEPATH);
1310 fd = open(AFSDIR_SERVER_SYSID_FILEPATH, O_WRONLY | O_TRUNC | O_CREAT,
1314 ("%s: can't create (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1318 vsn.magic = SYSIDMAGIC;
1320 if ((i = write(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1322 ("%s: write failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1327 afs_htonuuid(&uuid);
1329 write(fd, (char *)&uuid,
1330 sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1332 ("%s: write of uuid failed (%d)\n",
1333 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1337 write(fd, (char *)&FS_HostAddr_cnt,
1338 sizeof(afs_int32))) != sizeof(afs_int32)) {
1340 ("%s: write of # of entries failed (%d)\n",
1341 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1344 for (i = 0; i < FS_HostAddr_cnt; i++) {
1345 if (write(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1346 sizeof(afs_int32)) {
1348 ("%s: write of addresses failed (%d)\n",
1349 AFSDIR_SERVER_SYSID_FILEPATH, errno));
1359 * This routine sets up the buffers for the VL_RegisterAddrs RPC. All addresses
1360 * in FS_HostAddrs[] are in NBO, while the RPC treats them as a "blob" of data
1361 * and so we need to convert each of them into HBO which is what the extra
1362 * array called FS_HostAddrs_HBO is used here.
1369 extern int VL_RegisterAddrs();
1370 afs_uint32 FS_HostAddrs_HBO[ADDRSPERSITE];
1373 for (i = 0; i < FS_HostAddr_cnt; i++)
1374 FS_HostAddrs_HBO[i] = ntohl(FS_HostAddrs[i]);
1375 addrs.bulkaddrs_len = FS_HostAddr_cnt;
1376 addrs.bulkaddrs_val = (afs_uint32 *) FS_HostAddrs_HBO;
1377 code = ubik_Call(VL_RegisterAddrs, cstruct, 0, &FS_HostUUID, 0, &addrs);
1379 if (code == VL_MULTIPADDR) {
1381 ("VL_RegisterAddrs rpc failed; The ethernet address exist on a different server; repair it\n"));
1383 ("VL_RegisterAddrs rpc failed; See VLLog for details\n"));
1385 } else if (code == RXGEN_OPCODE) {
1387 ("vlserver doesn't support VL_RegisterAddrs rpc; ignored\n"));
1388 FS_registered = 2; /* So we don't have to retry in the gc daemon */
1391 ("VL_RegisterAddrs rpc failed; will retry periodically (code=%d, err=%d)\n",
1395 FS_registered = 2; /* So we don't have to retry in the gc daemon */
1408 extern int rxi_numNetAddrs;
1409 extern afs_uint32 rxi_NetAddrs[];
1412 * If this fails, it's because something major is wrong, and is not
1413 * likely to be time dependent.
1415 code = vl_Initialize(AFSDIR_SERVER_ETC_DIRPATH);
1418 ("Couldn't initialize protection library; code=%d.\n", code));
1422 /* Read or create the sysid file and register the fileserver's
1423 * IP addresses with the vlserver.
1425 code = ReadSysIdFile();
1427 /* Need to create the file */
1428 ViceLog(0, ("Creating new SysID file\n"));
1429 if ((code = afs_uuid_create(&FS_HostUUID))) {
1430 ViceLog(0, ("Failed to create new uuid: %d\n", code));
1434 /* A good sysid file exists; inform the vlserver. If any conflicts,
1435 * we always use the latest interface available as the real truth.
1437 #ifndef AFS_NT40_ENV
1438 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
1440 * Find addresses we are supposed to register as per the netrestrict
1441 * and netinfo files (/usr/afs/local/NetInfo and
1442 * /usr/afs/local/NetRestict)
1445 afs_int32 code = parseNetFiles(FS_HostAddrs, NULL, NULL,
1446 ADDRSPERSITE, reason,
1447 AFSDIR_SERVER_NETINFO_FILEPATH,
1448 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1450 ViceLog(0, ("Can't register any valid addresses: %s\n", reason));
1453 FS_HostAddr_cnt = (afs_uint32) code;
1457 FS_HostAddr_cnt = rx_getAllAddr(FS_HostAddrs, ADDRSPERSITE);
1461 code = Do_VLRegisterRPC();
1466 main(int argc, char *argv[])
1472 struct rx_securityClass *sc[4];
1473 struct rx_service *tservice;
1474 #ifdef AFS_PTHREAD_ENV
1475 pthread_t parentPid, serverPid;
1476 pthread_attr_t tattr;
1477 #else /* AFS_PTHREAD_ENV */
1478 PROCESS parentPid, serverPid;
1479 #endif /* AFS_PTHREAD_ENV */
1481 int minVnodesRequired; /* min size of vnode cache */
1482 #ifndef AFS_NT40_ENV
1483 struct rlimit rlim; /* max number of open file descriptors */
1487 #ifdef AFS_AIX32_ENV
1488 struct sigaction nsa;
1490 sigemptyset(&nsa.sa_mask);
1491 nsa.sa_handler = SIG_DFL;
1492 nsa.sa_flags = SA_FULLDUMP;
1493 sigaction(SIGABRT, &nsa, NULL);
1494 sigaction(SIGSEGV, &nsa, NULL);
1497 /* Initialize dirpaths */
1498 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
1500 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
1502 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
1506 #ifndef AFS_QUIETFS_ENV
1507 console = fopen("/dev/console", "w");
1510 if (ParseArgs(argc, argv)) {
1514 #ifdef AFS_PTHREAD_ENV
1515 assert(pthread_mutex_init(&fileproc_glock_mutex, NULL) == 0);
1516 #endif /* AFS_PTHREAD_ENV */
1518 #ifdef AFS_SGI_VNODE_GLUE
1519 if (afs_init_kernel_config(-1) < 0) {
1521 ("Can't determine NUMA configuration, not starting fileserver.\n");
1525 confDir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1527 fprintf(stderr, "Unable to open config directory %s\n",
1528 AFSDIR_SERVER_ETC_DIRPATH);
1534 /* Open FileLog on stdout, stderr, fd 1 and fd2 (for perror), sigh. */
1535 serverLogSyslogTag = "fileserver";
1536 OpenLog(AFSDIR_SERVER_FILELOG_FILEPATH);
1539 if (SawSpare && SawPctSpare) {
1540 ViceLog(0, ("Both -spare and -pctspare specified, exiting.\n"));
1543 #ifdef AFS_SGI_XFS_IOPS_ENV
1544 ViceLog(0, ("XFS/EFS File server starting\n"));
1546 ViceLog(0, ("File server starting\n"));
1549 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
1550 /* initialize the pthread soft signal handler thread */
1554 /* install signal handlers for controlling the fileserver process */
1555 ResetCheckSignal(); /* set CheckSignal_Signal() sig handler */
1556 ResetCheckDescriptors(); /* set CheckDescriptors_Signal() sig handler */
1558 #if defined(AFS_SGI_ENV)
1559 /* give this guy a non-degrading priority so help busy servers */
1560 schedctl(NDPRI, 0, NDPNORMMAX);
1564 #ifndef AFS_NT40_ENV
1565 nice(-5); /* TODO: */
1568 assert(DInit(buffs) == 0);
1571 if (afs_winsockInit() < 0) {
1572 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
1573 ViceLog(0, ("File server failed to intialize winsock.\n"));
1579 /* if we support more than 16 threads, then we better have the ability
1580 ** to keep open a large number of files simultaneously
1582 #if defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV)
1583 curLimit = OPEN_MAX; /* for pre AIX 4.2 systems */
1584 #elif defined(AFS_NT40_ENV)
1585 curLimit = NT_OPEN_MAX; /* open file descriptor limit on NT */
1588 curLimit = 0; /* the number of open file descriptors */
1589 code = getrlimit(RLIMIT_NOFILE, &rlim);
1591 curLimit = rlim.rlim_cur;
1592 rlim.rlim_cur = rlim.rlim_max;
1593 code = setrlimit(RLIMIT_NOFILE, &rlim);
1595 curLimit = rlim.rlim_max;
1598 ViceLog(0, ("Failed to increase open file limit, using default\n"));
1600 #endif /* defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV) */
1602 curLimit -= 32; /* leave a slack of 32 file descriptors */
1603 if (lwps > curLimit) {
1607 lwps = 16; /* default to a maximum of 16 threads */
1609 ("The system supports a max of %d open files and we are starting %d threads\n",
1612 #ifndef AFS_PTHREAD_ENV
1613 assert(LWP_InitializeProcessSupport(LWP_MAX_PRIORITY - 2, &parentPid) ==
1615 #endif /* !AFS_PTHREAD_ENV */
1617 /* Initialize volume support */
1619 V_BreakVolumeCallbacks = BreakVolumeCallBacksLater;
1622 /* initialize libacl routines */
1623 acl_Initialize(ACL_VERSION);
1625 /* initialize RX support */
1626 #ifndef AFS_NT40_ENV
1627 rxi_syscallp = viced_syscall;
1629 rx_extraPackets = rxpackets;
1630 rx_extraQuota = 4; /* for outgoing prserver calls from R threads */
1631 rx_SetBusyThreshold(busy_threshold, VBUSY);
1632 rx_SetCallAbortThreshold(abort_threshold);
1633 rx_SetConnAbortThreshold(abort_threshold);
1634 stackSize = lwps * 4000;
1635 if (stackSize < 32000)
1637 else if (stackSize > 44000)
1639 #if defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV) || defined(AFS_SGI51_ENV)
1640 rx_SetStackSize(1, stackSize);
1643 rx_SetUdpBufSize(udpBufSize); /* set the UDP buffer size for receive */
1644 if (rx_Init((int)htons(7000)) < 0) {
1645 ViceLog(0, ("Cannot initialize RX\n"));
1648 if (!rxJumbograms) {
1649 /* Don't send and don't allow 3.4 clients to send jumbograms. */
1653 rx_SetRxDeadTime(30);
1654 sc[0] = rxnull_NewServerSecurityObject();
1655 sc[1] = 0; /* rxvab_NewServerSecurityObject(key1, 0) */
1656 sc[2] = rxkad_NewServerSecurityObject(rxkad_clear, NULL, get_key, NULL);
1657 sc[3] = rxkad_NewServerSecurityObject(rxkad_crypt, NULL, get_key, NULL);
1659 rx_NewService( /* port */ 0, /* service id */ 1, /*service name */
1661 /* security classes */ sc, /* numb sec classes */ 4,
1662 RXAFS_ExecuteRequest);
1665 ("Failed to initialize RX, probably two servers running.\n"));
1668 rx_SetDestroyConnProc(tservice, (void (*)())h_FreeConnection);
1669 rx_SetMinProcs(tservice, 3);
1670 rx_SetMaxProcs(tservice, lwps);
1671 rx_SetCheckReach(tservice, 1);
1674 rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 4,
1675 RXSTATS_ExecuteRequest);
1677 ViceLog(0, ("Failed to initialize rpc stat service.\n"));
1680 rx_SetMinProcs(tservice, 2);
1681 rx_SetMaxProcs(tservice, 4);
1684 * Enable RX hot threads, which allows the listener thread to trade
1685 * places with an idle thread and moves the context switch from listener
1686 * to worker out of the critical path.
1688 rx_EnableHotThread();
1690 /* Some rx debugging */
1691 if (rxlog || eventlog) {
1692 debugFile = fopen("rx_dbg", "w");
1694 rx_debugFile = debugFile;
1696 rxevent_debugFile = debugFile;
1699 init_sys_error_to_et(); /* Set up error table translation */
1700 h_InitHostPackage(); /* set up local cellname and realmname */
1701 InitCallBack(numberofcbs);
1706 ViceLog(0, ("Fatal error in library initialization, exiting!!\n"));
1712 ViceLog(0, ("Fatal error in protection initialization, exiting!!\n"));
1716 /* allow super users to manage RX statistics */
1717 rx_SetRxStatUserOk(fs_rxstat_userok);
1719 rx_StartServer(0); /* now start handling requests */
1721 /* we ensure that there is enough space in the vnode buffer to satisfy
1722 ** requests from all concurrent threads.
1723 ** the maximum number of vnodes used by a single thread at any one time
1724 ** is three ( "link" uses three vnodes simultaneously, one vLarge and
1725 ** two vSmall for linking files and two vLarge and one vSmall for linking
1728 minVnodesRequired = 2 * lwps + 1;
1729 if (minVnodesRequired > nSmallVns) {
1730 nSmallVns = minVnodesRequired;
1732 ("Overriding -s command line parameter with %d\n",
1735 if (minVnodesRequired > large) {
1736 large = minVnodesRequired;
1737 ViceLog(0, ("Overriding -l command line parameter with %d\n", large));
1740 /* We now do this after getting the listener up and running, so that client
1741 * connections don't timeout (maybe) if a file server is restarted, since it
1742 * will be available "real soon now". Worry about whether we can satisfy the
1743 * calls in the volume package itself.
1745 if (VInitVolumePackage(fileServer, large, nSmallVns, 0, volcache)) {
1747 ("Shutting down: errors encountered initializing volume package\n"));
1753 * We are done calling fopen/fdopen. It is safe to use a large
1754 * of the file descriptor cache.
1758 #ifdef AFS_PTHREAD_ENV
1759 ViceLog(5, ("Starting pthreads\n"));
1760 assert(pthread_attr_init(&tattr) == 0);
1761 assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
1763 assert(pthread_create
1764 (&serverPid, &tattr, (void *)FiveMinuteCheckLWP,
1765 &fiveminutes) == 0);
1766 assert(pthread_create
1767 (&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0);
1768 assert(pthread_create
1769 (&serverPid, &tattr, (void *)FsyncCheckLWP, &fiveminutes) == 0);
1770 #else /* AFS_PTHREAD_ENV */
1771 ViceLog(5, ("Starting LWP\n"));
1772 assert(LWP_CreateProcess
1773 (FiveMinuteCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1774 (void *)&fiveminutes, "FiveMinuteChecks",
1775 &serverPid) == LWP_SUCCESS);
1777 assert(LWP_CreateProcess
1778 (HostCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1779 (void *)&fiveminutes, "HostCheck", &serverPid) == LWP_SUCCESS);
1780 assert(LWP_CreateProcess
1781 (FsyncCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1782 (void *)&fiveminutes, "FsyncCheck", &serverPid) == LWP_SUCCESS);
1783 #endif /* AFS_PTHREAD_ENV */
1785 TM_GetTimeOfDay(&tp, 0);
1787 #ifndef AFS_QUIETFS_ENV
1788 if (console != NULL) {
1789 fprintf(console, "File server has started at %s\r",
1790 afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer)));
1795 * Figure out the FileServer's name and primary address.
1797 ViceLog(0, ("Getting FileServer name...\n"));
1798 code = gethostname(FS_HostName, 64);
1800 ViceLog(0, ("gethostname() failed\n"));
1802 ViceLog(0, ("FileServer host name is '%s'\n", FS_HostName));
1804 ViceLog(0, ("Getting FileServer address...\n"));
1805 he = gethostbyname(FS_HostName);
1807 ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName));
1810 memcpy(&FS_HostAddr_NBO, he->h_addr, 4);
1811 afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
1812 FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
1814 ("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
1815 FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
1818 /* Install handler to catch the shutdown signal;
1819 * bosserver assumes SIGQUIT shutdown
1821 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
1822 softsig_signal(SIGQUIT, ShutDown_Signal);
1824 signal(SIGQUIT, ShutDown_Signal);
1828 ("File Server started %s",
1829 afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer))));
1830 #if FS_STATS_DETAILED
1831 afs_FullPerfStats.det.epoch.tv_sec = StartTime = tp.tv_sec;
1833 #ifdef AFS_PTHREAD_ENV
1835 sleep(1000); /* long time */
1837 #else /* AFS_PTHREAD_ENV */
1838 assert(LWP_WaitProcess(&parentPid) == LWP_SUCCESS);
1839 #endif /* AFS_PTHREAD_ENV */