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*/
34 #include <afs/afs_args.h>
36 #include <afs/afsutil.h>
38 #if defined(AFS_OSF_ENV) || defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
39 /* For SGI 6.2, this is changed to 1 if it's a 32 bit kernel. */
40 int afs_icl_sizeofLong = 2;
42 int afs_icl_sizeofLong = 1;
45 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
46 int afs_64bit_kernel = 1; /* Default for 6.2+, and always for 6.1 */
47 extern int afs_icl_sizeofLong; /* Used in ICL_SIZEHACK() */
51 /* If _SC_KERN_POINTERS not in sysconf, then we can assume a 32 bit abi. */
53 set_kernel_sizeof_long(void)
58 retval = sysconf(_SC_KERN_POINTERS);
61 afs_icl_sizeofLong = 2;
64 afs_icl_sizeofLong = 1;
68 #endif /* AFS_SGI62_ENV */
69 #endif /* AFS_SGI61_ENV */
71 #define BUFFER_MULTIPLIER 1024
73 /* make it big enough to snapshot everything at once, since
74 * decoding takes so long.
76 #define IBSIZE 100000 /* default size */
79 struct logInfo *nextp;
83 char dumpFileName[256] = "";
84 RegisterIclDumpFileName(name)
87 (void)sprintf(dumpFileName, "icl.%.250s", name);
90 /* define globals to use for bulk info */
91 afs_icl_bulkSetinfo_t *setInfo = (afs_icl_bulkSetinfo_t *) 0;
92 afs_icl_bulkLoginfo_t *logInfo = (afs_icl_bulkLoginfo_t *) 0;
94 struct afs_icl_set *icl_allSets = 0;
98 /* given a type and an address, get the size of the thing
102 icl_GetSize(type, addr)
110 ICL_SIZEHACK(type, addr);
114 /* Check types in printf string "bufferp", making sure that each
115 * is compatible with the corresponding parameter type described
116 * by typesp. Also watch for prematurely running out of parameters
117 * before the string is gone.
119 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
121 CheckTypes(bufferp, typesp, typeCount, outMsgBuffer)
133 for (tc = *bufferp;; outMsgBuffer++, tc = *(++bufferp)) {
136 /* hit end of string. We win as long as we aren't
145 inPercent = 1 - inPercent;
149 if (tc >= '0' && tc <= '9') {
150 /* skip digits in % string */
155 /* 'l' is a type modifier. */
159 /* otherwise, we've finally gotten to the type-describing
160 * character. Make sure there's a type descriptor, and then
161 * check the type descriptor.
165 return 0; /* no more type descriptors left */
167 if (typesp[tix] != 1) /* not a string descriptor */
170 *outMsgBuffer = (char)1;
172 if (tc == 'u' || tc == 'x' || tc == 'd' || tc == 'o') {
173 if (typesp[tix] != 0)
174 return 0; /* not an integer descriptor */
178 *outMsgBuffer = (char)2;
181 *outMsgBuffer = (char)3;
184 *outMsgBuffer = (char)4;
188 *outMsgBuffer = (char)5;
192 /* otherwise we're fine, so eat this descriptor */
198 #else /* AFS_SGI61_ENV */
200 CheckTypes(bufferp, typesp, typeCount)
211 for (tc = *bufferp;; tc = *(++bufferp)) {
213 /* hit end of string. We win as long as we aren't
222 inPercent = 1 - inPercent;
226 if (tc >= '0' && tc <= '9')
227 continue; /* skip digits in % string */
228 /* otherwise, we've finally gotten to the type-describing
229 * character. Make sure there's a type descriptor, and then
230 * check the type descriptor.
234 return 0; /* no more type descriptors left */
235 if (tc == 's' && typesp[tix] != 1) /* not a string descriptor */
237 if ((tc == 'u' || tc == 'l' || tc == 'x' || tc == 'd')
238 && (typesp[tix] != 0))
239 return 0; /* not an integer descriptor */
240 /* otherwise we're fine, so eat this descriptor */
246 #endif /* AFS_SGI61_ENV */
248 /* display a single record.
249 * alp points at the first word in the array to be interpreted
250 * rsize gives the # of words in the array
252 #if defined(AFS_SGI61_ENV) && !defined(AFS_SGI62_ENV)
253 #define uint64_t long long
256 DisplayRecord(outFilep, alp, rsize)
258 register afs_int32 *alp;
261 char msgBuffer[1024];
262 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
263 char outMsgBuffer[1024];
265 uint64_t printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
266 char *printfStrings[ICL_MAXEXPANSION * /* max parms */ 4];
267 #else /* AFS_SGI61_ENV */
268 long printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
269 #endif /* AFS_SGI61_ENV */
270 int printfTypes[ICL_MAXEXPANSION * 4];
276 int pix; /* index in alp */
277 int pfpix; /* index in printfParms */
278 int pftix; /* index in printfTypes */
280 int printed; /* did we print the string yet? */
284 /* decode parameters */
285 temp = alp[0]; /* type encoded in low-order 24 bits, t0 high */
291 for (i = 0; i < 4 * ICL_MAXEXPANSION; i++)
293 /* decode each parameter, getting addrs for afs_hyper_t and strings */
294 for (i = 0; !done && i < 4; i++) {
295 type = (temp >> (18 - i * 6)) & 0x3f;
301 case ICL_TYPE_POINTER:
302 printfTypes[pftix++] = 0;
303 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
304 printfParms[pfpix] = alp[pix];
305 printfParms[pfpix] &= 0xffffffff;
306 if (afs_64bit_kernel) {
307 printfParms[pfpix] <<= 32;
308 printfParms[pfpix] |= alp[pix + 1];
310 #elif defined(AFS_OSF_ENV)
311 printfParms[pfpix] = alp[pix + 1];
312 printfParms[pfpix] |= (alp[pix] <<= 32);
313 #else /* !AFS_OSF_ENV && !AFS_SGI61_ENV */
314 printfParms[pfpix] = alp[pix];
319 printfTypes[pftix++] = 0;
320 printfParms[pfpix++] = alp[pix];
324 printfTypes[pftix++] = 0;
325 printfParms[pfpix++] = alp[pix];
326 printfTypes[pftix++] = 0;
327 printfParms[pfpix++] = alp[pix + 1];
330 printfTypes[pftix++] = 0;
331 printfParms[pfpix++] = alp[pix];
332 printfTypes[pftix++] = 0;
333 printfParms[pfpix++] = alp[pix + 1];
334 printfTypes[pftix++] = 0;
335 printfParms[pfpix++] = alp[pix + 2];
336 printfTypes[pftix++] = 0;
337 printfParms[pfpix++] = alp[pix + 3];
339 case ICL_TYPE_STRING:
340 printfTypes[pftix++] = 1;
342 printfStrings[pfpix++] = (char *)&alp[pix];
343 #else /* AFS_SGI64_ENV */
344 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
345 printfStrings[pfpix++] = (char *)&alp[pix];
346 #else /* AFS_SGI61_ENV */
347 printfParms[pfpix++] = (long)&alp[pix];
348 #endif /* AFS_SGI61_ENV */
349 #endif /* AFS_SGI64_ENV */
351 case ICL_TYPE_UNIXDATE:
353 printfParms[pfpix++] = (long)ctime(&tmv);
356 printf("DisplayRecord: Bad type %d in decode switch.\n", type);
363 pix += icl_GetSize(type, (char *)&alp[pix]);
366 /* next, try to decode the opcode into a printf string */
367 dce1_error_inq_text(alp[1], msgBuffer, &status);
369 /* if we got a string back, and it is compatible with the
370 * parms we've got, then print it.
374 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
375 if (CheckTypes(msgBuffer, printfTypes, pftix, outMsgBuffer)) {
376 /* we have a string to use, but it ends "(dfs / zcm)",
377 * so we remove the extra gunk.
379 j = strlen(outMsgBuffer);
381 outMsgBuffer[j - 11] = 0;
385 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
386 alp[3] % 1000000, alp[2]);
387 for (i = 0; i < j; i++) {
388 if ((int)outMsgBuffer[i] > 5)
389 fputc(outMsgBuffer[i], outFilep);
391 switch (outMsgBuffer[i]) {
395 fprintf(outFilep, "%s", printfStrings[pfpix++]);
397 case 2: /* signed integer */
398 fprintf(outFilep, "%lld", printfParms[pfpix++]);
400 case 3: /* unsigned integer */
401 fprintf(outFilep, "%llu", printfParms[pfpix++]);
403 case 4: /* octal integer */
404 fprintf(outFilep, "%llo", printfParms[pfpix++]);
406 case 5: /* hex integer */
407 fprintf(outFilep, "%llx", printfParms[pfpix++]);
411 "fstrace: Bad char %d in outMsgBuffer for parm %d\n",
412 outMsgBuffer[i], pfpix);
413 fprintf(outFilep, "fstrace: msgBuffer='%s'\n",
419 fprintf(outFilep, "\n");
422 #else /* AFS_SGI61_ENV */
423 if (CheckTypes(msgBuffer, printfTypes, pftix)) {
424 /* we have a string to use, but it ends "(dfs / zcm)",
425 * so we remove the extra gunk.
427 j = strlen(msgBuffer);
429 msgBuffer[j - 11] = 0;
430 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
431 alp[3] % 1000000, alp[2]);
432 fprintf(outFilep, msgBuffer, printfParms[0], printfParms[1],
433 printfParms[2], printfParms[3], printfParms[4],
434 printfParms[5], printfParms[6], printfParms[7],
435 printfParms[8], printfParms[9], printfParms[10],
436 printfParms[11], printfParms[12], printfParms[13],
437 printfParms[14], printfParms[15]);
438 fprintf(outFilep, "\n");
441 #endif /* AFS_SGI61_ENV */
443 fprintf(outFilep, "Type mismatch, using raw print.\n");
444 fprintf(outFilep, "%s", msgBuffer);
448 if (alp[1] == ICL_INFO_TIMESTAMP) {
450 fprintf(outFilep, "time %d.%06d, pid %u: %s\n", alp[3] / 1000000,
451 alp[3] % 1000000, alp[2], ctime(&tmv));
453 fprintf(outFilep, "raw op %d, time %d.%06d, pid %u\n", alp[1],
454 alp[3] / 1000000, alp[3] % 1000000, alp[2]);
455 /* now decode each parameter and print it */
458 for (i = 0; !done && i < 4; i++) {
459 type = (temp >> (18 - i * 6)) & 0x3f;
465 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
469 tempParam = alp[pix];
471 tempParam |= alp[pix + 1];
472 fprintf(outFilep, "p%d:%lld ", i, tempParam);
473 #else /* AFS_SGI61_ENV */
474 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
475 #endif /* AFS_SGI61_ENV */
477 case ICL_TYPE_POINTER:
479 tempParam = alp[pix];
481 tempParam |= alp[pix + 1];
482 fprintf(outFilep, "p%d:0x%llx ", i, tempParam);
483 #else /* AFS_SGI61_ENV */
484 fprintf(outFilep, "p%d:0x%x ", i, alp[pix]);
485 #endif /* AFS_SGI61_ENV */
489 fprintf(outFilep, "p%d:%x.%x ", i, alp[pix],
493 fprintf(outFilep, "p%d:%d.%d.%d.%d ", i, alp[pix],
494 alp[pix + 1], alp[pix + 2], alp[pix + 3]);
496 case ICL_TYPE_STRING:
497 fprintf(outFilep, "p%d:%s ", i, (char *)&alp[pix]);
499 case ICL_TYPE_UNIXDATE:
501 fprintf(outFilep, "p%d:%s ", i,
506 ("DisplayRecord: Bad type %d in raw print switch.\n",
514 pix += icl_GetSize(type, (char *)&alp[pix]);
517 fprintf(outFilep, "\n"); /* done with line */
527 #include <nl_types.h>
529 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
531 static nl_catd catopen1();
533 static nl_catd _do1_open();
534 static nl_catd cat_already_open();
535 static int make_sets();
536 static FILE *open1catfile();
537 static void add_open_cat();
538 static void cat_hard_close();
539 extern char *strchr();
541 static int catpid[NL_MAXOPEN];
542 static CATD *catsopen[NL_MAXOPEN];
543 #define PATH_FORMAT "/usr/lib/nls/msg/%L/%N:/etc/nls/msg/%L/%N"
544 #define DEFAULT_LANG "C"
545 #define TOO_MANY_HOLES(num_holes, num_non_holes) \
546 (((num_holes) > 100) && ((num_holes) > (num_non_holes)))
552 /*---- n: the number of bytes to be malloc'ed ----*/
556 t = (char *)malloc(n);
558 printf("Failed to get mem\n");
568 /*---- char *cat: the name of the cat to be opened ----*/
569 /*---- int dummy: dummy variable ----*/
573 nl_catd _do_open(); /*---- routine that actually opens
580 if (catd = cat_already_open(cat)) {
581 catd->_count = catd->_count + 1;
585 catd = (CATD *) rmalloc(sizeof(CATD));
588 catd->_name = (char *)rmalloc(strlen(cat) + 1);
589 if (catd->_name == NULL)
591 strcpy(catd->_name, cat);
593 catd->_magic = CAT_MAGIC;
595 #ifndef AFS_OSF20_ENV
596 catd->_pid = getpid();
599 if (_do1_open(catd) != CATD_ERR)
614 /*---- pointer to the partially set up cat descriptor ----*/
617 int make_sets(); /*---- routine to unpack the sets into
618 fast acccess mode ----*/
619 void add_open_cat(); /*---- routine to keep a list of
622 int i; /*---- Misc counter(s) used for loop */
629 catd->_fd = open1catfile(catd->_name);
633 fread((void *)&magic, (size_t) 4, (size_t) 1, catd->_fd);
634 if (magic != CAT_MAGIC) {
635 printf("Magic was %x instead of %x -> %x\n", magic, CAT_MAGIC,
643 /* if ((catd->_mem = shmat((int)fileno(catd->_fd), NULL, SHM_MAP | SHM_RDONLY))
644 == (char * )ERR ) { */
646 if (1) { /* disable the shmat, share memory segemnt */
648 /*______________________________________________________________________
649 If the file can not be mapped then simulate mapping for the index
650 table so that make_sets cat set things up. (rmalloc an area big
651 enough for the index table and read the whole thing in)
652 ______________________________________________________________________*/
654 /* reset the file pointer to the beginning of catalog */
655 fseek(catd->_fd, (long)0, 0);
657 /* malloc the header, if fails return error */
658 catd->_hd = (struct _header *)rmalloc(sizeof(struct _header));
659 if (catd->_hd == NULL)
662 /* read in the whole header */
663 fread((void *)catd->_hd, (size_t) sizeof(struct _header), (size_t) 1,
666 /* cs is a dummpy to hold a set temperorily. The purpose of */
667 /* this for loop is to fread the whole catalog so that the */
668 /* file pointer will be moved to the end of the catalog. */
669 for (i = 0; i < catd->_hd->_n_sets; i++) {
670 fread((void *)&cs, (size_t) 4, (size_t) 1, catd->_fd);
671 fseek(catd->_fd, (long)(cs._n_msgs * sizeof(struct _msgptr)), 1);
674 /* after the for loop, ftell returns the byte offset of the */
675 /* end of the catalog relative to the begining of the file. */
676 /* i.e. i contains the byte offset of the whole catalog. */
677 i = ftell(catd->_fd);
679 /* malloc _mem as a temp pointer to hold the entire catalog. */
680 catd->_mem = (char *)rmalloc(i);
681 if (catd->_mem == NULL)
684 /* reset the file pointer to the begining. */
685 fseek(catd->_fd, (long)0, 0);
687 /* read in the whole catalog into _mem */
688 fread((void *)catd->_mem, (size_t) i, (size_t) 1, catd->_fd);
691 * If there aren't many holes in the set numbers,
692 * fully expand the compacted set array from the
693 * catalog. Then in catgets(), we'll be able to use
694 * the set number to index directly into the expanded
697 * If there are a lot of holes, leave the set array
698 * compacted. In catgets(), we'll search through it
699 * for the requested set.
702 num_holes = catd->_hd->_setmax - catd->_hd->_n_sets;
703 if (!TOO_MANY_HOLES(num_holes, catd->_hd->_n_sets)) {
704 catd->_sets_expanded = TRUE;
705 catd->_n_sets = catd->_hd->_setmax;
707 catd->_sets_expanded = FALSE;
708 catd->_n_sets = catd->_hd->_n_sets - 1;
711 /* malloc one extra set more than the max. set index */
713 (struct _catset *)rmalloc((catd->_n_sets + 1) *
714 sizeof(struct _catset));
715 if (catd->_set == NULL)
718 /* save the max. set number in catd->_setmax */
719 catd->_setmax = catd->_hd->_setmax;
720 /* call make_set to malloc memory for every message */
721 if (make_sets(catd) == -1)
729 /*______________________________________________________________________
730 Normal mapping has occurred, set a few things up and call make_sets
731 ______________________________________________________________________*/
733 catd->_hd = (struct _header *)(catd->_mem);
734 catd->_setmax = catd->_hd->_setmax;
736 (struct _catset *)rmalloc((catd->_hd->_setmax + 1) *
737 sizeof(struct _catset));
738 if (catd->_set == NULL)
740 if (make_sets(catd) == -1)
751 /*---- catd to be added to the list of catalogs ----*/
754 int i = 0; /*---- Misc counter(s) used for loops ----*/
755 while (i < NL_MAXOPEN && catsopen[i]) {
756 if (!strcmp(catd->_name, catsopen[i]->_name)
757 #ifndef AFS_OSF20_ENV
758 && getpid() == catsopen[i]->_pid)
762 return; /*---- The catalog is already here ----*/
766 if (i < NL_MAXOPEN) {
768 catpid[i] = getpid();
777 * FUNCTION: Expands the compacted version of the catalog index table into
778 * the fast access memory version.
780 * EXECUTION ENVIRONMENT:
782 * Make_set executes under a process.
792 struct _catset *cset;
793 char *base = catd->_mem;
794 int n_sets = catd->_hd->_n_sets;
795 int i; /*---- Misc counter(s) used for loops ----*/
796 int j; /*---- Misc counter(s) used for loops ----*/
797 int msgmax; /*---- The maximum number of _messages in a set ----*/
798 char *cmpct_set_ptr; /*---- pointer into the index table ----*/
799 struct _catset cs; /*---- used to look at the sets in the table -*/
802 cmpct_set_ptr = base + sizeof(struct _header);
804 for (i = 0; i < n_sets; i++) {
805 /* loop through each compacted set */
807 cs = *(struct _catset *)cmpct_set_ptr;
808 /* set the _catset ptr to the base of the current
812 (struct _msgptr *)(cmpct_set_ptr + 2 * sizeof(unsigned short));
813 /* set the ms array ptr to the base of
814 * compacted array of _msgptr's */
817 (catd->_sets_expanded) ? &catd->_set[cs._setno] : &catd->_set[i];
820 * If there aren't many holes in the message numbers,
821 * fully expand the compacted message array from the
822 * catalog. Then in catgets(), we'll be able to use
823 * the message number to index directly into the
826 * If there are many holes, leave the message array
827 * compacted. In catgets(), we'll search through it
828 * for the requested message.
831 msgmax = cs._mp[cs._n_msgs - 1]._msgno;
832 num_holes = msgmax - cs._n_msgs;
833 if (!TOO_MANY_HOLES(num_holes, cs._n_msgs)) {
834 cset->_msgs_expanded = TRUE;
835 cset->_n_msgs = msgmax;
837 cset->_msgs_expanded = FALSE;
838 cset->_n_msgs = cs._n_msgs - 1;
842 (struct _msgptr *)rmalloc((1 + cset->_n_msgs) *
843 sizeof(struct _msgptr));
844 if (cset->_mp == NULL)
848 (char **)rmalloc((1 + cset->_n_msgs) * sizeof(char *));
849 if (cset->_msgtxt == NULL)
852 if (cset->_msgs_expanded) {
853 for (j = 0; j < cs._n_msgs; j++) {
854 cset->_mp[cs._mp[j]._msgno] = cs._mp[j];
857 for (j = 0; j < cs._n_msgs; j++) {
858 cset->_mp[j] = cs._mp[j];
862 cset->_setno = cs._setno;
863 /* Superfluous but should have the correct data. Increment
864 * the base of the set pointer. */
867 2 * sizeof(unsigned short) + cs._n_msgs * sizeof(struct _msgptr);
878 * FUNCTION: Opens a catalog file, looking in the language path first (if
879 * there is no slash) and returns a pointer to the file stream.
881 * EXECUTION ENVIRONMENT:
883 * Opencatfile executes under a process.
885 * RETURNS: Returns a pointer to the file stream, and a NULL pointer on
893 extern char *getenv();
894 char fl[PATH_MAX]; /*---- place to hold full path ----*/
895 char *nlspath; /*---- pointer to the nlspath val ----*/
896 FILE *fp; /*---- file pointer ----*/
897 char cpth[PATH_MAX]; /*---- current value of nlspath ----*/
899 char *fulllang; /* %L language value */
900 char lang[PATH_MAX]; /* %l language value */
901 char *territory; /* %t language value */
902 char *codeset; /* %c language value */
903 char *ptr; /* for decompose of $LANG */
908 char outptr[PATH_MAX];
911 if (strchr(file, '/')) {
912 if ((fp = fopen(file, "r"))) {
913 fcntl(fileno(fp), F_SETFD, 1);
914 /* set the close-on-exec flag for
919 if (!(nlspath = getenv("NLSPATH")))
920 nlspath = PATH_FORMAT;
921 if (!(fulllang = getenv("LANG")))
922 fulllang = DEFAULT_LANG;
923 if (fulllang == DEFAULT_LANG)
924 nlspath = PATH_FORMAT; /* if fullang is C, use the
925 * the default nlspath: */
928 ** LANG is a composite of three fields:
929 ** language_territory.codeset
930 ** and we're going to break it into those
934 strcpy(lang, fulllang);
939 ptr = strchr(lang, '_');
943 ptr = strchr(territory, '.');
949 ptr = strchr(lang, '.');
959 while (*np && *np != ':')
962 if (*np) /*---- iff on a colon then advance --*/
970 while (*ptr != '\0') {
971 while ((*ptr != '\0') && (*ptr != '%')
972 && (nchars < PATH_MAX)) {
973 *(optr++) = *(ptr++);
1001 lenstr = strlen(str);
1003 if (nchars < PATH_MAX) {
1011 if (nchars >= PATH_MAX) {
1017 strcpy(cpth, outptr);
1018 } else { /*---- iff leading | trailing |
1019 adjacent colons ... --*/
1023 if (valid == 1 && (fp = fopen(cpth, "r"))) {
1024 fcntl(fileno(fp), F_SETFD, 1);
1025 /* set the close-on-exec flag for
1030 if (fp = fopen(file, "r")) {
1031 fcntl(fileno(fp), F_SETFD, 1);
1032 /* set the close-on-exec flag for
1046 * NAME: cat_already_open
1048 * FUNCTION: Checkes to see if a specific cat has already been opened.
1050 * EXECUTION ENVIRONMENT:
1052 * Cat_already_open executes under a process.
1054 * RETURNS: Returns a pointer to the existing CATD if one exists, and
1055 * a NULL pointer if no CATD exists.
1059 cat_already_open(cat)
1061 /*---- name of the catalog to be opened ----*/
1064 int i; /*---- Misc counter(s) used for loops ----*/
1066 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1067 #ifndef AFS_OSF20_ENV
1068 if (!strcmp(cat, catsopen[i]->_name) && getpid() == catsopen[i]->_pid) {
1070 if (!strcmp(cat, catsopen[i]->_name)) {
1072 return (catsopen[i]);
1080 catclose1(catd) /*---- the catd to be closed ----*/
1081 nl_catd catd; /*---- the catd to be closed ----*/
1087 if (catd == CATD_ERR)
1089 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1090 #ifndef AFS_OSF20_ENV
1091 if (catd == catsopen[i] && getpid() == catsopen[i]->_pid)
1093 if (catd == catsopen[i])
1097 if (i == NL_MAXOPEN || catsopen[i] == NULL)
1099 if (catd->_fd == (FILE *) NULL)
1100 /*---- return if this is an extra open or
1101 a bad catalog discriptor ----*/
1103 if (cat_already_open(catd->_name)) {
1104 if (catd->_count == 1) {
1105 cat_hard_close(catd);
1106 return (0); /*--- the last legal clsoe ---*/
1107 } else if (catd->_count > 1) {
1108 catd->_count = catd->_count - 1;
1109 return (0); /*--- a legal close ---*/
1111 return (-1); /*--- an extra illegal close ---*/
1118 cat_hard_close(catd)
1120 /*---- the catd to be closed ----*/
1123 int i; /*---- Misc counter(s) used for loops ----*/
1124 int j; /*---- Misc counter ----*/
1126 if (catd == CATD_ERR)
1129 /*______________________________________________________________________
1130 remove any entry for the catalog in the catsopen array
1131 ______________________________________________________________________*/
1133 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1134 if (catd == catsopen[i]) {
1135 for (; i < NL_MAXOPEN - 1; i++) {
1136 catsopen[i] = catsopen[i + 1];
1137 catpid[i] = catpid[i + 1];
1144 /*______________________________________________________________________
1145 close the cat and free up the memory
1146 ______________________________________________________________________*/
1147 if (catd->_mem == FALSE) {
1148 for (i = 0; i <= catd->_n_sets; i++) {
1149 if (catd->_set[i]._mp)
1150 free(catd->_set[i]._mp);
1151 /*---- free the _message pointer arrays ----*/
1153 if (catd->_set[i]._msgtxt) {
1154 for (j = 0; j <= catd->_set[i]._n_msgs; j++) {
1155 if (catd->_set[i]._msgtxt[j]) {
1156 /* free(catd->_set[i]._msgtxt[j]);*/
1159 if (catd->_set[i]._msgtxt)
1160 free(catd->_set[i]._msgtxt);
1166 fclose(catd->_fd); /*---- close the ctatlog ----*/
1168 free(catd->_set); /*---- free the sets ----*/
1170 free(catd->_name); /*---- free the name ----*/
1172 free(catd->_hd); /*---- free the header ----*/
1174 free(catd); /*---- free the catd ----*/
1178 _do1_read_msg(nl_catd catd, int setno, int msgno)
1180 /*---- catd: the catd of the catalog to be read from ----*/
1181 /*---- setno: the set number of the message ----*/
1182 /*---- msgno: the msgno of the message ----*/
1184 nl_catd catd1; /*--- catd for different process ----*/
1187 #ifndef AFS_OSF20_ENV
1188 if (getpid() == catd->_pid)
1192 return (_read1_msg(catd, setno, msgno));
1195 * Since our pid is different from the one in
1196 * catd, catd must have come from a catopen()
1197 * in our parent. We need a catd of our own.
1198 * The first time through here, the call to
1199 * catopen() creates a new catd and we try to
1200 * open its message catalog. After that, the
1201 * catopen() just retrieves the catd.
1203 if (((catd1 = catopen1(catd->_name, 0)) != CATD_ERR)
1204 && ((catd1->_fd == NL_FILE_CLOSED && _do1_open(catd1) != CATD_ERR)
1205 || (catd1->_fd != NL_FILE_UNUSED)))
1206 return (_read1_msg(catd1, setno, msgno));
1213 struct _catset *_cat1_get_catset();
1214 static struct _msgptr *_cat1_get_msgptr();
1216 _read1_msg(nl_catd catd, int setno, int msgno)
1218 struct _catset *set; /*--- ptr to set's _catset structure ---*/
1219 struct _msgptr *msg; /*--- ptr to msg's _msgptr structure ---*/
1220 char **msgtxt; /*--- temporary pointer to the message text
1223 set = _cat1_get_catset(catd, setno);
1225 msg = _cat1_get_msgptr(set, msgno);
1227 msgtxt = &set->_msgtxt[msg - set->_mp];
1228 if (1 /*!*msgtxt */ ) {
1229 *msgtxt = (char *)malloc(msg->_msglen + 1);
1233 fseek(catd->_fd, (long)msg->_offset, 0);
1235 ((void *)*msgtxt, (size_t) (msg->_msglen + 1), (size_t) 1,
1247 * NAME: compare_sets
1249 * FUNCTION: Compare function used by bsearch() in _cat_get_catset().
1252 * key - pointer to set number we're searching for
1253 * element - pointer to current _catset structure
1255 * RETURNS: Returns -1, 0, or 1, depending on whether the set number
1256 * is less than, equal to, or greater than the set number of
1257 * the _catset structure.
1262 compare_sets(const void *key, const void *element)
1264 int *setno = (int *)key;
1265 struct _catset *set = (struct _catset *)element;
1267 if (*setno < set->_setno)
1269 if (*setno > set->_setno)
1277 * NAME: _cat_get_catset
1279 * FUNCTION: Find a set in the catd->_set array. Assumes that the
1280 * sets in the array are sorted by increasing set number.
1283 * catd - catalog descripter obtained from catopen()
1284 * setno - message catalogue set number
1286 * RETURNS: Returns a pointer to the set on success.
1287 * On any error, returns NULL.
1292 _cat1_get_catset(nl_catd catd, int setno)
1294 struct _catset *set;
1296 if ((catd == (nl_catd) NULL) || (catd == CATD_ERR))
1297 return (struct _catset *)NULL;
1299 if (catd->_sets_expanded) {
1300 if ((setno < 0) || (setno > catd->_n_sets))
1301 return (struct _catset *)NULL;
1303 set = &catd->_set[setno];
1306 * Catch empty elements in the array. They aren't
1310 if (set->_mp == (struct _msgptr *)NULL)
1311 return (struct _catset *)NULL;
1314 (struct _catset *)bsearch((void *)&setno, catd->_set,
1316 sizeof(struct _catset), compare_sets);
1319 * Since the sets are compacted, there aren't any
1320 * empty elements in the array to check for.
1329 * NAME: compare_msgs
1331 * FUNCTION: Compare function used by bsearch() in _cat_get_msgptr().
1334 * key - pointer to message number we're searching for
1335 * element - pointer to current _msgptr structure
1337 * RETURNS: Returns -1, 0, or 1, depending on whether the message
1338 * number is less than, equal to, or greater than the message
1339 * number of the _msgptr structure.
1344 compare_msgs(const void *key, const void *element)
1346 int *msgno = (int *)key;
1347 struct _msgptr *msg = (struct _msgptr *)element;
1349 if (*msgno < msg->_msgno)
1351 if (*msgno > msg->_msgno)
1358 * NAME: _cat1_get_msgptr
1360 * FUNCTION: Find a message in a set's set->_mp array. Assumes that
1361 * the messages in the array are sorted by increasing
1365 * set - ptr to _catset structure
1366 * msgno - message catalogue message number
1368 * RETURNS: Returns a pointer to the message on success.
1369 * On any error, returns NULL.
1372 static struct _msgptr *
1373 _cat1_get_msgptr(struct _catset *set, int msgno)
1375 struct _msgptr *msg;
1377 if (set == (struct _catset *)NULL)
1378 return (struct _msgptr *)NULL;
1380 if (set->_mp == (struct _msgptr *)NULL) /* empty set */
1381 return (struct _msgptr *)NULL;
1383 if (set->_msgs_expanded) {
1384 if ((msgno < 0) || (msgno > set->_n_msgs))
1385 return (struct _msgptr *)NULL;
1387 msg = &set->_mp[msgno];
1390 * Catch empty elements in the array. They aren't
1395 return (struct _msgptr *)NULL;
1398 (struct _msgptr *)bsearch((void *)&msgno, set->_mp,
1400 sizeof(struct _msgptr), compare_msgs);
1403 * Since the messages are compacted, there aren't any
1404 * empty elements in the array to check for.
1412 catgets1(nl_catd catd, int setno, int msgno, char *def)
1413 /*---- catd: the catd to get the message from ----*/
1414 /*---- setno: the set number of the message ----*/
1415 /*---- msgno: the message number of the message ----*/
1416 /*---- def: the default string to be returned ----*/
1419 char *_do_read_msg();
1423 if (catd == NULL || catd == CATD_ERR || catd->_magic != CAT_MAGIC
1424 || catd->_fd == NL_FILE_UNUSED) {
1427 if (catd->_fd == NL_FILE_CLOSED) {
1428 catd = _do1_open(catd);
1429 if (catd == CATD_ERR)
1433 if (catd->_mem) { /*---- for mapped files ----*/
1434 if (setno <= catd->_hd->_setmax) {
1435 if (msgno < catd->_set[setno]._n_msgs) {
1436 if (catd->_set[setno]._mp[msgno]._offset) {
1437 return (catd->_mem +
1438 catd->_set[setno]._mp[msgno]._offset);
1443 } else { /*---- for unmapped files ----*/
1444 m = _do1_read_msg(catd, setno, msgno);
1454 #define FACILITY_CODE_MASK 0xF0000000
1455 #define FACILITY_CODE_SHIFT 28
1457 #define COMPONENT_CODE_MASK 0x0FFFF000
1458 #define COMPONENT_CODE_SHIFT 12
1460 #define STATUS_CODE_MASK 0x00000FFF
1461 #define STATUS_CODE_SHIFT 0
1463 #define NO_MESSAGE "THIS IS NOT A MESSAGE"
1466 * The system-dependant location for the catalog files is defined in sysconf.h
1467 * RPC_DEFAULT_NLSPATH should be defined in sysconf.h. Otherwise we use
1468 * /usr/afs/etc/C/%s.cat
1471 #ifndef RPC_NLS_FORMAT
1472 #define RPC_NLS_FORMAT "%s.cat"
1475 dce1_error_inq_text(status_to_convert, error_text, status)
1476 afs_uint32 status_to_convert;
1477 unsigned char *error_text;
1481 unsigned short facility_code;
1482 unsigned short component_code;
1483 unsigned short status_code;
1484 unsigned short i, failed = 0;
1486 char component_name[4];
1487 char *facility_name;
1488 char filename_prefix[7];
1489 char nls_filename[11];
1490 char alt_filename[80];
1492 #if defined(AFS_64BITPOINTER_ENV)
1497 static char *facility_names[] = {
1503 * set up output status for future error returns
1505 if (status != NULL) {
1509 * check for ok input status
1511 if (status_to_convert == 0) {
1512 if (status != NULL) {
1515 strcpy((char *)error_text, "successful completion");
1520 * extract the component, facility and status codes
1523 (status_to_convert & FACILITY_CODE_MASK) >> FACILITY_CODE_SHIFT;
1525 (status_to_convert & COMPONENT_CODE_MASK) >> COMPONENT_CODE_SHIFT;
1526 status_code = (status_to_convert & STATUS_CODE_MASK) >> STATUS_CODE_SHIFT;
1529 * see if this is a recognized facility
1531 if (facility_code == 0
1532 || facility_code > sizeof(facility_names) / sizeof(char *)) {
1533 sprintf((char *)error_text, "status %08x (unknown facility)",
1537 facility_name = facility_names[facility_code - 1];
1539 * Convert component name from RAD-50 component code. (Mapping is:
1540 * 0 => 'a', ..., 25 => 'z', 26 => '{', 27 => '0', ..., 36 => '9'.)
1542 component_name[3] = 0;
1543 component_name[2] = component_code % 40;
1544 component_code /= 40;
1545 component_name[1] = component_code % 40;
1546 component_name[0] = component_code / 40;
1547 for (i = 0; i < 3; i++) {
1548 component_name[i] += (component_name[i] <= 26) ? 'a' : ('0' - 27);
1550 sprintf(filename_prefix, "%3s%3s", facility_name, component_name);
1551 sprintf(nls_filename, RPC_NLS_FORMAT, filename_prefix);
1554 * Open the message file
1556 #if defined(AFS_OSF_ENV)
1557 #if defined(AFS_OSF20_ENV)
1558 catd = (nl_catd) catopen(nls_filename, 0);
1560 catd = (nl_catd) catopen1(nls_filename, 0);
1563 #if defined(AFS_64BITPOINTER_ENV)
1564 J = (long)catopen(nls_filename, 0);
1566 J = (int)catopen(nls_filename, 0);
1570 if (catd == (nl_catd) - 1) {
1572 * If we did not succeed in opening message file using NLSPATH,
1573 * try to open the message file in a well-known default area
1576 #ifndef RPC_DEFAULT_NLSPATH
1577 sprintf(alt_filename, "%s/C/%s.cat", AFSDIR_CLIENT_ETC_DIRPATH,
1580 sprintf(alt_filename, RPC_DEFAULT_NLSPATH, filename_prefix);
1583 #if defined(AFS_OSF_ENV)
1584 #if defined(AFS_OSF20_ENV)
1585 catd = (nl_catd) catopen(alt_filename, 0);
1587 catd = (nl_catd) catopen1(alt_filename, 0);
1590 #if defined(AFS_64BITPOINTER_ENV)
1591 J = (long)catopen(alt_filename, 0);
1593 J = (int)catopen(alt_filename, 0);
1597 if (catd == (nl_catd) - 1) {
1598 sprintf((char *)error_text, "status %08x (%s / %s)",
1599 status_to_convert, facility_name, component_name);
1604 * try to get the specified message from the file
1606 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1607 message = (char *)catgets1(catd, 1, status_code, NO_MESSAGE);
1609 message = (char *)catgets(catd, 1, status_code, NO_MESSAGE);
1612 * if everything went well, return the resulting message
1614 if (strcmp(message, NO_MESSAGE) != 0) {
1615 sprintf((char *)error_text, "%s (%s / %s)", message, facility_name,
1617 if (status != NULL) {
1623 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1630 sprintf((char *)error_text, "status %08x (%s / %s)",
1631 status_to_convert, facility_name, component_name);
1633 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1642 icl_DumpKernel(outFilep, setname)
1646 afs_int32 bufferSize = 0;
1649 afs_int32 code, retVal = 0;
1654 afs_int32 dummy, dummy2;
1655 struct logInfo *lip;
1657 /* first, enumerate the logs we're interested in */
1660 /* dump logs for a particular set */
1661 for (i = 0; i < ICL_LOGSPERSET; i++) {
1663 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname,
1664 i, (long)tname, sizeof(tname));
1666 if (errno == EBADF) {
1668 continue; /* missing slot, nothing to worry about */
1673 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1674 (long)&dummy, (long)&dummy2, 0);
1678 if (dummy > bufferSize) /* find biggest log */
1680 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1681 memset((char *)lip, 0, sizeof(*lip));
1682 lip->nextp = allInfo;
1684 lip->name = (char *)malloc(strlen(tname) + 1);
1685 strcpy(lip->name, tname);
1690 for (i = 0; i < 1000; i++) {
1692 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1693 sizeof(tname), (long)&dummy);
1696 if (dummy > bufferSize) /* find biggest log */
1698 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1699 memset((char *)lip, 0, sizeof(*lip));
1700 lip->nextp = allInfo;
1702 lip->name = (char *)malloc(strlen(tname) + 1);
1703 strcpy(lip->name, tname);
1707 if (bufferSize == 0)
1709 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
1713 fprintf(outFilep, "Found %d logs.\n", i);
1715 /* now print out the contents of each log */
1716 for (lip = allInfo; lip; lip = lip->nextp) {
1717 fprintf(outFilep, "\nContents of log %s:\n", lip->name);
1718 /* read out everything first; gets a more consistent
1721 nwords = 0; /* total words copied out */
1723 /* display all the entries in the log */
1724 if (bufferSize - nwords <= 0)
1725 break; /* filled whole buffer */
1727 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUT, (long)lip->name,
1728 (long)(bufferp + nwords), bufferSize - nwords,
1731 /* otherwise we've got an error */
1732 fprintf(outFilep, "Returned error %d dumping log.\n", errno);
1735 /* otherwise, we have flags in the high order byte, and
1736 * a length (in words) in the remainder.
1738 if ((code >> 24) & ICL_COPYOUTF_MISSEDSOME)
1739 fprintf(outFilep, "Log wrapped; data missing.\n");
1747 } /* for loop over all cookies */
1749 /* otherwise we should display all of the log entries here.
1750 * Note that a record may end in the middle, in which case
1751 * we should start over with the cookie value of the start
1754 for (ix = 0; ix < nwords;) {
1755 /* start of a record */
1756 rlength = (bufferp[ix] >> 24) & 0xff;
1758 fprintf(outFilep, "Internal error: 0 length record\n");
1762 /* ensure that entire record fits */
1763 if (ix + rlength > nwords) {
1764 /* doesn't fit, adjust cookie and break */
1767 /* print the record */
1768 DisplayRecord(outFilep, &bufferp[ix], rlength);
1771 /* obsolete: read entire buffer first */
1772 i += rlength; /* update cookie value, too */
1774 } /* for loop displaying buffer */
1775 } /* for loop over all logs */
1782 /* clear out log 'name' */
1788 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRLOG, (long)name, 0, 0, 0);
1792 /* clear out set 'name' */
1798 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRSET, (long)name, 0, 0, 0);
1802 /* clear out all logs */
1807 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRALL, 0, 0, 0, 0);
1811 /* list out all available sets to outFileP */
1813 icl_ListSets(outFileP)
1821 for (i = 0; i < 1000; i++) {
1823 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMSETS, i, (long)tname,
1824 sizeof(tname), (long)&states);
1827 (void)fprintf(outFileP, "%s %s%s%s\n", tname,
1828 (states & ICL_SETF_ACTIVE) ? "active" : "inactive",
1829 (states & ICL_SETF_FREED) ? " (dormant)" : "",
1830 (states & ICL_SETF_PERSISTENT) ? " persistent" : "");
1836 /* list out all available logs to outFileP */
1838 icl_ListLogs(outFileP, int32flg)
1848 for (i = 0; i < 1000; i++) {
1850 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1851 sizeof(tname), (long)&logSize);
1855 /* get more information on the log */
1857 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1858 (long)&logSize, (long)&allocated, 0);
1861 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1863 allocated ? "allocated" : "unallocated");
1865 (void)fprintf(outFileP, "%s\n", tname);
1871 /* list out all available logs to outFileP */
1873 icl_ListLogsBySet(outFileP, setname, int32flg)
1884 for (i = 0; i < ICL_LOGSPERSET; i++) {
1886 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname, i,
1887 (long)tname, sizeof(tname));
1889 if (errno == EBADF) {
1891 continue; /* missing */
1896 /* get more information on the log */
1898 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1899 (long)&logSize, (long)&allocated, 0);
1902 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1904 allocated ? "allocated" : "unallocated");
1906 (void)fprintf(outFileP, "%s\n", tname);
1912 /* activate/deactivate/free specified set */
1914 icl_ChangeSetState(name, op)
1920 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTAT, (long)name, op, 0, 0);
1924 /* activate/deactivate/free all sets */
1926 icl_ChangeAllSetState(op)
1931 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTATALL, op, 0, 0, 0);
1935 /* set size if log */
1937 icl_ChangeLogSize(name, logSize)
1944 afs_syscall(AFSCALL_ICL, ICL_OP_SETLOGSIZE, (long)name, logSize, 0,
1949 /* get logsize of specified log */
1951 icl_GetLogsize(logname, logSizeP, allocatedP)
1953 afs_int32 *logSizeP;
1958 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
1959 (long)logSizeP, (long)allocatedP, 0);
1963 /* get state of specified set */
1965 icl_GetSetState(setname, stateP)
1971 afs_syscall(AFSCALL_ICL, ICL_OP_GETSETINFO, (long)setname,
1972 (long)stateP, 0, 0);
1976 icl_TailKernel(outFilep, logname, waitTime)
1981 afs_int32 bufferSize = 0;
1982 afs_int32 newBufferSize;
1985 afs_int32 code, retVal = 0;
1990 struct logInfo *lip;
1992 /* get information about the specified log */
1994 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
1995 (long)&bufferSize, (long)&allocated, 0);
1997 if (errno == ENOENT)
1998 (void)fprintf(stderr, "'%s' not found\n", logname);
2000 (void)fprintf(stderr,
2001 "cannot get information on log '%s' (errno = %d)\n",
2007 (void)fprintf(stderr, "'%s' not allocated\n", logname);
2011 if (bufferSize == 0)
2013 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2015 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2020 /* start "infinite" loop */
2022 /* read out all that's currently there */
2023 nwords = 0; /* total words copied out */
2024 i = 0; /* initialize cookie */
2026 /* display all the entries in the log */
2027 if (bufferSize - nwords <= 0)
2028 break; /* filled whole buffer, clear when done */
2030 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUTCLR, (long)logname,
2031 (long)(bufferp + nwords), bufferSize - nwords,
2034 /* otherwise we've got an error */
2035 fprintf(stderr, "returned error %d dumping log.\n", errno);
2039 /* otherwise, we have flags in the high order byte, and
2040 * a length (in words) in the remainder.
2049 } /* for loop over all cookies */
2051 /* otherwise we should display all of the log entries here.
2052 * Note that a record may end in the middle, in which case
2053 * we should start over with the cookie value of the start
2056 for (ix = 0; ix < nwords;) {
2057 /* start of a record */
2058 rlength = (bufferp[ix] >> 24) & 0xff;
2059 /* ensure that entire record fits */
2060 if (ix + rlength > nwords) {
2061 /* doesn't fit, adjust cookie and break */
2063 fprintf(stderr, "BOGUS: 0 length record\n");
2069 /* print the record */
2070 DisplayRecord(outFilep, &bufferp[ix], rlength);
2072 } /* for loop displaying buffer */
2077 /* see if things have changed */
2079 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
2080 (long)&newBufferSize, (long)&allocated, 0);
2082 if (errno == ENOENT)
2083 (void)fprintf(stderr, "'%s' not found\n", logname);
2085 (void)fprintf(stderr,
2086 "cannot get information on log '%s' (errno = %d)\n",
2093 (void)fprintf(stderr, "'%s' no int32er allocated\n", logname);
2098 if (bufferSize == 0) {
2099 (void)fprintf(stderr, "buffer size has become 0\n");
2103 if (bufferSize != newBufferSize) {
2104 /* have to reallocate a buffer */
2105 bufferSize = newBufferSize;
2107 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2109 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2115 } /* infinite loop */
2122 #if !defined(AFS_SGI_ENV)
2123 afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6)
2124 long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6;
2127 #ifdef AFS_LINUX20_ENV
2128 #if defined AFS_LINUX_64BIT_KERNEL
2130 /* don't want to sign extend it to 64bit, so using ulong */
2131 eparm[0] = (unsigned long)parm3;
2132 eparm[1] = (unsigned long)parm4;
2133 eparm[2] = (unsigned long)parm5;
2134 eparm[3] = (unsigned long)parm6;
2142 /* Linux can only handle 5 arguments in the actual syscall. */
2143 if (call == AFSCALL_ICL) {
2144 rval = proc_afs_syscall(call, parm0, parm1, parm2, eparm, &code);
2146 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
2148 rval = proc_afs_syscall(call, parm0, parm1, parm2, parm3, &code);
2150 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
2152 #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
2153 /* on sparc this function returns none value, so do it myself */
2154 __asm__ __volatile__("mov %o0, %i0; ret; restore");
2157 #ifdef AFS_DARWIN80_ENV
2158 code = ioctl_afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, &rval);
2159 if (!code) code = rval;
2161 #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
2162 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3, parm4);
2164 #if defined(AFS_SGI_ENV)
2165 code = syscall(AFS_ICL, call, parm0, parm1, parm2, parm3, parm4); /* XXX */
2167 code = syscall(AFSCALL_ICL, parm0, parm1, parm2, parm3, parm4);
2171 #endif /* AFS_LINUX20_ENV */
2179 /* init function, called once, under icl_lock */
2185 /* setup signal handler, in user space */
2191 icl_CreateSet(name, baseLogp, fatalLogp, outSetpp)
2193 struct afs_icl_log *baseLogp;
2194 struct afs_icl_log *fatalLogp;
2195 struct afs_icl_set **outSetpp;
2197 return icl_CreateSetWithFlags(name, baseLogp, fatalLogp, /*flags */ 0,
2201 /* create a set, given pointers to base and fatal logs, if any.
2202 * Logs are unlocked, but referenced, and *outSetpp is returned
2203 * referenced. Function bumps reference count on logs, since it
2204 * addds references from the new icl_set. When the set is destroyed,
2205 * those references will be released.
2207 icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
2209 struct afs_icl_log *baseLogp;
2210 struct afs_icl_log *fatalLogp;
2212 struct afs_icl_set **outSetpp;
2214 register struct afs_icl_set *setp;
2216 afs_int32 states = ICL_DEFAULT_SET_STATES;
2221 for (setp = icl_allSets; setp; setp = setp->nextp) {
2222 if (strcmp(setp->name, name) == 0) {
2225 if (flags & ICL_CRSET_FLAG_PERSISTENT) {
2226 setp->states |= ICL_SETF_PERSISTENT;
2232 /* determine initial state */
2233 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2234 states = ICL_SETF_ACTIVE;
2235 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2236 states = ICL_SETF_FREED;
2237 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2238 states |= ICL_SETF_PERSISTENT;
2240 setp = (struct afs_icl_set *)osi_Alloc(sizeof(struct afs_icl_set));
2241 memset((caddr_t) setp, 0, sizeof(*setp));
2243 if (states & ICL_SETF_FREED)
2244 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2245 setp->states = states;
2247 setp->name = (char *)osi_Alloc(strlen(name) + 1);
2248 strcpy(setp->name, name);
2249 setp->nevents = ICL_DEFAULTEVENTS;
2250 setp->eventFlags = (char *)osi_Alloc(ICL_DEFAULTEVENTS);
2251 for (i = 0; i < ICL_DEFAULTEVENTS; i++)
2252 setp->eventFlags[i] = 0xff; /* default to enabled */
2254 /* update this global info under the icl_lock */
2255 setp->nextp = icl_allSets;
2258 /* set's basic lock is still held, so we can finish init */
2260 setp->logs[0] = baseLogp;
2261 icl_LogHold(baseLogp);
2262 if (!(setp->states & ICL_SETF_FREED))
2263 icl_LogUse(baseLogp); /* log is actually being used */
2266 setp->logs[1] = fatalLogp;
2267 icl_LogHold(fatalLogp);
2268 if (!(setp->states & ICL_SETF_FREED))
2269 icl_LogUse(fatalLogp); /* log is actually being used */
2276 /* function to change event enabling information for a particular set */
2277 icl_SetEnable(setp, eventID, setValue)
2278 struct afs_icl_set *setp;
2284 if (!ICL_EVENTOK(setp, eventID)) {
2287 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2289 *tp |= ICL_EVENTMASK(eventID);
2291 *tp &= ~(ICL_EVENTMASK(eventID));
2295 /* return indication of whether a particular event ID is enabled
2296 * for tracing. If *getValuep is set to 0, the event is disabled,
2297 * otherwise it is enabled. All events start out enabled by default.
2299 icl_GetEnable(setp, eventID, getValuep)
2300 struct afs_icl_set *setp;
2304 if (!ICL_EVENTOK(setp, eventID)) {
2307 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2314 /* hold and release event sets */
2316 register struct afs_icl_set *setp;
2322 /* free a set. Called with icl_lock locked */
2324 register struct afs_icl_set *setp;
2326 register struct afs_icl_set **lpp, *tp;
2328 register struct afs_icl_log *tlp;
2330 for (lpp = &icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2332 /* found the dude we want to remove */
2334 osi_Free(setp->name, 1 + strlen(setp->name));
2335 osi_Free(setp->eventFlags, ICL_EVENTBYTES(setp->nevents));
2336 for (i = 0; i < ICL_LOGSPERSET; i++) {
2337 if (tlp = setp->logs[i])
2340 osi_Free(setp, sizeof(struct afs_icl_set));
2341 break; /* won't find it twice */
2347 /* do the release, watching for deleted entries */
2349 register struct afs_icl_set *setp;
2351 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2352 icl_ZapSet(setp); /* destroys setp's lock! */
2357 /* free a set entry, dropping its reference count */
2359 register struct afs_icl_set *setp;
2361 setp->states |= ICL_SETF_DELETED;
2366 /* find a set by name, returning it held */
2367 struct afs_icl_set *
2371 register struct afs_icl_set *tp;
2373 for (tp = icl_allSets; tp; tp = tp->nextp) {
2374 if (strcmp(tp->name, name) == 0) {
2375 /* this is the dude we want */
2383 /* zero out all the logs in the set */
2385 struct afs_icl_set *setp;
2390 struct afs_icl_log *logp;
2392 for (i = 0; i < ICL_LOGSPERSET; i++) {
2393 logp = setp->logs[i];
2396 tcode = icl_ZeroLog(logp);
2398 code = tcode; /* save the last bad one */
2405 icl_EnumerateSets(aproc, arock)
2409 register struct afs_icl_set *tp, *np;
2410 register afs_int32 code;
2413 for (tp = icl_allSets; tp; tp = np) {
2414 tp->refCount++; /* hold this guy */
2415 code = (*aproc) (tp->name, arock, tp);
2416 np = tp->nextp; /* tp may disappear next, but not np */
2417 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
2425 icl_AddLogToSet(setp, newlogp)
2426 struct afs_icl_set *setp;
2427 struct afs_icl_log *newlogp;
2431 struct afs_icl_log *logp;
2433 for (i = 0; i < ICL_LOGSPERSET; i++) {
2434 if (!setp->logs[i]) {
2435 setp->logs[i] = newlogp;
2437 icl_LogHold(newlogp);
2438 if (!(setp->states & ICL_SETF_FREED)) {
2439 /* bump up the number of sets using the log */
2440 icl_LogUse(newlogp);
2448 icl_SetSetStat(setp, op)
2449 struct afs_icl_set *setp;
2454 struct afs_icl_log *logp;
2457 case ICL_OP_SS_ACTIVATE: /* activate a log */
2459 * If we are not already active, see if we have released
2460 * our demand that the log be allocated (FREED set). If
2461 * we have, reassert our desire.
2463 if (!(setp->states & ICL_SETF_ACTIVE)) {
2464 if (setp->states & ICL_SETF_FREED) {
2465 /* have to reassert desire for logs */
2466 for (i = 0; i < ICL_LOGSPERSET; i++) {
2467 logp = setp->logs[i];
2474 setp->states &= ~ICL_SETF_FREED;
2476 setp->states |= ICL_SETF_ACTIVE;
2481 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
2482 /* this doesn't require anything beyond clearing the ACTIVE flag */
2483 setp->states &= ~ICL_SETF_ACTIVE;
2487 case ICL_OP_SS_FREE: /* deassert design for log */
2489 * if we are already in this state, do nothing; otherwise
2490 * deassert desire for log
2492 if (setp->states & ICL_SETF_ACTIVE)
2495 if (!(setp->states & ICL_SETF_FREED)) {
2496 for (i = 0; i < ICL_LOGSPERSET; i++) {
2497 logp = setp->logs[i];
2500 icl_LogFreeUse(logp);
2504 setp->states |= ICL_SETF_FREED;
2517 struct afs_icl_log *afs_icl_allLogs = 0;
2519 /* hold and release logs */
2521 register struct afs_icl_log *logp;
2527 /* hold and release logs, called with lock already held */
2529 register struct afs_icl_log *logp;
2535 /* keep track of how many sets believe the log itself is allocated */
2537 register struct afs_icl_log *logp;
2539 if (logp->setCount == 0) {
2540 /* this is the first set actually using the log -- allocate it */
2541 if (logp->logSize == 0) {
2542 /* we weren't passed in a hint and it wasn't set */
2543 logp->logSize = ICL_DEFAULT_LOGSIZE;
2546 (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logp->logSize);
2552 /* decrement the number of real users of the log, free if possible */
2553 icl_LogFreeUse(logp)
2554 register struct afs_icl_log *logp;
2556 if (--logp->setCount == 0) {
2557 /* no more users -- free it (but keep log structure around) */
2558 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2559 logp->firstUsed = logp->firstFree = 0;
2560 logp->logElements = 0;
2566 /* set the size of the log to 'logSize' */
2567 icl_LogSetSize(logp, logSize)
2568 register struct afs_icl_log *logp;
2572 /* nothing to worry about since it's not allocated */
2573 logp->logSize = logSize;
2576 logp->firstUsed = logp->firstFree = 0;
2577 logp->logElements = 0;
2579 /* free and allocate a new one */
2580 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2581 logp->datap = (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logSize);
2582 logp->logSize = logSize;
2588 /* free a log. Called with icl_lock locked. */
2590 register struct afs_icl_log *logp;
2592 register struct afs_icl_log **lpp, *tp;
2594 for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2596 /* found the dude we want to remove */
2598 osi_Free(logp->name, 1 + strlen(logp->name));
2599 osi_Free(logp->datap, logp->logSize * sizeof(afs_int32));
2600 osi_Free(logp, sizeof(struct icl_log));
2601 break; /* won't find it twice */
2607 /* do the release, watching for deleted entries */
2609 register struct afs_icl_log *logp;
2611 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2612 icl_ZapLog(logp); /* destroys logp's lock! */
2617 /* do the release, watching for deleted entries, log already held */
2619 register struct afs_icl_log *logp;
2621 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2622 icl_ZapLog(logp); /* destroys logp's lock! */
2627 /* zero out the log */
2629 icl_ZeroLog(register struct afs_icl_log *logp)
2631 logp->firstUsed = logp->firstFree = 0;
2632 logp->logElements = 0;
2636 /* free a log entry, and drop its reference count */
2638 register struct afs_icl_log *logp;
2640 logp->states |= ICL_LOGF_DELETED;
2647 icl_EnumerateLogs(int (*aproc)
2648 (char *name, char *arock, struct afs_icl_log * tp),
2651 register struct afs_icl_log *tp;
2652 register afs_int32 code;
2655 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2656 tp->refCount++; /* hold this guy */
2657 code = (*aproc) (tp->name, arock, tp);
2658 if (--tp->refCount == 0)
2667 afs_icl_bulkSetinfo_t *
2670 unsigned int infoSize;
2673 sizeof(afs_icl_bulkSetinfo_t) + (ICL_RPC_MAX_SETS -
2674 1) * sizeof(afs_icl_setinfo_t);
2676 setInfo = (afs_icl_bulkSetinfo_t *) malloc(infoSize);
2678 (void)fprintf(stderr,
2679 "Could not allocate the memory for bulk set info structure\n");
2683 memset((char *)setInfo, 0, infoSize);
2688 afs_icl_bulkLoginfo_t *
2691 unsigned int infoSize;
2694 sizeof(afs_icl_bulkLoginfo_t) + (ICL_RPC_MAX_LOGS -
2695 1) * sizeof(afs_icl_loginfo_t);
2697 logInfo = (afs_icl_bulkLoginfo_t *) malloc(infoSize);
2699 (void)fprintf(stderr,
2700 "Could not allocate the memory for bulk log info structure\n");
2705 memset((char *)logInfo, 0, infoSize);
2711 DoDump(struct cmd_syndesc *as, void *arock)
2715 afs_int32 waitTime = 10 /* seconds */ ;
2719 FILE *outfp = stdout;
2721 struct cmd_item *itemp;
2723 if (geteuid() != 0) {
2724 printf("fstrace must be run as root\n");
2728 if (as->parms[3].items) {
2729 if (!as->parms[1].items) {
2730 (void)fprintf(stderr, "-sleep can only be used with -follow\n");
2733 waitTime = strtol(as->parms[3].items->data, NULL, 0);
2736 if (as->parms[2].items) {
2737 /* try to open the specified output file */
2738 if ((outfp = fopen(as->parms[2].items->data, "w")) == NULL) {
2739 (void)fprintf(stderr, "Cannot open file '%s' for writing\n",
2740 as->parms[2].items->data);
2744 #ifdef AFS_SGI64_ENV
2745 startTime = time((time_t *) 0);
2747 startTime = time(0);
2749 (void)fprintf(outfp, "AFS Trace Dump -\n\n Date: %s\n",
2752 if (as->parms[0].items) {
2753 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2754 tcode = icl_DumpKernel(outfp, itemp->data);
2756 (void)fprintf(stderr, "Unable to dump set %s (errno = %d)\n",
2757 itemp->data, errno);
2761 } else if (as->parms[1].items) {
2762 logname = as->parms[1].items->data;
2763 code = icl_TailKernel(outfp, logname, waitTime);
2765 (void)fprintf(stderr,
2766 "Error tailing kernel log '%s' (errno = %d)\n",
2770 code = icl_DumpKernel(outfp, NULL);
2772 (void)fprintf(outfp, "\nAFS Trace Dump - %s\n",
2773 code ? "FAILED" : "Completed");
2775 if (outfp != stdout)
2776 (void)fclose(outfp);
2784 struct cmd_syndesc *dumpSyntax;
2787 cmd_CreateSyntax("dump", DoDump, NULL, "dump AFS trace logs");
2788 (void)cmd_AddParm(dumpSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2789 (void)cmd_AddParm(dumpSyntax, "-follow", CMD_SINGLE, CMD_OPTIONAL,
2791 (void)cmd_AddParm(dumpSyntax, "-file", CMD_SINGLE, CMD_OPTIONAL,
2793 (void)cmd_AddParm(dumpSyntax, "-sleep", CMD_SINGLE, CMD_OPTIONAL,
2794 "seconds_between_reads");
2798 DoShowLog(register struct cmd_syndesc *as, void *arock)
2800 afs_int32 retVal = 0;
2805 struct cmd_item *itemp;
2807 if (geteuid() != 0) {
2808 printf("fstrace must be run as root\n");
2811 if (as->parms[2].items)
2814 if (as->parms[0].items) {
2815 /* enumerate logs for the specified sets */
2816 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2817 (void)fprintf(stdout, "Logs for set '%s':\n", itemp->data);
2818 code = icl_ListLogsBySet(stdout, itemp->data, int32flg);
2820 (void)fprintf(stderr,
2821 "Error in enumerating set %s (errno = %d)\n",
2822 itemp->data, errno);
2826 } else if (as->parms[1].items) {
2827 /* print out log information */
2828 for (itemp = as->parms[1].items; itemp; itemp = itemp->next) {
2829 code = icl_GetLogsize(itemp->data, &logSize, &allocated);
2831 (void)fprintf(stdout, "%s : %d kbytes (%s)\n", itemp->data,
2833 allocated ? "allocated" : "unallocated");
2835 (void)fprintf(stderr,
2836 "Could not find log '%s' (errno = %d)\n",
2837 itemp->data, errno);
2843 (void)fprintf(stdout, "Available logs:\n");
2844 code = icl_ListLogs(stdout, int32flg);
2846 (void)fprintf(stderr, "Error in listing logs (errno = %d)\n",
2858 struct cmd_syndesc *showSyntax;
2861 cmd_CreateSyntax("lslog", DoShowLog, NULL,
2862 "list available logs");
2863 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2864 (void)cmd_AddParm(showSyntax, "-log", CMD_LIST, CMD_OPTIONAL, "log_name");
2865 (void)cmd_AddParm(showSyntax, "-long", CMD_FLAG, CMD_OPTIONAL, "");
2869 DoShowSet(register struct cmd_syndesc *as, void *arock)
2871 afs_int32 retVal = 0;
2874 struct cmd_item *itemp;
2876 if (geteuid() != 0) {
2877 printf("fstrace must be run as root\n");
2880 if (as->parms[0].items) {
2881 /* print information on the specified sets */
2882 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2883 code = icl_GetSetState(itemp->data, &state);
2885 (void)fprintf(stderr,
2886 "Error getting status on set %s (errno = %d)\n",
2887 itemp->data, errno);
2890 (void)fprintf(stdout, "Set %s: %s%s%s\n", itemp->data,
2891 (state & ICL_SETF_ACTIVE) ? "active" :
2893 (state & ICL_SETF_FREED) ? " (dormant)" : "",
2894 (state & ICL_SETF_PERSISTENT) ? " persistent" :
2899 (void)fprintf(stdout, "Available sets:\n");
2900 code = icl_ListSets(stdout);
2902 (void)fprintf(stderr, "Error in listing sets (errno = %d)\n",
2914 struct cmd_syndesc *showSyntax;
2917 cmd_CreateSyntax("lsset", DoShowSet, NULL,
2918 "list available event sets");
2919 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2923 DoClear(register struct cmd_syndesc *as, void *arock)
2925 afs_int32 retVal = 0;
2927 struct cmd_item *itemp;
2929 if (geteuid() != 0) {
2930 printf("fstrace must be run as root\n");
2933 if (as->parms[0].items) {
2934 /* clear logs for the specified sets */
2935 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2936 code = icl_ClearSet(itemp->data);
2938 (void)fprintf(stderr,
2939 "Error in clearing set %s (errno = %d)\n",
2940 itemp->data, errno);
2944 } else if (as->parms[1].items) {
2945 /* clear specified log */
2946 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2947 code = icl_ClearLog(itemp->data);
2949 (void)fprintf(stderr,
2950 "Error in clearing log %s (errno = %d)\n",
2951 itemp->data, errno);
2956 /* clear all logs */
2957 code = icl_ClearAll();
2959 (void)fprintf(stderr, "Error in clearing logs (errno = %d)\n",
2971 struct cmd_syndesc *clearSyntax;
2974 cmd_CreateSyntax("clear", DoClear, NULL,
2975 "clear logs by logname or by event set");
2976 (void)cmd_AddParm(clearSyntax, "-set", CMD_LIST, CMD_OPTIONAL,
2978 (void)cmd_AddParm(clearSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
2983 DoSet(register struct cmd_syndesc *as, void *arock)
2985 afs_int32 retVal = 0;
2990 struct cmd_item *itemp;
2992 if (geteuid() != 0) {
2993 printf("fstrace must be run as root\n");
2996 if (as->parms[1].items) {
2997 op = ICL_OP_SS_ACTIVATE;
2998 operation = "active";
2999 } else if (as->parms[2].items) {
3000 op = ICL_OP_SS_DEACTIVATE;
3001 operation = "inactive";
3002 } else if (as->parms[3].items) {
3003 op = ICL_OP_SS_DEACTIVATE;
3004 operation = "inactive";
3007 /* assume active" */
3008 op = ICL_OP_SS_ACTIVATE;
3009 operation = "active";
3012 if (as->parms[0].items) {
3013 /* activate specified sets */
3014 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
3015 code = icl_ChangeSetState(itemp->data, op);
3017 (void)fprintf(stderr,
3018 "cannot set state of %s to %s (errno = %d)\n",
3019 itemp->data, operation, errno);
3021 } else if (doFree) {
3022 /* try to make it dormant as well */
3023 code = icl_ChangeSetState(itemp->data, ICL_OP_SS_FREE);
3025 (void)fprintf(stderr,
3026 "cannot set state of %s to dormant (errno = %d)\n",
3027 itemp->data, errno);
3034 code = icl_ChangeAllSetState(op);
3036 (void)fprintf(stderr,
3037 "cannot set the state of all sets to %s (errno = %d)\n",
3040 } else if (doFree) {
3041 /* try to make it dormant as well */
3042 code = icl_ChangeAllSetState(ICL_OP_SS_FREE);
3044 (void)fprintf(stderr,
3045 "cannot set the state of all sets to dormant (errno = %d)\n",
3058 struct cmd_syndesc *setSyntax;
3061 cmd_CreateSyntax("setset", DoSet, NULL,
3062 "set state of event sets");
3063 (void)cmd_AddParm(setSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
3064 (void)cmd_AddParm(setSyntax, "-active", CMD_FLAG, CMD_OPTIONAL, "");
3065 (void)cmd_AddParm(setSyntax, "-inactive", CMD_FLAG, CMD_OPTIONAL, "");
3066 (void)cmd_AddParm(setSyntax, "-dormant", CMD_FLAG, CMD_OPTIONAL, "");
3070 DoResize(register struct cmd_syndesc *as, void *arock)
3072 afs_int32 retVal = 0;
3074 afs_int32 bufferSize;
3075 struct cmd_item *itemp;
3077 if (geteuid() != 0) {
3078 printf("fstrace must be run as root\n");
3081 /* get buffer size */
3082 bufferSize = atoi(as->parms[1].items->data);
3083 bufferSize *= BUFFER_MULTIPLIER;
3084 if (bufferSize == 0)
3085 bufferSize = ICL_DEFAULT_LOGSIZE;
3087 /* set the size of the specified logs */
3088 if (itemp = as->parms[0].items) {
3089 for (; itemp; itemp = itemp->next) {
3090 code = icl_ChangeLogSize(itemp->data, bufferSize);
3092 (void)fprintf(stderr,
3093 "Error in changing log %s buffer size (errno = %d)\n",
3094 itemp->data, errno);
3099 /* Use the only current support log, "cmfx" */
3100 code = icl_ChangeLogSize("cmfx", bufferSize);
3102 (void)fprintf(stderr,
3103 "Error in changing log cmfx buffer size (errno = %d)\n",
3115 struct cmd_syndesc *setsizeSyntax;
3118 cmd_CreateSyntax("setlog", DoResize, NULL,
3119 "set the size of a log");
3120 (void)cmd_AddParm(setsizeSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
3122 (void)cmd_AddParm(setsizeSyntax, "-buffersize", CMD_SINGLE, CMD_REQUIRED,
3123 "1-kilobyte_units");
3126 #include "AFS_component_version_number.c"
3132 setlocale(LC_ALL, "");
3133 #ifdef AFS_SGI62_ENV
3134 set_kernel_sizeof_long();
3137 /* set up user interface then dispatch */
3145 return (cmd_Dispatch(argc, argv));
3148 #include "AFS_component_version_number.c"
3152 printf("fstrace is NOT supported for this OS\n");