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
13 #include <afsconfig.h>
14 #include <afs/param.h>
20 #include <sys/types.h>
21 #if !defined(AFS_SUN3_ENV) && !defined(sys_vax_ul43)
23 /*#ifdef AFS_AIX_ENV*/
40 #include <afs/afs_args.h>
42 #include <afs/afsutil.h>
44 #if defined(AFS_OSF_ENV) || defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
45 /* For SGI 6.2, this is changed to 1 if it's a 32 bit kernel. */
46 int afs_icl_sizeofLong = 2;
48 int afs_icl_sizeofLong = 1;
51 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
52 int afs_64bit_kernel = 1; /* Default for 6.2+, and always for 6.1 */
53 extern int afs_icl_sizeofLong; /* Used in ICL_SIZEHACK() */
57 /* If _SC_KERN_POINTERS not in sysconf, then we can assume a 32 bit abi. */
59 set_kernel_sizeof_long(void)
64 retval = sysconf(_SC_KERN_POINTERS);
67 afs_icl_sizeofLong = 2;
70 afs_icl_sizeofLong = 1;
74 #endif /* AFS_SGI62_ENV */
75 #endif /* AFS_SGI61_ENV */
77 #define BUFFER_MULTIPLIER 1024
79 /* make it big enough to snapshot everything at once, since
80 * decoding takes so long.
82 #define IBSIZE 100000 /* default size */
85 struct logInfo *nextp;
89 char dumpFileName[256] = "";
90 RegisterIclDumpFileName(name)
93 (void)sprintf(dumpFileName, "icl.%.250s", name);
96 /* define globals to use for bulk info */
97 afs_icl_bulkSetinfo_t *setInfo = (afs_icl_bulkSetinfo_t *) 0;
98 afs_icl_bulkLoginfo_t *logInfo = (afs_icl_bulkLoginfo_t *) 0;
100 struct afs_icl_set *icl_allSets = 0;
104 /* given a type and an address, get the size of the thing
108 icl_GetSize(type, addr)
116 ICL_SIZEHACK(type, addr);
120 /* Check types in printf string "bufferp", making sure that each
121 * is compatible with the corresponding parameter type described
122 * by typesp. Also watch for prematurely running out of parameters
123 * before the string is gone.
125 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
127 CheckTypes(bufferp, typesp, typeCount, outMsgBuffer)
139 for (tc = *bufferp;; outMsgBuffer++, tc = *(++bufferp)) {
142 /* hit end of string. We win as long as we aren't
151 inPercent = 1 - inPercent;
155 if (tc >= '0' && tc <= '9') {
156 /* skip digits in % string */
161 /* 'l' is a type modifier. */
165 /* otherwise, we've finally gotten to the type-describing
166 * character. Make sure there's a type descriptor, and then
167 * check the type descriptor.
171 return 0; /* no more type descriptors left */
173 if (typesp[tix] != 1) /* not a string descriptor */
176 *outMsgBuffer = (char)1;
178 if (tc == 'u' || tc == 'x' || tc == 'd' || tc == 'o') {
179 if (typesp[tix] != 0)
180 return 0; /* not an integer descriptor */
184 *outMsgBuffer = (char)2;
187 *outMsgBuffer = (char)3;
190 *outMsgBuffer = (char)4;
194 *outMsgBuffer = (char)5;
198 /* otherwise we're fine, so eat this descriptor */
204 #else /* AFS_SGI61_ENV */
206 CheckTypes(bufferp, typesp, typeCount)
217 for (tc = *bufferp;; tc = *(++bufferp)) {
219 /* hit end of string. We win as long as we aren't
228 inPercent = 1 - inPercent;
232 if (tc >= '0' && tc <= '9')
233 continue; /* skip digits in % string */
234 /* otherwise, we've finally gotten to the type-describing
235 * character. Make sure there's a type descriptor, and then
236 * check the type descriptor.
240 return 0; /* no more type descriptors left */
241 if (tc == 's' && typesp[tix] != 1) /* not a string descriptor */
243 if ((tc == 'u' || tc == 'l' || tc == 'x' || tc == 'd')
244 && (typesp[tix] != 0))
245 return 0; /* not an integer descriptor */
246 /* otherwise we're fine, so eat this descriptor */
252 #endif /* AFS_SGI61_ENV */
254 /* display a single record.
255 * alp points at the first word in the array to be interpreted
256 * rsize gives the # of words in the array
258 #if defined(AFS_SGI61_ENV) && !defined(AFS_SGI62_ENV)
259 #define uint64_t long long
262 DisplayRecord(outFilep, alp, rsize)
264 register afs_int32 *alp;
267 char msgBuffer[1024];
268 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
269 char outMsgBuffer[1024];
271 uint64_t printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
272 char *printfStrings[ICL_MAXEXPANSION * /* max parms */ 4];
273 #else /* AFS_SGI61_ENV */
274 long printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
275 #endif /* AFS_SGI61_ENV */
276 int printfTypes[ICL_MAXEXPANSION * 4];
282 int pix; /* index in alp */
283 int pfpix; /* index in printfParms */
284 int pftix; /* index in printfTypes */
286 int printed; /* did we print the string yet? */
289 /* decode parameters */
290 temp = alp[0]; /* type encoded in low-order 24 bits, t0 high */
296 for (i = 0; i < 4 * ICL_MAXEXPANSION; i++)
298 /* decode each parameter, getting addrs for afs_hyper_t and strings */
299 for (i = 0; !done && i < 4; i++) {
300 type = (temp >> (18 - i * 6)) & 0x3f;
306 case ICL_TYPE_POINTER:
307 printfTypes[pftix++] = 0;
308 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
309 printfParms[pfpix] = alp[pix];
310 printfParms[pfpix] &= 0xffffffff;
311 if (afs_64bit_kernel) {
312 printfParms[pfpix] <<= 32;
313 printfParms[pfpix] |= alp[pix + 1];
315 #elif defined(AFS_OSF_ENV)
316 printfParms[pfpix] = alp[pix + 1];
317 printfParms[pfpix] |= (alp[pix] <<= 32);
318 #else /* !AFS_OSF_ENV && !AFS_SGI61_ENV */
319 printfParms[pfpix] = alp[pix];
324 printfTypes[pftix++] = 0;
325 printfParms[pfpix++] = alp[pix];
329 printfTypes[pftix++] = 0;
330 printfParms[pfpix++] = alp[pix];
331 printfTypes[pftix++] = 0;
332 printfParms[pfpix++] = alp[pix + 1];
335 printfTypes[pftix++] = 0;
336 printfParms[pfpix++] = alp[pix];
337 printfTypes[pftix++] = 0;
338 printfParms[pfpix++] = alp[pix + 1];
339 printfTypes[pftix++] = 0;
340 printfParms[pfpix++] = alp[pix + 2];
341 printfTypes[pftix++] = 0;
342 printfParms[pfpix++] = alp[pix + 3];
344 case ICL_TYPE_STRING:
345 printfTypes[pftix++] = 1;
347 printfStrings[pfpix++] = (char *)&alp[pix];
348 #else /* AFS_SGI64_ENV */
349 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
350 printfStrings[pfpix++] = (char *)&alp[pix];
351 #else /* AFS_SGI61_ENV */
352 printfParms[pfpix++] = (long)&alp[pix];
353 #endif /* AFS_SGI61_ENV */
354 #endif /* AFS_SGI64_ENV */
356 case ICL_TYPE_UNIXDATE:
357 printfParms[pfpix++] = (long)ctime((time_t *) & alp[pix]);
360 printf("DisplayRecord: Bad type %d in decode switch.\n", type);
367 pix += icl_GetSize(type, (char *)&alp[pix]);
370 /* next, try to decode the opcode into a printf string */
371 dce1_error_inq_text(alp[1], msgBuffer, &status);
373 /* if we got a string back, and it is compatible with the
374 * parms we've got, then print it.
378 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
379 if (CheckTypes(msgBuffer, printfTypes, pftix, outMsgBuffer)) {
380 /* we have a string to use, but it ends "(dfs / zcm)",
381 * so we remove the extra gunk.
383 j = strlen(outMsgBuffer);
385 outMsgBuffer[j - 11] = 0;
389 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
390 alp[3] % 1000000, alp[2]);
391 for (i = 0; i < j; i++) {
392 if ((int)outMsgBuffer[i] > 5)
393 fputc(outMsgBuffer[i], outFilep);
395 switch (outMsgBuffer[i]) {
399 fprintf(outFilep, "%s", printfStrings[pfpix++]);
401 case 2: /* signed integer */
402 fprintf(outFilep, "%lld", printfParms[pfpix++]);
404 case 3: /* unsigned integer */
405 fprintf(outFilep, "%llu", printfParms[pfpix++]);
407 case 4: /* octal integer */
408 fprintf(outFilep, "%llo", printfParms[pfpix++]);
410 case 5: /* hex integer */
411 fprintf(outFilep, "%llx", printfParms[pfpix++]);
415 "fstrace: Bad char %d in outMsgBuffer for parm %d\n",
416 outMsgBuffer[i], pfpix);
417 fprintf(outFilep, "fstrace: msgBuffer='%s'\n",
423 fprintf(outFilep, "\n");
426 #else /* AFS_SGI61_ENV */
427 if (CheckTypes(msgBuffer, printfTypes, pftix)) {
428 /* we have a string to use, but it ends "(dfs / zcm)",
429 * so we remove the extra gunk.
431 j = strlen(msgBuffer);
433 msgBuffer[j - 11] = 0;
434 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
435 alp[3] % 1000000, alp[2]);
436 fprintf(outFilep, msgBuffer, printfParms[0], printfParms[1],
437 printfParms[2], printfParms[3], printfParms[4],
438 printfParms[5], printfParms[6], printfParms[7],
439 printfParms[8], printfParms[9], printfParms[10],
440 printfParms[11], printfParms[12], printfParms[13],
441 printfParms[14], printfParms[15]);
442 fprintf(outFilep, "\n");
445 #endif /* AFS_SGI61_ENV */
447 fprintf(outFilep, "Type mismatch, using raw print.\n");
448 fprintf(outFilep, "%s", msgBuffer);
452 if (alp[1] == ICL_INFO_TIMESTAMP) {
453 fprintf(outFilep, "time %d.%06d, pid %u: %s\n", alp[3] / 1000000,
454 alp[3] % 1000000, alp[2], ctime((time_t *) & alp[4]));
456 fprintf(outFilep, "raw op %d, time %d.%06d, pid %u\n", alp[1],
457 alp[3] / 1000000, alp[3] % 1000000, alp[2]);
458 /* now decode each parameter and print it */
461 for (i = 0; !done && i < 4; i++) {
462 type = (temp >> (18 - i * 6)) & 0x3f;
468 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
472 tempParam = alp[pix];
474 tempParam |= alp[pix + 1];
475 fprintf(outFilep, "p%d:%lld ", i, tempParam);
476 #else /* AFS_SGI61_ENV */
477 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
478 #endif /* AFS_SGI61_ENV */
480 case ICL_TYPE_POINTER:
482 tempParam = alp[pix];
484 tempParam |= alp[pix + 1];
485 fprintf(outFilep, "p%d:0x%llx ", i, tempParam);
486 #else /* AFS_SGI61_ENV */
487 fprintf(outFilep, "p%d:0x%x ", i, alp[pix]);
488 #endif /* AFS_SGI61_ENV */
492 fprintf(outFilep, "p%d:%x.%x ", i, alp[pix],
496 fprintf(outFilep, "p%d:%d.%d.%d.%d ", i, alp[pix],
497 alp[pix + 1], alp[pix + 2], alp[pix + 3]);
499 case ICL_TYPE_STRING:
500 fprintf(outFilep, "p%d:%s ", i, (char *)&alp[pix]);
502 case ICL_TYPE_UNIXDATE:
503 fprintf(outFilep, "p%d:%s ", i,
504 ctime((time_t *) & alp[pix]));
508 ("DisplayRecord: Bad type %d in raw print switch.\n",
516 pix += icl_GetSize(type, (char *)&alp[pix]);
519 fprintf(outFilep, "\n"); /* done with line */
529 #include <nl_types.h>
531 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
533 static nl_catd catopen1();
535 static nl_catd _do1_open();
536 static nl_catd cat_already_open();
537 static int make_sets();
538 static FILE *open1catfile();
539 static void add_open_cat();
540 static void cat_hard_close();
541 extern char *strchr();
543 static int catpid[NL_MAXOPEN];
544 static CATD *catsopen[NL_MAXOPEN];
545 #define PATH_FORMAT "/usr/lib/nls/msg/%L/%N:/etc/nls/msg/%L/%N"
546 #define DEFAULT_LANG "C"
547 #define TOO_MANY_HOLES(num_holes, num_non_holes) \
548 (((num_holes) > 100) && ((num_holes) > (num_non_holes)))
554 /*---- n: the number of bytes to be malloc'ed ----*/
558 t = (char *)malloc(n);
560 printf("Failed to get mem\n");
570 /*---- char *cat: the name of the cat to be opened ----*/
571 /*---- int dummy: dummy variable ----*/
575 nl_catd _do_open(); /*---- routine that actually opens
582 if (catd = cat_already_open(cat)) {
583 catd->_count = catd->_count + 1;
587 catd = (CATD *) rmalloc(sizeof(CATD));
590 catd->_name = (char *)rmalloc(strlen(cat) + 1);
591 if (catd->_name == NULL)
593 strcpy(catd->_name, cat);
595 catd->_magic = CAT_MAGIC;
597 #ifndef AFS_OSF20_ENV
598 catd->_pid = getpid();
601 if (_do1_open(catd) != CATD_ERR)
616 /*---- pointer to the partially set up cat descriptor ----*/
619 int make_sets(); /*---- routine to unpack the sets into
620 fast acccess mode ----*/
621 void add_open_cat(); /*---- routine to keep a list of
624 int i; /*---- Misc counter(s) used for loop */
631 catd->_fd = open1catfile(catd->_name);
635 fread((void *)&magic, (size_t) 4, (size_t) 1, catd->_fd);
636 if (magic != CAT_MAGIC) {
637 printf("Magic was %x instead of %x -> %x\n", magic, CAT_MAGIC,
645 /* if ((catd->_mem = shmat((int)fileno(catd->_fd), NULL, SHM_MAP | SHM_RDONLY))
646 == (char * )ERR ) { */
648 if (1) { /* disable the shmat, share memory segemnt */
650 /*______________________________________________________________________
651 If the file can not be mapped then simulate mapping for the index
652 table so that make_sets cat set things up. (rmalloc an area big
653 enough for the index table and read the whole thing in)
654 ______________________________________________________________________*/
656 /* reset the file pointer to the beginning of catalog */
657 fseek(catd->_fd, (long)0, 0);
659 /* malloc the header, if fails return error */
660 catd->_hd = (struct _header *)rmalloc(sizeof(struct _header));
661 if (catd->_hd == NULL)
664 /* read in the whole header */
665 fread((void *)catd->_hd, (size_t) sizeof(struct _header), (size_t) 1,
668 /* cs is a dummpy to hold a set temperorily. The purpose of */
669 /* this for loop is to fread the whole catalog so that the */
670 /* file pointer will be moved to the end of the catalog. */
671 for (i = 0; i < catd->_hd->_n_sets; i++) {
672 fread((void *)&cs, (size_t) 4, (size_t) 1, catd->_fd);
673 fseek(catd->_fd, (long)(cs._n_msgs * sizeof(struct _msgptr)), 1);
676 /* after the for loop, ftell returns the byte offset of the */
677 /* end of the catalog relative to the begining of the file. */
678 /* i.e. i contains the byte offset of the whole catalog. */
679 i = ftell(catd->_fd);
681 /* malloc _mem as a temp pointer to hold the entire catalog. */
682 catd->_mem = (char *)rmalloc(i);
683 if (catd->_mem == NULL)
686 /* reset the file pointer to the begining. */
687 fseek(catd->_fd, (long)0, 0);
689 /* read in the whole catalog into _mem */
690 fread((void *)catd->_mem, (size_t) i, (size_t) 1, catd->_fd);
693 * If there aren't many holes in the set numbers,
694 * fully expand the compacted set array from the
695 * catalog. Then in catgets(), we'll be able to use
696 * the set number to index directly into the expanded
699 * If there are a lot of holes, leave the set array
700 * compacted. In catgets(), we'll search through it
701 * for the requested set.
704 num_holes = catd->_hd->_setmax - catd->_hd->_n_sets;
705 if (!TOO_MANY_HOLES(num_holes, catd->_hd->_n_sets)) {
706 catd->_sets_expanded = TRUE;
707 catd->_n_sets = catd->_hd->_setmax;
709 catd->_sets_expanded = FALSE;
710 catd->_n_sets = catd->_hd->_n_sets - 1;
713 /* malloc one extra set more than the max. set index */
715 (struct _catset *)rmalloc((catd->_n_sets + 1) *
716 sizeof(struct _catset));
717 if (catd->_set == NULL)
720 /* save the max. set number in catd->_setmax */
721 catd->_setmax = catd->_hd->_setmax;
722 /* call make_set to malloc memory for every message */
723 if (make_sets(catd) == -1)
731 /*______________________________________________________________________
732 Normal mapping has occurred, set a few things up and call make_sets
733 ______________________________________________________________________*/
735 catd->_hd = (struct _header *)(catd->_mem);
736 catd->_setmax = catd->_hd->_setmax;
738 (struct _catset *)rmalloc((catd->_hd->_setmax + 1) *
739 sizeof(struct _catset));
740 if (catd->_set == NULL)
742 if (make_sets(catd) == -1)
753 /*---- catd to be added to the list of catalogs ----*/
756 int i = 0; /*---- Misc counter(s) used for loops ----*/
757 while (i < NL_MAXOPEN && catsopen[i]) {
758 if (!strcmp(catd->_name, catsopen[i]->_name)
759 #ifndef AFS_OSF20_ENV
760 && getpid() == catsopen[i]->_pid)
764 return; /*---- The catalog is already here ----*/
768 if (i < NL_MAXOPEN) {
770 catpid[i] = getpid();
779 * FUNCTION: Expands the compacted version of the catalog index table into
780 * the fast access memory version.
782 * EXECUTION ENVIRONMENT:
784 * Make_set executes under a process.
794 struct _catset *cset;
795 char *base = catd->_mem;
796 int n_sets = catd->_hd->_n_sets;
797 int i; /*---- Misc counter(s) used for loops ----*/
798 int j; /*---- Misc counter(s) used for loops ----*/
799 int msgmax; /*---- The maximum number of _messages in a set ----*/
800 char *cmpct_set_ptr; /*---- pointer into the index table ----*/
801 struct _catset cs; /*---- used to look at the sets in the table -*/
804 cmpct_set_ptr = base + sizeof(struct _header);
806 for (i = 0; i < n_sets; i++) {
807 /* loop through each compacted set */
809 cs = *(struct _catset *)cmpct_set_ptr;
810 /* set the _catset ptr to the base of the current
814 (struct _msgptr *)(cmpct_set_ptr + 2 * sizeof(unsigned short));
815 /* set the ms array ptr to the base of
816 * compacted array of _msgptr's */
819 (catd->_sets_expanded) ? &catd->_set[cs._setno] : &catd->_set[i];
822 * If there aren't many holes in the message numbers,
823 * fully expand the compacted message array from the
824 * catalog. Then in catgets(), we'll be able to use
825 * the message number to index directly into the
828 * If there are many holes, leave the message array
829 * compacted. In catgets(), we'll search through it
830 * for the requested message.
833 msgmax = cs._mp[cs._n_msgs - 1]._msgno;
834 num_holes = msgmax - cs._n_msgs;
835 if (!TOO_MANY_HOLES(num_holes, cs._n_msgs)) {
836 cset->_msgs_expanded = TRUE;
837 cset->_n_msgs = msgmax;
839 cset->_msgs_expanded = FALSE;
840 cset->_n_msgs = cs._n_msgs - 1;
844 (struct _msgptr *)rmalloc((1 + cset->_n_msgs) *
845 sizeof(struct _msgptr));
846 if (cset->_mp == NULL)
850 (char **)rmalloc((1 + cset->_n_msgs) * sizeof(char *));
851 if (cset->_msgtxt == NULL)
854 if (cset->_msgs_expanded) {
855 for (j = 0; j < cs._n_msgs; j++) {
856 cset->_mp[cs._mp[j]._msgno] = cs._mp[j];
859 for (j = 0; j < cs._n_msgs; j++) {
860 cset->_mp[j] = cs._mp[j];
864 cset->_setno = cs._setno;
865 /* Superfluous but should have the correct data. Increment
866 * the base of the set pointer. */
869 2 * sizeof(unsigned short) + cs._n_msgs * sizeof(struct _msgptr);
880 * FUNCTION: Opens a catalog file, looking in the language path first (if
881 * there is no slash) and returns a pointer to the file stream.
883 * EXECUTION ENVIRONMENT:
885 * Opencatfile executes under a process.
887 * RETURNS: Returns a pointer to the file stream, and a NULL pointer on
895 extern char *getenv();
896 char fl[PATH_MAX]; /*---- place to hold full path ----*/
897 char *nlspath; /*---- pointer to the nlspath val ----*/
898 FILE *fp; /*---- file pointer ----*/
899 char cpth[PATH_MAX]; /*---- current value of nlspath ----*/
901 char *fulllang; /* %L language value */
902 char lang[PATH_MAX]; /* %l language value */
903 char *territory; /* %t language value */
904 char *codeset; /* %c language value */
905 char *ptr; /* for decompose of $LANG */
910 char outptr[PATH_MAX];
913 if (strchr(file, '/')) {
914 if ((fp = fopen(file, "r"))) {
915 fcntl(fileno(fp), F_SETFD, 1);
916 /* set the close-on-exec flag for
921 if (!(nlspath = getenv("NLSPATH")))
922 nlspath = PATH_FORMAT;
923 if (!(fulllang = getenv("LANG")))
924 fulllang = DEFAULT_LANG;
925 if (fulllang == DEFAULT_LANG)
926 nlspath = PATH_FORMAT; /* if fullang is C, use the
927 * the default nlspath: */
930 ** LANG is a composite of three fields:
931 ** language_territory.codeset
932 ** and we're going to break it into those
936 strcpy(lang, fulllang);
941 ptr = strchr(lang, '_');
945 ptr = strchr(territory, '.');
951 ptr = strchr(lang, '.');
961 while (*np && *np != ':')
964 if (*np) /*---- iff on a colon then advance --*/
972 while (*ptr != '\0') {
973 while ((*ptr != '\0') && (*ptr != '%')
974 && (nchars < PATH_MAX)) {
975 *(optr++) = *(ptr++);
1003 lenstr = strlen(str);
1005 if (nchars < PATH_MAX) {
1013 if (nchars >= PATH_MAX) {
1019 strcpy(cpth, outptr);
1020 } else { /*---- iff leading | trailing |
1021 adjacent colons ... --*/
1025 if (valid == 1 && (fp = fopen(cpth, "r"))) {
1026 fcntl(fileno(fp), F_SETFD, 1);
1027 /* set the close-on-exec flag for
1032 if (fp = fopen(file, "r")) {
1033 fcntl(fileno(fp), F_SETFD, 1);
1034 /* set the close-on-exec flag for
1048 * NAME: cat_already_open
1050 * FUNCTION: Checkes to see if a specific cat has already been opened.
1052 * EXECUTION ENVIRONMENT:
1054 * Cat_already_open executes under a process.
1056 * RETURNS: Returns a pointer to the existing CATD if one exists, and
1057 * a NULL pointer if no CATD exists.
1061 cat_already_open(cat)
1063 /*---- name of the catalog to be opened ----*/
1066 int i; /*---- Misc counter(s) used for loops ----*/
1068 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1069 #ifndef AFS_OSF20_ENV
1070 if (!strcmp(cat, catsopen[i]->_name) && getpid() == catsopen[i]->_pid) {
1072 if (!strcmp(cat, catsopen[i]->_name)) {
1074 return (catsopen[i]);
1082 catclose1(catd) /*---- the catd to be closed ----*/
1083 nl_catd catd; /*---- the catd to be closed ----*/
1089 if (catd == CATD_ERR)
1091 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1092 #ifndef AFS_OSF20_ENV
1093 if (catd == catsopen[i] && getpid() == catsopen[i]->_pid)
1095 if (catd == catsopen[i])
1099 if (i == NL_MAXOPEN || catsopen[i] == NULL)
1101 if (catd->_fd == (FILE *) NULL)
1102 /*---- return if this is an extra open or
1103 a bad catalog discriptor ----*/
1105 if (cat_already_open(catd->_name)) {
1106 if (catd->_count == 1) {
1107 cat_hard_close(catd);
1108 return (0); /*--- the last legal clsoe ---*/
1109 } else if (catd->_count > 1) {
1110 catd->_count = catd->_count - 1;
1111 return (0); /*--- a legal close ---*/
1113 return (-1); /*--- an extra illegal close ---*/
1120 cat_hard_close(catd)
1122 /*---- the catd to be closed ----*/
1125 int i; /*---- Misc counter(s) used for loops ----*/
1126 int j; /*---- Misc counter ----*/
1128 if (catd == CATD_ERR)
1131 /*______________________________________________________________________
1132 remove any entry for the catalog in the catsopen array
1133 ______________________________________________________________________*/
1135 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1136 if (catd == catsopen[i]) {
1137 for (; i < NL_MAXOPEN - 1; i++) {
1138 catsopen[i] = catsopen[i + 1];
1139 catpid[i] = catpid[i + 1];
1146 /*______________________________________________________________________
1147 close the cat and free up the memory
1148 ______________________________________________________________________*/
1149 if (catd->_mem == FALSE) {
1150 for (i = 0; i <= catd->_n_sets; i++) {
1151 if (catd->_set[i]._mp)
1152 free(catd->_set[i]._mp);
1153 /*---- free the _message pointer arrays ----*/
1155 if (catd->_set[i]._msgtxt) {
1156 for (j = 0; j <= catd->_set[i]._n_msgs; j++) {
1157 if (catd->_set[i]._msgtxt[j]) {
1158 /* free(catd->_set[i]._msgtxt[j]);*/
1161 if (catd->_set[i]._msgtxt)
1162 free(catd->_set[i]._msgtxt);
1168 fclose(catd->_fd); /*---- close the ctatlog ----*/
1170 free(catd->_set); /*---- free the sets ----*/
1172 free(catd->_name); /*---- free the name ----*/
1174 free(catd->_hd); /*---- free the header ----*/
1176 free(catd); /*---- free the catd ----*/
1180 _do1_read_msg(nl_catd catd, int setno, int msgno)
1182 /*---- catd: the catd of the catalog to be read from ----*/
1183 /*---- setno: the set number of the message ----*/
1184 /*---- msgno: the msgno of the message ----*/
1186 nl_catd catd1; /*--- catd for different process ----*/
1189 #ifndef AFS_OSF20_ENV
1190 if (getpid() == catd->_pid)
1194 return (_read1_msg(catd, setno, msgno));
1197 * Since our pid is different from the one in
1198 * catd, catd must have come from a catopen()
1199 * in our parent. We need a catd of our own.
1200 * The first time through here, the call to
1201 * catopen() creates a new catd and we try to
1202 * open its message catalog. After that, the
1203 * catopen() just retrieves the catd.
1205 if (((catd1 = catopen1(catd->_name, 0)) != CATD_ERR)
1206 && ((catd1->_fd == NL_FILE_CLOSED && _do1_open(catd1) != CATD_ERR)
1207 || (catd1->_fd != NL_FILE_UNUSED)))
1208 return (_read1_msg(catd1, setno, msgno));
1215 struct _catset *_cat1_get_catset();
1216 static struct _msgptr *_cat1_get_msgptr();
1218 _read1_msg(nl_catd catd, int setno, int msgno)
1220 struct _catset *set; /*--- ptr to set's _catset structure ---*/
1221 struct _msgptr *msg; /*--- ptr to msg's _msgptr structure ---*/
1222 char **msgtxt; /*--- temporary pointer to the message text
1225 set = _cat1_get_catset(catd, setno);
1227 msg = _cat1_get_msgptr(set, msgno);
1229 msgtxt = &set->_msgtxt[msg - set->_mp];
1230 if (1 /*!*msgtxt */ ) {
1231 *msgtxt = (char *)malloc(msg->_msglen + 1);
1235 fseek(catd->_fd, (long)msg->_offset, 0);
1237 ((void *)*msgtxt, (size_t) (msg->_msglen + 1), (size_t) 1,
1249 * NAME: compare_sets
1251 * FUNCTION: Compare function used by bsearch() in _cat_get_catset().
1254 * key - pointer to set number we're searching for
1255 * element - pointer to current _catset structure
1257 * RETURNS: Returns -1, 0, or 1, depending on whether the set number
1258 * is less than, equal to, or greater than the set number of
1259 * the _catset structure.
1264 compare_sets(const void *key, const void *element)
1266 int *setno = (int *)key;
1267 struct _catset *set = (struct _catset *)element;
1269 if (*setno < set->_setno)
1271 if (*setno > set->_setno)
1279 * NAME: _cat_get_catset
1281 * FUNCTION: Find a set in the catd->_set array. Assumes that the
1282 * sets in the array are sorted by increasing set number.
1285 * catd - catalog descripter obtained from catopen()
1286 * setno - message catalogue set number
1288 * RETURNS: Returns a pointer to the set on success.
1289 * On any error, returns NULL.
1294 _cat1_get_catset(nl_catd catd, int setno)
1296 struct _catset *set;
1298 if ((catd == (nl_catd) NULL) || (catd == CATD_ERR))
1299 return (struct _catset *)NULL;
1301 if (catd->_sets_expanded) {
1302 if ((setno < 0) || (setno > catd->_n_sets))
1303 return (struct _catset *)NULL;
1305 set = &catd->_set[setno];
1308 * Catch empty elements in the array. They aren't
1312 if (set->_mp == (struct _msgptr *)NULL)
1313 return (struct _catset *)NULL;
1316 (struct _catset *)bsearch((void *)&setno, catd->_set,
1318 sizeof(struct _catset), compare_sets);
1321 * Since the sets are compacted, there aren't any
1322 * empty elements in the array to check for.
1331 * NAME: compare_msgs
1333 * FUNCTION: Compare function used by bsearch() in _cat_get_msgptr().
1336 * key - pointer to message number we're searching for
1337 * element - pointer to current _msgptr structure
1339 * RETURNS: Returns -1, 0, or 1, depending on whether the message
1340 * number is less than, equal to, or greater than the message
1341 * number of the _msgptr structure.
1346 compare_msgs(const void *key, const void *element)
1348 int *msgno = (int *)key;
1349 struct _msgptr *msg = (struct _msgptr *)element;
1351 if (*msgno < msg->_msgno)
1353 if (*msgno > msg->_msgno)
1360 * NAME: _cat1_get_msgptr
1362 * FUNCTION: Find a message in a set's set->_mp array. Assumes that
1363 * the messages in the array are sorted by increasing
1367 * set - ptr to _catset structure
1368 * msgno - message catalogue message number
1370 * RETURNS: Returns a pointer to the message on success.
1371 * On any error, returns NULL.
1374 static struct _msgptr *
1375 _cat1_get_msgptr(struct _catset *set, int msgno)
1377 struct _msgptr *msg;
1379 if (set == (struct _catset *)NULL)
1380 return (struct _msgptr *)NULL;
1382 if (set->_mp == (struct _msgptr *)NULL) /* empty set */
1383 return (struct _msgptr *)NULL;
1385 if (set->_msgs_expanded) {
1386 if ((msgno < 0) || (msgno > set->_n_msgs))
1387 return (struct _msgptr *)NULL;
1389 msg = &set->_mp[msgno];
1392 * Catch empty elements in the array. They aren't
1397 return (struct _msgptr *)NULL;
1400 (struct _msgptr *)bsearch((void *)&msgno, set->_mp,
1402 sizeof(struct _msgptr), compare_msgs);
1405 * Since the messages are compacted, there aren't any
1406 * empty elements in the array to check for.
1414 catgets1(nl_catd catd, int setno, int msgno, char *def)
1415 /*---- catd: the catd to get the message from ----*/
1416 /*---- setno: the set number of the message ----*/
1417 /*---- msgno: the message number of the message ----*/
1418 /*---- def: the default string to be returned ----*/
1421 char *_do_read_msg();
1425 if (catd == NULL || catd == CATD_ERR || catd->_magic != CAT_MAGIC
1426 || catd->_fd == NL_FILE_UNUSED) {
1429 if (catd->_fd == NL_FILE_CLOSED) {
1430 catd = _do1_open(catd);
1431 if (catd == CATD_ERR)
1435 if (catd->_mem) { /*---- for mapped files ----*/
1436 if (setno <= catd->_hd->_setmax) {
1437 if (msgno < catd->_set[setno]._n_msgs) {
1438 if (catd->_set[setno]._mp[msgno]._offset) {
1439 return (catd->_mem +
1440 catd->_set[setno]._mp[msgno]._offset);
1445 } else { /*---- for unmapped files ----*/
1446 m = _do1_read_msg(catd, setno, msgno);
1456 #define FACILITY_CODE_MASK 0xF0000000
1457 #define FACILITY_CODE_SHIFT 28
1459 #define COMPONENT_CODE_MASK 0x0FFFF000
1460 #define COMPONENT_CODE_SHIFT 12
1462 #define STATUS_CODE_MASK 0x00000FFF
1463 #define STATUS_CODE_SHIFT 0
1465 #define NO_MESSAGE "THIS IS NOT A MESSAGE"
1468 * The system-dependant location for the catalog files is defined in sysconf.h
1469 * RPC_DEFAULT_NLSPATH should be defined in sysconf.h. Otherwise we use
1470 * /usr/afs/etc/C/%s.cat
1473 #ifndef RPC_NLS_FORMAT
1474 #define RPC_NLS_FORMAT "%s.cat"
1477 dce1_error_inq_text(status_to_convert, error_text, status)
1478 afs_uint32 status_to_convert;
1479 unsigned char *error_text;
1483 unsigned short facility_code;
1484 unsigned short component_code;
1485 unsigned short status_code;
1486 unsigned short i, failed = 0;
1488 char component_name[4];
1489 char *facility_name;
1490 char filename_prefix[7];
1491 char nls_filename[11];
1492 char alt_filename[80];
1495 static char *facility_names[] = {
1501 * set up output status for future error returns
1503 if (status != NULL) {
1507 * check for ok input status
1509 if (status_to_convert == 0) {
1510 if (status != NULL) {
1513 strcpy((char *)error_text, "successful completion");
1518 * extract the component, facility and status codes
1521 (status_to_convert & FACILITY_CODE_MASK) >> FACILITY_CODE_SHIFT;
1523 (status_to_convert & COMPONENT_CODE_MASK) >> COMPONENT_CODE_SHIFT;
1524 status_code = (status_to_convert & STATUS_CODE_MASK) >> STATUS_CODE_SHIFT;
1527 * see if this is a recognized facility
1529 if (facility_code == 0
1530 || facility_code > sizeof(facility_names) / sizeof(char *)) {
1531 sprintf((char *)error_text, "status %08x (unknown facility)",
1535 facility_name = facility_names[facility_code - 1];
1537 * Convert component name from RAD-50 component code. (Mapping is:
1538 * 0 => 'a', ..., 25 => 'z', 26 => '{', 27 => '0', ..., 36 => '9'.)
1540 component_name[3] = 0;
1541 component_name[2] = component_code % 40;
1542 component_code /= 40;
1543 component_name[1] = component_code % 40;
1544 component_name[0] = component_code / 40;
1545 for (i = 0; i < 3; i++) {
1546 component_name[i] += (component_name[i] <= 26) ? 'a' : ('0' - 27);
1548 sprintf(filename_prefix, "%3s%3s", facility_name, component_name);
1549 sprintf(nls_filename, RPC_NLS_FORMAT, filename_prefix);
1552 * Open the message file
1554 #if defined(AFS_OSF_ENV)
1555 #if defined(AFS_OSF20_ENV)
1556 catd = (nl_catd) catopen(nls_filename, 0);
1558 catd = (nl_catd) catopen1(nls_filename, 0);
1561 J = (int)catopen(nls_filename, 0);
1564 if (catd == (nl_catd) - 1) {
1566 * If we did not succeed in opening message file using NLSPATH,
1567 * try to open the message file in a well-known default area
1570 #ifndef RPC_DEFAULT_NLSPATH
1571 sprintf(alt_filename, "%s/C/%s.cat", AFSDIR_CLIENT_ETC_DIRPATH,
1574 sprintf(alt_filename, RPC_DEFAULT_NLSPATH, filename_prefix);
1577 #if defined(AFS_OSF_ENV)
1578 #if defined(AFS_OSF20_ENV)
1579 catd = (nl_catd) catopen(alt_filename, 0);
1581 catd = (nl_catd) catopen1(alt_filename, 0);
1584 J = (int)catopen(alt_filename, 0);
1587 if (catd == (nl_catd) - 1) {
1588 sprintf((char *)error_text, "status %08x (%s / %s)",
1589 status_to_convert, facility_name, component_name);
1594 * try to get the specified message from the file
1596 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1597 message = (char *)catgets1(catd, 1, status_code, NO_MESSAGE);
1599 message = (char *)catgets(catd, 1, status_code, NO_MESSAGE);
1602 * if everything went well, return the resulting message
1604 if (strcmp(message, NO_MESSAGE) != 0) {
1605 sprintf((char *)error_text, "%s (%s / %s)", message, facility_name,
1607 if (status != NULL) {
1613 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1620 sprintf((char *)error_text, "status %08x (%s / %s)",
1621 status_to_convert, facility_name, component_name);
1623 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1632 icl_DumpKernel(outFilep, setname)
1636 afs_int32 bufferSize = 0;
1639 afs_int32 code, retVal = 0;
1644 afs_int32 dummy, dummy2;
1645 struct logInfo *lip;
1647 /* first, enumerate the logs we're interested in */
1650 /* dump logs for a particular set */
1651 for (i = 0; i < ICL_LOGSPERSET; i++) {
1653 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname,
1654 i, (long)tname, sizeof(tname));
1656 if (errno == EBADF) {
1658 continue; /* missing slot, nothing to worry about */
1663 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1664 (long)&dummy, (long)&dummy2, 0);
1668 if (dummy > bufferSize) /* find biggest log */
1670 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1671 memset((char *)lip, 0, sizeof(*lip));
1672 lip->nextp = allInfo;
1674 lip->name = (char *)malloc(strlen(tname) + 1);
1675 strcpy(lip->name, tname);
1680 for (i = 0; i < 1000; i++) {
1682 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1683 sizeof(tname), (long)&dummy);
1686 if (dummy > bufferSize) /* find biggest log */
1688 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1689 memset((char *)lip, 0, sizeof(*lip));
1690 lip->nextp = allInfo;
1692 lip->name = (char *)malloc(strlen(tname) + 1);
1693 strcpy(lip->name, tname);
1697 if (bufferSize == 0)
1699 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
1703 fprintf(outFilep, "Found %d logs.\n", i);
1705 /* now print out the contents of each log */
1706 for (lip = allInfo; lip; lip = lip->nextp) {
1707 fprintf(outFilep, "\nContents of log %s:\n", lip->name);
1708 /* read out everything first; gets a more consistent
1711 nwords = 0; /* total words copied out */
1713 /* display all the entries in the log */
1714 if (bufferSize - nwords <= 0)
1715 break; /* filled whole buffer */
1717 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUT, (long)lip->name,
1718 (long)(bufferp + nwords), bufferSize - nwords,
1721 /* otherwise we've got an error */
1722 fprintf(outFilep, "Returned error %d dumping log.\n", errno);
1725 /* otherwise, we have flags in the high order byte, and
1726 * a length (in words) in the remainder.
1728 if ((code >> 24) & ICL_COPYOUTF_MISSEDSOME)
1729 fprintf(outFilep, "Log wrapped; data missing.\n");
1737 } /* for loop over all cookies */
1739 /* otherwise we should display all of the log entries here.
1740 * Note that a record may end in the middle, in which case
1741 * we should start over with the cookie value of the start
1744 for (ix = 0; ix < nwords;) {
1745 /* start of a record */
1746 rlength = (bufferp[ix] >> 24) & 0xff;
1748 fprintf(outFilep, "Internal error: 0 length record\n");
1752 /* ensure that entire record fits */
1753 if (ix + rlength > nwords) {
1754 /* doesn't fit, adjust cookie and break */
1757 /* print the record */
1758 DisplayRecord(outFilep, &bufferp[ix], rlength);
1761 /* obsolete: read entire buffer first */
1762 i += rlength; /* update cookie value, too */
1764 } /* for loop displaying buffer */
1765 } /* for loop over all logs */
1772 /* clear out log 'name' */
1778 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRLOG, (long)name, 0, 0, 0);
1782 /* clear out set 'name' */
1788 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRSET, (long)name, 0, 0, 0);
1792 /* clear out all logs */
1797 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRALL, 0, 0, 0, 0);
1801 /* list out all available sets to outFileP */
1803 icl_ListSets(outFileP)
1811 for (i = 0; i < 1000; i++) {
1813 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMSETS, i, (long)tname,
1814 sizeof(tname), (long)&states);
1817 (void)fprintf(outFileP, "%s %s%s%s\n", tname,
1818 (states & ICL_SETF_ACTIVE) ? "active" : "inactive",
1819 (states & ICL_SETF_FREED) ? " (dormant)" : "",
1820 (states & ICL_SETF_PERSISTENT) ? " persistent" : "");
1826 /* list out all available logs to outFileP */
1828 icl_ListLogs(outFileP, int32flg)
1838 for (i = 0; i < 1000; i++) {
1840 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1841 sizeof(tname), (long)&logSize);
1845 /* get more information on the log */
1847 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1848 (long)&logSize, (long)&allocated, 0);
1851 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1853 allocated ? "allocated" : "unallocated");
1855 (void)fprintf(outFileP, "%s\n", tname);
1861 /* list out all available logs to outFileP */
1863 icl_ListLogsBySet(outFileP, setname, int32flg)
1874 for (i = 0; i < ICL_LOGSPERSET; i++) {
1876 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname, i,
1877 (long)tname, sizeof(tname));
1879 if (errno == EBADF) {
1881 continue; /* missing */
1886 /* get more information on the log */
1888 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1889 (long)&logSize, (long)&allocated, 0);
1892 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1894 allocated ? "allocated" : "unallocated");
1896 (void)fprintf(outFileP, "%s\n", tname);
1902 /* activate/deactivate/free specified set */
1904 icl_ChangeSetState(name, op)
1910 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTAT, (long)name, op, 0, 0);
1914 /* activate/deactivate/free all sets */
1916 icl_ChangeAllSetState(op)
1921 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTATALL, op, 0, 0, 0);
1925 /* set size if log */
1927 icl_ChangeLogSize(name, logSize)
1934 afs_syscall(AFSCALL_ICL, ICL_OP_SETLOGSIZE, (long)name, logSize, 0,
1939 /* get logsize of specified log */
1941 icl_GetLogsize(logname, logSizeP, allocatedP)
1943 afs_int32 *logSizeP;
1948 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
1949 (long)logSizeP, (long)allocatedP, 0);
1953 /* get state of specified set */
1955 icl_GetSetState(setname, stateP)
1961 afs_syscall(AFSCALL_ICL, ICL_OP_GETSETINFO, (long)setname,
1962 (long)stateP, 0, 0);
1966 icl_TailKernel(outFilep, logname, waitTime)
1971 afs_int32 bufferSize = 0;
1972 afs_int32 newBufferSize;
1975 afs_int32 code, retVal = 0;
1980 struct logInfo *lip;
1982 /* get information about the specified log */
1984 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
1985 (long)&bufferSize, (long)&allocated, 0);
1987 if (errno == ENOENT)
1988 (void)fprintf(stderr, "'%s' not found\n", logname);
1990 (void)fprintf(stderr,
1991 "cannot get information on log '%s' (errno = %d)\n",
1997 (void)fprintf(stderr, "'%s' not allocated\n", logname);
2001 if (bufferSize == 0)
2003 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2005 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2010 /* start "infinite" loop */
2012 /* read out all that's currently there */
2013 nwords = 0; /* total words copied out */
2014 i = 0; /* initialize cookie */
2016 /* display all the entries in the log */
2017 if (bufferSize - nwords <= 0)
2018 break; /* filled whole buffer, clear when done */
2020 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUTCLR, (long)logname,
2021 (long)(bufferp + nwords), bufferSize - nwords,
2024 /* otherwise we've got an error */
2025 fprintf(stderr, "returned error %d dumping log.\n", errno);
2029 /* otherwise, we have flags in the high order byte, and
2030 * a length (in words) in the remainder.
2039 } /* for loop over all cookies */
2041 /* otherwise we should display all of the log entries here.
2042 * Note that a record may end in the middle, in which case
2043 * we should start over with the cookie value of the start
2046 for (ix = 0; ix < nwords;) {
2047 /* start of a record */
2048 rlength = (bufferp[ix] >> 24) & 0xff;
2049 /* ensure that entire record fits */
2050 if (ix + rlength > nwords) {
2051 /* doesn't fit, adjust cookie and break */
2053 fprintf(stderr, "BOGUS: 0 length record\n");
2059 /* print the record */
2060 DisplayRecord(outFilep, &bufferp[ix], rlength);
2062 } /* for loop displaying buffer */
2067 /* see if things have changed */
2069 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
2070 (long)&newBufferSize, (long)&allocated, 0);
2072 if (errno == ENOENT)
2073 (void)fprintf(stderr, "'%s' not found\n", logname);
2075 (void)fprintf(stderr,
2076 "cannot get information on log '%s' (errno = %d)\n",
2083 (void)fprintf(stderr, "'%s' no int32er allocated\n", logname);
2088 if (bufferSize == 0) {
2089 (void)fprintf(stderr, "buffer size has become 0\n");
2093 if (bufferSize != newBufferSize) {
2094 /* have to reallocate a buffer */
2095 bufferSize = newBufferSize;
2097 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2099 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2105 } /* infinite loop */
2112 #if !defined(AFS_SGI_ENV)
2113 afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6)
2114 long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6;
2117 #ifdef AFS_LINUX20_ENV
2118 #if defined AFS_LINUX_64BIT_KERNEL
2120 /* don't want to sign extend it to 64bit, so using ulong */
2121 eparm[0] = (unsigned long)parm3;
2122 eparm[1] = (unsigned long)parm4;
2123 eparm[2] = (unsigned long)parm5;
2124 eparm[3] = (unsigned long)parm6;
2132 /* Linux can only handle 5 arguments in the actual syscall. */
2133 if (call == AFSCALL_ICL) {
2134 rval = proc_afs_syscall(call, parm0, parm1, parm2, eparm, &code);
2136 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
2138 rval = proc_afs_syscall(call, parm0, parm1, parm2, parm3, &code);
2140 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
2142 #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
2143 /* on sparc this function returns none value, so do it myself */
2144 __asm__ __volatile__("mov %o0, %i0; ret; restore");
2147 #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
2148 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3, parm4);
2150 #if defined(AFS_SGI_ENV)
2151 code = syscall(AFS_ICL, call, parm0, parm1, parm2, parm3, parm4); /* XXX */
2153 code = syscall(AFSCALL_ICL, parm0, parm1, parm2, parm3, parm4);
2156 #endif /* AFS_LINUX20_ENV */
2164 /* init function, called once, under icl_lock */
2170 /* setup signal handler, in user space */
2176 icl_CreateSet(name, baseLogp, fatalLogp, outSetpp)
2178 struct afs_icl_log *baseLogp;
2179 struct afs_icl_log *fatalLogp;
2180 struct afs_icl_set **outSetpp;
2182 return icl_CreateSetWithFlags(name, baseLogp, fatalLogp, /*flags */ 0,
2186 /* create a set, given pointers to base and fatal logs, if any.
2187 * Logs are unlocked, but referenced, and *outSetpp is returned
2188 * referenced. Function bumps reference count on logs, since it
2189 * addds references from the new icl_set. When the set is destroyed,
2190 * those references will be released.
2192 icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
2194 struct afs_icl_log *baseLogp;
2195 struct afs_icl_log *fatalLogp;
2197 struct afs_icl_set **outSetpp;
2199 register struct afs_icl_set *setp;
2201 afs_int32 states = ICL_DEFAULT_SET_STATES;
2206 for (setp = icl_allSets; setp; setp = setp->nextp) {
2207 if (strcmp(setp->name, name) == 0) {
2210 if (flags & ICL_CRSET_FLAG_PERSISTENT) {
2211 setp->states |= ICL_SETF_PERSISTENT;
2217 /* determine initial state */
2218 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2219 states = ICL_SETF_ACTIVE;
2220 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2221 states = ICL_SETF_FREED;
2222 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2223 states |= ICL_SETF_PERSISTENT;
2225 setp = (struct afs_icl_set *)osi_Alloc(sizeof(struct afs_icl_set));
2226 memset((caddr_t) setp, 0, sizeof(*setp));
2228 if (states & ICL_SETF_FREED)
2229 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2230 setp->states = states;
2232 setp->name = (char *)osi_Alloc(strlen(name) + 1);
2233 strcpy(setp->name, name);
2234 setp->nevents = ICL_DEFAULTEVENTS;
2235 setp->eventFlags = (char *)osi_Alloc(ICL_DEFAULTEVENTS);
2236 for (i = 0; i < ICL_DEFAULTEVENTS; i++)
2237 setp->eventFlags[i] = 0xff; /* default to enabled */
2239 /* update this global info under the icl_lock */
2240 setp->nextp = icl_allSets;
2243 /* set's basic lock is still held, so we can finish init */
2245 setp->logs[0] = baseLogp;
2246 icl_LogHold(baseLogp);
2247 if (!(setp->states & ICL_SETF_FREED))
2248 icl_LogUse(baseLogp); /* log is actually being used */
2251 setp->logs[1] = fatalLogp;
2252 icl_LogHold(fatalLogp);
2253 if (!(setp->states & ICL_SETF_FREED))
2254 icl_LogUse(fatalLogp); /* log is actually being used */
2261 /* function to change event enabling information for a particular set */
2262 icl_SetEnable(setp, eventID, setValue)
2263 struct afs_icl_set *setp;
2269 if (!ICL_EVENTOK(setp, eventID)) {
2272 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2274 *tp |= ICL_EVENTMASK(eventID);
2276 *tp &= ~(ICL_EVENTMASK(eventID));
2280 /* return indication of whether a particular event ID is enabled
2281 * for tracing. If *getValuep is set to 0, the event is disabled,
2282 * otherwise it is enabled. All events start out enabled by default.
2284 icl_GetEnable(setp, eventID, getValuep)
2285 struct afs_icl_set *setp;
2289 if (!ICL_EVENTOK(setp, eventID)) {
2292 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2299 /* hold and release event sets */
2301 register struct afs_icl_set *setp;
2307 /* free a set. Called with icl_lock locked */
2309 register struct afs_icl_set *setp;
2311 register struct afs_icl_set **lpp, *tp;
2313 register struct afs_icl_log *tlp;
2315 for (lpp = &icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2317 /* found the dude we want to remove */
2319 osi_Free(setp->name, 1 + strlen(setp->name));
2320 osi_Free(setp->eventFlags, ICL_EVENTBYTES(setp->nevents));
2321 for (i = 0; i < ICL_LOGSPERSET; i++) {
2322 if (tlp = setp->logs[i])
2325 osi_Free(setp, sizeof(struct afs_icl_set));
2326 break; /* won't find it twice */
2332 /* do the release, watching for deleted entries */
2334 register struct afs_icl_set *setp;
2336 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2337 icl_ZapSet(setp); /* destroys setp's lock! */
2342 /* free a set entry, dropping its reference count */
2344 register struct afs_icl_set *setp;
2346 setp->states |= ICL_SETF_DELETED;
2351 /* find a set by name, returning it held */
2352 struct afs_icl_set *
2356 register struct afs_icl_set *tp;
2358 for (tp = icl_allSets; tp; tp = tp->nextp) {
2359 if (strcmp(tp->name, name) == 0) {
2360 /* this is the dude we want */
2368 /* zero out all the logs in the set */
2370 struct afs_icl_set *setp;
2375 struct afs_icl_log *logp;
2377 for (i = 0; i < ICL_LOGSPERSET; i++) {
2378 logp = setp->logs[i];
2381 tcode = icl_ZeroLog(logp);
2383 code = tcode; /* save the last bad one */
2390 icl_EnumerateSets(aproc, arock)
2394 register struct afs_icl_set *tp, *np;
2395 register afs_int32 code;
2398 for (tp = icl_allSets; tp; tp = np) {
2399 tp->refCount++; /* hold this guy */
2400 code = (*aproc) (tp->name, arock, tp);
2401 np = tp->nextp; /* tp may disappear next, but not np */
2402 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
2410 icl_AddLogToSet(setp, newlogp)
2411 struct afs_icl_set *setp;
2412 struct afs_icl_log *newlogp;
2416 struct afs_icl_log *logp;
2418 for (i = 0; i < ICL_LOGSPERSET; i++) {
2419 if (!setp->logs[i]) {
2420 setp->logs[i] = newlogp;
2422 icl_LogHold(newlogp);
2423 if (!(setp->states & ICL_SETF_FREED)) {
2424 /* bump up the number of sets using the log */
2425 icl_LogUse(newlogp);
2433 icl_SetSetStat(setp, op)
2434 struct afs_icl_set *setp;
2439 struct afs_icl_log *logp;
2442 case ICL_OP_SS_ACTIVATE: /* activate a log */
2444 * If we are not already active, see if we have released
2445 * our demand that the log be allocated (FREED set). If
2446 * we have, reassert our desire.
2448 if (!(setp->states & ICL_SETF_ACTIVE)) {
2449 if (setp->states & ICL_SETF_FREED) {
2450 /* have to reassert desire for logs */
2451 for (i = 0; i < ICL_LOGSPERSET; i++) {
2452 logp = setp->logs[i];
2459 setp->states &= ~ICL_SETF_FREED;
2461 setp->states |= ICL_SETF_ACTIVE;
2466 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
2467 /* this doesn't require anything beyond clearing the ACTIVE flag */
2468 setp->states &= ~ICL_SETF_ACTIVE;
2472 case ICL_OP_SS_FREE: /* deassert design for log */
2474 * if we are already in this state, do nothing; otherwise
2475 * deassert desire for log
2477 if (setp->states & ICL_SETF_ACTIVE)
2480 if (!(setp->states & ICL_SETF_FREED)) {
2481 for (i = 0; i < ICL_LOGSPERSET; i++) {
2482 logp = setp->logs[i];
2485 icl_LogFreeUse(logp);
2489 setp->states |= ICL_SETF_FREED;
2502 struct afs_icl_log *afs_icl_allLogs = 0;
2504 /* hold and release logs */
2506 register struct afs_icl_log *logp;
2512 /* hold and release logs, called with lock already held */
2514 register struct afs_icl_log *logp;
2520 /* keep track of how many sets believe the log itself is allocated */
2522 register struct afs_icl_log *logp;
2524 if (logp->setCount == 0) {
2525 /* this is the first set actually using the log -- allocate it */
2526 if (logp->logSize == 0) {
2527 /* we weren't passed in a hint and it wasn't set */
2528 logp->logSize = ICL_DEFAULT_LOGSIZE;
2531 (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logp->logSize);
2537 /* decrement the number of real users of the log, free if possible */
2538 icl_LogFreeUse(logp)
2539 register struct afs_icl_log *logp;
2541 if (--logp->setCount == 0) {
2542 /* no more users -- free it (but keep log structure around) */
2543 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2544 logp->firstUsed = logp->firstFree = 0;
2545 logp->logElements = 0;
2551 /* set the size of the log to 'logSize' */
2552 icl_LogSetSize(logp, logSize)
2553 register struct afs_icl_log *logp;
2557 /* nothing to worry about since it's not allocated */
2558 logp->logSize = logSize;
2561 logp->firstUsed = logp->firstFree = 0;
2562 logp->logElements = 0;
2564 /* free and allocate a new one */
2565 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2566 logp->datap = (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logSize);
2567 logp->logSize = logSize;
2573 /* free a log. Called with icl_lock locked. */
2575 register struct afs_icl_log *logp;
2577 register struct afs_icl_log **lpp, *tp;
2579 for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2581 /* found the dude we want to remove */
2583 osi_Free(logp->name, 1 + strlen(logp->name));
2584 osi_Free(logp->datap, logp->logSize * sizeof(afs_int32));
2585 osi_Free(logp, sizeof(struct icl_log));
2586 break; /* won't find it twice */
2592 /* do the release, watching for deleted entries */
2594 register struct afs_icl_log *logp;
2596 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2597 icl_ZapLog(logp); /* destroys logp's lock! */
2602 /* do the release, watching for deleted entries, log already held */
2604 register struct afs_icl_log *logp;
2606 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2607 icl_ZapLog(logp); /* destroys logp's lock! */
2612 /* zero out the log */
2614 icl_ZeroLog(register struct afs_icl_log *logp)
2616 logp->firstUsed = logp->firstFree = 0;
2617 logp->logElements = 0;
2621 /* free a log entry, and drop its reference count */
2623 register struct afs_icl_log *logp;
2625 logp->states |= ICL_LOGF_DELETED;
2632 icl_EnumerateLogs(int (*aproc)
2633 (char *name, char *arock, struct afs_icl_log * tp),
2636 register struct afs_icl_log *tp;
2637 register afs_int32 code;
2640 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2641 tp->refCount++; /* hold this guy */
2642 code = (*aproc) (tp->name, arock, tp);
2643 if (--tp->refCount == 0)
2652 afs_icl_bulkSetinfo_t *
2655 unsigned int infoSize;
2658 sizeof(afs_icl_bulkSetinfo_t) + (ICL_RPC_MAX_SETS -
2659 1) * sizeof(afs_icl_setinfo_t);
2661 setInfo = (afs_icl_bulkSetinfo_t *) malloc(infoSize);
2663 (void)fprintf(stderr,
2664 "Could not allocate the memory for bulk set info structure\n");
2668 memset((char *)setInfo, 0, infoSize);
2673 afs_icl_bulkLoginfo_t *
2676 unsigned int infoSize;
2679 sizeof(afs_icl_bulkLoginfo_t) + (ICL_RPC_MAX_LOGS -
2680 1) * sizeof(afs_icl_loginfo_t);
2682 logInfo = (afs_icl_bulkLoginfo_t *) malloc(infoSize);
2684 (void)fprintf(stderr,
2685 "Could not allocate the memory for bulk log info structure\n");
2690 memset((char *)logInfo, 0, infoSize);
2697 register struct cmd_syndesc *as;
2702 afs_int32 waitTime = 10 /* seconds */ ;
2706 FILE *outfp = stdout;
2708 struct cmd_item *itemp;
2710 if (geteuid() != 0) {
2711 printf("fstrace must be run as root\n");
2715 if (as->parms[3].items) {
2716 if (!as->parms[1].items) {
2717 (void)fprintf(stderr, "-sleep can only be used with -follow\n");
2720 waitTime = strtol(as->parms[3].items->data, NULL, 0);
2723 if (as->parms[2].items) {
2724 /* try to open the specified output file */
2725 if ((outfp = fopen(as->parms[2].items->data, "w")) == NULL) {
2726 (void)fprintf(stderr, "Cannot open file '%s' for writing\n",
2727 as->parms[2].items->data);
2731 #ifdef AFS_SGI64_ENV
2732 startTime = time((time_t *) 0);
2734 startTime = time(0);
2736 (void)fprintf(outfp, "AFS Trace Dump -\n\n Date: %s\n",
2739 if (as->parms[0].items) {
2740 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2741 tcode = icl_DumpKernel(outfp, itemp->data);
2743 (void)fprintf(stderr, "Unable to dump set %s (errno = %d)\n",
2744 itemp->data, errno);
2748 } else if (as->parms[1].items) {
2749 logname = as->parms[1].items->data;
2750 code = icl_TailKernel(outfp, logname, waitTime);
2752 (void)fprintf(stderr,
2753 "Error tailing kernel log '%s' (errno = %d)\n",
2757 code = icl_DumpKernel(outfp, NULL);
2759 (void)fprintf(outfp, "\nAFS Trace Dump - %s\n",
2760 code ? "FAILED" : "Completed");
2762 if (outfp != stdout)
2763 (void)fclose(outfp);
2771 struct cmd_syndesc *dumpSyntax;
2774 cmd_CreateSyntax("dump", DoDump, (char *)NULL, "dump AFS trace logs");
2775 (void)cmd_AddParm(dumpSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2776 (void)cmd_AddParm(dumpSyntax, "-follow", CMD_SINGLE, CMD_OPTIONAL,
2778 (void)cmd_AddParm(dumpSyntax, "-file", CMD_SINGLE, CMD_OPTIONAL,
2780 (void)cmd_AddParm(dumpSyntax, "-sleep", CMD_SINGLE, CMD_OPTIONAL,
2781 "seconds_between_reads");
2785 DoShowLog(as, arock)
2786 register struct cmd_syndesc *as;
2789 afs_int32 retVal = 0;
2794 struct cmd_item *itemp;
2796 if (geteuid() != 0) {
2797 printf("fstrace must be run as root\n");
2800 if (as->parms[2].items)
2803 if (as->parms[0].items) {
2804 /* enumerate logs for the specified sets */
2805 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2806 (void)fprintf(stdout, "Logs for set '%s':\n", itemp->data);
2807 code = icl_ListLogsBySet(stdout, itemp->data, int32flg);
2809 (void)fprintf(stderr,
2810 "Error in enumerating set %s (errno = %d)\n",
2811 itemp->data, errno);
2815 } else if (as->parms[1].items) {
2816 /* print out log information */
2817 for (itemp = as->parms[1].items; itemp; itemp = itemp->next) {
2818 code = icl_GetLogsize(itemp->data, &logSize, &allocated);
2820 (void)fprintf(stdout, "%s : %d kbytes (%s)\n", itemp->data,
2822 allocated ? "allocated" : "unallocated");
2824 (void)fprintf(stderr,
2825 "Could not find log '%s' (errno = %d)\n",
2826 itemp->data, errno);
2832 (void)fprintf(stdout, "Available logs:\n");
2833 code = icl_ListLogs(stdout, int32flg);
2835 (void)fprintf(stderr, "Error in listing logs (errno = %d)\n",
2847 struct cmd_syndesc *showSyntax;
2850 cmd_CreateSyntax("lslog", DoShowLog, (char *)NULL,
2851 "list available logs");
2852 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2853 (void)cmd_AddParm(showSyntax, "-log", CMD_LIST, CMD_OPTIONAL, "log_name");
2854 (void)cmd_AddParm(showSyntax, "-long", CMD_FLAG, CMD_OPTIONAL, "");
2858 DoShowSet(as, arock)
2859 register struct cmd_syndesc *as;
2862 afs_int32 retVal = 0;
2865 struct cmd_item *itemp;
2867 if (geteuid() != 0) {
2868 printf("fstrace must be run as root\n");
2871 if (as->parms[0].items) {
2872 /* print information on the specified sets */
2873 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2874 code = icl_GetSetState(itemp->data, &state);
2876 (void)fprintf(stderr,
2877 "Error getting status on set %s (errno = %d)\n",
2878 itemp->data, errno);
2881 (void)fprintf(stdout, "Set %s: %s%s%s\n", itemp->data,
2882 (state & ICL_SETF_ACTIVE) ? "active" :
2884 (state & ICL_SETF_FREED) ? " (dormant)" : "",
2885 (state & ICL_SETF_PERSISTENT) ? " persistent" :
2890 (void)fprintf(stdout, "Available sets:\n");
2891 code = icl_ListSets(stdout);
2893 (void)fprintf(stderr, "Error in listing sets (errno = %d)\n",
2905 struct cmd_syndesc *showSyntax;
2908 cmd_CreateSyntax("lsset", DoShowSet, (char *)NULL,
2909 "list available event sets");
2910 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2915 register struct cmd_syndesc *as;
2918 afs_int32 retVal = 0;
2920 struct cmd_item *itemp;
2922 if (geteuid() != 0) {
2923 printf("fstrace must be run as root\n");
2926 if (as->parms[0].items) {
2927 /* clear logs for the specified sets */
2928 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2929 code = icl_ClearSet(itemp->data);
2931 (void)fprintf(stderr,
2932 "Error in clearing set %s (errno = %d)\n",
2933 itemp->data, errno);
2937 } else if (as->parms[1].items) {
2938 /* clear specified log */
2939 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2940 code = icl_ClearLog(itemp->data);
2942 (void)fprintf(stderr,
2943 "Error in clearing log %s (errno = %d)\n",
2944 itemp->data, errno);
2949 /* clear all logs */
2950 code = icl_ClearAll();
2952 (void)fprintf(stderr, "Error in clearing logs (errno = %d)\n",
2964 struct cmd_syndesc *clearSyntax;
2967 cmd_CreateSyntax("clear", DoClear, (char *)NULL,
2968 "clear logs by logname or by event set");
2969 (void)cmd_AddParm(clearSyntax, "-set", CMD_LIST, CMD_OPTIONAL,
2971 (void)cmd_AddParm(clearSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
2977 register struct cmd_syndesc *as;
2980 afs_int32 retVal = 0;
2985 struct cmd_item *itemp;
2987 if (geteuid() != 0) {
2988 printf("fstrace must be run as root\n");
2991 if (as->parms[1].items) {
2992 op = ICL_OP_SS_ACTIVATE;
2993 operation = "active";
2994 } else if (as->parms[2].items) {
2995 op = ICL_OP_SS_DEACTIVATE;
2996 operation = "inactive";
2997 } else if (as->parms[3].items) {
2998 op = ICL_OP_SS_DEACTIVATE;
2999 operation = "inactive";
3002 /* assume active" */
3003 op = ICL_OP_SS_ACTIVATE;
3004 operation = "active";
3007 if (as->parms[0].items) {
3008 /* activate specified sets */
3009 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
3010 code = icl_ChangeSetState(itemp->data, op);
3012 (void)fprintf(stderr,
3013 "cannot set state of %s to %s (errno = %d)\n",
3014 itemp->data, operation, errno);
3016 } else if (doFree) {
3017 /* try to make it dormant as well */
3018 code = icl_ChangeSetState(itemp->data, ICL_OP_SS_FREE);
3020 (void)fprintf(stderr,
3021 "cannot set state of %s to dormant (errno = %d)\n",
3022 itemp->data, errno);
3029 code = icl_ChangeAllSetState(op);
3031 (void)fprintf(stderr,
3032 "cannot set the state of all sets to %s (errno = %d)\n",
3035 } else if (doFree) {
3036 /* try to make it dormant as well */
3037 code = icl_ChangeAllSetState(ICL_OP_SS_FREE);
3039 (void)fprintf(stderr,
3040 "cannot set the state of all sets to dormant (errno = %d)\n",
3053 struct cmd_syndesc *setSyntax;
3056 cmd_CreateSyntax("setset", DoSet, (char *)NULL,
3057 "set state of event sets");
3058 (void)cmd_AddParm(setSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
3059 (void)cmd_AddParm(setSyntax, "-active", CMD_FLAG, CMD_OPTIONAL, "");
3060 (void)cmd_AddParm(setSyntax, "-inactive", CMD_FLAG, CMD_OPTIONAL, "");
3061 (void)cmd_AddParm(setSyntax, "-dormant", CMD_FLAG, CMD_OPTIONAL, "");
3066 register struct cmd_syndesc *as;
3069 afs_int32 retVal = 0;
3071 afs_int32 bufferSize;
3072 struct cmd_item *itemp;
3074 if (geteuid() != 0) {
3075 printf("fstrace must be run as root\n");
3078 /* get buffer size */
3079 bufferSize = atoi(as->parms[1].items->data);
3080 bufferSize *= BUFFER_MULTIPLIER;
3081 if (bufferSize == 0)
3082 bufferSize = ICL_DEFAULT_LOGSIZE;
3084 /* set the size of the specified logs */
3085 if (itemp = as->parms[0].items) {
3086 for (; itemp; itemp = itemp->next) {
3087 code = icl_ChangeLogSize(itemp->data, bufferSize);
3089 (void)fprintf(stderr,
3090 "Error in changing log %s buffer size (errno = %d)\n",
3091 itemp->data, errno);
3096 /* Use the only current support log, "cmfx" */
3097 code = icl_ChangeLogSize("cmfx", bufferSize);
3099 (void)fprintf(stderr,
3100 "Error in changing log cmfx buffer size (errno = %d)\n",
3112 struct cmd_syndesc *setsizeSyntax;
3115 cmd_CreateSyntax("setlog", DoResize, (char *)NULL,
3116 "set the size of a log");
3117 (void)cmd_AddParm(setsizeSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
3119 (void)cmd_AddParm(setsizeSyntax, "-buffersize", CMD_SINGLE, CMD_REQUIRED,
3120 "1-kilobyte_units");
3123 #include "AFS_component_version_number.c"
3129 setlocale(LC_ALL, "");
3130 #ifdef AFS_SGI62_ENV
3131 set_kernel_sizeof_long();
3134 /* set up user interface then dispatch */
3142 return (cmd_Dispatch(argc, argv));
3145 #include "AFS_component_version_number.c"
3149 printf("fstrace is NOT supported for this OS\n");