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? */
290 /* decode parameters */
291 temp = alp[0]; /* type encoded in low-order 24 bits, t0 high */
297 for (i = 0; i < 4 * ICL_MAXEXPANSION; i++)
299 /* decode each parameter, getting addrs for afs_hyper_t and strings */
300 for (i = 0; !done && i < 4; i++) {
301 type = (temp >> (18 - i * 6)) & 0x3f;
307 case ICL_TYPE_POINTER:
308 printfTypes[pftix++] = 0;
309 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
310 printfParms[pfpix] = alp[pix];
311 printfParms[pfpix] &= 0xffffffff;
312 if (afs_64bit_kernel) {
313 printfParms[pfpix] <<= 32;
314 printfParms[pfpix] |= alp[pix + 1];
316 #elif defined(AFS_OSF_ENV)
317 printfParms[pfpix] = alp[pix + 1];
318 printfParms[pfpix] |= (alp[pix] <<= 32);
319 #else /* !AFS_OSF_ENV && !AFS_SGI61_ENV */
320 printfParms[pfpix] = alp[pix];
325 printfTypes[pftix++] = 0;
326 printfParms[pfpix++] = alp[pix];
330 printfTypes[pftix++] = 0;
331 printfParms[pfpix++] = alp[pix];
332 printfTypes[pftix++] = 0;
333 printfParms[pfpix++] = alp[pix + 1];
336 printfTypes[pftix++] = 0;
337 printfParms[pfpix++] = alp[pix];
338 printfTypes[pftix++] = 0;
339 printfParms[pfpix++] = alp[pix + 1];
340 printfTypes[pftix++] = 0;
341 printfParms[pfpix++] = alp[pix + 2];
342 printfTypes[pftix++] = 0;
343 printfParms[pfpix++] = alp[pix + 3];
345 case ICL_TYPE_STRING:
346 printfTypes[pftix++] = 1;
348 printfStrings[pfpix++] = (char *)&alp[pix];
349 #else /* AFS_SGI64_ENV */
350 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
351 printfStrings[pfpix++] = (char *)&alp[pix];
352 #else /* AFS_SGI61_ENV */
353 printfParms[pfpix++] = (long)&alp[pix];
354 #endif /* AFS_SGI61_ENV */
355 #endif /* AFS_SGI64_ENV */
357 case ICL_TYPE_UNIXDATE:
359 printfParms[pfpix++] = (long)ctime(&tmv);
362 printf("DisplayRecord: Bad type %d in decode switch.\n", type);
369 pix += icl_GetSize(type, (char *)&alp[pix]);
372 /* next, try to decode the opcode into a printf string */
373 dce1_error_inq_text(alp[1], msgBuffer, &status);
375 /* if we got a string back, and it is compatible with the
376 * parms we've got, then print it.
380 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
381 if (CheckTypes(msgBuffer, printfTypes, pftix, outMsgBuffer)) {
382 /* we have a string to use, but it ends "(dfs / zcm)",
383 * so we remove the extra gunk.
385 j = strlen(outMsgBuffer);
387 outMsgBuffer[j - 11] = 0;
391 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
392 alp[3] % 1000000, alp[2]);
393 for (i = 0; i < j; i++) {
394 if ((int)outMsgBuffer[i] > 5)
395 fputc(outMsgBuffer[i], outFilep);
397 switch (outMsgBuffer[i]) {
401 fprintf(outFilep, "%s", printfStrings[pfpix++]);
403 case 2: /* signed integer */
404 fprintf(outFilep, "%lld", printfParms[pfpix++]);
406 case 3: /* unsigned integer */
407 fprintf(outFilep, "%llu", printfParms[pfpix++]);
409 case 4: /* octal integer */
410 fprintf(outFilep, "%llo", printfParms[pfpix++]);
412 case 5: /* hex integer */
413 fprintf(outFilep, "%llx", printfParms[pfpix++]);
417 "fstrace: Bad char %d in outMsgBuffer for parm %d\n",
418 outMsgBuffer[i], pfpix);
419 fprintf(outFilep, "fstrace: msgBuffer='%s'\n",
425 fprintf(outFilep, "\n");
428 #else /* AFS_SGI61_ENV */
429 if (CheckTypes(msgBuffer, printfTypes, pftix)) {
430 /* we have a string to use, but it ends "(dfs / zcm)",
431 * so we remove the extra gunk.
433 j = strlen(msgBuffer);
435 msgBuffer[j - 11] = 0;
436 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
437 alp[3] % 1000000, alp[2]);
438 fprintf(outFilep, msgBuffer, printfParms[0], printfParms[1],
439 printfParms[2], printfParms[3], printfParms[4],
440 printfParms[5], printfParms[6], printfParms[7],
441 printfParms[8], printfParms[9], printfParms[10],
442 printfParms[11], printfParms[12], printfParms[13],
443 printfParms[14], printfParms[15]);
444 fprintf(outFilep, "\n");
447 #endif /* AFS_SGI61_ENV */
449 fprintf(outFilep, "Type mismatch, using raw print.\n");
450 fprintf(outFilep, "%s", msgBuffer);
454 if (alp[1] == ICL_INFO_TIMESTAMP) {
456 fprintf(outFilep, "time %d.%06d, pid %u: %s\n", alp[3] / 1000000,
457 alp[3] % 1000000, alp[2], ctime(&tmv));
459 fprintf(outFilep, "raw op %d, time %d.%06d, pid %u\n", alp[1],
460 alp[3] / 1000000, alp[3] % 1000000, alp[2]);
461 /* now decode each parameter and print it */
464 for (i = 0; !done && i < 4; i++) {
465 type = (temp >> (18 - i * 6)) & 0x3f;
471 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
475 tempParam = alp[pix];
477 tempParam |= alp[pix + 1];
478 fprintf(outFilep, "p%d:%lld ", i, tempParam);
479 #else /* AFS_SGI61_ENV */
480 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
481 #endif /* AFS_SGI61_ENV */
483 case ICL_TYPE_POINTER:
485 tempParam = alp[pix];
487 tempParam |= alp[pix + 1];
488 fprintf(outFilep, "p%d:0x%llx ", i, tempParam);
489 #else /* AFS_SGI61_ENV */
490 fprintf(outFilep, "p%d:0x%x ", i, alp[pix]);
491 #endif /* AFS_SGI61_ENV */
495 fprintf(outFilep, "p%d:%x.%x ", i, alp[pix],
499 fprintf(outFilep, "p%d:%d.%d.%d.%d ", i, alp[pix],
500 alp[pix + 1], alp[pix + 2], alp[pix + 3]);
502 case ICL_TYPE_STRING:
503 fprintf(outFilep, "p%d:%s ", i, (char *)&alp[pix]);
505 case ICL_TYPE_UNIXDATE:
507 fprintf(outFilep, "p%d:%s ", i,
512 ("DisplayRecord: Bad type %d in raw print switch.\n",
520 pix += icl_GetSize(type, (char *)&alp[pix]);
523 fprintf(outFilep, "\n"); /* done with line */
533 #include <nl_types.h>
535 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
537 static nl_catd catopen1();
539 static nl_catd _do1_open();
540 static nl_catd cat_already_open();
541 static int make_sets();
542 static FILE *open1catfile();
543 static void add_open_cat();
544 static void cat_hard_close();
545 extern char *strchr();
547 static int catpid[NL_MAXOPEN];
548 static CATD *catsopen[NL_MAXOPEN];
549 #define PATH_FORMAT "/usr/lib/nls/msg/%L/%N:/etc/nls/msg/%L/%N"
550 #define DEFAULT_LANG "C"
551 #define TOO_MANY_HOLES(num_holes, num_non_holes) \
552 (((num_holes) > 100) && ((num_holes) > (num_non_holes)))
558 /*---- n: the number of bytes to be malloc'ed ----*/
562 t = (char *)malloc(n);
564 printf("Failed to get mem\n");
574 /*---- char *cat: the name of the cat to be opened ----*/
575 /*---- int dummy: dummy variable ----*/
579 nl_catd _do_open(); /*---- routine that actually opens
586 if (catd = cat_already_open(cat)) {
587 catd->_count = catd->_count + 1;
591 catd = (CATD *) rmalloc(sizeof(CATD));
594 catd->_name = (char *)rmalloc(strlen(cat) + 1);
595 if (catd->_name == NULL)
597 strcpy(catd->_name, cat);
599 catd->_magic = CAT_MAGIC;
601 #ifndef AFS_OSF20_ENV
602 catd->_pid = getpid();
605 if (_do1_open(catd) != CATD_ERR)
620 /*---- pointer to the partially set up cat descriptor ----*/
623 int make_sets(); /*---- routine to unpack the sets into
624 fast acccess mode ----*/
625 void add_open_cat(); /*---- routine to keep a list of
628 int i; /*---- Misc counter(s) used for loop */
635 catd->_fd = open1catfile(catd->_name);
639 fread((void *)&magic, (size_t) 4, (size_t) 1, catd->_fd);
640 if (magic != CAT_MAGIC) {
641 printf("Magic was %x instead of %x -> %x\n", magic, CAT_MAGIC,
649 /* if ((catd->_mem = shmat((int)fileno(catd->_fd), NULL, SHM_MAP | SHM_RDONLY))
650 == (char * )ERR ) { */
652 if (1) { /* disable the shmat, share memory segemnt */
654 /*______________________________________________________________________
655 If the file can not be mapped then simulate mapping for the index
656 table so that make_sets cat set things up. (rmalloc an area big
657 enough for the index table and read the whole thing in)
658 ______________________________________________________________________*/
660 /* reset the file pointer to the beginning of catalog */
661 fseek(catd->_fd, (long)0, 0);
663 /* malloc the header, if fails return error */
664 catd->_hd = (struct _header *)rmalloc(sizeof(struct _header));
665 if (catd->_hd == NULL)
668 /* read in the whole header */
669 fread((void *)catd->_hd, (size_t) sizeof(struct _header), (size_t) 1,
672 /* cs is a dummpy to hold a set temperorily. The purpose of */
673 /* this for loop is to fread the whole catalog so that the */
674 /* file pointer will be moved to the end of the catalog. */
675 for (i = 0; i < catd->_hd->_n_sets; i++) {
676 fread((void *)&cs, (size_t) 4, (size_t) 1, catd->_fd);
677 fseek(catd->_fd, (long)(cs._n_msgs * sizeof(struct _msgptr)), 1);
680 /* after the for loop, ftell returns the byte offset of the */
681 /* end of the catalog relative to the begining of the file. */
682 /* i.e. i contains the byte offset of the whole catalog. */
683 i = ftell(catd->_fd);
685 /* malloc _mem as a temp pointer to hold the entire catalog. */
686 catd->_mem = (char *)rmalloc(i);
687 if (catd->_mem == NULL)
690 /* reset the file pointer to the begining. */
691 fseek(catd->_fd, (long)0, 0);
693 /* read in the whole catalog into _mem */
694 fread((void *)catd->_mem, (size_t) i, (size_t) 1, catd->_fd);
697 * If there aren't many holes in the set numbers,
698 * fully expand the compacted set array from the
699 * catalog. Then in catgets(), we'll be able to use
700 * the set number to index directly into the expanded
703 * If there are a lot of holes, leave the set array
704 * compacted. In catgets(), we'll search through it
705 * for the requested set.
708 num_holes = catd->_hd->_setmax - catd->_hd->_n_sets;
709 if (!TOO_MANY_HOLES(num_holes, catd->_hd->_n_sets)) {
710 catd->_sets_expanded = TRUE;
711 catd->_n_sets = catd->_hd->_setmax;
713 catd->_sets_expanded = FALSE;
714 catd->_n_sets = catd->_hd->_n_sets - 1;
717 /* malloc one extra set more than the max. set index */
719 (struct _catset *)rmalloc((catd->_n_sets + 1) *
720 sizeof(struct _catset));
721 if (catd->_set == NULL)
724 /* save the max. set number in catd->_setmax */
725 catd->_setmax = catd->_hd->_setmax;
726 /* call make_set to malloc memory for every message */
727 if (make_sets(catd) == -1)
735 /*______________________________________________________________________
736 Normal mapping has occurred, set a few things up and call make_sets
737 ______________________________________________________________________*/
739 catd->_hd = (struct _header *)(catd->_mem);
740 catd->_setmax = catd->_hd->_setmax;
742 (struct _catset *)rmalloc((catd->_hd->_setmax + 1) *
743 sizeof(struct _catset));
744 if (catd->_set == NULL)
746 if (make_sets(catd) == -1)
757 /*---- catd to be added to the list of catalogs ----*/
760 int i = 0; /*---- Misc counter(s) used for loops ----*/
761 while (i < NL_MAXOPEN && catsopen[i]) {
762 if (!strcmp(catd->_name, catsopen[i]->_name)
763 #ifndef AFS_OSF20_ENV
764 && getpid() == catsopen[i]->_pid)
768 return; /*---- The catalog is already here ----*/
772 if (i < NL_MAXOPEN) {
774 catpid[i] = getpid();
783 * FUNCTION: Expands the compacted version of the catalog index table into
784 * the fast access memory version.
786 * EXECUTION ENVIRONMENT:
788 * Make_set executes under a process.
798 struct _catset *cset;
799 char *base = catd->_mem;
800 int n_sets = catd->_hd->_n_sets;
801 int i; /*---- Misc counter(s) used for loops ----*/
802 int j; /*---- Misc counter(s) used for loops ----*/
803 int msgmax; /*---- The maximum number of _messages in a set ----*/
804 char *cmpct_set_ptr; /*---- pointer into the index table ----*/
805 struct _catset cs; /*---- used to look at the sets in the table -*/
808 cmpct_set_ptr = base + sizeof(struct _header);
810 for (i = 0; i < n_sets; i++) {
811 /* loop through each compacted set */
813 cs = *(struct _catset *)cmpct_set_ptr;
814 /* set the _catset ptr to the base of the current
818 (struct _msgptr *)(cmpct_set_ptr + 2 * sizeof(unsigned short));
819 /* set the ms array ptr to the base of
820 * compacted array of _msgptr's */
823 (catd->_sets_expanded) ? &catd->_set[cs._setno] : &catd->_set[i];
826 * If there aren't many holes in the message numbers,
827 * fully expand the compacted message array from the
828 * catalog. Then in catgets(), we'll be able to use
829 * the message number to index directly into the
832 * If there are many holes, leave the message array
833 * compacted. In catgets(), we'll search through it
834 * for the requested message.
837 msgmax = cs._mp[cs._n_msgs - 1]._msgno;
838 num_holes = msgmax - cs._n_msgs;
839 if (!TOO_MANY_HOLES(num_holes, cs._n_msgs)) {
840 cset->_msgs_expanded = TRUE;
841 cset->_n_msgs = msgmax;
843 cset->_msgs_expanded = FALSE;
844 cset->_n_msgs = cs._n_msgs - 1;
848 (struct _msgptr *)rmalloc((1 + cset->_n_msgs) *
849 sizeof(struct _msgptr));
850 if (cset->_mp == NULL)
854 (char **)rmalloc((1 + cset->_n_msgs) * sizeof(char *));
855 if (cset->_msgtxt == NULL)
858 if (cset->_msgs_expanded) {
859 for (j = 0; j < cs._n_msgs; j++) {
860 cset->_mp[cs._mp[j]._msgno] = cs._mp[j];
863 for (j = 0; j < cs._n_msgs; j++) {
864 cset->_mp[j] = cs._mp[j];
868 cset->_setno = cs._setno;
869 /* Superfluous but should have the correct data. Increment
870 * the base of the set pointer. */
873 2 * sizeof(unsigned short) + cs._n_msgs * sizeof(struct _msgptr);
884 * FUNCTION: Opens a catalog file, looking in the language path first (if
885 * there is no slash) and returns a pointer to the file stream.
887 * EXECUTION ENVIRONMENT:
889 * Opencatfile executes under a process.
891 * RETURNS: Returns a pointer to the file stream, and a NULL pointer on
899 extern char *getenv();
900 char fl[PATH_MAX]; /*---- place to hold full path ----*/
901 char *nlspath; /*---- pointer to the nlspath val ----*/
902 FILE *fp; /*---- file pointer ----*/
903 char cpth[PATH_MAX]; /*---- current value of nlspath ----*/
905 char *fulllang; /* %L language value */
906 char lang[PATH_MAX]; /* %l language value */
907 char *territory; /* %t language value */
908 char *codeset; /* %c language value */
909 char *ptr; /* for decompose of $LANG */
914 char outptr[PATH_MAX];
917 if (strchr(file, '/')) {
918 if ((fp = fopen(file, "r"))) {
919 fcntl(fileno(fp), F_SETFD, 1);
920 /* set the close-on-exec flag for
925 if (!(nlspath = getenv("NLSPATH")))
926 nlspath = PATH_FORMAT;
927 if (!(fulllang = getenv("LANG")))
928 fulllang = DEFAULT_LANG;
929 if (fulllang == DEFAULT_LANG)
930 nlspath = PATH_FORMAT; /* if fullang is C, use the
931 * the default nlspath: */
934 ** LANG is a composite of three fields:
935 ** language_territory.codeset
936 ** and we're going to break it into those
940 strcpy(lang, fulllang);
945 ptr = strchr(lang, '_');
949 ptr = strchr(territory, '.');
955 ptr = strchr(lang, '.');
965 while (*np && *np != ':')
968 if (*np) /*---- iff on a colon then advance --*/
976 while (*ptr != '\0') {
977 while ((*ptr != '\0') && (*ptr != '%')
978 && (nchars < PATH_MAX)) {
979 *(optr++) = *(ptr++);
1007 lenstr = strlen(str);
1009 if (nchars < PATH_MAX) {
1017 if (nchars >= PATH_MAX) {
1023 strcpy(cpth, outptr);
1024 } else { /*---- iff leading | trailing |
1025 adjacent colons ... --*/
1029 if (valid == 1 && (fp = fopen(cpth, "r"))) {
1030 fcntl(fileno(fp), F_SETFD, 1);
1031 /* set the close-on-exec flag for
1036 if (fp = fopen(file, "r")) {
1037 fcntl(fileno(fp), F_SETFD, 1);
1038 /* set the close-on-exec flag for
1052 * NAME: cat_already_open
1054 * FUNCTION: Checkes to see if a specific cat has already been opened.
1056 * EXECUTION ENVIRONMENT:
1058 * Cat_already_open executes under a process.
1060 * RETURNS: Returns a pointer to the existing CATD if one exists, and
1061 * a NULL pointer if no CATD exists.
1065 cat_already_open(cat)
1067 /*---- name of the catalog to be opened ----*/
1070 int i; /*---- Misc counter(s) used for loops ----*/
1072 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1073 #ifndef AFS_OSF20_ENV
1074 if (!strcmp(cat, catsopen[i]->_name) && getpid() == catsopen[i]->_pid) {
1076 if (!strcmp(cat, catsopen[i]->_name)) {
1078 return (catsopen[i]);
1086 catclose1(catd) /*---- the catd to be closed ----*/
1087 nl_catd catd; /*---- the catd to be closed ----*/
1093 if (catd == CATD_ERR)
1095 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1096 #ifndef AFS_OSF20_ENV
1097 if (catd == catsopen[i] && getpid() == catsopen[i]->_pid)
1099 if (catd == catsopen[i])
1103 if (i == NL_MAXOPEN || catsopen[i] == NULL)
1105 if (catd->_fd == (FILE *) NULL)
1106 /*---- return if this is an extra open or
1107 a bad catalog discriptor ----*/
1109 if (cat_already_open(catd->_name)) {
1110 if (catd->_count == 1) {
1111 cat_hard_close(catd);
1112 return (0); /*--- the last legal clsoe ---*/
1113 } else if (catd->_count > 1) {
1114 catd->_count = catd->_count - 1;
1115 return (0); /*--- a legal close ---*/
1117 return (-1); /*--- an extra illegal close ---*/
1124 cat_hard_close(catd)
1126 /*---- the catd to be closed ----*/
1129 int i; /*---- Misc counter(s) used for loops ----*/
1130 int j; /*---- Misc counter ----*/
1132 if (catd == CATD_ERR)
1135 /*______________________________________________________________________
1136 remove any entry for the catalog in the catsopen array
1137 ______________________________________________________________________*/
1139 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1140 if (catd == catsopen[i]) {
1141 for (; i < NL_MAXOPEN - 1; i++) {
1142 catsopen[i] = catsopen[i + 1];
1143 catpid[i] = catpid[i + 1];
1150 /*______________________________________________________________________
1151 close the cat and free up the memory
1152 ______________________________________________________________________*/
1153 if (catd->_mem == FALSE) {
1154 for (i = 0; i <= catd->_n_sets; i++) {
1155 if (catd->_set[i]._mp)
1156 free(catd->_set[i]._mp);
1157 /*---- free the _message pointer arrays ----*/
1159 if (catd->_set[i]._msgtxt) {
1160 for (j = 0; j <= catd->_set[i]._n_msgs; j++) {
1161 if (catd->_set[i]._msgtxt[j]) {
1162 /* free(catd->_set[i]._msgtxt[j]);*/
1165 if (catd->_set[i]._msgtxt)
1166 free(catd->_set[i]._msgtxt);
1172 fclose(catd->_fd); /*---- close the ctatlog ----*/
1174 free(catd->_set); /*---- free the sets ----*/
1176 free(catd->_name); /*---- free the name ----*/
1178 free(catd->_hd); /*---- free the header ----*/
1180 free(catd); /*---- free the catd ----*/
1184 _do1_read_msg(nl_catd catd, int setno, int msgno)
1186 /*---- catd: the catd of the catalog to be read from ----*/
1187 /*---- setno: the set number of the message ----*/
1188 /*---- msgno: the msgno of the message ----*/
1190 nl_catd catd1; /*--- catd for different process ----*/
1193 #ifndef AFS_OSF20_ENV
1194 if (getpid() == catd->_pid)
1198 return (_read1_msg(catd, setno, msgno));
1201 * Since our pid is different from the one in
1202 * catd, catd must have come from a catopen()
1203 * in our parent. We need a catd of our own.
1204 * The first time through here, the call to
1205 * catopen() creates a new catd and we try to
1206 * open its message catalog. After that, the
1207 * catopen() just retrieves the catd.
1209 if (((catd1 = catopen1(catd->_name, 0)) != CATD_ERR)
1210 && ((catd1->_fd == NL_FILE_CLOSED && _do1_open(catd1) != CATD_ERR)
1211 || (catd1->_fd != NL_FILE_UNUSED)))
1212 return (_read1_msg(catd1, setno, msgno));
1219 struct _catset *_cat1_get_catset();
1220 static struct _msgptr *_cat1_get_msgptr();
1222 _read1_msg(nl_catd catd, int setno, int msgno)
1224 struct _catset *set; /*--- ptr to set's _catset structure ---*/
1225 struct _msgptr *msg; /*--- ptr to msg's _msgptr structure ---*/
1226 char **msgtxt; /*--- temporary pointer to the message text
1229 set = _cat1_get_catset(catd, setno);
1231 msg = _cat1_get_msgptr(set, msgno);
1233 msgtxt = &set->_msgtxt[msg - set->_mp];
1234 if (1 /*!*msgtxt */ ) {
1235 *msgtxt = (char *)malloc(msg->_msglen + 1);
1239 fseek(catd->_fd, (long)msg->_offset, 0);
1241 ((void *)*msgtxt, (size_t) (msg->_msglen + 1), (size_t) 1,
1253 * NAME: compare_sets
1255 * FUNCTION: Compare function used by bsearch() in _cat_get_catset().
1258 * key - pointer to set number we're searching for
1259 * element - pointer to current _catset structure
1261 * RETURNS: Returns -1, 0, or 1, depending on whether the set number
1262 * is less than, equal to, or greater than the set number of
1263 * the _catset structure.
1268 compare_sets(const void *key, const void *element)
1270 int *setno = (int *)key;
1271 struct _catset *set = (struct _catset *)element;
1273 if (*setno < set->_setno)
1275 if (*setno > set->_setno)
1283 * NAME: _cat_get_catset
1285 * FUNCTION: Find a set in the catd->_set array. Assumes that the
1286 * sets in the array are sorted by increasing set number.
1289 * catd - catalog descripter obtained from catopen()
1290 * setno - message catalogue set number
1292 * RETURNS: Returns a pointer to the set on success.
1293 * On any error, returns NULL.
1298 _cat1_get_catset(nl_catd catd, int setno)
1300 struct _catset *set;
1302 if ((catd == (nl_catd) NULL) || (catd == CATD_ERR))
1303 return (struct _catset *)NULL;
1305 if (catd->_sets_expanded) {
1306 if ((setno < 0) || (setno > catd->_n_sets))
1307 return (struct _catset *)NULL;
1309 set = &catd->_set[setno];
1312 * Catch empty elements in the array. They aren't
1316 if (set->_mp == (struct _msgptr *)NULL)
1317 return (struct _catset *)NULL;
1320 (struct _catset *)bsearch((void *)&setno, catd->_set,
1322 sizeof(struct _catset), compare_sets);
1325 * Since the sets are compacted, there aren't any
1326 * empty elements in the array to check for.
1335 * NAME: compare_msgs
1337 * FUNCTION: Compare function used by bsearch() in _cat_get_msgptr().
1340 * key - pointer to message number we're searching for
1341 * element - pointer to current _msgptr structure
1343 * RETURNS: Returns -1, 0, or 1, depending on whether the message
1344 * number is less than, equal to, or greater than the message
1345 * number of the _msgptr structure.
1350 compare_msgs(const void *key, const void *element)
1352 int *msgno = (int *)key;
1353 struct _msgptr *msg = (struct _msgptr *)element;
1355 if (*msgno < msg->_msgno)
1357 if (*msgno > msg->_msgno)
1364 * NAME: _cat1_get_msgptr
1366 * FUNCTION: Find a message in a set's set->_mp array. Assumes that
1367 * the messages in the array are sorted by increasing
1371 * set - ptr to _catset structure
1372 * msgno - message catalogue message number
1374 * RETURNS: Returns a pointer to the message on success.
1375 * On any error, returns NULL.
1378 static struct _msgptr *
1379 _cat1_get_msgptr(struct _catset *set, int msgno)
1381 struct _msgptr *msg;
1383 if (set == (struct _catset *)NULL)
1384 return (struct _msgptr *)NULL;
1386 if (set->_mp == (struct _msgptr *)NULL) /* empty set */
1387 return (struct _msgptr *)NULL;
1389 if (set->_msgs_expanded) {
1390 if ((msgno < 0) || (msgno > set->_n_msgs))
1391 return (struct _msgptr *)NULL;
1393 msg = &set->_mp[msgno];
1396 * Catch empty elements in the array. They aren't
1401 return (struct _msgptr *)NULL;
1404 (struct _msgptr *)bsearch((void *)&msgno, set->_mp,
1406 sizeof(struct _msgptr), compare_msgs);
1409 * Since the messages are compacted, there aren't any
1410 * empty elements in the array to check for.
1418 catgets1(nl_catd catd, int setno, int msgno, char *def)
1419 /*---- catd: the catd to get the message from ----*/
1420 /*---- setno: the set number of the message ----*/
1421 /*---- msgno: the message number of the message ----*/
1422 /*---- def: the default string to be returned ----*/
1425 char *_do_read_msg();
1429 if (catd == NULL || catd == CATD_ERR || catd->_magic != CAT_MAGIC
1430 || catd->_fd == NL_FILE_UNUSED) {
1433 if (catd->_fd == NL_FILE_CLOSED) {
1434 catd = _do1_open(catd);
1435 if (catd == CATD_ERR)
1439 if (catd->_mem) { /*---- for mapped files ----*/
1440 if (setno <= catd->_hd->_setmax) {
1441 if (msgno < catd->_set[setno]._n_msgs) {
1442 if (catd->_set[setno]._mp[msgno]._offset) {
1443 return (catd->_mem +
1444 catd->_set[setno]._mp[msgno]._offset);
1449 } else { /*---- for unmapped files ----*/
1450 m = _do1_read_msg(catd, setno, msgno);
1460 #define FACILITY_CODE_MASK 0xF0000000
1461 #define FACILITY_CODE_SHIFT 28
1463 #define COMPONENT_CODE_MASK 0x0FFFF000
1464 #define COMPONENT_CODE_SHIFT 12
1466 #define STATUS_CODE_MASK 0x00000FFF
1467 #define STATUS_CODE_SHIFT 0
1469 #define NO_MESSAGE "THIS IS NOT A MESSAGE"
1472 * The system-dependant location for the catalog files is defined in sysconf.h
1473 * RPC_DEFAULT_NLSPATH should be defined in sysconf.h. Otherwise we use
1474 * /usr/afs/etc/C/%s.cat
1477 #ifndef RPC_NLS_FORMAT
1478 #define RPC_NLS_FORMAT "%s.cat"
1481 dce1_error_inq_text(status_to_convert, error_text, status)
1482 afs_uint32 status_to_convert;
1483 unsigned char *error_text;
1487 unsigned short facility_code;
1488 unsigned short component_code;
1489 unsigned short status_code;
1490 unsigned short i, failed = 0;
1492 char component_name[4];
1493 char *facility_name;
1494 char filename_prefix[7];
1495 char nls_filename[11];
1496 char alt_filename[80];
1498 #if defined(AFS_64BITPOINTER_ENV)
1503 static char *facility_names[] = {
1509 * set up output status for future error returns
1511 if (status != NULL) {
1515 * check for ok input status
1517 if (status_to_convert == 0) {
1518 if (status != NULL) {
1521 strcpy((char *)error_text, "successful completion");
1526 * extract the component, facility and status codes
1529 (status_to_convert & FACILITY_CODE_MASK) >> FACILITY_CODE_SHIFT;
1531 (status_to_convert & COMPONENT_CODE_MASK) >> COMPONENT_CODE_SHIFT;
1532 status_code = (status_to_convert & STATUS_CODE_MASK) >> STATUS_CODE_SHIFT;
1535 * see if this is a recognized facility
1537 if (facility_code == 0
1538 || facility_code > sizeof(facility_names) / sizeof(char *)) {
1539 sprintf((char *)error_text, "status %08x (unknown facility)",
1543 facility_name = facility_names[facility_code - 1];
1545 * Convert component name from RAD-50 component code. (Mapping is:
1546 * 0 => 'a', ..., 25 => 'z', 26 => '{', 27 => '0', ..., 36 => '9'.)
1548 component_name[3] = 0;
1549 component_name[2] = component_code % 40;
1550 component_code /= 40;
1551 component_name[1] = component_code % 40;
1552 component_name[0] = component_code / 40;
1553 for (i = 0; i < 3; i++) {
1554 component_name[i] += (component_name[i] <= 26) ? 'a' : ('0' - 27);
1556 sprintf(filename_prefix, "%3s%3s", facility_name, component_name);
1557 sprintf(nls_filename, RPC_NLS_FORMAT, filename_prefix);
1560 * Open the message file
1562 #if defined(AFS_OSF_ENV)
1563 #if defined(AFS_OSF20_ENV)
1564 catd = (nl_catd) catopen(nls_filename, 0);
1566 catd = (nl_catd) catopen1(nls_filename, 0);
1569 #if defined(AFS_64BITPOINTER_ENV)
1570 J = (long)catopen(nls_filename, 0);
1572 J = (int)catopen(nls_filename, 0);
1576 if (catd == (nl_catd) - 1) {
1578 * If we did not succeed in opening message file using NLSPATH,
1579 * try to open the message file in a well-known default area
1582 #ifndef RPC_DEFAULT_NLSPATH
1583 sprintf(alt_filename, "%s/C/%s.cat", AFSDIR_CLIENT_ETC_DIRPATH,
1586 sprintf(alt_filename, RPC_DEFAULT_NLSPATH, filename_prefix);
1589 #if defined(AFS_OSF_ENV)
1590 #if defined(AFS_OSF20_ENV)
1591 catd = (nl_catd) catopen(alt_filename, 0);
1593 catd = (nl_catd) catopen1(alt_filename, 0);
1596 #if defined(AFS_64BITPOINTER_ENV)
1597 J = (long)catopen(alt_filename, 0);
1599 J = (int)catopen(alt_filename, 0);
1603 if (catd == (nl_catd) - 1) {
1604 sprintf((char *)error_text, "status %08x (%s / %s)",
1605 status_to_convert, facility_name, component_name);
1610 * try to get the specified message from the file
1612 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1613 message = (char *)catgets1(catd, 1, status_code, NO_MESSAGE);
1615 message = (char *)catgets(catd, 1, status_code, NO_MESSAGE);
1618 * if everything went well, return the resulting message
1620 if (strcmp(message, NO_MESSAGE) != 0) {
1621 sprintf((char *)error_text, "%s (%s / %s)", message, facility_name,
1623 if (status != NULL) {
1629 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1636 sprintf((char *)error_text, "status %08x (%s / %s)",
1637 status_to_convert, facility_name, component_name);
1639 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1648 icl_DumpKernel(outFilep, setname)
1652 afs_int32 bufferSize = 0;
1655 afs_int32 code, retVal = 0;
1660 afs_int32 dummy, dummy2;
1661 struct logInfo *lip;
1663 /* first, enumerate the logs we're interested in */
1666 /* dump logs for a particular set */
1667 for (i = 0; i < ICL_LOGSPERSET; i++) {
1669 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname,
1670 i, (long)tname, sizeof(tname));
1672 if (errno == EBADF) {
1674 continue; /* missing slot, nothing to worry about */
1679 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1680 (long)&dummy, (long)&dummy2, 0);
1684 if (dummy > bufferSize) /* find biggest log */
1686 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1687 memset((char *)lip, 0, sizeof(*lip));
1688 lip->nextp = allInfo;
1690 lip->name = (char *)malloc(strlen(tname) + 1);
1691 strcpy(lip->name, tname);
1696 for (i = 0; i < 1000; i++) {
1698 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1699 sizeof(tname), (long)&dummy);
1702 if (dummy > bufferSize) /* find biggest log */
1704 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1705 memset((char *)lip, 0, sizeof(*lip));
1706 lip->nextp = allInfo;
1708 lip->name = (char *)malloc(strlen(tname) + 1);
1709 strcpy(lip->name, tname);
1713 if (bufferSize == 0)
1715 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
1719 fprintf(outFilep, "Found %d logs.\n", i);
1721 /* now print out the contents of each log */
1722 for (lip = allInfo; lip; lip = lip->nextp) {
1723 fprintf(outFilep, "\nContents of log %s:\n", lip->name);
1724 /* read out everything first; gets a more consistent
1727 nwords = 0; /* total words copied out */
1729 /* display all the entries in the log */
1730 if (bufferSize - nwords <= 0)
1731 break; /* filled whole buffer */
1733 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUT, (long)lip->name,
1734 (long)(bufferp + nwords), bufferSize - nwords,
1737 /* otherwise we've got an error */
1738 fprintf(outFilep, "Returned error %d dumping log.\n", errno);
1741 /* otherwise, we have flags in the high order byte, and
1742 * a length (in words) in the remainder.
1744 if ((code >> 24) & ICL_COPYOUTF_MISSEDSOME)
1745 fprintf(outFilep, "Log wrapped; data missing.\n");
1753 } /* for loop over all cookies */
1755 /* otherwise we should display all of the log entries here.
1756 * Note that a record may end in the middle, in which case
1757 * we should start over with the cookie value of the start
1760 for (ix = 0; ix < nwords;) {
1761 /* start of a record */
1762 rlength = (bufferp[ix] >> 24) & 0xff;
1764 fprintf(outFilep, "Internal error: 0 length record\n");
1768 /* ensure that entire record fits */
1769 if (ix + rlength > nwords) {
1770 /* doesn't fit, adjust cookie and break */
1773 /* print the record */
1774 DisplayRecord(outFilep, &bufferp[ix], rlength);
1777 /* obsolete: read entire buffer first */
1778 i += rlength; /* update cookie value, too */
1780 } /* for loop displaying buffer */
1781 } /* for loop over all logs */
1788 /* clear out log 'name' */
1794 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRLOG, (long)name, 0, 0, 0);
1798 /* clear out set 'name' */
1804 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRSET, (long)name, 0, 0, 0);
1808 /* clear out all logs */
1813 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRALL, 0, 0, 0, 0);
1817 /* list out all available sets to outFileP */
1819 icl_ListSets(outFileP)
1827 for (i = 0; i < 1000; i++) {
1829 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMSETS, i, (long)tname,
1830 sizeof(tname), (long)&states);
1833 (void)fprintf(outFileP, "%s %s%s%s\n", tname,
1834 (states & ICL_SETF_ACTIVE) ? "active" : "inactive",
1835 (states & ICL_SETF_FREED) ? " (dormant)" : "",
1836 (states & ICL_SETF_PERSISTENT) ? " persistent" : "");
1842 /* list out all available logs to outFileP */
1844 icl_ListLogs(outFileP, int32flg)
1854 for (i = 0; i < 1000; i++) {
1856 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1857 sizeof(tname), (long)&logSize);
1861 /* get more information on the log */
1863 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1864 (long)&logSize, (long)&allocated, 0);
1867 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1869 allocated ? "allocated" : "unallocated");
1871 (void)fprintf(outFileP, "%s\n", tname);
1877 /* list out all available logs to outFileP */
1879 icl_ListLogsBySet(outFileP, setname, int32flg)
1890 for (i = 0; i < ICL_LOGSPERSET; i++) {
1892 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname, i,
1893 (long)tname, sizeof(tname));
1895 if (errno == EBADF) {
1897 continue; /* missing */
1902 /* get more information on the log */
1904 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1905 (long)&logSize, (long)&allocated, 0);
1908 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1910 allocated ? "allocated" : "unallocated");
1912 (void)fprintf(outFileP, "%s\n", tname);
1918 /* activate/deactivate/free specified set */
1920 icl_ChangeSetState(name, op)
1926 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTAT, (long)name, op, 0, 0);
1930 /* activate/deactivate/free all sets */
1932 icl_ChangeAllSetState(op)
1937 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTATALL, op, 0, 0, 0);
1941 /* set size if log */
1943 icl_ChangeLogSize(name, logSize)
1950 afs_syscall(AFSCALL_ICL, ICL_OP_SETLOGSIZE, (long)name, logSize, 0,
1955 /* get logsize of specified log */
1957 icl_GetLogsize(logname, logSizeP, allocatedP)
1959 afs_int32 *logSizeP;
1964 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
1965 (long)logSizeP, (long)allocatedP, 0);
1969 /* get state of specified set */
1971 icl_GetSetState(setname, stateP)
1977 afs_syscall(AFSCALL_ICL, ICL_OP_GETSETINFO, (long)setname,
1978 (long)stateP, 0, 0);
1982 icl_TailKernel(outFilep, logname, waitTime)
1987 afs_int32 bufferSize = 0;
1988 afs_int32 newBufferSize;
1991 afs_int32 code, retVal = 0;
1996 struct logInfo *lip;
1998 /* get information about the specified log */
2000 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
2001 (long)&bufferSize, (long)&allocated, 0);
2003 if (errno == ENOENT)
2004 (void)fprintf(stderr, "'%s' not found\n", logname);
2006 (void)fprintf(stderr,
2007 "cannot get information on log '%s' (errno = %d)\n",
2013 (void)fprintf(stderr, "'%s' not allocated\n", logname);
2017 if (bufferSize == 0)
2019 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2021 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2026 /* start "infinite" loop */
2028 /* read out all that's currently there */
2029 nwords = 0; /* total words copied out */
2030 i = 0; /* initialize cookie */
2032 /* display all the entries in the log */
2033 if (bufferSize - nwords <= 0)
2034 break; /* filled whole buffer, clear when done */
2036 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUTCLR, (long)logname,
2037 (long)(bufferp + nwords), bufferSize - nwords,
2040 /* otherwise we've got an error */
2041 fprintf(stderr, "returned error %d dumping log.\n", errno);
2045 /* otherwise, we have flags in the high order byte, and
2046 * a length (in words) in the remainder.
2055 } /* for loop over all cookies */
2057 /* otherwise we should display all of the log entries here.
2058 * Note that a record may end in the middle, in which case
2059 * we should start over with the cookie value of the start
2062 for (ix = 0; ix < nwords;) {
2063 /* start of a record */
2064 rlength = (bufferp[ix] >> 24) & 0xff;
2065 /* ensure that entire record fits */
2066 if (ix + rlength > nwords) {
2067 /* doesn't fit, adjust cookie and break */
2069 fprintf(stderr, "BOGUS: 0 length record\n");
2075 /* print the record */
2076 DisplayRecord(outFilep, &bufferp[ix], rlength);
2078 } /* for loop displaying buffer */
2083 /* see if things have changed */
2085 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
2086 (long)&newBufferSize, (long)&allocated, 0);
2088 if (errno == ENOENT)
2089 (void)fprintf(stderr, "'%s' not found\n", logname);
2091 (void)fprintf(stderr,
2092 "cannot get information on log '%s' (errno = %d)\n",
2099 (void)fprintf(stderr, "'%s' no int32er allocated\n", logname);
2104 if (bufferSize == 0) {
2105 (void)fprintf(stderr, "buffer size has become 0\n");
2109 if (bufferSize != newBufferSize) {
2110 /* have to reallocate a buffer */
2111 bufferSize = newBufferSize;
2113 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2115 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2121 } /* infinite loop */
2128 #if !defined(AFS_SGI_ENV)
2129 afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6)
2130 long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6;
2133 #ifdef AFS_LINUX20_ENV
2134 #if defined AFS_LINUX_64BIT_KERNEL
2136 /* don't want to sign extend it to 64bit, so using ulong */
2137 eparm[0] = (unsigned long)parm3;
2138 eparm[1] = (unsigned long)parm4;
2139 eparm[2] = (unsigned long)parm5;
2140 eparm[3] = (unsigned long)parm6;
2148 /* Linux can only handle 5 arguments in the actual syscall. */
2149 if (call == AFSCALL_ICL) {
2150 rval = proc_afs_syscall(call, parm0, parm1, parm2, eparm, &code);
2152 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
2154 rval = proc_afs_syscall(call, parm0, parm1, parm2, parm3, &code);
2156 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
2158 #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
2159 /* on sparc this function returns none value, so do it myself */
2160 __asm__ __volatile__("mov %o0, %i0; ret; restore");
2163 #ifdef AFS_DARWIN80_ENV
2164 code = ioctl_afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, &rval);
2165 if (!code) code = rval;
2167 #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
2168 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3, parm4);
2170 #if defined(AFS_SGI_ENV)
2171 code = syscall(AFS_ICL, call, parm0, parm1, parm2, parm3, parm4); /* XXX */
2173 code = syscall(AFSCALL_ICL, parm0, parm1, parm2, parm3, parm4);
2177 #endif /* AFS_LINUX20_ENV */
2185 /* init function, called once, under icl_lock */
2191 /* setup signal handler, in user space */
2197 icl_CreateSet(name, baseLogp, fatalLogp, outSetpp)
2199 struct afs_icl_log *baseLogp;
2200 struct afs_icl_log *fatalLogp;
2201 struct afs_icl_set **outSetpp;
2203 return icl_CreateSetWithFlags(name, baseLogp, fatalLogp, /*flags */ 0,
2207 /* create a set, given pointers to base and fatal logs, if any.
2208 * Logs are unlocked, but referenced, and *outSetpp is returned
2209 * referenced. Function bumps reference count on logs, since it
2210 * addds references from the new icl_set. When the set is destroyed,
2211 * those references will be released.
2213 icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
2215 struct afs_icl_log *baseLogp;
2216 struct afs_icl_log *fatalLogp;
2218 struct afs_icl_set **outSetpp;
2220 register struct afs_icl_set *setp;
2222 afs_int32 states = ICL_DEFAULT_SET_STATES;
2227 for (setp = icl_allSets; setp; setp = setp->nextp) {
2228 if (strcmp(setp->name, name) == 0) {
2231 if (flags & ICL_CRSET_FLAG_PERSISTENT) {
2232 setp->states |= ICL_SETF_PERSISTENT;
2238 /* determine initial state */
2239 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2240 states = ICL_SETF_ACTIVE;
2241 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2242 states = ICL_SETF_FREED;
2243 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2244 states |= ICL_SETF_PERSISTENT;
2246 setp = (struct afs_icl_set *)osi_Alloc(sizeof(struct afs_icl_set));
2247 memset((caddr_t) setp, 0, sizeof(*setp));
2249 if (states & ICL_SETF_FREED)
2250 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2251 setp->states = states;
2253 setp->name = (char *)osi_Alloc(strlen(name) + 1);
2254 strcpy(setp->name, name);
2255 setp->nevents = ICL_DEFAULTEVENTS;
2256 setp->eventFlags = (char *)osi_Alloc(ICL_DEFAULTEVENTS);
2257 for (i = 0; i < ICL_DEFAULTEVENTS; i++)
2258 setp->eventFlags[i] = 0xff; /* default to enabled */
2260 /* update this global info under the icl_lock */
2261 setp->nextp = icl_allSets;
2264 /* set's basic lock is still held, so we can finish init */
2266 setp->logs[0] = baseLogp;
2267 icl_LogHold(baseLogp);
2268 if (!(setp->states & ICL_SETF_FREED))
2269 icl_LogUse(baseLogp); /* log is actually being used */
2272 setp->logs[1] = fatalLogp;
2273 icl_LogHold(fatalLogp);
2274 if (!(setp->states & ICL_SETF_FREED))
2275 icl_LogUse(fatalLogp); /* log is actually being used */
2282 /* function to change event enabling information for a particular set */
2283 icl_SetEnable(setp, eventID, setValue)
2284 struct afs_icl_set *setp;
2290 if (!ICL_EVENTOK(setp, eventID)) {
2293 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2295 *tp |= ICL_EVENTMASK(eventID);
2297 *tp &= ~(ICL_EVENTMASK(eventID));
2301 /* return indication of whether a particular event ID is enabled
2302 * for tracing. If *getValuep is set to 0, the event is disabled,
2303 * otherwise it is enabled. All events start out enabled by default.
2305 icl_GetEnable(setp, eventID, getValuep)
2306 struct afs_icl_set *setp;
2310 if (!ICL_EVENTOK(setp, eventID)) {
2313 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2320 /* hold and release event sets */
2322 register struct afs_icl_set *setp;
2328 /* free a set. Called with icl_lock locked */
2330 register struct afs_icl_set *setp;
2332 register struct afs_icl_set **lpp, *tp;
2334 register struct afs_icl_log *tlp;
2336 for (lpp = &icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2338 /* found the dude we want to remove */
2340 osi_Free(setp->name, 1 + strlen(setp->name));
2341 osi_Free(setp->eventFlags, ICL_EVENTBYTES(setp->nevents));
2342 for (i = 0; i < ICL_LOGSPERSET; i++) {
2343 if (tlp = setp->logs[i])
2346 osi_Free(setp, sizeof(struct afs_icl_set));
2347 break; /* won't find it twice */
2353 /* do the release, watching for deleted entries */
2355 register struct afs_icl_set *setp;
2357 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2358 icl_ZapSet(setp); /* destroys setp's lock! */
2363 /* free a set entry, dropping its reference count */
2365 register struct afs_icl_set *setp;
2367 setp->states |= ICL_SETF_DELETED;
2372 /* find a set by name, returning it held */
2373 struct afs_icl_set *
2377 register struct afs_icl_set *tp;
2379 for (tp = icl_allSets; tp; tp = tp->nextp) {
2380 if (strcmp(tp->name, name) == 0) {
2381 /* this is the dude we want */
2389 /* zero out all the logs in the set */
2391 struct afs_icl_set *setp;
2396 struct afs_icl_log *logp;
2398 for (i = 0; i < ICL_LOGSPERSET; i++) {
2399 logp = setp->logs[i];
2402 tcode = icl_ZeroLog(logp);
2404 code = tcode; /* save the last bad one */
2411 icl_EnumerateSets(aproc, arock)
2415 register struct afs_icl_set *tp, *np;
2416 register afs_int32 code;
2419 for (tp = icl_allSets; tp; tp = np) {
2420 tp->refCount++; /* hold this guy */
2421 code = (*aproc) (tp->name, arock, tp);
2422 np = tp->nextp; /* tp may disappear next, but not np */
2423 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
2431 icl_AddLogToSet(setp, newlogp)
2432 struct afs_icl_set *setp;
2433 struct afs_icl_log *newlogp;
2437 struct afs_icl_log *logp;
2439 for (i = 0; i < ICL_LOGSPERSET; i++) {
2440 if (!setp->logs[i]) {
2441 setp->logs[i] = newlogp;
2443 icl_LogHold(newlogp);
2444 if (!(setp->states & ICL_SETF_FREED)) {
2445 /* bump up the number of sets using the log */
2446 icl_LogUse(newlogp);
2454 icl_SetSetStat(setp, op)
2455 struct afs_icl_set *setp;
2460 struct afs_icl_log *logp;
2463 case ICL_OP_SS_ACTIVATE: /* activate a log */
2465 * If we are not already active, see if we have released
2466 * our demand that the log be allocated (FREED set). If
2467 * we have, reassert our desire.
2469 if (!(setp->states & ICL_SETF_ACTIVE)) {
2470 if (setp->states & ICL_SETF_FREED) {
2471 /* have to reassert desire for logs */
2472 for (i = 0; i < ICL_LOGSPERSET; i++) {
2473 logp = setp->logs[i];
2480 setp->states &= ~ICL_SETF_FREED;
2482 setp->states |= ICL_SETF_ACTIVE;
2487 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
2488 /* this doesn't require anything beyond clearing the ACTIVE flag */
2489 setp->states &= ~ICL_SETF_ACTIVE;
2493 case ICL_OP_SS_FREE: /* deassert design for log */
2495 * if we are already in this state, do nothing; otherwise
2496 * deassert desire for log
2498 if (setp->states & ICL_SETF_ACTIVE)
2501 if (!(setp->states & ICL_SETF_FREED)) {
2502 for (i = 0; i < ICL_LOGSPERSET; i++) {
2503 logp = setp->logs[i];
2506 icl_LogFreeUse(logp);
2510 setp->states |= ICL_SETF_FREED;
2523 struct afs_icl_log *afs_icl_allLogs = 0;
2525 /* hold and release logs */
2527 register struct afs_icl_log *logp;
2533 /* hold and release logs, called with lock already held */
2535 register struct afs_icl_log *logp;
2541 /* keep track of how many sets believe the log itself is allocated */
2543 register struct afs_icl_log *logp;
2545 if (logp->setCount == 0) {
2546 /* this is the first set actually using the log -- allocate it */
2547 if (logp->logSize == 0) {
2548 /* we weren't passed in a hint and it wasn't set */
2549 logp->logSize = ICL_DEFAULT_LOGSIZE;
2552 (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logp->logSize);
2558 /* decrement the number of real users of the log, free if possible */
2559 icl_LogFreeUse(logp)
2560 register struct afs_icl_log *logp;
2562 if (--logp->setCount == 0) {
2563 /* no more users -- free it (but keep log structure around) */
2564 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2565 logp->firstUsed = logp->firstFree = 0;
2566 logp->logElements = 0;
2572 /* set the size of the log to 'logSize' */
2573 icl_LogSetSize(logp, logSize)
2574 register struct afs_icl_log *logp;
2578 /* nothing to worry about since it's not allocated */
2579 logp->logSize = logSize;
2582 logp->firstUsed = logp->firstFree = 0;
2583 logp->logElements = 0;
2585 /* free and allocate a new one */
2586 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2587 logp->datap = (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logSize);
2588 logp->logSize = logSize;
2594 /* free a log. Called with icl_lock locked. */
2596 register struct afs_icl_log *logp;
2598 register struct afs_icl_log **lpp, *tp;
2600 for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2602 /* found the dude we want to remove */
2604 osi_Free(logp->name, 1 + strlen(logp->name));
2605 osi_Free(logp->datap, logp->logSize * sizeof(afs_int32));
2606 osi_Free(logp, sizeof(struct icl_log));
2607 break; /* won't find it twice */
2613 /* do the release, watching for deleted entries */
2615 register struct afs_icl_log *logp;
2617 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2618 icl_ZapLog(logp); /* destroys logp's lock! */
2623 /* do the release, watching for deleted entries, log already held */
2625 register struct afs_icl_log *logp;
2627 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2628 icl_ZapLog(logp); /* destroys logp's lock! */
2633 /* zero out the log */
2635 icl_ZeroLog(register struct afs_icl_log *logp)
2637 logp->firstUsed = logp->firstFree = 0;
2638 logp->logElements = 0;
2642 /* free a log entry, and drop its reference count */
2644 register struct afs_icl_log *logp;
2646 logp->states |= ICL_LOGF_DELETED;
2653 icl_EnumerateLogs(int (*aproc)
2654 (char *name, char *arock, struct afs_icl_log * tp),
2657 register struct afs_icl_log *tp;
2658 register afs_int32 code;
2661 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2662 tp->refCount++; /* hold this guy */
2663 code = (*aproc) (tp->name, arock, tp);
2664 if (--tp->refCount == 0)
2673 afs_icl_bulkSetinfo_t *
2676 unsigned int infoSize;
2679 sizeof(afs_icl_bulkSetinfo_t) + (ICL_RPC_MAX_SETS -
2680 1) * sizeof(afs_icl_setinfo_t);
2682 setInfo = (afs_icl_bulkSetinfo_t *) malloc(infoSize);
2684 (void)fprintf(stderr,
2685 "Could not allocate the memory for bulk set info structure\n");
2689 memset((char *)setInfo, 0, infoSize);
2694 afs_icl_bulkLoginfo_t *
2697 unsigned int infoSize;
2700 sizeof(afs_icl_bulkLoginfo_t) + (ICL_RPC_MAX_LOGS -
2701 1) * sizeof(afs_icl_loginfo_t);
2703 logInfo = (afs_icl_bulkLoginfo_t *) malloc(infoSize);
2705 (void)fprintf(stderr,
2706 "Could not allocate the memory for bulk log info structure\n");
2711 memset((char *)logInfo, 0, infoSize);
2718 register struct cmd_syndesc *as;
2723 afs_int32 waitTime = 10 /* seconds */ ;
2727 FILE *outfp = stdout;
2729 struct cmd_item *itemp;
2731 if (geteuid() != 0) {
2732 printf("fstrace must be run as root\n");
2736 if (as->parms[3].items) {
2737 if (!as->parms[1].items) {
2738 (void)fprintf(stderr, "-sleep can only be used with -follow\n");
2741 waitTime = strtol(as->parms[3].items->data, NULL, 0);
2744 if (as->parms[2].items) {
2745 /* try to open the specified output file */
2746 if ((outfp = fopen(as->parms[2].items->data, "w")) == NULL) {
2747 (void)fprintf(stderr, "Cannot open file '%s' for writing\n",
2748 as->parms[2].items->data);
2752 #ifdef AFS_SGI64_ENV
2753 startTime = time((time_t *) 0);
2755 startTime = time(0);
2757 (void)fprintf(outfp, "AFS Trace Dump -\n\n Date: %s\n",
2760 if (as->parms[0].items) {
2761 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2762 tcode = icl_DumpKernel(outfp, itemp->data);
2764 (void)fprintf(stderr, "Unable to dump set %s (errno = %d)\n",
2765 itemp->data, errno);
2769 } else if (as->parms[1].items) {
2770 logname = as->parms[1].items->data;
2771 code = icl_TailKernel(outfp, logname, waitTime);
2773 (void)fprintf(stderr,
2774 "Error tailing kernel log '%s' (errno = %d)\n",
2778 code = icl_DumpKernel(outfp, NULL);
2780 (void)fprintf(outfp, "\nAFS Trace Dump - %s\n",
2781 code ? "FAILED" : "Completed");
2783 if (outfp != stdout)
2784 (void)fclose(outfp);
2792 struct cmd_syndesc *dumpSyntax;
2795 cmd_CreateSyntax("dump", DoDump, (char *)NULL, "dump AFS trace logs");
2796 (void)cmd_AddParm(dumpSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2797 (void)cmd_AddParm(dumpSyntax, "-follow", CMD_SINGLE, CMD_OPTIONAL,
2799 (void)cmd_AddParm(dumpSyntax, "-file", CMD_SINGLE, CMD_OPTIONAL,
2801 (void)cmd_AddParm(dumpSyntax, "-sleep", CMD_SINGLE, CMD_OPTIONAL,
2802 "seconds_between_reads");
2806 DoShowLog(as, arock)
2807 register struct cmd_syndesc *as;
2810 afs_int32 retVal = 0;
2815 struct cmd_item *itemp;
2817 if (geteuid() != 0) {
2818 printf("fstrace must be run as root\n");
2821 if (as->parms[2].items)
2824 if (as->parms[0].items) {
2825 /* enumerate logs for the specified sets */
2826 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2827 (void)fprintf(stdout, "Logs for set '%s':\n", itemp->data);
2828 code = icl_ListLogsBySet(stdout, itemp->data, int32flg);
2830 (void)fprintf(stderr,
2831 "Error in enumerating set %s (errno = %d)\n",
2832 itemp->data, errno);
2836 } else if (as->parms[1].items) {
2837 /* print out log information */
2838 for (itemp = as->parms[1].items; itemp; itemp = itemp->next) {
2839 code = icl_GetLogsize(itemp->data, &logSize, &allocated);
2841 (void)fprintf(stdout, "%s : %d kbytes (%s)\n", itemp->data,
2843 allocated ? "allocated" : "unallocated");
2845 (void)fprintf(stderr,
2846 "Could not find log '%s' (errno = %d)\n",
2847 itemp->data, errno);
2853 (void)fprintf(stdout, "Available logs:\n");
2854 code = icl_ListLogs(stdout, int32flg);
2856 (void)fprintf(stderr, "Error in listing logs (errno = %d)\n",
2868 struct cmd_syndesc *showSyntax;
2871 cmd_CreateSyntax("lslog", DoShowLog, (char *)NULL,
2872 "list available logs");
2873 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2874 (void)cmd_AddParm(showSyntax, "-log", CMD_LIST, CMD_OPTIONAL, "log_name");
2875 (void)cmd_AddParm(showSyntax, "-long", CMD_FLAG, CMD_OPTIONAL, "");
2879 DoShowSet(as, arock)
2880 register struct cmd_syndesc *as;
2883 afs_int32 retVal = 0;
2886 struct cmd_item *itemp;
2888 if (geteuid() != 0) {
2889 printf("fstrace must be run as root\n");
2892 if (as->parms[0].items) {
2893 /* print information on the specified sets */
2894 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2895 code = icl_GetSetState(itemp->data, &state);
2897 (void)fprintf(stderr,
2898 "Error getting status on set %s (errno = %d)\n",
2899 itemp->data, errno);
2902 (void)fprintf(stdout, "Set %s: %s%s%s\n", itemp->data,
2903 (state & ICL_SETF_ACTIVE) ? "active" :
2905 (state & ICL_SETF_FREED) ? " (dormant)" : "",
2906 (state & ICL_SETF_PERSISTENT) ? " persistent" :
2911 (void)fprintf(stdout, "Available sets:\n");
2912 code = icl_ListSets(stdout);
2914 (void)fprintf(stderr, "Error in listing sets (errno = %d)\n",
2926 struct cmd_syndesc *showSyntax;
2929 cmd_CreateSyntax("lsset", DoShowSet, (char *)NULL,
2930 "list available event sets");
2931 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2936 register struct cmd_syndesc *as;
2939 afs_int32 retVal = 0;
2941 struct cmd_item *itemp;
2943 if (geteuid() != 0) {
2944 printf("fstrace must be run as root\n");
2947 if (as->parms[0].items) {
2948 /* clear logs for the specified sets */
2949 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2950 code = icl_ClearSet(itemp->data);
2952 (void)fprintf(stderr,
2953 "Error in clearing set %s (errno = %d)\n",
2954 itemp->data, errno);
2958 } else if (as->parms[1].items) {
2959 /* clear specified log */
2960 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2961 code = icl_ClearLog(itemp->data);
2963 (void)fprintf(stderr,
2964 "Error in clearing log %s (errno = %d)\n",
2965 itemp->data, errno);
2970 /* clear all logs */
2971 code = icl_ClearAll();
2973 (void)fprintf(stderr, "Error in clearing logs (errno = %d)\n",
2985 struct cmd_syndesc *clearSyntax;
2988 cmd_CreateSyntax("clear", DoClear, (char *)NULL,
2989 "clear logs by logname or by event set");
2990 (void)cmd_AddParm(clearSyntax, "-set", CMD_LIST, CMD_OPTIONAL,
2992 (void)cmd_AddParm(clearSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
2998 register struct cmd_syndesc *as;
3001 afs_int32 retVal = 0;
3006 struct cmd_item *itemp;
3008 if (geteuid() != 0) {
3009 printf("fstrace must be run as root\n");
3012 if (as->parms[1].items) {
3013 op = ICL_OP_SS_ACTIVATE;
3014 operation = "active";
3015 } else if (as->parms[2].items) {
3016 op = ICL_OP_SS_DEACTIVATE;
3017 operation = "inactive";
3018 } else if (as->parms[3].items) {
3019 op = ICL_OP_SS_DEACTIVATE;
3020 operation = "inactive";
3023 /* assume active" */
3024 op = ICL_OP_SS_ACTIVATE;
3025 operation = "active";
3028 if (as->parms[0].items) {
3029 /* activate specified sets */
3030 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
3031 code = icl_ChangeSetState(itemp->data, op);
3033 (void)fprintf(stderr,
3034 "cannot set state of %s to %s (errno = %d)\n",
3035 itemp->data, operation, errno);
3037 } else if (doFree) {
3038 /* try to make it dormant as well */
3039 code = icl_ChangeSetState(itemp->data, ICL_OP_SS_FREE);
3041 (void)fprintf(stderr,
3042 "cannot set state of %s to dormant (errno = %d)\n",
3043 itemp->data, errno);
3050 code = icl_ChangeAllSetState(op);
3052 (void)fprintf(stderr,
3053 "cannot set the state of all sets to %s (errno = %d)\n",
3056 } else if (doFree) {
3057 /* try to make it dormant as well */
3058 code = icl_ChangeAllSetState(ICL_OP_SS_FREE);
3060 (void)fprintf(stderr,
3061 "cannot set the state of all sets to dormant (errno = %d)\n",
3074 struct cmd_syndesc *setSyntax;
3077 cmd_CreateSyntax("setset", DoSet, (char *)NULL,
3078 "set state of event sets");
3079 (void)cmd_AddParm(setSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
3080 (void)cmd_AddParm(setSyntax, "-active", CMD_FLAG, CMD_OPTIONAL, "");
3081 (void)cmd_AddParm(setSyntax, "-inactive", CMD_FLAG, CMD_OPTIONAL, "");
3082 (void)cmd_AddParm(setSyntax, "-dormant", CMD_FLAG, CMD_OPTIONAL, "");
3087 register struct cmd_syndesc *as;
3090 afs_int32 retVal = 0;
3092 afs_int32 bufferSize;
3093 struct cmd_item *itemp;
3095 if (geteuid() != 0) {
3096 printf("fstrace must be run as root\n");
3099 /* get buffer size */
3100 bufferSize = atoi(as->parms[1].items->data);
3101 bufferSize *= BUFFER_MULTIPLIER;
3102 if (bufferSize == 0)
3103 bufferSize = ICL_DEFAULT_LOGSIZE;
3105 /* set the size of the specified logs */
3106 if (itemp = as->parms[0].items) {
3107 for (; itemp; itemp = itemp->next) {
3108 code = icl_ChangeLogSize(itemp->data, bufferSize);
3110 (void)fprintf(stderr,
3111 "Error in changing log %s buffer size (errno = %d)\n",
3112 itemp->data, errno);
3117 /* Use the only current support log, "cmfx" */
3118 code = icl_ChangeLogSize("cmfx", bufferSize);
3120 (void)fprintf(stderr,
3121 "Error in changing log cmfx buffer size (errno = %d)\n",
3133 struct cmd_syndesc *setsizeSyntax;
3136 cmd_CreateSyntax("setlog", DoResize, (char *)NULL,
3137 "set the size of a log");
3138 (void)cmd_AddParm(setsizeSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
3140 (void)cmd_AddParm(setsizeSyntax, "-buffersize", CMD_SINGLE, CMD_REQUIRED,
3141 "1-kilobyte_units");
3144 #include "AFS_component_version_number.c"
3150 setlocale(LC_ALL, "");
3151 #ifdef AFS_SGI62_ENV
3152 set_kernel_sizeof_long();
3155 /* set up user interface then dispatch */
3163 return (cmd_Dispatch(argc, argv));
3166 #include "AFS_component_version_number.c"
3170 printf("fstrace is NOT supported for this OS\n");