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>
27 #include <sys/types.h>
28 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
34 #include <WINNT/afsevent.h>
37 #include <netinet/in.h>
39 #include <unistd.h> /* sysconf() */
51 #endif /* ITIMER_REAL */
52 #include <sys/resource.h>
53 #endif /* AFS_NT40_ENV */
58 #ifdef AFS_PTHREAD_ENV
60 #else /* AFS_PTHREAD_ENV */
61 #include <afs/assert.h>
62 #endif /* AFS_PTHREAD_ENV */
65 #include <afs/ptclient.h>
66 #include <afs/afsint.h>
67 #include <afs/vldbint.h>
68 #include <afs/errors.h>
69 #include <afs/ihandle.h>
70 #include <afs/vnode.h>
71 #include <afs/volume.h>
73 #include <afs/cellconfig.h>
75 #include <afs/prs_fs.h>
79 #include <afs/afs_args.h>
80 #include <afs/vlserver.h>
81 #include <afs/afsutil.h>
82 #include <afs/fileutil.h>
84 #include <afs/netutils.h>
88 #if defined(AFS_SGI_ENV)
89 #include "sys/schedctl.h"
92 #include <rx/rx_globals.h>
95 extern int BreakVolumeCallBacks(), InitCallBack();
96 extern int BreakVolumeCallBacks(), InitCallBack(), BreakLaterCallBacks();
97 extern int BreakVolumeCallBacksLater();
98 extern int LogLevel, etext;
99 extern afs_int32 BlocksSpare, PctSpare;
102 static void ClearXStatValues(), NewParms(), PrintCounters();
103 static void ResetCheckDescriptors(void), ResetCheckSignal(void);
104 static void CheckSignal(void);
105 extern int GetKeysFromToken();
106 extern int RXAFS_ExecuteRequest();
107 extern int RXSTATS_ExecuteRequest();
109 int eventlog = 0, rxlog = 0;
111 FILE * console = NULL;
113 #ifdef AFS_PTHREAD_ENV
114 pthread_mutex_t fsync_glock_mutex;
115 pthread_cond_t fsync_cond;
118 #endif /* AFS_PTHREAD_ENV */
121 #define AFS_QUIETFS_ENV 1
122 #define NT_OPEN_MAX 1024 /* This is an arbitrary no. we came up with for
123 * now. We hope this will be replaced by a more
124 * intelligent estimate later. */
127 int SystemId; /* ViceID of "Administrators"*/
128 int SystemAnyUser; /* Viceid of "System:AnyUser" */
129 prlist SystemAnyUserCPS; /* CPS for "system:AnyUser */
130 int AnonymousID = 0; /* ViceId of "Anonymous"*/
131 prlist AnonCPS; /* CPS for "Anonymous"*/
133 struct afsconf_dir *confDir; /* Configuration dir object */
135 int restartMode = RESTART_ORDINARY;
137 int Testing = 0; /* for ListViceInodes */
140 * Home for the performance statistics.
142 struct afs_PerfStats afs_perfstats;
145 extern int Statistics;
152 int rxJumbograms = 1; /* default is to send and receive jumbograms. */
153 afs_int32 implicitAdminRights = PRSFS_LOOKUP; /* The ADMINISTER right is
155 afs_int32 readonlyServer = 0;
158 int stackSize = 24000;
159 int fiveminutes = 300; /* 5 minutes. Change this for debugging only */
160 int CurrentConnections = 0;
161 int hostaclRefresh = 7200; /* refresh host clients' acls every 2 hrs */
162 #if defined(AFS_SGI_ENV)
167 int rxpackets = 150; /* 100 */
168 int nSmallVns = 400; /* 200 */
169 int large = 400; /* 200 */
170 int volcache = 400; /* 400 */
171 int numberofcbs = 60000; /* 60000 */
172 int lwps = 9; /* 6 */
173 int buffs = 90; /* 70 */
174 int novbc = 0; /* Enable Volume Break calls */
175 int busy_threshold = 600;
176 int udpBufSize = 0; /* UDP buffer size for receive*/
177 int sendBufSize = 16384; /* send buffer size */
182 * FileServer's name and IP address, both network byte order and
185 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
187 char FS_HostName[128] = "localhost";
188 afs_uint32 FS_HostAddr_NBO;
189 afs_uint32 FS_HostAddr_HBO;
190 afs_uint32 FS_HostAddrs[ADDRSPERSITE], FS_HostAddr_cnt = 0, FS_registered=0;
191 /* All addresses in FS_HostAddrs are in NBO */
194 static void FlagMsg();
197 * Home for the performance statistics.
201 static void CheckDescriptors()
205 register int tsize = getdtablesize();
207 for (i = 0; i<tsize; i++) {
208 if (fstat(i, &status) != -1) {
209 printf("%d: dev %x, inode %u, length %u, type/mode %x\n",
210 i, status.st_dev, status.st_ino,
211 status.st_size, status.st_mode);
215 ResetCheckDescriptors();
217 } /*CheckDescriptors*/
220 #ifdef AFS_PTHREAD_ENV
221 void CheckSignal_Signal(x) {CheckSignal();}
222 void ShutDown_Signal(x) {ShutDown();}
223 void CheckDescriptors_Signal(x) {CheckDescriptors();}
224 #else /* AFS_PTHREAD_ENV */
225 void CheckSignal_Signal(x) {IOMGR_SoftSig(CheckSignal, 0);}
226 void ShutDown_Signal(x) {IOMGR_SoftSig(ShutDown, 0);}
227 void CheckDescriptors_Signal(x) {IOMGR_SoftSig(CheckDescriptors, 0);}
228 #endif /* AFS_PTHREAD_ENV */
230 /* check whether caller is authorized to manage RX statistics */
231 int fs_rxstat_userok(struct rx_call *call)
233 return afsconf_SuperUser(confDir, call, NULL);
236 static void ResetCheckSignal(void)
239 signal(SIGPOLL, CheckSignal_Signal);
242 signal(SIGUSR2, CheckSignal_Signal);
244 signal(SIGXCPU, CheckSignal_Signal);
249 static void ResetCheckDescriptors(void)
252 signal(SIGTERM, CheckDescriptors_Signal);
257 /* proc called by rxkad module to get a key */
258 static int get_key(char *arock, register afs_int32 akvno, char *akey)
261 static struct afsconf_key tkey;
262 register afs_int32 code;
265 ViceLog(0, ("conf dir not open\n"));
268 code = afsconf_GetKey(confDir, akvno, tkey.key);
271 memcpy(akey, tkey.key, sizeof(tkey.key));
277 int viced_syscall(afs_uint32 a3, afs_uint32 a4, void * a5)
282 #ifndef AFS_LINUX20_ENV
283 old = (void (*)())signal(SIGSYS, SIG_IGN);
285 rcode = syscall (AFS_SYSCALL, 28 /* AFSCALL_CALL */, a3, a4, a5);
286 #ifndef AFS_LINUX20_ENV
294 #if !defined(AFS_NT40_ENV)
295 #include "AFS_component_version_number.c"
296 #endif /* !AFS_NT40_ENV */
298 #define MAXADMINNAME 64
299 char adminName[MAXADMINNAME];
307 if ((stat("/AdminName", &status)) || /* if file does not exist */
308 (status.st_size <= 0) || /* or it is too short */
309 (status.st_size >= (MAXADMINNAME)) || /* or it is too long */
310 !(fd = open("/AdminName", O_RDONLY, 0))) { /* or the open fails */
311 strcpy(adminName, "System:Administrators"); /* use the default name */
314 read(fd, adminName, status.st_size); /* use name from the file */
317 close(fd); /* close fd if it was opened */
322 /* This LWP does things roughly every 5 minutes */
323 static void FiveMinuteCheckLWP()
328 ViceLog(1, ("Starting five minute check process\n"));
330 #ifdef AFS_PTHREAD_ENV
332 #else /* AFS_PTHREAD_ENV */
333 IOMGR_Sleep(fiveminutes);
334 #endif /* AFS_PTHREAD_ENV */
336 /* close the log so it can be removed */
337 ReOpenLog(AFSDIR_SERVER_FILELOG_FILEPATH); /* don't trunc, just append */
338 ViceLog(2, ("Cleaning up timed out callbacks\n"));
339 if(CleanupTimedOutCallBacks())
340 ViceLog(5,("Timed out callbacks deleted\n"));
341 ViceLog(2, ("Set disk usage statistics\n"));
343 if (FS_registered == 1) Do_VLRegisterRPC();
344 /* Force wakeup in case we missed something; pthreads does timedwait */
345 #ifndef AFS_PTHREAD_ENV
346 LWP_NoYieldSignal(&fsync_wait);
348 if(printBanner && (++msg&1)) { /* Every 10 minutes */
349 time_t now = FT_ApproxTime();
350 if (console != NULL) {
351 #ifndef AFS_QUIETFS_ENV
352 fprintf(console,"File server is running at %s\r",
353 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
354 #endif /* AFS_QUIETFS_ENV */
355 ViceLog(2, ("File server is running at %s\n",
356 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
360 } /*FiveMinuteCheckLWP*/
363 /* This LWP does host checks every 5 minutes: it should not be used for
364 * other 5 minute activities because it may be delayed by timeouts when
365 * it probes the workstations
367 static void HostCheckLWP()
369 ViceLog(1, ("Starting Host check process\n"));
371 #ifdef AFS_PTHREAD_ENV
373 #else /* AFS_PTHREAD_ENV */
374 IOMGR_Sleep(fiveminutes);
375 #endif /* AFS_PTHREAD_ENV */
376 ViceLog(2, ("Checking for dead venii & clients\n"));
381 /* This LWP does fsync checks every 5 minutes: it should not be used for
382 * other 5 minute activities because it may be delayed by timeouts when
383 * it probes the workstations
385 static FsyncCheckLWP()
388 #ifdef AFS_PTHREAD_ENV
389 struct timespec fsync_next;
391 ViceLog(1, ("Starting fsync check process\n"));
393 #ifdef AFS_PTHREAD_ENV
394 assert(pthread_cond_init(&fsync_cond, NULL) == 0);
395 assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0);
400 #ifdef AFS_PTHREAD_ENV
401 /* rounding is fine */
402 fsync_next.tv_nsec = 0;
403 fsync_next.tv_sec = time(0) + fiveminutes;
405 code = pthread_cond_timedwait(&fsync_cond, &fsync_glock_mutex,
407 if (code != 0 && code != ETIMEDOUT)
408 ViceLog(0, ("pthread_cond_timedwait returned %d\n", code));
409 #else /* AFS_PTHREAD_ENV */
410 if (( code = LWP_WaitProcess(&fsync_wait)) != LWP_SUCCESS)
411 ViceLog(0, ("LWP_WaitProcess returned %d\n", code));
412 #endif /* AFS_PTHREAD_ENV */
413 ViceLog(2, ("Checking for fsync events\n"));
415 code = BreakLaterCallBacks();
420 /*------------------------------------------------------------------------
421 * PRIVATE ClearXStatValues
424 * Initialize all of the values collected via the xstat
434 * Must be called during File Server initialization.
438 *------------------------------------------------------------------------*/
440 static void ClearXStatValues()
441 { /*ClearXStatValues*/
443 struct fs_stats_opTimingData *opTimeP; /*Ptr to timing struct*/
444 struct fs_stats_xferData *opXferP; /*Ptr to xfer struct*/
445 int i; /*Loop counter*/
448 * Zero all xstat-related structures.
450 memset((char *)(&afs_perfstats), 0, sizeof(struct afs_PerfStats));
451 #if FS_STATS_DETAILED
452 memset((char *)(&afs_FullPerfStats), 0, sizeof(struct fs_stats_FullPerfStats));
455 * That's not enough. We have to set reasonable minima for
456 * time and xfer values in the detailed stats.
458 opTimeP = &(afs_FullPerfStats.det.rpcOpTimes[0]);
459 for (i = 0; i < FS_STATS_NUM_RPC_OPS; i++, opTimeP++)
460 opTimeP->minTime.tv_sec = 999999;
462 opXferP = &(afs_FullPerfStats.det.xferOpTimes[0]);
463 for (i = 0; i < FS_STATS_NUM_XFER_OPS; i++, opXferP++) {
464 opXferP->minTime.tv_sec = 999999;
465 opXferP->minBytes = 999999999;
469 * There's more. We have to set our unique system identifier, as
470 * declared in param.h. If such a thing is not defined, we bitch
471 * and declare ourselves to be an unknown system type.
474 afs_perfstats.sysname_ID = SYS_NAME_ID;
477 ViceLog(0, ("Sys name ID constant not defined in param.h!!\n"));
478 ViceLog(0, ("[Choosing ``undefined'' sys name ID.\n"));
480 afs_perfstats.sysname_ID = SYS_NAME_ID_UNDEFINED;
481 #endif /* SYS_NAME_ID */
484 } /*ClearXStatValues*/
487 static void PrintCounters()
489 int dirbuff, dircall, dirio;
491 int workstations, activeworkstations, delworkstations;
495 TM_GetTimeOfDay(&tpl, 0);
497 ViceLog(0, ("Vice was last started at %s\n",
498 afs_ctime(&StartTime, tbuffer, sizeof(tbuffer))));
502 DStat(&dirbuff, &dircall, &dirio);
503 ViceLog(0,("With %d directory buffers; %d reads resulted in %d read I/Os\n",
504 dirbuff, dircall, dirio));
505 rx_PrintStats(stderr);
507 PrintCallBackStats();
509 processSize = -1; /* TODO: */
511 processSize = (int)((long) sbrk(0) >> 10);
513 ViceLog(0,("There are %d connections, process size %d\n", CurrentConnections, processSize));
514 h_GetWorkStats(&workstations, &activeworkstations, &delworkstations,
517 ("There are %d workstations, %d are active (req in < 15 mins), %d marked \"down\"\n",
518 workstations, activeworkstations, delworkstations));
525 static void CheckSignal()
527 if (FS_registered > 0) {
529 * We have proper ip addresses; tell the vlserver what we got; the following
530 * routine will do the proper reporting for us
542 void ShutDownAndCore(int dopanic)
544 time_t now = time(0);
548 ViceLog(0, ("Shutting down file server at %s",
549 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
551 ViceLog(0, ("ABNORMAL SHUTDOWN, see core file.\n"));
552 #ifndef AFS_QUIETFS_ENV
553 if (console != NULL) {
554 fprintf(console,"File server restart/shutdown received at %s\r",
555 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
561 /* do not allows new reqests to be served from now on, all new requests
562 are returned with an error code of RX_RESTARTING ( transient failure ) */
563 rx_SetRxTranquil(); /* dhruba */
567 rx_PrintStats(debugFile);
570 if (console != NULL) {
573 #ifndef AFS_QUIETFS_ENV
574 fprintf(console, "File server has terminated abnormally at %s\r",
575 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
577 ViceLog(0, ("File server has terminated abnormally at %s\n",
578 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
580 #ifndef AFS_QUIETFS_ENV
581 fprintf(console, "File server has terminated normally at %s\r",
582 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
584 ViceLog(0, ("File server has terminated normally at %s\n",
585 afs_ctime(&now, tbuffer, sizeof(tbuffer))));
593 void ShutDown(void) /* backward compatibility */
595 ShutDownAndCore(DONTPANIC);
599 static void FlagMsg()
603 /* default supports help flag */
605 strcpy(buffer, "Usage: fileserver ");
606 strcat(buffer, "[-d <debug level>] ");
607 strcat(buffer, "[-p <number of processes>] ");
608 strcat(buffer, "[-spare <number of spare blocks>] ");
609 strcat(buffer, "[-pctspare <percentage spare>] ");
610 strcat(buffer, "[-b <buffers>] ");
611 strcat(buffer, "[-l <large vnodes>] ");
612 strcat(buffer, "[-s <small vnodes>] ");
613 strcat(buffer, "[-vc <volume cachesize>] ");
614 strcat(buffer, "[-w <call back wait interval>] ");
615 strcat(buffer, "[-cb <number of call backs>] ");
616 strcat(buffer, "[-banner (print banner every 10 minutes)] ");
617 strcat(buffer, "[-novbc (whole volume cbs disabled)] ");
618 strcat(buffer, "[-implicit <admin mode bits: rlidwka>] ");
619 strcat(buffer, "[-readonly (read-only file server)] ");
620 strcat(buffer, "[-hr <number of hours between refreshing the host cps>] ");
621 strcat(buffer, "[-busyat <redirect clients when queue > n>] ");
622 strcat(buffer, "[-rxpck <number of rx extra packets>] ");
623 strcat(buffer, "[-rxdbg (enable rx debugging)] ");
624 strcat(buffer, "[-rxdbge (enable rxevent debugging)] ");
626 strcat(buffer, "[-m <min percentage spare in partition>] ");
628 #if defined(AFS_SGI_ENV)
629 strcat(buffer, "[-lock (keep fileserver from swapping)] ");
631 strcat(buffer, "[-L (large server conf)] ");
632 strcat(buffer, "[-S (small server conf)] ");
633 strcat(buffer, "[-k <stack size>] ");
634 strcat(buffer, "[-realm <Kerberos realm name>] ");
635 strcat(buffer, "[-udpsize <size of socket buffer in bytes>] ");
636 strcat(buffer, "[-sendsize <size of send buffer in bytes>] ");
637 /* strcat(buffer, "[-enable_peer_stats] "); */
638 /* strcat(buffer, "[-enable_process_stats] "); */
639 strcat(buffer, "[-help]\n");
641 ViceLog(0, ("%s", buffer));
650 static afs_int32 ParseRights(char *arights)
656 if (!arights || !strcmp(arights, "")) {
657 printf("Missing list of mode bits on -implicit option\n");
660 if (!strcmp(arights, "none"))
662 else if (!strcmp(arights, "read"))
663 mode = PRSFS_READ | PRSFS_LOOKUP;
664 else if (!strcmp(arights, "write"))
665 mode = PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT |
666 PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
667 else if (!strcmp(arights, "all"))
668 mode = PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT |
669 PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
671 len = strlen(arights);
674 if (tc == 'r') mode |= PRSFS_READ;
675 else if (tc == 'l') mode |= PRSFS_LOOKUP;
676 else if (tc == 'i') mode |= PRSFS_INSERT;
677 else if (tc == 'd') mode |= PRSFS_DELETE;
678 else if (tc == 'w') mode |= PRSFS_WRITE;
679 else if (tc == 'k') mode |= PRSFS_LOCK;
680 else if (tc == 'a') mode |= PRSFS_ADMINISTER;
681 else if (tc == 'A') mode |= PRSFS_USR0;
682 else if (tc == 'B') mode |= PRSFS_USR1;
683 else if (tc == 'C') mode |= PRSFS_USR2;
684 else if (tc == 'D') mode |= PRSFS_USR3;
685 else if (tc == 'E') mode |= PRSFS_USR4;
686 else if (tc == 'F') mode |= PRSFS_USR5;
687 else if (tc == 'G') mode |= PRSFS_USR6;
688 else if (tc == 'H') mode |= PRSFS_USR7;
690 printf("Illegal -implicit rights character '%c'.\n", tc);
699 * Limit MAX_FILESERVER_THREAD by the system limit on the number of
700 * pthreads (sysconf(_SC_THREAD_THREADS_MAX)), if applicable and
703 * AIX: sysconf() limit is real
704 * HP-UX: sysconf() limit is real
705 * IRIX: sysconf() limit is apparently NOT real -- too small
706 * DUX: sysconf() limit is apparently NOT real -- too big
707 * Linux: sysconf() limit is apparently NOT real -- too big
708 * Solaris: no sysconf() limit
711 max_fileserver_thread(void)
713 #if defined(AFS_PTHREAD_ENV)
714 #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV)
717 ans = sysconf(_SC_THREAD_THREADS_MAX);
718 if (0 < ans && ans < MAX_FILESERVER_THREAD)
721 #endif /* defined(AFS_PTHREAD_ENV) */
722 return MAX_FILESERVER_THREAD;
725 static int ParseArgs(int argc, char *argv[])
727 int SawL=0, SawS=0, SawVC=0;
728 int Sawrxpck = 0, Sawsmall=0, Sawlarge=0, Sawcbs=0, Sawlwps=0, Sawbufs=0;
731 int bufSize = 0; /* temp variable to read in udp socket buf size*/
733 for (i = 1; i < argc; i++) {
734 if (!strcmp(argv[i], "-d")) {
735 debuglevel = atoi(argv[++i]);
736 LogLevel = debuglevel;
739 if (!strcmp(argv[i], "-banner")) {
742 if (!strcmp(argv[i], "-implicit")) {
743 implicitAdminRights = ParseRights(argv[++i]);
744 if (implicitAdminRights < 0) return implicitAdminRights;
746 if (!strcmp(argv[i], "-readonly")) {
749 if (!strcmp(argv[i], "-L")) {
752 if (!strcmp(argv[i], "-S")) {
756 if (!strcmp(argv[i], "-p")) {
757 int lwps_max = max_fileserver_thread() - FILESERVER_HELPER_THREADS;
759 lwps = atoi(argv[++i]);
766 if (!strcmp(argv[i], "-b")) {
768 buffs = atoi(argv[++i]);
771 if (!strcmp(argv[i], "-l")) {
773 large = atoi(argv[++i]);
776 if (!strcmp(argv[i], "-vc")) {
778 volcache = atoi(argv[++i]);
781 if (!strcmp(argv[i], "-novbc")) {
785 if (!strcmp(argv[i], "-rxpck")) {
787 rxpackets = atoi(argv[++i]);
790 if (!strcmp(argv[i], "-s")) {
792 nSmallVns = atoi(argv[++i]);
795 if (!strcmp(argv[i], "-k"))
796 stack = atoi(argv[++i]);
797 #if defined(AFS_SGI_ENV)
799 if (!strcmp(argv[i], "-lock")) {
804 if (!strcmp(argv[i], "-spare")) {
805 BlocksSpare = atoi(argv[++i]);
809 if (!strcmp(argv[i], "-pctspare")) {
810 PctSpare = atoi(argv[++i]);
811 BlocksSpare = 0; /* has non-zero default */
815 if (!strcmp(argv[i], "-w"))
816 fiveminutes = atoi(argv[++i]);
818 if (!strcmp(argv[i], "-hr")) {
819 int hr = atoi(argv[++i]);
820 if ((hr < 1) || (hr > 36)) {
821 printf("host acl refresh interval of %d hours is invalid; hours must be between 1 and 36\n\n",
825 hostaclRefresh = hr*60*60;
827 if (!strcmp(argv[i], "-rxdbg"))
830 if (!strcmp(argv[i], "-rxdbge"))
833 if (!strcmp(argv[i], "-cb")) {
835 numberofcbs = atoi(argv[++i]);
836 if ((numberofcbs < 10000) || (numberofcbs > 2147483647)) {
837 printf("number of cbs %d invalid; must be between 10000 and 2147483647\n",
843 if (!strcmp(argv[i], "-busyat")) {
845 busy_threshold = atoi(argv[++i]);
846 if (busy_threshold < 10) {
847 printf("Busy threshold %d is too low, will compute default.\n",
854 if (!strcmp(argv[i], "-m")) {
855 extern int aixlow_water;
856 aixlow_water = atoi(argv[++i]);
857 if ((aixlow_water < 0) || (aixlow_water > 30)) {
858 printf("space reserved %d% invalid; must be between 0-30%\n", aixlow_water);
864 if (!strcmp(argv[i], "-nojumbo")) {
868 if (!strcmp(argv[i], "-realm")) {
869 extern char local_realm[AFS_REALM_SZ];
870 if (strlen(argv[++i]) >= AFS_REALM_SZ) {
871 printf("-realm argument must contain fewer than %d characters.\n",AFS_REALM_SZ);
874 strncpy (local_realm, argv[i], AFS_REALM_SZ);
877 if ( !strcmp(argv[i], "-udpsize")) {
878 if ( (i+1) >= argc ) {
879 printf("You have to specify -udpsize <integer value>\n");
882 bufSize = atoi(argv[++i]);
883 if ( bufSize < rx_GetMinUdpBufSize() )
884 printf("Warning:udpsize %d is less than minimum %d; ignoring\n",
885 bufSize, rx_GetMinUdpBufSize() );
887 udpBufSize = bufSize;
890 if ( !strcmp(argv[i], "-sendsize")) {
891 if ( (i+1) >= argc ) {
892 printf("You have to specify -sendsize <integer value>\n");
895 bufSize = atoi(argv[++i]);
896 if ( bufSize < 16384 )
897 printf("Warning:sendsize %d is less than minimum %d; ignoring\n",
900 sendBufSize = bufSize;
903 if (!strcmp(argv[i], "-enable_peer_stats")) {
904 rx_enablePeerRPCStats();
907 if (!strcmp(argv[i], "-enable_process_stats")) {
908 rx_enableProcessRPCStats();
912 if (strcmp(argv[i], "-syslog")==0) {
913 /* set syslog logging flag */
917 if (strncmp(argv[i], "-syslog=", 8)==0) {
919 serverLogSyslogFacility = atoi(argv[i]+8);
927 printf("Only one of -L, or -S must be specified\n");
931 if (!Sawrxpck) rxpackets = 100;
932 if (!Sawsmall) nSmallVns = 200;
933 if (!Sawlarge) large = 200;
934 if (!Sawcbs) numberofcbs = 20000;
935 if (!Sawlwps) lwps = 6;
936 if (!Sawbufs) buffs = 70;
937 if (!SawVC) volcache = 200;
940 if (!Sawrxpck) rxpackets = 200;
941 if (!Sawsmall) nSmallVns = 600;
942 if (!Sawlarge) large = 600;
943 if (!Sawcbs) numberofcbs = 64000;
944 if (!Sawlwps) lwps = 12;
945 if (!Sawbufs) buffs = 120;
946 if (!SawVC) volcache = 600;
949 busy_threshold = 3*rxpackets/2;
958 static void NewParms(int initializing)
960 static struct stat sbuf;
963 char *argv[MAXPARMS];
966 if (!(stat("/vice/file/parms",&sbuf))) {
967 parms = (char *)malloc(sbuf.st_size);
969 fd = open("parms", O_RDONLY, 0666);
971 ViceLog(0, ("Open for parms failed with errno = %d\n", errno));
975 i = read(fd, parms, sbuf.st_size);
977 if(i != sbuf.st_size) {
979 ViceLog(0, ("Read on parms failed with errno = %d\n", errno));
982 ("Read on parms failed; expected %d bytes but read %d\n",
989 for (i = 0;i < MAXPARMS; argv[i++] = 0 );
991 for (argc = i = 0; i < sbuf.st_size; i++) {
992 if ((*(parms + i) != ' ') && (*(parms + i) != '\n')){
993 if(argv[argc] == 0) argv[argc] = (parms+i);
997 if(argv[argc] != 0) {
998 if(++argc == MAXPARMS) break;
1000 while ((*(parms + i + 1) == ' ') || (*(parms + i + 1) == '\n'))
1004 if(ParseArgs(argc, argv) == 0) {
1005 ViceLog(0, ("Change parameters to:"));
1007 ViceLog(0, ("Invalid parameter in:"));
1009 for(i = 0; i < argc; i++) {
1010 ViceLog(0, (" %s", argv[i]));
1017 ViceLog(0, ("Received request to change parms but no parms file exists\n"));
1022 /* Miscellaneous routines */
1023 void Die (char *msg)
1025 ViceLog (0,("%s\n", msg));
1036 * If this fails, it's because something major is wrong, and is not
1037 * likely to be time dependent.
1039 code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
1041 ViceLog(0, ("Couldn't initialize protection library; code=%d.\n", code));
1044 SystemId = SYSADMINID;
1045 SystemAnyUser = ANYUSERID;
1046 SystemAnyUserCPS.prlist_len = 0;
1047 SystemAnyUserCPS.prlist_val = NULL;
1048 AnonCPS.prlist_len = 0;
1049 AnonCPS.prlist_val = NULL;
1051 code = pr_GetCPS(SystemAnyUser, &SystemAnyUserCPS);
1054 ("Couldn't get CPS for AnyUser, will try again in 30 seconds; code=%d.\n",
1058 code = pr_GetCPS(ANONYMOUSID,&AnonCPS);
1060 ViceLog(0,("Couldn't get Anonymous CPS, exiting; code=%d.\n", code));
1063 AnonymousID = ANONYMOUSID;
1066 #ifdef AFS_PTHREAD_ENV
1068 #else /* AFS_PTHREAD_ENV */
1070 #endif /* AFS_PTHREAD_ENV */
1074 struct rx_connection *serverconns[MAXSERVERS];
1075 struct ubik_client *cstruct;
1077 afs_int32 vl_Initialize(char *confDir)
1078 { afs_int32 code, scIndex = 0, i;
1079 struct afsconf_dir *tdir;
1080 struct rx_securityClass *sc;
1081 struct afsconf_cell info;
1083 tdir = afsconf_Open(confDir);
1085 ViceLog(0, ("Could not open configuration directory (%s).\n", confDir));
1088 code = afsconf_ClientAuth(tdir, &sc, &scIndex);
1090 ViceLog(0, ("Could not get security object for localAuth\n"));
1093 code = afsconf_GetCellInfo(tdir,NULL, AFSCONF_VLDBSERVICE, &info);
1094 if (info.numServers > MAXSERVERS) {
1095 ViceLog(0, ("vl_Initialize: info.numServers=%d (> MAXSERVERS=%d)\n",info.numServers, MAXSERVERS));
1098 for (i = 0;i<info.numServers;i++)
1099 serverconns[i] = rx_NewConnection(info.hostAddr[i].sin_addr.s_addr, info.hostAddr[i].sin_port,
1100 USER_SERVICE_ID, sc, scIndex);
1101 code = ubik_ClientInit(serverconns, &cstruct);
1103 ViceLog(0, ("vl_Initialize: ubik client init failed.\n"));
1109 #define SYSIDMAGIC 0x88aabbcc
1110 #define SYSIDVERSION 1
1114 afs_int32 fd, nentries, i;
1115 struct versionStamp vsn;
1119 if ((stat(AFSDIR_SERVER_SYSID_FILEPATH, &status)) || (status.st_size <= 0)) {
1120 ViceLog(0, ("%s: doesn't exist\n", AFSDIR_SERVER_SYSID_FILEPATH));
1123 if (!(fd = open(AFSDIR_SERVER_SYSID_FILEPATH, O_RDONLY, 0))) {
1124 ViceLog(0, ("%s: can't open (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1127 if ((i = read(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1128 ViceLog(0, ("%s: Read failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1131 if (vsn.magic != SYSIDMAGIC) {
1132 ViceLog(0, ("%s: wrong magic %x (we support %x)\n", AFSDIR_SERVER_SYSID_FILEPATH, vsn.magic, SYSIDMAGIC));
1135 if (vsn.version != SYSIDVERSION) {
1136 ViceLog(0, ("%s: wrong version %d (we support %d)\n", AFSDIR_SERVER_SYSID_FILEPATH, vsn.version, SYSIDVERSION));
1139 if ((i = read(fd, (char *)&uuid, sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1140 ViceLog(0, ("%s: read of uuid failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1143 afs_ntohuuid(&uuid);
1145 if ((i = read(fd, (char *)&nentries, sizeof(afs_int32))) != sizeof(afs_int32)) {
1146 ViceLog(0, ("%s: Read of entries failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1149 if (nentries <= 0 || nentries > ADDRSPERSITE) {
1150 ViceLog(0, ("%s: invalid num of interfaces: %d\n", AFSDIR_SERVER_SYSID_FILEPATH, nentries));
1153 FS_HostAddr_cnt = nentries;
1154 for (i = 0; i < nentries; i++) {
1155 if (read(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) != sizeof(afs_int32)) {
1156 ViceLog(0, ("%s: Read of addresses failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1157 FS_HostAddr_cnt = 0; /* reset it */
1167 afs_int32 fd, nentries, i;
1168 struct versionStamp vsn;
1172 if (!stat(AFSDIR_SERVER_SYSID_FILEPATH, &status)) {
1174 * File exists; keep the old one around
1176 renamefile(AFSDIR_SERVER_SYSID_FILEPATH, AFSDIR_SERVER_OLDSYSID_FILEPATH);
1178 fd = open(AFSDIR_SERVER_SYSID_FILEPATH, O_WRONLY|O_TRUNC|O_CREAT, 0666);
1180 ViceLog(0, ("%s: can't create (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1183 vsn.magic = SYSIDMAGIC;
1185 if ((i = write(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1186 ViceLog(0, ("%s: write failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1190 afs_htonuuid(&uuid);
1191 if ((i = write(fd, (char *)&uuid, sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1192 ViceLog(0, ("%s: write of uuid failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1195 if ((i = write(fd, (char *)&FS_HostAddr_cnt, sizeof(afs_int32))) != sizeof(afs_int32)) {
1196 ViceLog(0, ("%s: write of # of entries failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1199 for (i = 0; i < FS_HostAddr_cnt; i++) {
1200 if (write(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) != sizeof(afs_int32)) {
1201 ViceLog(0, ("%s: write of addresses failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH, errno));
1211 * This routine sets up the buffers for the VL_RegisterAddrs RPC. All addresses
1212 * in FS_HostAddrs[] are in NBO, while the RPC treats them as a "blob" of data
1213 * and so we need to convert each of them into HBO which is what the extra
1214 * array called FS_HostAddrs_HBO is used here.
1217 Do_VLRegisterRPC() {
1220 extern int VL_RegisterAddrs();
1221 afs_uint32 FS_HostAddrs_HBO[ADDRSPERSITE];
1224 for (i=0; i < FS_HostAddr_cnt ; i++)
1225 FS_HostAddrs_HBO[i]=ntohl(FS_HostAddrs[i]);
1226 addrs.bulkaddrs_len = FS_HostAddr_cnt;
1227 addrs.bulkaddrs_val = (afs_uint32 *)FS_HostAddrs_HBO;
1228 code = ubik_Call(VL_RegisterAddrs, cstruct, 0, &FS_HostUUID, 0, &addrs);
1230 if (code == VL_MULTIPADDR) {
1231 ViceLog(0, ("VL_RegisterAddrs rpc failed; The ethernet address exist on a different server; repair it\n"));
1232 ViceLog(0, ("VL_RegisterAddrs rpc failed; See VLLog for details\n"));
1234 } else if (code == RXGEN_OPCODE) {
1235 ViceLog(0, ("vlserver doesn't support VL_RegisterAddrs rpc; ignored\n"));
1236 FS_registered = 2; /* So we don't have to retry in the gc daemon */
1238 ViceLog(0, ("VL_RegisterAddrs rpc failed; will retry periodically (code=%d, err=%d)\n",
1242 FS_registered = 2; /* So we don't have to retry in the gc daemon */
1250 static int AddrsEqual(cnt, addr1, addr2)
1252 afs_int32 *addr1, *addr2;
1256 for (i = 0; i < cnt; i++) {
1257 for (j = 0; j < cnt; j++) {
1258 if (addr1[i] == addr2[j]) break;
1260 if (j == cnt) return 0;
1271 extern int rxi_numNetAddrs;
1272 extern afs_uint32 rxi_NetAddrs[];
1275 * If this fails, it's because something major is wrong, and is not
1276 * likely to be time dependent.
1278 code = vl_Initialize(AFSDIR_SERVER_ETC_DIRPATH);
1280 ViceLog(0, ("Couldn't initialize protection library; code=%d.\n", code));
1284 /* Read or create the sysid file and register the fileserver's
1285 * IP addresses with the vlserver.
1287 code = ReadSysIdFile();
1289 /* Need to create the file */
1290 ViceLog(0, ("Creating new SysID file\n"));
1291 if ((code = afs_uuid_create(&FS_HostUUID))) {
1292 ViceLog(0, ("Failed to create new uuid: %d\n", code));
1296 /* A good sysid file exists; inform the vlserver. If any conflicts,
1297 * we always use the latest interface available as the real truth.
1299 #ifndef AFS_NT40_ENV
1300 if(AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
1302 * Find addresses we are supposed to register as per the netrestrict
1303 * and netinfo files (/usr/afs/local/NetInfo and
1304 * /usr/afs/local/NetRestict)
1307 afs_int32 code = parseNetFiles(FS_HostAddrs,NULL, NULL,
1308 ADDRSPERSITE, reason,
1309 AFSDIR_SERVER_NETINFO_FILEPATH,
1310 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1312 ViceLog(0,("Can't register any valid addresses: %s\n",reason));
1315 FS_HostAddr_cnt = (afs_uint32) code;
1320 FS_HostAddr_cnt = rx_getAllAddr(FS_HostAddrs, ADDRSPERSITE);
1324 code = Do_VLRegisterRPC();
1329 main(int argc, char * argv[])
1335 struct rx_securityClass *sc[4];
1336 struct rx_service *tservice;
1337 #ifdef AFS_PTHREAD_ENV
1338 pthread_t parentPid, serverPid;
1339 pthread_attr_t tattr;
1341 #else /* AFS_PTHREAD_ENV */
1342 PROCESS parentPid, serverPid;
1343 #endif /* AFS_PTHREAD_ENV */
1345 int minVnodesRequired; /* min size of vnode cache */
1346 #ifndef AFS_NT40_ENV
1347 struct rlimit rlim; /* max number of open file descriptors */
1351 #ifdef AFS_AIX32_ENV
1352 struct sigaction nsa;
1354 sigemptyset(&nsa.sa_mask);
1355 nsa.sa_handler = SIG_DFL;
1356 nsa.sa_flags = SA_FULLDUMP;
1357 sigaction(SIGABRT, &nsa, NULL);
1358 sigaction(SIGSEGV, &nsa, NULL);
1361 /* Initialize dirpaths */
1362 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
1364 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0],0);
1366 fprintf(stderr,"%s: Unable to obtain AFS server directory.\n", argv[0]);
1370 #ifndef AFS_QUIETFS_ENV
1371 console = fopen("/dev/console","w");
1374 if(ParseArgs(argc,argv)) {
1379 #ifdef AFS_PTHREAD_ENV
1380 assert(pthread_mutex_init(&fileproc_glock_mutex, NULL) == 0);
1381 #endif /* AFS_PTHREAD_ENV */
1383 #ifdef AFS_SGI_VNODE_GLUE
1384 if (afs_init_kernel_config(-1) <0) {
1385 printf("Can't determine NUMA configuration, not starting fileserver.\n");
1389 confDir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1391 fprintf(stderr, "Unable to open config directory %s\n",
1392 AFSDIR_SERVER_ETC_DIRPATH);
1398 /* Open FileLog on stdout, stderr, fd 1 and fd2 (for perror), sigh. */
1399 OpenLog(AFSDIR_SERVER_FILELOG_FILEPATH);
1402 if (SawSpare && SawPctSpare) {
1403 ViceLog(0, ("Both -spare and -pctspare specified, exiting.\n"));
1407 #ifdef AFS_SGI_XFS_IOPS_ENV
1408 ViceLog(0, ("XFS/EFS File server starting\n"));
1410 ViceLog(0, ("File server starting\n"));
1413 /* install signal handlers for controlling the fileserver process */
1414 ResetCheckSignal(); /* set CheckSignal_Signal() sig handler */
1415 ResetCheckDescriptors(); /* set CheckDescriptors_Signal() sig handler */
1417 #if defined(AFS_SGI_ENV)
1418 /* give this guy a non-degrading priority so help busy servers */
1419 schedctl(NDPRI, 0, NDPNORMMAX);
1423 #ifndef AFS_NT40_ENV
1424 nice(-5); /* TODO: */
1427 assert(DInit(buffs) == 0);
1430 if (afs_winsockInit()<0) {
1431 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
1432 ViceLog(0, ("File server failed to intialize winsock.\n"));
1438 /* if we support more than 16 threads, then we better have the ability
1439 ** to keep open a large number of files simultaneously
1441 #if defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV)
1442 curLimit = OPEN_MAX; /* for pre AIX 4.2 systems */
1443 #elif defined(AFS_NT40_ENV)
1444 curLimit = NT_OPEN_MAX; /* open file descriptor limit on NT */
1447 curLimit = 0; /* the number of open file descriptors */
1448 code = getrlimit(RLIMIT_NOFILE, &rlim);
1450 curLimit = rlim.rlim_cur;
1451 rlim.rlim_cur = rlim.rlim_max;
1452 code = setrlimit(RLIMIT_NOFILE, &rlim);
1454 curLimit = rlim.rlim_max;
1457 ViceLog(0, ("Failed to increase open file limit, using default\n"));
1459 #endif /* defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV) */
1461 curLimit -= 32; /* leave a slack of 32 file descriptors */
1462 if ( lwps > curLimit ) {
1465 else if ( lwps > 16 )
1466 lwps = 16; /* default to a maximum of 16 threads */
1467 ViceLog(0, ("The system supports a max of %d open files and we are starting %d threads\n", curLimit, lwps));
1471 #ifndef AFS_PTHREAD_ENV
1472 assert(LWP_InitializeProcessSupport(LWP_MAX_PRIORITY - 2, &parentPid) == LWP_SUCCESS);
1473 #endif /* !AFS_PTHREAD_ENV */
1475 /* Initialize volume support */
1477 V_BreakVolumeCallbacks = BreakVolumeCallBacksLater;
1480 /* initialize libacl routines */
1481 acl_Initialize(ACL_VERSION);
1483 /* initialize RX support */
1484 #ifndef AFS_NT40_ENV
1485 rxi_syscallp = viced_syscall;
1487 rx_extraPackets = rxpackets;
1488 rx_extraQuota = 4; /* for outgoing prserver calls from R threads */
1489 rx_SetBusyThreshold(busy_threshold, VBUSY);
1490 rx_SetCallAbortThreshold(10);
1491 rx_SetConnAbortThreshold(10);
1492 stackSize = lwps * 4000;
1493 if (stackSize < 32000)
1495 else if (stackSize > 44000)
1497 #if defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV) || defined(AFS_SGI51_ENV)
1498 rx_SetStackSize(1, stackSize);
1501 rx_SetUdpBufSize(udpBufSize);/* set the UDP buffer size for receive */
1502 if (rx_Init((int)htons(7000))<0) {
1503 ViceLog(0, ("Cannot initialize RX\n"));
1506 if (!rxJumbograms) {
1507 /* Don't send and don't allow 3.4 clients to send jumbograms. */
1511 rx_SetRxDeadTime(30);
1512 sc[0] = rxnull_NewServerSecurityObject();
1513 sc[1] = 0; /* rxvab_NewServerSecurityObject(key1, 0) */
1514 sc[2] = rxkad_NewServerSecurityObject (rxkad_clear, NULL,
1516 sc[3] = rxkad_NewServerSecurityObject (rxkad_crypt, NULL,
1518 tservice = rx_NewService
1519 (/* port */ 0, /* service id */ 1, /*service name */ "AFS",
1520 /* security classes */ sc, /* numb sec classes */ 4,
1521 RXAFS_ExecuteRequest);
1523 ViceLog(0, ("Failed to initialize RX, probably two servers running.\n"));
1526 rx_SetDestroyConnProc(tservice, (void (*)())h_FreeConnection);
1527 rx_SetMinProcs(tservice, 3);
1528 rx_SetMaxProcs(tservice, lwps);
1529 rx_SetCheckReach(tservice, 1);
1531 tservice = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 4, RXSTATS_ExecuteRequest);
1533 ViceLog(0, ("Failed to initialize rpc stat service.\n"));
1536 rx_SetMinProcs(tservice, 2);
1537 rx_SetMaxProcs(tservice, 4);
1540 * Enable RX hot threads, which allows the listener thread to trade
1541 * places with an idle thread and moves the context switch from listener
1542 * to worker out of the critical path.
1544 rx_EnableHotThread();
1546 /* Some rx debugging */
1547 if (rxlog || eventlog) {
1548 debugFile = fopen("rx_dbg", "w");
1549 if (rxlog) rx_debugFile = debugFile;
1550 if (eventlog) rxevent_debugFile = debugFile;
1553 h_InitHostPackage(); /* set up local cellname and realmname */
1554 InitCallBack(numberofcbs);
1559 ViceLog(0,("Fatal error in library initialization, exiting!!\n"));
1565 ViceLog(0,("Fatal error in protection initialization, exiting!!\n"));
1569 /* allow super users to manage RX statistics */
1570 rx_SetRxStatUserOk(fs_rxstat_userok);
1572 rx_StartServer(0); /* now start handling requests */
1574 /* we ensure that there is enough space in the vnode buffer to satisfy
1575 ** requests from all concurrent threads.
1576 ** the maximum number of vnodes used by a single thread at any one time
1577 ** is three ( "link" uses three vnodes simultaneously, one vLarge and
1578 ** two vSmall for linking files and two vLarge and one vSmall for linking
1581 minVnodesRequired = 2 * lwps + 1;
1582 if ( minVnodesRequired > nSmallVns ) {
1583 nSmallVns = minVnodesRequired;
1584 ViceLog(0, ("Overriding -s command line parameter with %d\n",
1587 if ( minVnodesRequired > large ) {
1588 large = minVnodesRequired;
1589 ViceLog(0, ("Overriding -l command line parameter with %d\n", large));
1592 /* We now do this after getting the listener up and running, so that client
1593 connections don't timeout (maybe) if a file server is restarted, since it
1594 will be available "real soon now". Worry about whether we can satisfy the
1595 calls in the volume package itself.
1597 if (VInitVolumePackage(fileServer,large,nSmallVns,0, volcache)) {
1598 ViceLog(0, ("Shutting down: errors encountered initializing volume package\n"));
1604 * We are done calling fopen/fdopen. It is safe to use a large
1605 * of the file descriptor cache.
1609 #ifdef AFS_PTHREAD_ENV
1610 assert(pthread_attr_init(&tattr) == 0);
1611 assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
1612 /* Block signals in the threads */
1614 assert(pthread_create(&serverPid, &tattr, (void *)FiveMinuteCheckLWP, &fiveminutes) == 0);
1615 assert(pthread_create(&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0);
1616 assert(pthread_create(&serverPid, &tattr, (void *)FsyncCheckLWP, &fiveminutes) == 0);
1617 AFS_SIGSET_RESTORE();
1618 #else /* AFS_PTHREAD_ENV */
1619 assert(LWP_CreateProcess(FiveMinuteCheckLWP, stack*1024, LWP_MAX_PRIORITY - 2,
1620 (void *) &fiveminutes, "FiveMinuteChecks", &serverPid) == LWP_SUCCESS);
1622 assert(LWP_CreateProcess(HostCheckLWP, stack*1024, LWP_MAX_PRIORITY - 2,
1623 (void *) &fiveminutes, "HostCheck", &serverPid) == LWP_SUCCESS);
1624 assert(LWP_CreateProcess(FsyncCheckLWP, stack*1024, LWP_MAX_PRIORITY - 2,
1625 (void *) &fiveminutes, "FsyncCheck", &serverPid) == LWP_SUCCESS);
1626 #endif /* AFS_PTHREAD_ENV */
1628 TM_GetTimeOfDay(&tp, 0);
1630 #ifndef AFS_QUIETFS_ENV
1631 if (console != NULL) {
1632 fprintf(console, "File server has started at %s\r",
1633 afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer)));
1638 * Figure out the FileServer's name and primary address.
1640 ViceLog(0, ("Getting FileServer name...\n"));
1641 code = gethostname(FS_HostName, 64);
1643 ViceLog(0, ("gethostname() failed\n"));
1645 ViceLog(0, ("FileServer host name is '%s'\n", FS_HostName));
1647 ViceLog(0, ("Getting FileServer address...\n"));
1648 he = gethostbyname(FS_HostName);
1650 ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName));
1654 memcpy(&FS_HostAddr_NBO, he->h_addr, 4);
1655 afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
1656 FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
1657 ViceLog(0,("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
1658 FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
1661 /* Install handler to catch the shutdown signal */
1662 signal(SIGQUIT, ShutDown_Signal); /* bosserver assumes SIGQUIT shutdown */
1664 ViceLog(0,("File Server started %s",
1665 afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer))));
1666 #if FS_STATS_DETAILED
1667 afs_FullPerfStats.det.epoch.tv_sec = StartTime = tp.tv_sec;
1669 #ifdef AFS_PTHREAD_ENV
1671 sleep(1000); /* long time */
1673 #else /* AFS_PTHREAD_ENV */
1674 assert(LWP_WaitProcess(&parentPid) == LWP_SUCCESS);
1675 #endif /* AFS_PTHREAD_ENV */