e2251bc177b7d3e2dc43222bb0a24a192b96be0c
[openafs.git] / src / viced / viced.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 /*  viced.c     - File Server main loop                                  */
11 /*                                                                       */
12 /*  Date: 5/1/85                                                         */
13 /*                                                                       */
14 /*  Function    - This routine has the initialization code for           */
15 /*                FileServer II                                          */
16 /*                                                                       */
17 /* ********************************************************************** */
18
19 #include <afsconfig.h>
20 #include <afs/param.h>
21
22 RCSID
23     ("$Header$");
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <errno.h>
28 #include <sys/types.h>
29 #include <afs/procmgmt.h>       /* signal(), kill(), wait(), etc. */
30 #include <sys/stat.h>
31 #ifdef AFS_NT40_ENV
32 #include <fcntl.h>
33 #include <io.h>
34 #include <windows.h>
35 #include <WINNT/afsevent.h>
36 #else
37 #include <sys/file.h>
38 #include <netinet/in.h>
39 #include <netdb.h>
40 #include <unistd.h>             /* sysconf() */
41
42 #ifdef HAVE_STRING_H
43 #include <string.h>
44 #else
45 #ifdef HAVE_STRINGS_H
46 #include <strings.h>
47 #endif
48 #endif
49
50 #ifndef ITIMER_REAL
51 #include <sys/time.h>
52 #endif /* ITIMER_REAL */
53 #include <sys/resource.h>
54 #endif /* AFS_NT40_ENV */
55 #include <afs/stds.h>
56 #undef SHARED
57 #include <rx/xdr.h>
58 #include <afs/nfs.h>
59 #ifdef AFS_PTHREAD_ENV
60 #include <assert.h>
61 #else /* AFS_PTHREAD_ENV */
62 #include <afs/assert.h>
63 #endif /* AFS_PTHREAD_ENV */
64 #include <lwp.h>
65 #include <lock.h>
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>
73 #include <afs/auth.h>
74 #include <afs/cellconfig.h>
75 #include <afs/acl.h>
76 #include <afs/prs_fs.h>
77 #include <rx/rx.h>
78 #include <rx/rxkad.h>
79 #include <afs/keys.h>
80 #include <afs/afs_args.h>
81 #include <afs/vlserver.h>
82 #include <afs/afsutil.h>
83 #include <afs/fileutil.h>
84 #ifndef AFS_NT40_ENV
85 #include <afs/netutils.h>
86 #endif
87 #include "viced.h"
88 #include "host.h"
89 #ifdef AFS_PTHREAD_ENV
90 #include "softsig.h"
91 #endif
92 #if defined(AFS_SGI_ENV)
93 #include "sys/schedctl.h"
94 #include "sys/lock.h"
95 #endif
96 #include <rx/rx_globals.h>
97
98 #ifdef O_LARGEFILE
99 #define afs_stat        stat64
100 #define afs_fstat       fstat64
101 #define afs_open        open64
102 #define afs_fopen       fopen64
103 #else /* !O_LARGEFILE */
104 #define afs_stat        stat
105 #define afs_fstat       fstat
106 #define afs_open        open
107 #define afs_fopen       fopen
108 #endif /* !O_LARGEFILE */
109
110 extern int BreakVolumeCallBacks(), InitCallBack();
111 extern int BreakVolumeCallBacks(), InitCallBack(), BreakLaterCallBacks();
112 extern int BreakVolumeCallBacksLater();
113 extern int LogLevel, etext;
114 extern afs_int32 BlocksSpare, PctSpare;
115
116 void ShutDown(void);
117 static void ClearXStatValues(), NewParms(), PrintCounters();
118 static void ResetCheckDescriptors(void), ResetCheckSignal(void);
119 static void CheckSignal(void);
120 extern int GetKeysFromToken();
121 extern int RXAFS_ExecuteRequest();
122 extern int RXSTATS_ExecuteRequest();
123 afs_int32 Do_VLRegisterRPC();
124
125 int eventlog = 0, rxlog = 0;
126 FILE *debugFile;
127 FILE *console = NULL;
128
129 #ifdef AFS_PTHREAD_ENV
130 pthread_mutex_t fsync_glock_mutex;
131 pthread_cond_t fsync_cond;
132 #else
133 char fsync_wait[1];
134 #endif /* AFS_PTHREAD_ENV */
135
136 #ifdef AFS_NT40_ENV
137 #define AFS_QUIETFS_ENV 1
138 #define NT_OPEN_MAX    1024     /* This is an arbitrary no. we came up with for 
139                                  * now. We hope this will be replaced by a more
140                                  * intelligent estimate later. */
141 #endif
142
143 int SystemId;                   /* ViceID of "Administrators" */
144 int SystemAnyUser;              /* Viceid of "System:AnyUser" */
145 prlist SystemAnyUserCPS;        /* CPS for "system:AnyUser */
146 int AnonymousID = 0;            /* ViceId of "Anonymous" */
147 prlist AnonCPS;                 /* CPS for "Anonymous" */
148
149 struct afsconf_dir *confDir;    /* Configuration dir object */
150
151 int restartMode = RESTART_ORDINARY;
152
153 int Testing = 0;                /* for ListViceInodes */
154
155 /*
156  * Home for the performance statistics.
157  */
158 struct afs_PerfStats afs_perfstats;
159
160 extern int LogLevel;
161 extern int Statistics;
162
163 int busyonrst = 1;
164 int timeout = 30;
165 int SawSpare;
166 int SawPctSpare;
167 int debuglevel = 0;
168 int printBanner = 0;
169 int rxJumbograms = 1;           /* default is to send and receive jumbograms. */
170 afs_int32 implicitAdminRights = PRSFS_LOOKUP;   /* The ADMINISTER right is 
171                                                  * already implied */
172 afs_int32 readonlyServer = 0;
173
174 int stack = 24;
175 int stackSize = 24000;
176 int fiveminutes = 300;          /* 5 minutes.  Change this for debugging only */
177 int CurrentConnections = 0;
178 int hostaclRefresh = 7200;      /* refresh host clients' acls every 2 hrs */
179 #if defined(AFS_SGI_ENV)
180 int SawLock;
181 #endif
182 time_t StartTime;
183
184 int rxpackets = 150;            /* 100 */
185 int nSmallVns = 400;            /* 200 */
186 int large = 400;                /* 200 */
187 int volcache = 400;             /* 400 */
188 int numberofcbs = 60000;        /* 60000 */
189 int lwps = 9;                   /* 6 */
190 int buffs = 90;                 /* 70 */
191 int novbc = 0;                  /* Enable Volume Break calls */
192 int busy_threshold = 600;
193 int abort_threshold = 10;
194 int udpBufSize = 0;             /* UDP buffer size for receive */
195 int sendBufSize = 16384;        /* send buffer size */
196
197 struct timeval tp;
198
199 /*
200  * FileServer's name and IP address, both network byte order and
201  * host byte order.
202  */
203 #define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
204
205 char FS_HostName[128] = "localhost";
206 afs_uint32 FS_HostAddr_NBO;
207 afs_uint32 FS_HostAddr_HBO;
208 afs_uint32 FS_HostAddrs[ADDRSPERSITE], FS_HostAddr_cnt = 0, FS_registered = 0;
209 /* All addresses in FS_HostAddrs are in NBO */
210 afsUUID FS_HostUUID;
211
212 static void FlagMsg();
213
214 /*
215  * Home for the performance statistics.
216  */
217
218 /* DEBUG HACK */
219 static void
220 CheckDescriptors()
221 {
222 #ifndef AFS_NT40_ENV
223     struct afs_stat status;
224     register int tsize = getdtablesize();
225     register int i;
226     for (i = 0; i < tsize; i++) {
227         if (afs_fstat(i, &status) != -1) {
228             printf("%d: dev %x, inode %u, length %u, type/mode %x\n", i,
229                    status.st_dev, status.st_ino, status.st_size,
230                    status.st_mode);
231         }
232     }
233     fflush(stdout);
234     ResetCheckDescriptors();
235 #endif
236 }                               /*CheckDescriptors */
237
238
239 #ifdef AFS_PTHREAD_ENV
240 void
241 CheckSignal_Signal(x)
242 {
243     CheckSignal();
244 }
245
246 void
247 ShutDown_Signal(x)
248 {
249     ShutDown();
250 }
251
252 void
253 CheckDescriptors_Signal(x)
254 {
255     CheckDescriptors();
256 }
257 #else /* AFS_PTHREAD_ENV */
258 void
259 CheckSignal_Signal(x)
260 {
261     IOMGR_SoftSig(CheckSignal, 0);
262 }
263
264 void
265 ShutDown_Signal(x)
266 {
267     IOMGR_SoftSig(ShutDown, 0);
268 }
269
270 void
271 CheckDescriptors_Signal(x)
272 {
273     IOMGR_SoftSig(CheckDescriptors, 0);
274 }
275 #endif /* AFS_PTHREAD_ENV */
276
277 /* check whether caller is authorized to manage RX statistics */
278 int
279 fs_rxstat_userok(struct rx_call *call)
280 {
281     return afsconf_SuperUser(confDir, call, NULL);
282 }
283
284 static void
285 ResetCheckSignal(void)
286 {
287     int signo;
288
289 #if defined(AFS_HPUX_ENV)
290     signo = SIGPOLL;
291 #else
292 #if defined(AFS_NT40_ENV)
293     signo = SIGUSR2;
294 #else
295     signo = SIGXCPU;
296 #endif
297 #endif
298
299 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
300     softsig_signal(signo, CheckSignal_Signal);
301 #else
302     signal(signo, CheckSignal_Signal);
303 #endif
304 }
305
306 static void
307 ResetCheckDescriptors(void)
308 {
309 #ifndef AFS_NT40_ENV
310 #if defined(AFS_PTHREAD_ENV)
311     softsig_signal(SIGTERM, CheckDescriptors_Signal);
312 #else
313     (void)signal(SIGTERM, CheckDescriptors_Signal);
314 #endif
315 #endif
316 }
317
318
319 /* proc called by rxkad module to get a key */
320 static int
321 get_key(char *arock, register afs_int32 akvno, char *akey)
322 {
323     /* find the key */
324     static struct afsconf_key tkey;
325     register afs_int32 code;
326
327     if (!confDir) {
328         ViceLog(0, ("conf dir not open\n"));
329         return 1;
330     }
331     code = afsconf_GetKey(confDir, akvno, tkey.key);
332     if (code)
333         return code;
334     memcpy(akey, tkey.key, sizeof(tkey.key));
335     return 0;
336
337 }                               /*get_key */
338
339 #ifndef AFS_NT40_ENV
340 int
341 viced_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
342 {
343     afs_uint32 rcode;
344     void (*old) ();
345
346 #ifndef AFS_LINUX20_ENV
347     old = (void (*)())signal(SIGSYS, SIG_IGN);
348 #endif
349     rcode = syscall(AFS_SYSCALL, 28 /* AFSCALL_CALL */ , a3, a4, a5);
350 #ifndef AFS_LINUX20_ENV
351     signal(SIGSYS, old);
352 #endif
353
354     return rcode;
355 }
356 #endif
357
358 #if !defined(AFS_NT40_ENV)
359 #include "AFS_component_version_number.c"
360 #endif /* !AFS_NT40_ENV */
361
362 #define MAXADMINNAME 64
363 char adminName[MAXADMINNAME];
364
365 static void
366 CheckAdminName()
367 {
368     int fd = 0;
369     struct afs_stat status;
370
371     if ((afs_stat("/AdminName", &status)) ||    /* if file does not exist */
372         (status.st_size <= 0) ||        /* or it is too short */
373         (status.st_size >= (MAXADMINNAME)) ||   /* or it is too long */
374         !(fd = afs_open("/AdminName", O_RDONLY, 0))) {  /* or the open fails */
375         strcpy(adminName, "System:Administrators");     /* use the default name */
376     } else {
377         (void)read(fd, adminName, status.st_size);      /* use name from the file */
378     }
379     if (fd)
380         close(fd);              /* close fd if it was opened */
381
382 }                               /*CheckAdminName */
383
384
385 static void
386 setThreadId(char *s)
387 {
388 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
389     /* set our 'thread-id' so that the host hold table works */
390     MUTEX_ENTER(&rx_stats_mutex);       /* protects rxi_pthread_hinum */
391     ++rxi_pthread_hinum;
392     pthread_setspecific(rx_thread_id_key, (void *)rxi_pthread_hinum);
393     MUTEX_EXIT(&rx_stats_mutex);
394     ViceLog(0,
395             ("Set thread id %d for '%s'\n",
396              pthread_getspecific(rx_thread_id_key), s));
397 #endif
398 }
399
400 /* This LWP does things roughly every 5 minutes */
401 static void
402 FiveMinuteCheckLWP()
403 {
404     static int msg = 0;
405     char tbuffer[32];
406
407     ViceLog(1, ("Starting five minute check process\n"));
408     setThreadId("FiveMinuteCheckLWP");
409     while (1) {
410 #ifdef AFS_PTHREAD_ENV
411         sleep(fiveminutes);
412 #else /* AFS_PTHREAD_ENV */
413         IOMGR_Sleep(fiveminutes);
414 #endif /* AFS_PTHREAD_ENV */
415
416         /* close the log so it can be removed */
417         ReOpenLog(AFSDIR_SERVER_FILELOG_FILEPATH);      /* don't trunc, just append */
418         ViceLog(2, ("Cleaning up timed out callbacks\n"));
419         if (CleanupTimedOutCallBacks())
420             ViceLog(5, ("Timed out callbacks deleted\n"));
421         ViceLog(2, ("Set disk usage statistics\n"));
422         VSetDiskUsage();
423         if (FS_registered == 1)
424             Do_VLRegisterRPC();
425         /* Force wakeup in case we missed something; pthreads does timedwait */
426 #ifndef AFS_PTHREAD_ENV
427         LWP_NoYieldSignal(fsync_wait);
428 #endif
429         if (printBanner && (++msg & 1)) {       /* Every 10 minutes */
430             time_t now = FT_ApproxTime();
431             if (console != NULL) {
432 #ifndef AFS_QUIETFS_ENV
433                 fprintf(console, "File server is running at %s\r",
434                         afs_ctime(&now, tbuffer, sizeof(tbuffer)));
435 #endif /* AFS_QUIETFS_ENV */
436                 ViceLog(2,
437                         ("File server is running at %s\n",
438                          afs_ctime(&now, tbuffer, sizeof(tbuffer))));
439             }
440         }
441     }
442 }                               /*FiveMinuteCheckLWP */
443
444
445 /* This LWP does host checks every 5 minutes:  it should not be used for
446  * other 5 minute activities because it may be delayed by timeouts when
447  * it probes the workstations
448  */
449 static void
450 HostCheckLWP()
451 {
452     ViceLog(1, ("Starting Host check process\n"));
453     setThreadId("HostCheckLWP");
454     while (1) {
455 #ifdef AFS_PTHREAD_ENV
456         sleep(fiveminutes);
457 #else /* AFS_PTHREAD_ENV */
458         IOMGR_Sleep(fiveminutes);
459 #endif /* AFS_PTHREAD_ENV */
460         ViceLog(2, ("Checking for dead venii & clients\n"));
461         h_CheckHosts();
462     }
463 }                               /*HostCheckLWP */
464
465 /* This LWP does fsync checks every 5 minutes:  it should not be used for
466  * other 5 minute activities because it may be delayed by timeouts when
467  * it probes the workstations
468  */
469 static
470 FsyncCheckLWP()
471 {
472     afs_int32 code;
473 #ifdef AFS_PTHREAD_ENV
474     struct timespec fsync_next;
475 #endif
476     ViceLog(1, ("Starting fsync check process\n"));
477
478     setThreadId("FsyncCheckLWP");
479
480 #ifdef AFS_PTHREAD_ENV
481     assert(pthread_cond_init(&fsync_cond, NULL) == 0);
482     assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0);
483 #endif
484
485     while (1) {
486         FSYNC_LOCK;
487 #ifdef AFS_PTHREAD_ENV
488         /* rounding is fine */
489         fsync_next.tv_nsec = 0;
490         fsync_next.tv_sec = time(0) + fiveminutes;
491
492         code =
493             pthread_cond_timedwait(&fsync_cond, &fsync_glock_mutex,
494                                    &fsync_next);
495         if (code != 0 && code != ETIMEDOUT)
496             ViceLog(0, ("pthread_cond_timedwait returned %d\n", code));
497 #else /* AFS_PTHREAD_ENV */
498         if ((code = LWP_WaitProcess(fsync_wait)) != LWP_SUCCESS)
499             ViceLog(0, ("LWP_WaitProcess returned %d\n", code));
500 #endif /* AFS_PTHREAD_ENV */
501         FSYNC_UNLOCK;
502         ViceLog(2, ("Checking for fsync events\n"));
503         do {
504             code = BreakLaterCallBacks();
505         } while (code != 0);
506     }
507 }
508
509 /*------------------------------------------------------------------------
510  * PRIVATE ClearXStatValues
511  *
512  * Description:
513  *      Initialize all of the values collected via the xstat
514  *      interface.
515  *
516  * Arguments:
517  *      None.
518  *
519  * Returns:
520  *      Nothing.
521  *
522  * Environment:
523  *      Must be called during File Server initialization.
524  *
525  * Side Effects:
526  *      As advertised.
527  *------------------------------------------------------------------------*/
528
529 static void
530 ClearXStatValues()
531 {                               /*ClearXStatValues */
532
533     struct fs_stats_opTimingData *opTimeP;      /*Ptr to timing struct */
534     struct fs_stats_xferData *opXferP;  /*Ptr to xfer struct */
535     int i;                      /*Loop counter */
536
537     /*
538      * Zero all xstat-related structures.
539      */
540     memset((char *)(&afs_perfstats), 0, sizeof(struct afs_PerfStats));
541 #if FS_STATS_DETAILED
542     memset((char *)(&afs_FullPerfStats), 0,
543            sizeof(struct fs_stats_FullPerfStats));
544
545     /*
546      * That's not enough.  We have to set reasonable minima for
547      * time and xfer values in the detailed stats.
548      */
549     opTimeP = &(afs_FullPerfStats.det.rpcOpTimes[0]);
550     for (i = 0; i < FS_STATS_NUM_RPC_OPS; i++, opTimeP++)
551         opTimeP->minTime.tv_sec = 999999;
552
553     opXferP = &(afs_FullPerfStats.det.xferOpTimes[0]);
554     for (i = 0; i < FS_STATS_NUM_XFER_OPS; i++, opXferP++) {
555         opXferP->minTime.tv_sec = 999999;
556         opXferP->minBytes = 999999999;
557     }
558
559     /*
560      * There's more.  We have to set our unique system identifier, as
561      * declared in param.h.  If such a thing is not defined, we bitch
562      * and declare ourselves to be an unknown system type.
563      */
564 #ifdef SYS_NAME_ID
565     afs_perfstats.sysname_ID = SYS_NAME_ID;
566 #else
567 #ifndef AFS_NT40_ENV
568     ViceLog(0, ("Sys name ID constant not defined in param.h!!\n"));
569     ViceLog(0, ("[Choosing ``undefined'' sys name ID.\n"));
570 #endif
571     afs_perfstats.sysname_ID = SYS_NAME_ID_UNDEFINED;
572 #endif /* SYS_NAME_ID */
573 #endif
574
575 }                               /*ClearXStatValues */
576
577
578 static void
579 PrintCounters()
580 {
581     int dirbuff, dircall, dirio;
582     struct timeval tpl;
583     int workstations, activeworkstations, delworkstations;
584     int processSize = 0;
585     char tbuffer[32];
586
587     TM_GetTimeOfDay(&tpl, 0);
588     Statistics = 1;
589     ViceLog(0,
590             ("Vice was last started at %s\n",
591              afs_ctime(&StartTime, tbuffer, sizeof(tbuffer))));
592
593     VPrintCacheStats();
594     VPrintDiskStats();
595     DStat(&dirbuff, &dircall, &dirio);
596     ViceLog(0,
597             ("With %d directory buffers; %d reads resulted in %d read I/Os\n",
598              dirbuff, dircall, dirio));
599     rx_PrintStats(stderr);
600     h_PrintStats();
601     PrintCallBackStats();
602 #ifdef AFS_NT40_ENV
603     processSize = -1;           /* TODO: */
604 #else
605     processSize = (int)((long)sbrk(0) >> 10);
606 #endif
607     ViceLog(0,
608             ("There are %d connections, process size %d\n",
609              CurrentConnections, processSize));
610     h_GetWorkStats(&workstations, &activeworkstations, &delworkstations,
611                    tpl.tv_sec - 15 * 60);
612     ViceLog(0,
613             ("There are %d workstations, %d are active (req in < 15 mins), %d marked \"down\"\n",
614              workstations, activeworkstations, delworkstations));
615     Statistics = 0;
616
617 }                               /*PrintCounters */
618
619
620
621 static void
622 CheckSignal()
623 {
624     if (FS_registered > 0) {
625         /*
626          * We have proper ip addresses; tell the vlserver what we got; the following
627          * routine will do the proper reporting for us
628          */
629         Do_VLRegisterRPC();
630     }
631     h_DumpHosts();
632     h_PrintClients();
633     DumpCallBackState();
634     PrintCounters();
635     ResetCheckSignal();
636
637 }                               /*CheckSignal */
638
639 void
640 ShutDownAndCore(int dopanic)
641 {
642     time_t now = time(0);
643     char tbuffer[32];
644
645     ViceLog(0,
646             ("Shutting down file server at %s",
647              afs_ctime(&now, tbuffer, sizeof(tbuffer))));
648     if (dopanic)
649         ViceLog(0, ("ABNORMAL SHUTDOWN, see core file.\n"));
650 #ifndef AFS_QUIETFS_ENV
651     if (console != NULL) {
652         fprintf(console, "File server restart/shutdown received at %s\r",
653                 afs_ctime(&now, tbuffer, sizeof(tbuffer)));
654     }
655 #endif
656     DFlush();
657     if (!dopanic)
658         PrintCounters();
659
660     /* do not allows new reqests to be served from now on, all new requests
661      * are returned with an error code of RX_RESTARTING ( transient failure ) */
662     rx_SetRxTranquil();         /* dhruba */
663     VShutdown();
664
665     if (debugFile) {
666         rx_PrintStats(debugFile);
667         fflush(debugFile);
668     }
669     if (console != NULL) {
670         now = time(0);
671         if (dopanic) {
672 #ifndef AFS_QUIETFS_ENV
673             fprintf(console, "File server has terminated abnormally at %s\r",
674                     afs_ctime(&now, tbuffer, sizeof(tbuffer)));
675 #endif
676             ViceLog(0,
677                     ("File server has terminated abnormally at %s\n",
678                      afs_ctime(&now, tbuffer, sizeof(tbuffer))));
679         } else {
680 #ifndef AFS_QUIETFS_ENV
681             fprintf(console, "File server has terminated normally at %s\r",
682                     afs_ctime(&now, tbuffer, sizeof(tbuffer)));
683 #endif
684             ViceLog(0,
685                     ("File server has terminated normally at %s\n",
686                      afs_ctime(&now, tbuffer, sizeof(tbuffer))));
687         }
688     }
689
690     exit(0);
691
692 }                               /*ShutDown */
693
694 void
695 ShutDown(void)
696 {                               /* backward compatibility */
697     ShutDownAndCore(DONTPANIC);
698 }
699
700
701 static void
702 FlagMsg()
703 {
704     char buffer[1024];
705
706     /* default supports help flag */
707
708     strcpy(buffer, "Usage: fileserver ");
709     strcat(buffer, "[-d <debug level>] ");
710     strcat(buffer, "[-p <number of processes>] ");
711     strcat(buffer, "[-spare <number of spare blocks>] ");
712     strcat(buffer, "[-pctspare <percentage spare>] ");
713     strcat(buffer, "[-b <buffers>] ");
714     strcat(buffer, "[-l <large vnodes>] ");
715     strcat(buffer, "[-s <small vnodes>] ");
716     strcat(buffer, "[-vc <volume cachesize>] ");
717     strcat(buffer, "[-w <call back wait interval>] ");
718     strcat(buffer, "[-cb <number of call backs>] ");
719     strcat(buffer, "[-banner (print banner every 10 minutes)] ");
720     strcat(buffer, "[-novbc (whole volume cbs disabled)] ");
721     strcat(buffer, "[-implicit <admin mode bits: rlidwka>] ");
722     strcat(buffer, "[-readonly (read-only file server)] ");
723     strcat(buffer,
724            "[-hr <number of hours between refreshing the host cps>] ");
725     strcat(buffer, "[-busyat <redirect clients when queue > n>] ");
726     strcat(buffer, "[-nobusy <no VBUSY before a volume is attached>] ");
727     strcat(buffer, "[-rxpck <number of rx extra packets>] ");
728     strcat(buffer, "[-rxdbg (enable rx debugging)] ");
729     strcat(buffer, "[-rxdbge (enable rxevent debugging)] ");
730 #ifdef  AFS_AIX32_ENV
731     strcat(buffer, "[-m <min percentage spare in partition>] ");
732 #endif
733 #if defined(AFS_SGI_ENV)
734     strcat(buffer, "[-lock (keep fileserver from swapping)] ");
735 #endif
736     strcat(buffer, "[-L (large server conf)] ");
737     strcat(buffer, "[-S (small server conf)] ");
738     strcat(buffer, "[-k <stack size>] ");
739     strcat(buffer, "[-realm <Kerberos realm name>] ");
740     strcat(buffer, "[-udpsize <size of socket buffer in bytes>] ");
741     strcat(buffer, "[-sendsize <size of send buffer in bytes>] ");
742 /*   strcat(buffer, "[-enable_peer_stats] "); */
743 /*   strcat(buffer, "[-enable_process_stats] "); */
744     strcat(buffer, "[-help]\n");
745 /*
746     ViceLog(0, ("%s", buffer));
747 */
748
749     printf("%s", buffer);
750     fflush(stdout);
751
752 }                               /*FlagMsg */
753
754
755 static afs_int32
756 ParseRights(char *arights)
757 {
758     afs_int32 mode = 0;
759     int i, len;
760     char tc;
761
762     if (!arights || !strcmp(arights, "")) {
763         printf("Missing list of mode bits on -implicit option\n");
764         return -1;
765     }
766     if (!strcmp(arights, "none"))
767         mode = 0;
768     else if (!strcmp(arights, "read"))
769         mode = PRSFS_READ | PRSFS_LOOKUP;
770     else if (!strcmp(arights, "write"))
771         mode =
772             PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
773             PRSFS_WRITE | PRSFS_LOCK;
774     else if (!strcmp(arights, "all"))
775         mode =
776             PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE |
777             PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
778     else {
779         len = strlen(arights);
780         for (i = 0; i < len; i++) {
781             tc = *arights++;
782             if (tc == 'r')
783                 mode |= PRSFS_READ;
784             else if (tc == 'l')
785                 mode |= PRSFS_LOOKUP;
786             else if (tc == 'i')
787                 mode |= PRSFS_INSERT;
788             else if (tc == 'd')
789                 mode |= PRSFS_DELETE;
790             else if (tc == 'w')
791                 mode |= PRSFS_WRITE;
792             else if (tc == 'k')
793                 mode |= PRSFS_LOCK;
794             else if (tc == 'a')
795                 mode |= PRSFS_ADMINISTER;
796             else if (tc == 'A')
797                 mode |= PRSFS_USR0;
798             else if (tc == 'B')
799                 mode |= PRSFS_USR1;
800             else if (tc == 'C')
801                 mode |= PRSFS_USR2;
802             else if (tc == 'D')
803                 mode |= PRSFS_USR3;
804             else if (tc == 'E')
805                 mode |= PRSFS_USR4;
806             else if (tc == 'F')
807                 mode |= PRSFS_USR5;
808             else if (tc == 'G')
809                 mode |= PRSFS_USR6;
810             else if (tc == 'H')
811                 mode |= PRSFS_USR7;
812             else {
813                 printf("Illegal -implicit rights character '%c'.\n", tc);
814                 return -1;
815             }
816         }
817     }
818     return mode;
819 }
820
821 /*
822  * Limit MAX_FILESERVER_THREAD by the system limit on the number of
823  * pthreads (sysconf(_SC_THREAD_THREADS_MAX)), if applicable and
824  * available.
825  *
826  * AIX:         sysconf() limit is real
827  * HP-UX:       sysconf() limit is real
828  * IRIX:        sysconf() limit is apparently NOT real -- too small
829  * DUX:         sysconf() limit is apparently NOT real -- too big
830  * Linux:       sysconf() limit is apparently NOT real -- too big
831  * Solaris:     no sysconf() limit
832  */
833 static int
834 max_fileserver_thread(void)
835 {
836 #if defined(AFS_PTHREAD_ENV)
837 #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV)
838     long ans;
839
840     ans = sysconf(_SC_THREAD_THREADS_MAX);
841     if (0 < ans && ans < MAX_FILESERVER_THREAD)
842         return (int)ans;
843 #endif
844 #endif /* defined(AFS_PTHREAD_ENV) */
845     return MAX_FILESERVER_THREAD;
846 }
847
848 static int
849 ParseArgs(int argc, char *argv[])
850 {
851     int SawL = 0, SawS = 0, SawVC = 0;
852     int Sawrxpck = 0, Sawsmall = 0, Sawlarge = 0, Sawcbs = 0, Sawlwps =
853         0, Sawbufs = 0;
854     int Sawbusy = 0;
855     int i;
856     int bufSize = 0;            /* temp variable to read in udp socket buf size */
857
858     for (i = 1; i < argc; i++) {
859         if (!strcmp(argv[i], "-d")) {
860             if ((i + 1) >= argc) {
861                 fprintf(stderr, "missing argument for -d\n"); 
862                 return -1; 
863             }
864             debuglevel = atoi(argv[++i]);
865             LogLevel = debuglevel;
866         } else if (!strcmp(argv[i], "-banner")) {
867             printBanner = 1;
868         } else if (!strcmp(argv[i], "-implicit")) {
869             if ((i + 1) >= argc) {
870                 fprintf(stderr, "missing argument for -implicit\n"); 
871                 return -1; 
872             }
873             implicitAdminRights = ParseRights(argv[++i]);
874             if (implicitAdminRights < 0)
875                 return implicitAdminRights;
876         } else if (!strcmp(argv[i], "-readonly")) {
877             readonlyServer = 1;
878         } else if (!strcmp(argv[i], "-L")) {
879             SawL = 1;
880         } else if (!strcmp(argv[i], "-S")) {
881             SawS = 1;
882         } else if (!strcmp(argv[i], "-p")) {
883             int lwps_max =
884                 max_fileserver_thread() - FILESERVER_HELPER_THREADS;
885             Sawlwps = 1;
886             if ((i + 1) >= argc) {
887                 fprintf(stderr, "missing argument for -p\n"); 
888                 return -1; 
889             }
890             lwps = atoi(argv[++i]);
891             if (lwps > lwps_max)
892                 lwps = lwps_max;
893             else if (lwps < 6)
894                 lwps = 6;
895         } else if (!strcmp(argv[i], "-b")) {
896             Sawbufs = 1;
897             if ((i + 1) >= argc) {
898                 fprintf(stderr, "missing argument for -b\n"); 
899                 return -1; 
900             }
901             buffs = atoi(argv[++i]);
902         } else if (!strcmp(argv[i], "-l")) {
903             Sawlarge = 1;
904             if ((i + 1) >= argc) {
905                 fprintf(stderr, "missing argument for -l\n"); 
906                 return -1; 
907             }
908             large = atoi(argv[++i]);
909         } else if (!strcmp(argv[i], "-vc")) {
910             SawVC = 1;
911             if ((i + 1) >= argc) {
912                 fprintf(stderr, "missing argument for -vc\n"); 
913                 return -1; 
914             }
915             volcache = atoi(argv[++i]);
916         } else if (!strcmp(argv[i], "-novbc")) {
917             novbc = 1;
918         } else if (!strcmp(argv[i], "-rxpck")) {
919             Sawrxpck = 1;
920             if ((i + 1) >= argc) {
921                 fprintf(stderr, "missing argument for -rxpck\n"); 
922                 return -1; 
923             }
924             rxpackets = atoi(argv[++i]);
925         } else if (!strcmp(argv[i], "-s")) {
926             Sawsmall = 1;
927             if ((i + 1) >= argc) {
928                 fprintf(stderr, "missing argument for -s\n"); 
929                 return -1; 
930             }
931             nSmallVns = atoi(argv[++i]);
932         } else if (!strcmp(argv[i], "-abortthreshold")) {
933             if ((i + 1) >= argc) {
934                 fprintf(stderr, "missing argument for -abortthreshold\n"); 
935                 return -1; 
936             }
937             abort_threshold = atoi(argv[++i]);
938         } else if (!strcmp(argv[i], "-k")) {
939             if ((i + 1) >= argc) {
940                 fprintf(stderr, "missing argument for -k\n"); 
941                 return -1; 
942             }
943             stack = atoi(argv[++i]);
944         }
945 #if defined(AFS_SGI_ENV)
946         else if (!strcmp(argv[i], "-lock")) {
947             SawLock = 1;
948         }
949 #endif
950         else if (!strcmp(argv[i], "-spare")) {
951             if ((i + 1) >= argc) {
952                 fprintf(stderr, "missing argument for -spare\n"); 
953                 return -1; 
954             }
955             BlocksSpare = atoi(argv[++i]);
956             SawSpare = 1;
957         } else if (!strcmp(argv[i], "-pctspare")) {
958             if ((i + 1) >= argc) {
959                 fprintf(stderr, "missing argument for -pctspare\n"); 
960                 return -1; 
961             }
962             PctSpare = atoi(argv[++i]);
963             BlocksSpare = 0;    /* has non-zero default */
964             SawPctSpare = 1;
965         } else if (!strcmp(argv[i], "-w")) {
966             if ((i + 1) >= argc) {
967                 fprintf(stderr, "missing argument for -w\n"); 
968                 return -1; 
969             }
970             fiveminutes = atoi(argv[++i]);
971         } else if (!strcmp(argv[i], "-hr")) {
972             int hr;
973             if ((i + 1) >= argc) {
974                 fprintf(stderr, "missing argument for -hr\n"); 
975                 return -1; 
976             }
977             hr = atoi(argv[++i]);
978             if ((hr < 1) || (hr > 36)) {
979                 printf
980                     ("host acl refresh interval of %d hours is invalid; hours must be between 1 and 36\n\n",
981                      hr);
982                 return -1;
983             }
984             hostaclRefresh = hr * 60 * 60;
985         } else if (!strcmp(argv[i], "-rxdbg"))
986             rxlog = 1;
987         else if (!strcmp(argv[i], "-rxdbge"))
988             eventlog = 1;
989         else if (!strcmp(argv[i], "-cb")) {
990             Sawcbs = 1;
991             if ((i + 1) >= argc) {
992                 fprintf(stderr, "missing argument for -cb\n"); 
993                 return -1; 
994             }
995             numberofcbs = atoi(argv[++i]);
996             if ((numberofcbs < 10000) || (numberofcbs > 2147483647)) {
997                 printf
998                     ("number of cbs %d invalid; must be between 10000 and 2147483647\n",
999                      numberofcbs);
1000                 return -1;
1001             }
1002         } else if (!strcmp(argv[i], "-busyat")) {
1003             Sawbusy = 1;
1004             if ((i + 1) >= argc) {
1005                 fprintf(stderr, "missing argument for -busyat\n"); 
1006                 return -1; 
1007             }
1008             busy_threshold = atoi(argv[++i]);
1009             if (busy_threshold < 10) {
1010                 printf
1011                     ("Busy threshold %d is too low, will compute default.\n",
1012                      busy_threshold);
1013                 Sawbusy = 0;
1014             }
1015         } else if (!strcmp(argv[i], "-nobusy"))
1016             busyonrst = 0;
1017 #ifdef  AFS_AIX32_ENV
1018         else if (!strcmp(argv[i], "-m")) {
1019             extern int aixlow_water;
1020             if ((i + 1) >= argc) {
1021                 fprintf(stderr, "missing argument for -m\n"); 
1022                 return -1; 
1023             }
1024             aixlow_water = atoi(argv[++i]);
1025             if ((aixlow_water < 0) || (aixlow_water > 30)) {
1026                 printf("space reserved %d% invalid; must be between 0-30%\n",
1027                        aixlow_water);
1028                 return -1;
1029             }
1030         }
1031 #endif
1032         else if (!strcmp(argv[i], "-nojumbo")) {
1033             rxJumbograms = 0;
1034         } else if (!strcmp(argv[i], "-realm")) {
1035             extern char local_realm[AFS_REALM_SZ];
1036             if ((i + 1) >= argc) {
1037                 fprintf(stderr, "missing argument for -realm\n"); 
1038                 return -1; 
1039             }
1040             if (strlen(argv[++i]) >= AFS_REALM_SZ) {
1041                 printf
1042                     ("-realm argument must contain fewer than %d characters.\n",
1043                      AFS_REALM_SZ);
1044                 return -1;
1045             }
1046             strncpy(local_realm, argv[i], AFS_REALM_SZ);
1047         } else if (!strcmp(argv[i], "-udpsize")) {
1048             if ((i + 1) >= argc) {
1049                 printf("You have to specify -udpsize <integer value>\n");
1050                 return -1;
1051             }
1052             bufSize = atoi(argv[++i]);
1053             if (bufSize < rx_GetMinUdpBufSize())
1054                 printf
1055                     ("Warning:udpsize %d is less than minimum %d; ignoring\n",
1056                      bufSize, rx_GetMinUdpBufSize());
1057             else
1058                 udpBufSize = bufSize;
1059         } else if (!strcmp(argv[i], "-sendsize")) {
1060             if ((i + 1) >= argc) {
1061                 printf("You have to specify -sendsize <integer value>\n");
1062                 return -1;
1063             }
1064             bufSize = atoi(argv[++i]);
1065             if (bufSize < 16384)
1066                 printf
1067                     ("Warning:sendsize %d is less than minimum %d; ignoring\n",
1068                      bufSize, 16384);
1069             else
1070                 sendBufSize = bufSize;
1071         } else if (!strcmp(argv[i], "-enable_peer_stats")) {
1072             rx_enablePeerRPCStats();
1073         } else if (!strcmp(argv[i], "-enable_process_stats")) {
1074             rx_enableProcessRPCStats();
1075         }
1076 #ifndef AFS_NT40_ENV
1077         else if (strcmp(argv[i], "-syslog") == 0) {
1078             /* set syslog logging flag */
1079             serverLogSyslog = 1;
1080         } else if (strncmp(argv[i], "-syslog=", 8) == 0) {
1081             serverLogSyslog = 1;
1082             serverLogSyslogFacility = atoi(argv[i] + 8);
1083         }
1084 #endif
1085         else {
1086             return (-1);
1087         }
1088     }
1089     if (SawS && SawL) {
1090         printf("Only one of -L, or -S must be specified\n");
1091         return -1;
1092     }
1093     if (SawS) {
1094         if (!Sawrxpck)
1095             rxpackets = 100;
1096         if (!Sawsmall)
1097             nSmallVns = 200;
1098         if (!Sawlarge)
1099             large = 200;
1100         if (!Sawcbs)
1101             numberofcbs = 20000;
1102         if (!Sawlwps)
1103             lwps = 6;
1104         if (!Sawbufs)
1105             buffs = 70;
1106         if (!SawVC)
1107             volcache = 200;
1108     }
1109     if (SawL) {
1110         if (!Sawrxpck)
1111             rxpackets = 200;
1112         if (!Sawsmall)
1113             nSmallVns = 600;
1114         if (!Sawlarge)
1115             large = 600;
1116         if (!Sawcbs)
1117             numberofcbs = 64000;
1118         if (!Sawlwps)
1119             lwps = 12;
1120         if (!Sawbufs)
1121             buffs = 120;
1122         if (!SawVC)
1123             volcache = 600;
1124     }
1125     if (!Sawbusy)
1126         busy_threshold = 3 * rxpackets / 2;
1127
1128     return (0);
1129
1130 }                               /*ParseArgs */
1131
1132
1133 #define MAXPARMS 15
1134
1135 static void
1136 NewParms(int initializing)
1137 {
1138     static struct afs_stat sbuf;
1139     register int i, fd;
1140     char *parms;
1141     char *argv[MAXPARMS];
1142     register int argc;
1143
1144     if (!(afs_stat("/vice/file/parms", &sbuf))) {
1145         parms = (char *)malloc(sbuf.st_size);
1146         if (!parms)
1147             return;
1148         fd = afs_open("parms", O_RDONLY, 0666);
1149         if (fd <= 0) {
1150             ViceLog(0, ("Open for parms failed with errno = %d\n", errno));
1151             return;
1152         }
1153
1154         i = read(fd, parms, sbuf.st_size);
1155         close(fd);
1156         if (i != sbuf.st_size) {
1157             if (i < 0) {
1158                 ViceLog(0, ("Read on parms failed with errno = %d\n", errno));
1159             } else {
1160                 ViceLog(0,
1161                         ("Read on parms failed; expected %d bytes but read %d\n",
1162                          sbuf.st_size, i));
1163             }
1164             free(parms);
1165             return;
1166         }
1167
1168         for (i = 0; i < MAXPARMS; argv[i++] = 0);
1169
1170         for (argc = i = 0; i < sbuf.st_size; i++) {
1171             if ((*(parms + i) != ' ') && (*(parms + i) != '\n')) {
1172                 if (argv[argc] == 0)
1173                     argv[argc] = (parms + i);
1174             } else {
1175                 *(parms + i) = '\0';
1176                 if (argv[argc] != 0) {
1177                     if (++argc == MAXPARMS)
1178                         break;
1179                 }
1180                 while ((*(parms + i + 1) == ' ')
1181                        || (*(parms + i + 1) == '\n'))
1182                     i++;
1183             }
1184         }
1185         if (ParseArgs(argc, argv) == 0) {
1186             ViceLog(0, ("Change parameters to:"));
1187         } else {
1188             ViceLog(0, ("Invalid parameter in:"));
1189         }
1190         for (i = 0; i < argc; i++) {
1191             ViceLog(0, (" %s", argv[i]));
1192         }
1193         ViceLog(0, ("\n"));
1194         free(parms);
1195     } else if (!initializing)
1196         ViceLog(0,
1197                 ("Received request to change parms but no parms file exists\n"));
1198
1199 }                               /*NewParms */
1200
1201
1202 /* Miscellaneous routines */
1203 void
1204 Die(char *msg)
1205 {
1206     ViceLog(0, ("%s\n", msg));
1207     assert(0);
1208
1209 }                               /*Die */
1210
1211
1212 afs_int32
1213 InitPR()
1214 {
1215     register code;
1216
1217     /*
1218      * If this fails, it's because something major is wrong, and is not
1219      * likely to be time dependent.
1220      */
1221     code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
1222     if (code != 0) {
1223         ViceLog(0,
1224                 ("Couldn't initialize protection library; code=%d.\n", code));
1225         return code;
1226     }
1227     SystemId = SYSADMINID;
1228     SystemAnyUser = ANYUSERID;
1229     SystemAnyUserCPS.prlist_len = 0;
1230     SystemAnyUserCPS.prlist_val = NULL;
1231     AnonCPS.prlist_len = 0;
1232     AnonCPS.prlist_val = NULL;
1233     while (1) {
1234         code = pr_GetCPS(SystemAnyUser, &SystemAnyUserCPS);
1235         if (code != 0) {
1236             ViceLog(0,
1237                     ("Couldn't get CPS for AnyUser, will try again in 30 seconds; code=%d.\n",
1238                      code));
1239             goto sleep;
1240         }
1241         code = pr_GetCPS(ANONYMOUSID, &AnonCPS);
1242         if (code != 0) {
1243             ViceLog(0,
1244                     ("Couldn't get Anonymous CPS, exiting; code=%d.\n",
1245                      code));
1246             return -1;
1247         }
1248         AnonymousID = ANONYMOUSID;
1249         return 0;
1250       sleep:
1251 #ifdef AFS_PTHREAD_ENV
1252         sleep(30);
1253 #else /* AFS_PTHREAD_ENV */
1254         IOMGR_Sleep(30);
1255 #endif /* AFS_PTHREAD_ENV */
1256     }
1257 }                               /*InitPR */
1258
1259 struct rx_connection *serverconns[MAXSERVERS];
1260 struct ubik_client *cstruct;
1261
1262 afs_int32
1263 vl_Initialize(char *confDir)
1264 {
1265     afs_int32 code, scIndex = 0, i;
1266     struct afsconf_dir *tdir;
1267     struct rx_securityClass *sc;
1268     struct afsconf_cell info;
1269
1270     tdir = afsconf_Open(confDir);
1271     if (!tdir) {
1272         ViceLog(0,
1273                 ("Could not open configuration directory (%s).\n", confDir));
1274         exit(1);
1275     }
1276     code = afsconf_ClientAuth(tdir, &sc, &scIndex);
1277     if (code) {
1278         ViceLog(0, ("Could not get security object for localAuth\n"));
1279         exit(1);
1280     }
1281     code = afsconf_GetCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info);
1282     if (info.numServers > MAXSERVERS) {
1283         ViceLog(0,
1284                 ("vl_Initialize: info.numServers=%d (> MAXSERVERS=%d)\n",
1285                  info.numServers, MAXSERVERS));
1286         exit(1);
1287     }
1288     for (i = 0; i < info.numServers; i++)
1289         serverconns[i] =
1290             rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
1291                              info.hostAddr[i].sin_port, USER_SERVICE_ID, sc,
1292                              scIndex);
1293     code = ubik_ClientInit(serverconns, &cstruct);
1294     if (code) {
1295         ViceLog(0, ("vl_Initialize: ubik client init failed.\n"));
1296         return code;
1297     }
1298     return 0;
1299 }
1300
1301 #define SYSIDMAGIC      0x88aabbcc
1302 #define SYSIDVERSION    1
1303
1304 afs_int32
1305 ReadSysIdFile()
1306 {
1307     afs_int32 fd, nentries, i;
1308     struct versionStamp vsn;
1309     struct afs_stat status;
1310     afsUUID uuid;
1311
1312     if ((afs_stat(AFSDIR_SERVER_SYSID_FILEPATH, &status))
1313         || (status.st_size <= 0)) {
1314         ViceLog(0, ("%s: doesn't exist\n", AFSDIR_SERVER_SYSID_FILEPATH));
1315         return ENOENT;
1316     }
1317     if (!(fd = afs_open(AFSDIR_SERVER_SYSID_FILEPATH, O_RDONLY, 0))) {
1318         ViceLog(0,
1319                 ("%s: can't open (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1320                  errno));
1321         return EIO;
1322     }
1323     if ((i = read(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1324         ViceLog(0,
1325                 ("%s: Read failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1326                  errno));
1327         return EIO;
1328     }
1329     if (vsn.magic != SYSIDMAGIC) {
1330         ViceLog(0,
1331                 ("%s: wrong magic %x (we support %x)\n",
1332                  AFSDIR_SERVER_SYSID_FILEPATH, vsn.magic, SYSIDMAGIC));
1333         return EIO;
1334     }
1335     if (vsn.version != SYSIDVERSION) {
1336         ViceLog(0,
1337                 ("%s: wrong version %d (we support %d)\n",
1338                  AFSDIR_SERVER_SYSID_FILEPATH, vsn.version, SYSIDVERSION));
1339         return EIO;
1340     }
1341     if ((i =
1342          read(fd, (char *)&uuid,
1343               sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1344         ViceLog(0,
1345                 ("%s: read of uuid failed (%d)\n",
1346                  AFSDIR_SERVER_SYSID_FILEPATH, errno));
1347         return EIO;
1348     }
1349     afs_ntohuuid(&uuid);
1350     FS_HostUUID = uuid;
1351     if ((i =
1352          read(fd, (char *)&nentries,
1353               sizeof(afs_int32))) != sizeof(afs_int32)) {
1354         ViceLog(0,
1355                 ("%s: Read of entries failed (%d)\n",
1356                  AFSDIR_SERVER_SYSID_FILEPATH, errno));
1357         return EIO;
1358     }
1359     if (nentries <= 0 || nentries > ADDRSPERSITE) {
1360         ViceLog(0,
1361                 ("%s: invalid num of interfaces: %d\n",
1362                  AFSDIR_SERVER_SYSID_FILEPATH, nentries));
1363         return EIO;
1364     }
1365     FS_HostAddr_cnt = nentries;
1366     for (i = 0; i < nentries; i++) {
1367         if (read(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1368             sizeof(afs_int32)) {
1369             ViceLog(0,
1370                     ("%s: Read of addresses failed (%d)\n",
1371                      AFSDIR_SERVER_SYSID_FILEPATH, errno));
1372             FS_HostAddr_cnt = 0;        /* reset it */
1373             return EIO;
1374         }
1375     }
1376     close(fd);
1377     return 0;
1378 }
1379
1380 afs_int32
1381 WriteSysIdFile()
1382 {
1383     afs_int32 fd, i;
1384     struct versionStamp vsn;
1385     struct afs_stat status;
1386     afsUUID uuid;
1387
1388     if (!afs_stat(AFSDIR_SERVER_SYSID_FILEPATH, &status)) {
1389         /*
1390          * File exists; keep the old one around
1391          */
1392         renamefile(AFSDIR_SERVER_SYSID_FILEPATH,
1393                    AFSDIR_SERVER_OLDSYSID_FILEPATH);
1394     }
1395     fd = afs_open(AFSDIR_SERVER_SYSID_FILEPATH, O_WRONLY | O_TRUNC | O_CREAT,
1396                   0666);
1397     if (fd < 1) {
1398         ViceLog(0,
1399                 ("%s: can't create (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1400                  errno));
1401         return EIO;
1402     }
1403     vsn.magic = SYSIDMAGIC;
1404     vsn.version = 1;
1405     if ((i = write(fd, (char *)&vsn, sizeof(vsn))) != sizeof(vsn)) {
1406         ViceLog(0,
1407                 ("%s: write failed (%d)\n", AFSDIR_SERVER_SYSID_FILEPATH,
1408                  errno));
1409         return EIO;
1410     }
1411     uuid = FS_HostUUID;
1412     afs_htonuuid(&uuid);
1413     if ((i =
1414          write(fd, (char *)&uuid,
1415                sizeof(struct afsUUID))) != sizeof(struct afsUUID)) {
1416         ViceLog(0,
1417                 ("%s: write of uuid failed (%d)\n",
1418                  AFSDIR_SERVER_SYSID_FILEPATH, errno));
1419         return EIO;
1420     }
1421     if ((i =
1422          write(fd, (char *)&FS_HostAddr_cnt,
1423                sizeof(afs_int32))) != sizeof(afs_int32)) {
1424         ViceLog(0,
1425                 ("%s: write of # of entries failed (%d)\n",
1426                  AFSDIR_SERVER_SYSID_FILEPATH, errno));
1427         return EIO;
1428     }
1429     for (i = 0; i < FS_HostAddr_cnt; i++) {
1430         if (write(fd, (char *)&FS_HostAddrs[i], sizeof(afs_int32)) !=
1431             sizeof(afs_int32)) {
1432             ViceLog(0,
1433                     ("%s: write of addresses failed (%d)\n",
1434                      AFSDIR_SERVER_SYSID_FILEPATH, errno));
1435             return EIO;
1436         }
1437     }
1438     close(fd);
1439     return 0;
1440 }
1441
1442 /*
1443  * defect 10966 
1444  * This routine sets up the buffers for the VL_RegisterAddrs RPC. All addresses
1445  * in FS_HostAddrs[] are in NBO, while the RPC treats them as a "blob" of data
1446  * and so we need to convert each of them into HBO which is what the extra 
1447  * array called FS_HostAddrs_HBO is used here.
1448  */
1449 afs_int32
1450 Do_VLRegisterRPC()
1451 {
1452     register int code;
1453     bulkaddrs addrs;
1454     extern int VL_RegisterAddrs();
1455     afs_uint32 FS_HostAddrs_HBO[ADDRSPERSITE];
1456     int i = 0;
1457
1458     for (i = 0; i < FS_HostAddr_cnt; i++)
1459         FS_HostAddrs_HBO[i] = ntohl(FS_HostAddrs[i]);
1460     addrs.bulkaddrs_len = FS_HostAddr_cnt;
1461     addrs.bulkaddrs_val = (afs_uint32 *) FS_HostAddrs_HBO;
1462     code = ubik_Call(VL_RegisterAddrs, cstruct, 0, &FS_HostUUID, 0, &addrs);
1463     if (code) {
1464         if (code == VL_MULTIPADDR) {
1465             ViceLog(0,
1466                     ("VL_RegisterAddrs rpc failed; The ethernet address exist on a different server; repair it\n"));
1467             ViceLog(0,
1468                     ("VL_RegisterAddrs rpc failed; See VLLog for details\n"));
1469             return code;
1470         } else if (code == RXGEN_OPCODE) {
1471             ViceLog(0,
1472                     ("vlserver doesn't support VL_RegisterAddrs rpc; ignored\n"));
1473             FS_registered = 2;  /* So we don't have to retry in the gc daemon */
1474         } else {
1475             ViceLog(0,
1476                     ("VL_RegisterAddrs rpc failed; will retry periodically (code=%d, err=%d)\n",
1477                      code, errno));
1478         }
1479     } else {
1480         FS_registered = 2;      /* So we don't have to retry in the gc daemon */
1481         WriteSysIdFile();
1482     }
1483
1484     return 0;
1485 }
1486
1487 afs_int32
1488 InitVL()
1489 {
1490     afs_int32 code;
1491     extern int rxi_numNetAddrs;
1492     extern afs_uint32 rxi_NetAddrs[];
1493
1494     /*
1495      * If this fails, it's because something major is wrong, and is not
1496      * likely to be time dependent.
1497      */
1498     code = vl_Initialize(AFSDIR_SERVER_ETC_DIRPATH);
1499     if (code != 0) {
1500         ViceLog(0,
1501                 ("Couldn't initialize protection library; code=%d.\n", code));
1502         return code;
1503     }
1504
1505     /* Read or create the sysid file and register the fileserver's
1506      * IP addresses with the vlserver.
1507      */
1508     code = ReadSysIdFile();
1509     if (code) {
1510         /* Need to create the file */
1511         ViceLog(0, ("Creating new SysID file\n"));
1512         if ((code = afs_uuid_create(&FS_HostUUID))) {
1513             ViceLog(0, ("Failed to create new uuid: %d\n", code));
1514             exit(1);
1515         }
1516     }
1517     /* A good sysid file exists; inform the vlserver. If any conflicts,
1518      * we always use the latest interface available as the real truth.
1519      */
1520 #ifndef AFS_NT40_ENV
1521     if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) {
1522         /*
1523          * Find addresses we are supposed to register as per the netrestrict 
1524          * and netinfo files (/usr/afs/local/NetInfo and 
1525          * /usr/afs/local/NetRestict)
1526          */
1527         char reason[1024];
1528         afs_int32 code = parseNetFiles(FS_HostAddrs, NULL, NULL,
1529                                        ADDRSPERSITE, reason,
1530                                        AFSDIR_SERVER_NETINFO_FILEPATH,
1531                                        AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1532         if (code < 0) {
1533             ViceLog(0, ("Can't register any valid addresses: %s\n", reason));
1534             exit(1);
1535         }
1536         FS_HostAddr_cnt = (afs_uint32) code;
1537     } else
1538 #endif
1539     {
1540         FS_HostAddr_cnt = rx_getAllAddr(FS_HostAddrs, ADDRSPERSITE);
1541     }
1542
1543     FS_registered = 1;
1544     code = Do_VLRegisterRPC();
1545     return code;
1546 }
1547
1548 int
1549 main(int argc, char *argv[])
1550 {
1551     afs_int32 code;
1552     char tbuffer[32];
1553     struct rx_securityClass *sc[4];
1554     struct rx_service *tservice;
1555 #ifdef AFS_PTHREAD_ENV
1556     pthread_t serverPid;
1557     pthread_attr_t tattr;
1558 #else /* AFS_PTHREAD_ENV */
1559     PROCESS parentPid, serverPid;
1560 #endif /* AFS_PTHREAD_ENV */
1561     struct hostent *he;
1562     int minVnodesRequired;      /* min size of vnode cache */
1563 #ifndef AFS_NT40_ENV
1564     struct rlimit rlim;         /* max number of open file descriptors */
1565 #endif
1566     int curLimit;
1567     time_t t;
1568
1569 #ifdef  AFS_AIX32_ENV
1570     struct sigaction nsa;
1571
1572     sigemptyset(&nsa.sa_mask);
1573     nsa.sa_handler = SIG_DFL;
1574     nsa.sa_flags = SA_FULLDUMP;
1575     sigaction(SIGABRT, &nsa, NULL);
1576     sigaction(SIGSEGV, &nsa, NULL);
1577 #endif
1578
1579     /* Initialize dirpaths */
1580     if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
1581 #ifdef AFS_NT40_ENV
1582         ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
1583 #endif
1584         fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
1585                 argv[0]);
1586         exit(2);
1587     }
1588 #ifndef AFS_QUIETFS_ENV
1589     console = afs_fopen("/dev/console", "w");
1590 #endif
1591
1592     if (ParseArgs(argc, argv)) {
1593         FlagMsg();
1594         exit(-1);
1595     }
1596 #ifdef AFS_PTHREAD_ENV
1597     assert(pthread_mutex_init(&fileproc_glock_mutex, NULL) == 0);
1598 #endif /* AFS_PTHREAD_ENV */
1599
1600 #ifdef AFS_SGI_VNODE_GLUE
1601     if (afs_init_kernel_config(-1) < 0) {
1602         printf
1603             ("Can't determine NUMA configuration, not starting fileserver.\n");
1604         exit(1);
1605     }
1606 #endif
1607     confDir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1608     if (!confDir) {
1609         fprintf(stderr, "Unable to open config directory %s\n",
1610                 AFSDIR_SERVER_ETC_DIRPATH);
1611         exit(-1);
1612     }
1613
1614     NewParms(1);
1615
1616     /* Open FileLog on stdout, stderr, fd 1 and fd2 (for perror), sigh. */
1617 #ifndef AFS_NT40_ENV
1618     serverLogSyslogTag = "fileserver";
1619 #endif
1620     OpenLog(AFSDIR_SERVER_FILELOG_FILEPATH);
1621     SetupLogSignals();
1622
1623     if (SawSpare && SawPctSpare) {
1624         ViceLog(0, ("Both -spare and -pctspare specified, exiting.\n"));
1625         exit(-1);
1626     }
1627 #ifdef AFS_SGI_XFS_IOPS_ENV
1628     ViceLog(0, ("XFS/EFS File server starting\n"));
1629 #else
1630     ViceLog(0, ("File server starting\n"));
1631 #endif
1632
1633 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
1634     /* initialize the pthread soft signal handler thread */
1635     softsig_init();
1636 #endif
1637
1638     /* install signal handlers for controlling the fileserver process */
1639     ResetCheckSignal();         /* set CheckSignal_Signal() sig handler */
1640     ResetCheckDescriptors();    /* set CheckDescriptors_Signal() sig handler */
1641
1642 #if defined(AFS_SGI_ENV)
1643     /* give this guy a non-degrading priority so help busy servers */
1644     schedctl(NDPRI, 0, NDPNORMMAX);
1645     if (SawLock)
1646         plock(PROCLOCK);
1647 #else
1648 #ifndef AFS_NT40_ENV
1649     nice(-5);                   /* TODO: */
1650 #endif
1651 #endif
1652     assert(DInit(buffs) == 0);
1653
1654 #ifdef AFS_NT40_ENV
1655     if (afs_winsockInit() < 0) {
1656         ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
1657         ViceLog(0, ("File server failed to intialize winsock.\n"));
1658         exit(1);
1659     }
1660 #endif
1661     CheckAdminName();
1662
1663     /* if we support more than 16 threads, then we better have the ability 
1664      ** to keep open a large number of files simultaneously 
1665      */
1666 #if     defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV)
1667     curLimit = OPEN_MAX;        /* for pre AIX 4.2 systems */
1668 #elif defined(AFS_NT40_ENV)
1669     curLimit = NT_OPEN_MAX;     /* open file descriptor limit on NT */
1670 #else
1671
1672     curLimit = 0;               /* the number of open file descriptors */
1673     code = getrlimit(RLIMIT_NOFILE, &rlim);
1674     if (code == 0) {
1675         curLimit = rlim.rlim_cur;
1676         rlim.rlim_cur = rlim.rlim_max;
1677         code = setrlimit(RLIMIT_NOFILE, &rlim);
1678         if (code == 0)
1679             curLimit = rlim.rlim_max;
1680     }
1681     if (code != 0)
1682         ViceLog(0, ("Failed to increase open file limit, using default\n"));
1683
1684 #endif /* defined(AFS_AIX_ENV) && !defined(AFS_AIX42_ENV) */
1685
1686     curLimit -= 32;             /* leave a slack of 32 file descriptors */
1687     if (lwps > curLimit) {
1688         if (curLimit > 0)
1689             lwps = curLimit;
1690         else if (lwps > 16)
1691             lwps = 16;          /* default to a maximum of 16 threads */
1692         ViceLog(0,
1693                 ("The system supports a max of %d open files and we are starting %d threads\n",
1694                  curLimit, lwps));
1695     }
1696 #ifndef AFS_PTHREAD_ENV
1697     assert(LWP_InitializeProcessSupport(LWP_MAX_PRIORITY - 2, &parentPid) ==
1698            LWP_SUCCESS);
1699 #endif /* !AFS_PTHREAD_ENV */
1700
1701     /* Initialize volume support */
1702     if (!novbc) {
1703         V_BreakVolumeCallbacks = BreakVolumeCallBacksLater;
1704     }
1705
1706     /* initialize libacl routines */
1707     acl_Initialize(ACL_VERSION);
1708
1709     /* initialize RX support */
1710 #ifndef AFS_NT40_ENV
1711     rxi_syscallp = viced_syscall;
1712 #endif
1713     rx_extraPackets = rxpackets;
1714     rx_extraQuota = 4;          /* for outgoing prserver calls from R threads */
1715     rx_SetBusyThreshold(busy_threshold, VBUSY);
1716     rx_SetCallAbortThreshold(abort_threshold);
1717     rx_SetConnAbortThreshold(abort_threshold);
1718     stackSize = lwps * 4000;
1719     if (stackSize < 32000)
1720         stackSize = 32000;
1721     else if (stackSize > 44000)
1722         stackSize = 44000;
1723 #if    defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV) || defined(AFS_SGI51_ENV)
1724     rx_SetStackSize(1, stackSize);
1725 #endif
1726     if (udpBufSize)
1727         rx_SetUdpBufSize(udpBufSize);   /* set the UDP buffer size for receive */
1728     if (rx_Init((int)htons(7000)) < 0) {
1729         ViceLog(0, ("Cannot initialize RX\n"));
1730         exit(1);
1731     }
1732     if (!rxJumbograms) {
1733         /* Don't send and don't allow 3.4 clients to send jumbograms. */
1734         rx_SetNoJumbo();
1735     }
1736     rx_GetIFInfo();
1737     rx_SetRxDeadTime(30);
1738     sc[0] = rxnull_NewServerSecurityObject();
1739     sc[1] = 0;                  /* rxvab_NewServerSecurityObject(key1, 0) */
1740     sc[2] = rxkad_NewServerSecurityObject(rxkad_clear, NULL, get_key, NULL);
1741     sc[3] = rxkad_NewServerSecurityObject(rxkad_crypt, NULL, get_key, NULL);
1742     tservice = rx_NewService( /* port */ 0, /* service id */ 1, /*service name */
1743                              "AFS",
1744                                                         /* security classes */ sc,
1745                                                         /* numb sec classes */
1746                              4, RXAFS_ExecuteRequest);
1747     if (!tservice) {
1748         ViceLog(0,
1749                 ("Failed to initialize RX, probably two servers running.\n"));
1750         exit(-1);
1751     }
1752     rx_SetDestroyConnProc(tservice, (void (*)())h_FreeConnection);
1753     rx_SetMinProcs(tservice, 3);
1754     rx_SetMaxProcs(tservice, lwps);
1755     rx_SetCheckReach(tservice, 1);
1756
1757     tservice =
1758         rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 4,
1759                       RXSTATS_ExecuteRequest);
1760     if (!tservice) {
1761         ViceLog(0, ("Failed to initialize rpc stat service.\n"));
1762         exit(-1);
1763     }
1764     rx_SetMinProcs(tservice, 2);
1765     rx_SetMaxProcs(tservice, 4);
1766
1767     /*
1768      * Enable RX hot threads, which allows the listener thread to trade
1769      * places with an idle thread and moves the context switch from listener
1770      * to worker out of the critical path.
1771      */
1772     rx_EnableHotThread();
1773
1774     /* Some rx debugging */
1775     if (rxlog || eventlog) {
1776         debugFile = afs_fopen("rx_dbg", "w");
1777         if (rxlog)
1778             rx_debugFile = debugFile;
1779         if (eventlog)
1780             rxevent_debugFile = debugFile;
1781     }
1782
1783     init_sys_error_to_et();     /* Set up error table translation */
1784     h_InitHostPackage();        /* set up local cellname and realmname */
1785     InitCallBack(numberofcbs);
1786     ClearXStatValues();
1787
1788     code = InitVL();
1789     if (code) {
1790         ViceLog(0, ("Fatal error in library initialization, exiting!!\n"));
1791         exit(1);
1792     }
1793
1794     code = InitPR();
1795     if (code) {
1796         ViceLog(0, ("Fatal error in protection initialization, exiting!!\n"));
1797         exit(1);
1798     }
1799
1800     /* allow super users to manage RX statistics */
1801     rx_SetRxStatUserOk(fs_rxstat_userok);
1802
1803     rx_StartServer(0);          /* now start handling requests */
1804
1805     /* we ensure that there is enough space in the vnode buffer to satisfy
1806      ** requests from all concurrent threads. 
1807      ** the maximum number of vnodes used by a single thread at any one time
1808      ** is three ( "link" uses three vnodes simultaneously, one vLarge and
1809      ** two vSmall for linking files and two vLarge and one vSmall for linking
1810      ** files  ) : dhruba 
1811      */
1812     minVnodesRequired = 2 * lwps + 1;
1813     if (minVnodesRequired > nSmallVns) {
1814         nSmallVns = minVnodesRequired;
1815         ViceLog(0,
1816                 ("Overriding -s command line parameter with %d\n",
1817                  nSmallVns));
1818     }
1819     if (minVnodesRequired > large) {
1820         large = minVnodesRequired;
1821         ViceLog(0, ("Overriding -l command line parameter with %d\n", large));
1822     }
1823
1824     /* We now do this after getting the listener up and running, so that client
1825      * connections don't timeout (maybe) if a file server is restarted, since it
1826      * will be available "real soon now".  Worry about whether we can satisfy the 
1827      * calls in the volume package itself.
1828      */
1829     if (VInitVolumePackage(fileServer, large, nSmallVns, 0, volcache)) {
1830         ViceLog(0,
1831                 ("Shutting down: errors encountered initializing volume package\n"));
1832         VShutdown();
1833         exit(1);
1834     }
1835
1836     /*
1837      * We are done calling fopen/fdopen. It is safe to use a large
1838      * of the file descriptor cache.
1839      */
1840     ih_UseLargeCache();
1841
1842 #ifdef AFS_PTHREAD_ENV
1843     ViceLog(5, ("Starting pthreads\n"));
1844     assert(pthread_attr_init(&tattr) == 0);
1845     assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
1846
1847     assert(pthread_create
1848            (&serverPid, &tattr, (void *)FiveMinuteCheckLWP,
1849             &fiveminutes) == 0);
1850     assert(pthread_create
1851            (&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0);
1852     assert(pthread_create
1853            (&serverPid, &tattr, (void *)FsyncCheckLWP, &fiveminutes) == 0);
1854 #else /* AFS_PTHREAD_ENV */
1855     ViceLog(5, ("Starting LWP\n"));
1856     assert(LWP_CreateProcess
1857            (FiveMinuteCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1858             (void *)&fiveminutes, "FiveMinuteChecks",
1859             &serverPid) == LWP_SUCCESS);
1860
1861     assert(LWP_CreateProcess
1862            (HostCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1863             (void *)&fiveminutes, "HostCheck", &serverPid) == LWP_SUCCESS);
1864     assert(LWP_CreateProcess
1865            (FsyncCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2,
1866             (void *)&fiveminutes, "FsyncCheck", &serverPid) == LWP_SUCCESS);
1867 #endif /* AFS_PTHREAD_ENV */
1868
1869     TM_GetTimeOfDay(&tp, 0);
1870
1871 #ifndef AFS_QUIETFS_ENV
1872     if (console != NULL) { 
1873         time_t t = tp.tv_sec;
1874         fprintf(console, "File server has started at %s\r",
1875                 afs_ctime(&t, tbuffer, sizeof(tbuffer)));
1876     }
1877 #endif
1878
1879     /*
1880      * Figure out the FileServer's name and primary address.
1881      */
1882     ViceLog(0, ("Getting FileServer name...\n"));
1883     code = gethostname(FS_HostName, 64);
1884     if (code) {
1885         ViceLog(0, ("gethostname() failed\n"));
1886     }
1887     ViceLog(0, ("FileServer host name is '%s'\n", FS_HostName));
1888
1889     ViceLog(0, ("Getting FileServer address...\n"));
1890     he = gethostbyname(FS_HostName);
1891     if (!he) {
1892         ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName));
1893     } else {
1894         char hoststr[16];
1895         memcpy(&FS_HostAddr_NBO, he->h_addr, 4);
1896         (void)afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
1897         FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
1898         ViceLog(0,
1899                 ("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
1900                  FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
1901     }
1902
1903     /* Install handler to catch the shutdown signal;
1904      * bosserver assumes SIGQUIT shutdown
1905      */
1906 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
1907     softsig_signal(SIGQUIT, ShutDown_Signal);
1908 #else
1909     (void)signal(SIGQUIT, ShutDown_Signal);
1910 #endif
1911
1912     t = tp.tv_sec;
1913     ViceLog(0,
1914             ("File Server started %s",
1915              afs_ctime(&t, tbuffer, sizeof(tbuffer))));
1916 #if FS_STATS_DETAILED
1917     afs_FullPerfStats.det.epoch.tv_sec = StartTime = tp.tv_sec;
1918 #endif
1919 #ifdef AFS_PTHREAD_ENV
1920     while (1) {
1921         sleep(1000);            /* long time */
1922     }
1923 #else /* AFS_PTHREAD_ENV */
1924     assert(LWP_WaitProcess(&parentPid) == LWP_SUCCESS);
1925 #endif /* AFS_PTHREAD_ENV */
1926 }