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] = "";
85 RegisterIclDumpFileName(name)
88 (void)sprintf(dumpFileName, "icl.%.250s", name);
91 /* define globals to use for bulk info */
92 afs_icl_bulkSetinfo_t *setInfo = (afs_icl_bulkSetinfo_t *) 0;
93 afs_icl_bulkLoginfo_t *logInfo = (afs_icl_bulkLoginfo_t *) 0;
95 struct afs_icl_set *icl_allSets = 0;
99 /* given a type and an address, get the size of the thing
103 icl_GetSize(type, addr)
111 ICL_SIZEHACK(type, addr);
115 /* Check types in printf string "bufferp", making sure that each
116 * is compatible with the corresponding parameter type described
117 * by typesp. Also watch for prematurely running out of parameters
118 * before the string is gone.
120 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
122 CheckTypes(bufferp, typesp, typeCount, outMsgBuffer)
134 for (tc = *bufferp;; outMsgBuffer++, tc = *(++bufferp)) {
137 /* hit end of string. We win as long as we aren't
146 inPercent = 1 - inPercent;
150 if (tc >= '0' && tc <= '9') {
151 /* skip digits in % string */
156 /* 'l' is a type modifier. */
160 /* otherwise, we've finally gotten to the type-describing
161 * character. Make sure there's a type descriptor, and then
162 * check the type descriptor.
166 return 0; /* no more type descriptors left */
168 if (typesp[tix] != 1) /* not a string descriptor */
171 *outMsgBuffer = (char)1;
173 if (tc == 'u' || tc == 'x' || tc == 'd' || tc == 'o') {
174 if (typesp[tix] != 0)
175 return 0; /* not an integer descriptor */
179 *outMsgBuffer = (char)2;
182 *outMsgBuffer = (char)3;
185 *outMsgBuffer = (char)4;
189 *outMsgBuffer = (char)5;
193 /* otherwise we're fine, so eat this descriptor */
199 #else /* AFS_SGI61_ENV */
201 CheckTypes(bufferp, typesp, typeCount)
212 for (tc = *bufferp;; tc = *(++bufferp)) {
214 /* hit end of string. We win as long as we aren't
223 inPercent = 1 - inPercent;
227 if (tc >= '0' && tc <= '9')
228 continue; /* skip digits in % string */
229 /* otherwise, we've finally gotten to the type-describing
230 * character. Make sure there's a type descriptor, and then
231 * check the type descriptor.
235 return 0; /* no more type descriptors left */
236 if (tc == 's' && typesp[tix] != 1) /* not a string descriptor */
238 if ((tc == 'u' || tc == 'l' || tc == 'x' || tc == 'd')
239 && (typesp[tix] != 0))
240 return 0; /* not an integer descriptor */
241 /* otherwise we're fine, so eat this descriptor */
247 #endif /* AFS_SGI61_ENV */
249 /* display a single record.
250 * alp points at the first word in the array to be interpreted
251 * rsize gives the # of words in the array
253 #if defined(AFS_SGI61_ENV) && !defined(AFS_SGI62_ENV)
254 #define uint64_t long long
257 DisplayRecord(outFilep, alp, rsize)
259 register afs_int32 *alp;
262 char msgBuffer[1024];
263 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
264 char outMsgBuffer[1024];
266 uint64_t printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
267 char *printfStrings[ICL_MAXEXPANSION * /* max parms */ 4];
268 #else /* AFS_SGI61_ENV */
269 long printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
270 #endif /* AFS_SGI61_ENV */
271 int printfTypes[ICL_MAXEXPANSION * 4];
277 int pix; /* index in alp */
278 int pfpix; /* index in printfParms */
279 int pftix; /* index in printfTypes */
281 int printed; /* did we print the string yet? */
285 /* decode parameters */
286 temp = alp[0]; /* type encoded in low-order 24 bits, t0 high */
292 for (i = 0; i < 4 * ICL_MAXEXPANSION; i++)
294 /* decode each parameter, getting addrs for afs_hyper_t and strings */
295 for (i = 0; !done && i < 4; i++) {
296 type = (temp >> (18 - i * 6)) & 0x3f;
302 case ICL_TYPE_POINTER:
303 printfTypes[pftix++] = 0;
304 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
305 printfParms[pfpix] = alp[pix];
306 printfParms[pfpix] &= 0xffffffff;
307 if (afs_64bit_kernel) {
308 printfParms[pfpix] <<= 32;
309 printfParms[pfpix] |= alp[pix + 1];
311 #elif defined(AFS_OSF_ENV)
312 printfParms[pfpix] = alp[pix + 1];
313 printfParms[pfpix] |= (alp[pix] <<= 32);
314 #else /* !AFS_OSF_ENV && !AFS_SGI61_ENV */
315 printfParms[pfpix] = alp[pix];
320 printfTypes[pftix++] = 0;
321 printfParms[pfpix++] = alp[pix];
325 printfTypes[pftix++] = 0;
326 printfParms[pfpix++] = alp[pix];
327 printfTypes[pftix++] = 0;
328 printfParms[pfpix++] = alp[pix + 1];
331 printfTypes[pftix++] = 0;
332 printfParms[pfpix++] = alp[pix];
333 printfTypes[pftix++] = 0;
334 printfParms[pfpix++] = alp[pix + 1];
335 printfTypes[pftix++] = 0;
336 printfParms[pfpix++] = alp[pix + 2];
337 printfTypes[pftix++] = 0;
338 printfParms[pfpix++] = alp[pix + 3];
340 case ICL_TYPE_STRING:
341 printfTypes[pftix++] = 1;
343 printfStrings[pfpix++] = (char *)&alp[pix];
344 #else /* AFS_SGI64_ENV */
345 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
346 printfStrings[pfpix++] = (char *)&alp[pix];
347 #else /* AFS_SGI61_ENV */
348 printfParms[pfpix++] = (long)&alp[pix];
349 #endif /* AFS_SGI61_ENV */
350 #endif /* AFS_SGI64_ENV */
352 case ICL_TYPE_UNIXDATE:
354 printfParms[pfpix++] = (long)ctime(&tmv);
357 printf("DisplayRecord: Bad type %d in decode switch.\n", type);
364 pix += icl_GetSize(type, (char *)&alp[pix]);
367 /* next, try to decode the opcode into a printf string */
368 dce1_error_inq_text(alp[1], msgBuffer, &status);
370 /* if we got a string back, and it is compatible with the
371 * parms we've got, then print it.
375 #if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
376 if (CheckTypes(msgBuffer, printfTypes, pftix, outMsgBuffer)) {
377 /* we have a string to use, but it ends "(dfs / zcm)",
378 * so we remove the extra gunk.
380 j = strlen(outMsgBuffer);
382 outMsgBuffer[j - 11] = 0;
386 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
387 alp[3] % 1000000, alp[2]);
388 for (i = 0; i < j; i++) {
389 if ((int)outMsgBuffer[i] > 5)
390 fputc(outMsgBuffer[i], outFilep);
392 switch (outMsgBuffer[i]) {
396 fprintf(outFilep, "%s", printfStrings[pfpix++]);
398 case 2: /* signed integer */
399 fprintf(outFilep, "%lld", printfParms[pfpix++]);
401 case 3: /* unsigned integer */
402 fprintf(outFilep, "%llu", printfParms[pfpix++]);
404 case 4: /* octal integer */
405 fprintf(outFilep, "%llo", printfParms[pfpix++]);
407 case 5: /* hex integer */
408 fprintf(outFilep, "%llx", printfParms[pfpix++]);
412 "fstrace: Bad char %d in outMsgBuffer for parm %d\n",
413 outMsgBuffer[i], pfpix);
414 fprintf(outFilep, "fstrace: msgBuffer='%s'\n",
420 fprintf(outFilep, "\n");
423 #else /* AFS_SGI61_ENV */
424 if (CheckTypes(msgBuffer, printfTypes, pftix)) {
425 /* we have a string to use, but it ends "(dfs / zcm)",
426 * so we remove the extra gunk.
428 j = strlen(msgBuffer);
430 msgBuffer[j - 11] = 0;
431 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3] / 1000000,
432 alp[3] % 1000000, alp[2]);
433 fprintf(outFilep, msgBuffer, printfParms[0], printfParms[1],
434 printfParms[2], printfParms[3], printfParms[4],
435 printfParms[5], printfParms[6], printfParms[7],
436 printfParms[8], printfParms[9], printfParms[10],
437 printfParms[11], printfParms[12], printfParms[13],
438 printfParms[14], printfParms[15]);
439 fprintf(outFilep, "\n");
442 #endif /* AFS_SGI61_ENV */
444 fprintf(outFilep, "Type mismatch, using raw print.\n");
445 fprintf(outFilep, "%s", msgBuffer);
449 if (alp[1] == ICL_INFO_TIMESTAMP) {
451 fprintf(outFilep, "time %d.%06d, pid %u: %s\n", alp[3] / 1000000,
452 alp[3] % 1000000, alp[2], ctime(&tmv));
454 fprintf(outFilep, "raw op %d, time %d.%06d, pid %u\n", alp[1],
455 alp[3] / 1000000, alp[3] % 1000000, alp[2]);
456 /* now decode each parameter and print it */
459 for (i = 0; !done && i < 4; i++) {
460 type = (temp >> (18 - i * 6)) & 0x3f;
466 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
470 tempParam = alp[pix];
472 tempParam |= alp[pix + 1];
473 fprintf(outFilep, "p%d:%lld ", i, tempParam);
474 #else /* AFS_SGI61_ENV */
475 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
476 #endif /* AFS_SGI61_ENV */
478 case ICL_TYPE_POINTER:
480 tempParam = alp[pix];
482 tempParam |= alp[pix + 1];
483 fprintf(outFilep, "p%d:0x%llx ", i, tempParam);
484 #else /* AFS_SGI61_ENV */
485 fprintf(outFilep, "p%d:0x%x ", i, alp[pix]);
486 #endif /* AFS_SGI61_ENV */
490 fprintf(outFilep, "p%d:%x.%x ", i, alp[pix],
494 fprintf(outFilep, "p%d:%d.%d.%d.%d ", i, alp[pix],
495 alp[pix + 1], alp[pix + 2], alp[pix + 3]);
497 case ICL_TYPE_STRING:
498 fprintf(outFilep, "p%d:%s ", i, (char *)&alp[pix]);
500 case ICL_TYPE_UNIXDATE:
502 fprintf(outFilep, "p%d:%s ", i,
507 ("DisplayRecord: Bad type %d in raw print switch.\n",
515 pix += icl_GetSize(type, (char *)&alp[pix]);
518 fprintf(outFilep, "\n"); /* done with line */
528 #include <nl_types.h>
530 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
532 static nl_catd catopen1();
534 static nl_catd _do1_open();
535 static nl_catd cat_already_open();
536 static int make_sets();
537 static FILE *open1catfile();
538 static void add_open_cat();
539 static void cat_hard_close();
540 extern char *strchr();
542 static int catpid[NL_MAXOPEN];
543 static CATD *catsopen[NL_MAXOPEN];
544 #define PATH_FORMAT "/usr/lib/nls/msg/%L/%N:/etc/nls/msg/%L/%N"
545 #define DEFAULT_LANG "C"
546 #define TOO_MANY_HOLES(num_holes, num_non_holes) \
547 (((num_holes) > 100) && ((num_holes) > (num_non_holes)))
553 /*---- n: the number of bytes to be malloc'ed ----*/
557 t = (char *)malloc(n);
559 printf("Failed to get mem\n");
569 /*---- char *cat: the name of the cat to be opened ----*/
570 /*---- int dummy: dummy variable ----*/
574 nl_catd _do_open(); /*---- routine that actually opens
581 if (catd = cat_already_open(cat)) {
582 catd->_count = catd->_count + 1;
586 catd = (CATD *) rmalloc(sizeof(CATD));
589 catd->_name = (char *)rmalloc(strlen(cat) + 1);
590 if (catd->_name == NULL)
592 strcpy(catd->_name, cat);
594 catd->_magic = CAT_MAGIC;
596 #ifndef AFS_OSF20_ENV
597 catd->_pid = getpid();
600 if (_do1_open(catd) != CATD_ERR)
615 /*---- pointer to the partially set up cat descriptor ----*/
618 int make_sets(); /*---- routine to unpack the sets into
619 fast acccess mode ----*/
620 void add_open_cat(); /*---- routine to keep a list of
623 int i; /*---- Misc counter(s) used for loop */
630 catd->_fd = open1catfile(catd->_name);
634 fread((void *)&magic, (size_t) 4, (size_t) 1, catd->_fd);
635 if (magic != CAT_MAGIC) {
636 printf("Magic was %x instead of %x -> %x\n", magic, CAT_MAGIC,
644 /* if ((catd->_mem = shmat((int)fileno(catd->_fd), NULL, SHM_MAP | SHM_RDONLY))
645 == (char * )ERR ) { */
647 if (1) { /* disable the shmat, share memory segemnt */
649 /*______________________________________________________________________
650 If the file can not be mapped then simulate mapping for the index
651 table so that make_sets cat set things up. (rmalloc an area big
652 enough for the index table and read the whole thing in)
653 ______________________________________________________________________*/
655 /* reset the file pointer to the beginning of catalog */
656 fseek(catd->_fd, (long)0, 0);
658 /* malloc the header, if fails return error */
659 catd->_hd = (struct _header *)rmalloc(sizeof(struct _header));
660 if (catd->_hd == NULL)
663 /* read in the whole header */
664 fread((void *)catd->_hd, (size_t) sizeof(struct _header), (size_t) 1,
667 /* cs is a dummpy to hold a set temperorily. The purpose of */
668 /* this for loop is to fread the whole catalog so that the */
669 /* file pointer will be moved to the end of the catalog. */
670 for (i = 0; i < catd->_hd->_n_sets; i++) {
671 fread((void *)&cs, (size_t) 4, (size_t) 1, catd->_fd);
672 fseek(catd->_fd, (long)(cs._n_msgs * sizeof(struct _msgptr)), 1);
675 /* after the for loop, ftell returns the byte offset of the */
676 /* end of the catalog relative to the begining of the file. */
677 /* i.e. i contains the byte offset of the whole catalog. */
678 i = ftell(catd->_fd);
680 /* malloc _mem as a temp pointer to hold the entire catalog. */
681 catd->_mem = (char *)rmalloc(i);
682 if (catd->_mem == NULL)
685 /* reset the file pointer to the begining. */
686 fseek(catd->_fd, (long)0, 0);
688 /* read in the whole catalog into _mem */
689 fread((void *)catd->_mem, (size_t) i, (size_t) 1, catd->_fd);
692 * If there aren't many holes in the set numbers,
693 * fully expand the compacted set array from the
694 * catalog. Then in catgets(), we'll be able to use
695 * the set number to index directly into the expanded
698 * If there are a lot of holes, leave the set array
699 * compacted. In catgets(), we'll search through it
700 * for the requested set.
703 num_holes = catd->_hd->_setmax - catd->_hd->_n_sets;
704 if (!TOO_MANY_HOLES(num_holes, catd->_hd->_n_sets)) {
705 catd->_sets_expanded = TRUE;
706 catd->_n_sets = catd->_hd->_setmax;
708 catd->_sets_expanded = FALSE;
709 catd->_n_sets = catd->_hd->_n_sets - 1;
712 /* malloc one extra set more than the max. set index */
714 (struct _catset *)rmalloc((catd->_n_sets + 1) *
715 sizeof(struct _catset));
716 if (catd->_set == NULL)
719 /* save the max. set number in catd->_setmax */
720 catd->_setmax = catd->_hd->_setmax;
721 /* call make_set to malloc memory for every message */
722 if (make_sets(catd) == -1)
730 /*______________________________________________________________________
731 Normal mapping has occurred, set a few things up and call make_sets
732 ______________________________________________________________________*/
734 catd->_hd = (struct _header *)(catd->_mem);
735 catd->_setmax = catd->_hd->_setmax;
737 (struct _catset *)rmalloc((catd->_hd->_setmax + 1) *
738 sizeof(struct _catset));
739 if (catd->_set == NULL)
741 if (make_sets(catd) == -1)
752 /*---- catd to be added to the list of catalogs ----*/
755 int i = 0; /*---- Misc counter(s) used for loops ----*/
756 while (i < NL_MAXOPEN && catsopen[i]) {
757 if (!strcmp(catd->_name, catsopen[i]->_name)
758 #ifndef AFS_OSF20_ENV
759 && getpid() == catsopen[i]->_pid)
763 return; /*---- The catalog is already here ----*/
767 if (i < NL_MAXOPEN) {
769 catpid[i] = getpid();
778 * FUNCTION: Expands the compacted version of the catalog index table into
779 * the fast access memory version.
781 * EXECUTION ENVIRONMENT:
783 * Make_set executes under a process.
793 struct _catset *cset;
794 char *base = catd->_mem;
795 int n_sets = catd->_hd->_n_sets;
796 int i; /*---- Misc counter(s) used for loops ----*/
797 int j; /*---- Misc counter(s) used for loops ----*/
798 int msgmax; /*---- The maximum number of _messages in a set ----*/
799 char *cmpct_set_ptr; /*---- pointer into the index table ----*/
800 struct _catset cs; /*---- used to look at the sets in the table -*/
803 cmpct_set_ptr = base + sizeof(struct _header);
805 for (i = 0; i < n_sets; i++) {
806 /* loop through each compacted set */
808 cs = *(struct _catset *)cmpct_set_ptr;
809 /* set the _catset ptr to the base of the current
813 (struct _msgptr *)(cmpct_set_ptr + 2 * sizeof(unsigned short));
814 /* set the ms array ptr to the base of
815 * compacted array of _msgptr's */
818 (catd->_sets_expanded) ? &catd->_set[cs._setno] : &catd->_set[i];
821 * If there aren't many holes in the message numbers,
822 * fully expand the compacted message array from the
823 * catalog. Then in catgets(), we'll be able to use
824 * the message number to index directly into the
827 * If there are many holes, leave the message array
828 * compacted. In catgets(), we'll search through it
829 * for the requested message.
832 msgmax = cs._mp[cs._n_msgs - 1]._msgno;
833 num_holes = msgmax - cs._n_msgs;
834 if (!TOO_MANY_HOLES(num_holes, cs._n_msgs)) {
835 cset->_msgs_expanded = TRUE;
836 cset->_n_msgs = msgmax;
838 cset->_msgs_expanded = FALSE;
839 cset->_n_msgs = cs._n_msgs - 1;
843 (struct _msgptr *)rmalloc((1 + cset->_n_msgs) *
844 sizeof(struct _msgptr));
845 if (cset->_mp == NULL)
849 (char **)rmalloc((1 + cset->_n_msgs) * sizeof(char *));
850 if (cset->_msgtxt == NULL)
853 if (cset->_msgs_expanded) {
854 for (j = 0; j < cs._n_msgs; j++) {
855 cset->_mp[cs._mp[j]._msgno] = cs._mp[j];
858 for (j = 0; j < cs._n_msgs; j++) {
859 cset->_mp[j] = cs._mp[j];
863 cset->_setno = cs._setno;
864 /* Superfluous but should have the correct data. Increment
865 * the base of the set pointer. */
868 2 * sizeof(unsigned short) + cs._n_msgs * sizeof(struct _msgptr);
879 * FUNCTION: Opens a catalog file, looking in the language path first (if
880 * there is no slash) and returns a pointer to the file stream.
882 * EXECUTION ENVIRONMENT:
884 * Opencatfile executes under a process.
886 * RETURNS: Returns a pointer to the file stream, and a NULL pointer on
894 extern char *getenv();
895 char fl[PATH_MAX]; /*---- place to hold full path ----*/
896 char *nlspath; /*---- pointer to the nlspath val ----*/
897 FILE *fp; /*---- file pointer ----*/
898 char cpth[PATH_MAX]; /*---- current value of nlspath ----*/
900 char *fulllang; /* %L language value */
901 char lang[PATH_MAX]; /* %l language value */
902 char *territory; /* %t language value */
903 char *codeset; /* %c language value */
904 char *ptr; /* for decompose of $LANG */
909 char outptr[PATH_MAX];
912 if (strchr(file, '/')) {
913 if ((fp = fopen(file, "r"))) {
914 fcntl(fileno(fp), F_SETFD, 1);
915 /* set the close-on-exec flag for
920 if (!(nlspath = getenv("NLSPATH")))
921 nlspath = PATH_FORMAT;
922 if (!(fulllang = getenv("LANG")))
923 fulllang = DEFAULT_LANG;
924 if (fulllang == DEFAULT_LANG)
925 nlspath = PATH_FORMAT; /* if fullang is C, use the
926 * the default nlspath: */
929 ** LANG is a composite of three fields:
930 ** language_territory.codeset
931 ** and we're going to break it into those
935 strcpy(lang, fulllang);
940 ptr = strchr(lang, '_');
944 ptr = strchr(territory, '.');
950 ptr = strchr(lang, '.');
960 while (*np && *np != ':')
963 if (*np) /*---- iff on a colon then advance --*/
971 while (*ptr != '\0') {
972 while ((*ptr != '\0') && (*ptr != '%')
973 && (nchars < PATH_MAX)) {
974 *(optr++) = *(ptr++);
1002 lenstr = strlen(str);
1004 if (nchars < PATH_MAX) {
1012 if (nchars >= PATH_MAX) {
1018 strcpy(cpth, outptr);
1019 } else { /*---- iff leading | trailing |
1020 adjacent colons ... --*/
1024 if (valid == 1 && (fp = fopen(cpth, "r"))) {
1025 fcntl(fileno(fp), F_SETFD, 1);
1026 /* set the close-on-exec flag for
1031 if (fp = fopen(file, "r")) {
1032 fcntl(fileno(fp), F_SETFD, 1);
1033 /* set the close-on-exec flag for
1047 * NAME: cat_already_open
1049 * FUNCTION: Checkes to see if a specific cat has already been opened.
1051 * EXECUTION ENVIRONMENT:
1053 * Cat_already_open executes under a process.
1055 * RETURNS: Returns a pointer to the existing CATD if one exists, and
1056 * a NULL pointer if no CATD exists.
1060 cat_already_open(cat)
1062 /*---- name of the catalog to be opened ----*/
1065 int i; /*---- Misc counter(s) used for loops ----*/
1067 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1068 #ifndef AFS_OSF20_ENV
1069 if (!strcmp(cat, catsopen[i]->_name) && getpid() == catsopen[i]->_pid) {
1071 if (!strcmp(cat, catsopen[i]->_name)) {
1073 return (catsopen[i]);
1081 catclose1(catd) /*---- the catd to be closed ----*/
1082 nl_catd catd; /*---- the catd to be closed ----*/
1088 if (catd == CATD_ERR)
1090 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1091 #ifndef AFS_OSF20_ENV
1092 if (catd == catsopen[i] && getpid() == catsopen[i]->_pid)
1094 if (catd == catsopen[i])
1098 if (i == NL_MAXOPEN || catsopen[i] == NULL)
1100 if (catd->_fd == (FILE *) NULL)
1101 /*---- return if this is an extra open or
1102 a bad catalog discriptor ----*/
1104 if (cat_already_open(catd->_name)) {
1105 if (catd->_count == 1) {
1106 cat_hard_close(catd);
1107 return (0); /*--- the last legal clsoe ---*/
1108 } else if (catd->_count > 1) {
1109 catd->_count = catd->_count - 1;
1110 return (0); /*--- a legal close ---*/
1112 return (-1); /*--- an extra illegal close ---*/
1119 cat_hard_close(catd)
1121 /*---- the catd to be closed ----*/
1124 int i; /*---- Misc counter(s) used for loops ----*/
1125 int j; /*---- Misc counter ----*/
1127 if (catd == CATD_ERR)
1130 /*______________________________________________________________________
1131 remove any entry for the catalog in the catsopen array
1132 ______________________________________________________________________*/
1134 for (i = 0; i < NL_MAXOPEN && catsopen[i]; i++) {
1135 if (catd == catsopen[i]) {
1136 for (; i < NL_MAXOPEN - 1; i++) {
1137 catsopen[i] = catsopen[i + 1];
1138 catpid[i] = catpid[i + 1];
1145 /*______________________________________________________________________
1146 close the cat and free up the memory
1147 ______________________________________________________________________*/
1148 if (catd->_mem == FALSE) {
1149 for (i = 0; i <= catd->_n_sets; i++) {
1150 if (catd->_set[i]._mp)
1151 free(catd->_set[i]._mp);
1152 /*---- free the _message pointer arrays ----*/
1154 if (catd->_set[i]._msgtxt) {
1155 for (j = 0; j <= catd->_set[i]._n_msgs; j++) {
1156 if (catd->_set[i]._msgtxt[j]) {
1157 /* free(catd->_set[i]._msgtxt[j]);*/
1160 if (catd->_set[i]._msgtxt)
1161 free(catd->_set[i]._msgtxt);
1167 fclose(catd->_fd); /*---- close the ctatlog ----*/
1169 free(catd->_set); /*---- free the sets ----*/
1171 free(catd->_name); /*---- free the name ----*/
1173 free(catd->_hd); /*---- free the header ----*/
1175 free(catd); /*---- free the catd ----*/
1179 _do1_read_msg(nl_catd catd, int setno, int msgno)
1181 /*---- catd: the catd of the catalog to be read from ----*/
1182 /*---- setno: the set number of the message ----*/
1183 /*---- msgno: the msgno of the message ----*/
1185 nl_catd catd1; /*--- catd for different process ----*/
1188 #ifndef AFS_OSF20_ENV
1189 if (getpid() == catd->_pid)
1193 return (_read1_msg(catd, setno, msgno));
1196 * Since our pid is different from the one in
1197 * catd, catd must have come from a catopen()
1198 * in our parent. We need a catd of our own.
1199 * The first time through here, the call to
1200 * catopen() creates a new catd and we try to
1201 * open its message catalog. After that, the
1202 * catopen() just retrieves the catd.
1204 if (((catd1 = catopen1(catd->_name, 0)) != CATD_ERR)
1205 && ((catd1->_fd == NL_FILE_CLOSED && _do1_open(catd1) != CATD_ERR)
1206 || (catd1->_fd != NL_FILE_UNUSED)))
1207 return (_read1_msg(catd1, setno, msgno));
1214 struct _catset *_cat1_get_catset();
1215 static struct _msgptr *_cat1_get_msgptr();
1217 _read1_msg(nl_catd catd, int setno, int msgno)
1219 struct _catset *set; /*--- ptr to set's _catset structure ---*/
1220 struct _msgptr *msg; /*--- ptr to msg's _msgptr structure ---*/
1221 char **msgtxt; /*--- temporary pointer to the message text
1224 set = _cat1_get_catset(catd, setno);
1226 msg = _cat1_get_msgptr(set, msgno);
1228 msgtxt = &set->_msgtxt[msg - set->_mp];
1229 if (1 /*!*msgtxt */ ) {
1230 *msgtxt = (char *)malloc(msg->_msglen + 1);
1234 fseek(catd->_fd, (long)msg->_offset, 0);
1236 ((void *)*msgtxt, (size_t) (msg->_msglen + 1), (size_t) 1,
1248 * NAME: compare_sets
1250 * FUNCTION: Compare function used by bsearch() in _cat_get_catset().
1253 * key - pointer to set number we're searching for
1254 * element - pointer to current _catset structure
1256 * RETURNS: Returns -1, 0, or 1, depending on whether the set number
1257 * is less than, equal to, or greater than the set number of
1258 * the _catset structure.
1263 compare_sets(const void *key, const void *element)
1265 int *setno = (int *)key;
1266 struct _catset *set = (struct _catset *)element;
1268 if (*setno < set->_setno)
1270 if (*setno > set->_setno)
1278 * NAME: _cat_get_catset
1280 * FUNCTION: Find a set in the catd->_set array. Assumes that the
1281 * sets in the array are sorted by increasing set number.
1284 * catd - catalog descripter obtained from catopen()
1285 * setno - message catalogue set number
1287 * RETURNS: Returns a pointer to the set on success.
1288 * On any error, returns NULL.
1293 _cat1_get_catset(nl_catd catd, int setno)
1295 struct _catset *set;
1297 if ((catd == (nl_catd) NULL) || (catd == CATD_ERR))
1298 return (struct _catset *)NULL;
1300 if (catd->_sets_expanded) {
1301 if ((setno < 0) || (setno > catd->_n_sets))
1302 return (struct _catset *)NULL;
1304 set = &catd->_set[setno];
1307 * Catch empty elements in the array. They aren't
1311 if (set->_mp == (struct _msgptr *)NULL)
1312 return (struct _catset *)NULL;
1315 (struct _catset *)bsearch((void *)&setno, catd->_set,
1317 sizeof(struct _catset), compare_sets);
1320 * Since the sets are compacted, there aren't any
1321 * empty elements in the array to check for.
1330 * NAME: compare_msgs
1332 * FUNCTION: Compare function used by bsearch() in _cat_get_msgptr().
1335 * key - pointer to message number we're searching for
1336 * element - pointer to current _msgptr structure
1338 * RETURNS: Returns -1, 0, or 1, depending on whether the message
1339 * number is less than, equal to, or greater than the message
1340 * number of the _msgptr structure.
1345 compare_msgs(const void *key, const void *element)
1347 int *msgno = (int *)key;
1348 struct _msgptr *msg = (struct _msgptr *)element;
1350 if (*msgno < msg->_msgno)
1352 if (*msgno > msg->_msgno)
1359 * NAME: _cat1_get_msgptr
1361 * FUNCTION: Find a message in a set's set->_mp array. Assumes that
1362 * the messages in the array are sorted by increasing
1366 * set - ptr to _catset structure
1367 * msgno - message catalogue message number
1369 * RETURNS: Returns a pointer to the message on success.
1370 * On any error, returns NULL.
1373 static struct _msgptr *
1374 _cat1_get_msgptr(struct _catset *set, int msgno)
1376 struct _msgptr *msg;
1378 if (set == (struct _catset *)NULL)
1379 return (struct _msgptr *)NULL;
1381 if (set->_mp == (struct _msgptr *)NULL) /* empty set */
1382 return (struct _msgptr *)NULL;
1384 if (set->_msgs_expanded) {
1385 if ((msgno < 0) || (msgno > set->_n_msgs))
1386 return (struct _msgptr *)NULL;
1388 msg = &set->_mp[msgno];
1391 * Catch empty elements in the array. They aren't
1396 return (struct _msgptr *)NULL;
1399 (struct _msgptr *)bsearch((void *)&msgno, set->_mp,
1401 sizeof(struct _msgptr), compare_msgs);
1404 * Since the messages are compacted, there aren't any
1405 * empty elements in the array to check for.
1413 catgets1(nl_catd catd, int setno, int msgno, char *def)
1414 /*---- catd: the catd to get the message from ----*/
1415 /*---- setno: the set number of the message ----*/
1416 /*---- msgno: the message number of the message ----*/
1417 /*---- def: the default string to be returned ----*/
1420 char *_do_read_msg();
1424 if (catd == NULL || catd == CATD_ERR || catd->_magic != CAT_MAGIC
1425 || catd->_fd == NL_FILE_UNUSED) {
1428 if (catd->_fd == NL_FILE_CLOSED) {
1429 catd = _do1_open(catd);
1430 if (catd == CATD_ERR)
1434 if (catd->_mem) { /*---- for mapped files ----*/
1435 if (setno <= catd->_hd->_setmax) {
1436 if (msgno < catd->_set[setno]._n_msgs) {
1437 if (catd->_set[setno]._mp[msgno]._offset) {
1438 return (catd->_mem +
1439 catd->_set[setno]._mp[msgno]._offset);
1444 } else { /*---- for unmapped files ----*/
1445 m = _do1_read_msg(catd, setno, msgno);
1455 #define FACILITY_CODE_MASK 0xF0000000
1456 #define FACILITY_CODE_SHIFT 28
1458 #define COMPONENT_CODE_MASK 0x0FFFF000
1459 #define COMPONENT_CODE_SHIFT 12
1461 #define STATUS_CODE_MASK 0x00000FFF
1462 #define STATUS_CODE_SHIFT 0
1464 #define NO_MESSAGE "THIS IS NOT A MESSAGE"
1467 * The system-dependant location for the catalog files is defined in sysconf.h
1468 * RPC_DEFAULT_NLSPATH should be defined in sysconf.h. Otherwise we use
1469 * /usr/afs/etc/C/%s.cat
1472 #ifndef RPC_NLS_FORMAT
1473 #define RPC_NLS_FORMAT "%s.cat"
1476 dce1_error_inq_text(status_to_convert, error_text, status)
1477 afs_uint32 status_to_convert;
1478 unsigned char *error_text;
1482 unsigned short facility_code;
1483 unsigned short component_code;
1484 unsigned short status_code;
1485 unsigned short i, failed = 0;
1487 char component_name[4];
1488 char *facility_name;
1489 char filename_prefix[7];
1490 char nls_filename[11];
1491 char alt_filename[80];
1493 #if defined(AFS_64BITPOINTER_ENV)
1498 static char *facility_names[] = {
1504 * set up output status for future error returns
1506 if (status != NULL) {
1510 * check for ok input status
1512 if (status_to_convert == 0) {
1513 if (status != NULL) {
1516 strcpy((char *)error_text, "successful completion");
1521 * extract the component, facility and status codes
1524 (status_to_convert & FACILITY_CODE_MASK) >> FACILITY_CODE_SHIFT;
1526 (status_to_convert & COMPONENT_CODE_MASK) >> COMPONENT_CODE_SHIFT;
1527 status_code = (status_to_convert & STATUS_CODE_MASK) >> STATUS_CODE_SHIFT;
1530 * see if this is a recognized facility
1532 if (facility_code == 0
1533 || facility_code > sizeof(facility_names) / sizeof(char *)) {
1534 sprintf((char *)error_text, "status %08x (unknown facility)",
1538 facility_name = facility_names[facility_code - 1];
1540 * Convert component name from RAD-50 component code. (Mapping is:
1541 * 0 => 'a', ..., 25 => 'z', 26 => '{', 27 => '0', ..., 36 => '9'.)
1543 component_name[3] = 0;
1544 component_name[2] = component_code % 40;
1545 component_code /= 40;
1546 component_name[1] = component_code % 40;
1547 component_name[0] = component_code / 40;
1548 for (i = 0; i < 3; i++) {
1549 component_name[i] += (component_name[i] <= 26) ? 'a' : ('0' - 27);
1551 sprintf(filename_prefix, "%3s%3s", facility_name, component_name);
1552 sprintf(nls_filename, RPC_NLS_FORMAT, filename_prefix);
1555 * Open the message file
1557 #if defined(AFS_OSF_ENV)
1558 #if defined(AFS_OSF20_ENV)
1559 catd = (nl_catd) catopen(nls_filename, 0);
1561 catd = (nl_catd) catopen1(nls_filename, 0);
1564 #if defined(AFS_64BITPOINTER_ENV)
1565 J = (long)catopen(nls_filename, 0);
1567 J = (int)catopen(nls_filename, 0);
1571 if (catd == (nl_catd) - 1) {
1573 * If we did not succeed in opening message file using NLSPATH,
1574 * try to open the message file in a well-known default area
1577 #ifndef RPC_DEFAULT_NLSPATH
1578 sprintf(alt_filename, "%s/C/%s.cat", AFSDIR_CLIENT_ETC_DIRPATH,
1581 sprintf(alt_filename, RPC_DEFAULT_NLSPATH, filename_prefix);
1584 #if defined(AFS_OSF_ENV)
1585 #if defined(AFS_OSF20_ENV)
1586 catd = (nl_catd) catopen(alt_filename, 0);
1588 catd = (nl_catd) catopen1(alt_filename, 0);
1591 #if defined(AFS_64BITPOINTER_ENV)
1592 J = (long)catopen(alt_filename, 0);
1594 J = (int)catopen(alt_filename, 0);
1598 if (catd == (nl_catd) - 1) {
1599 sprintf((char *)error_text, "status %08x (%s / %s)",
1600 status_to_convert, facility_name, component_name);
1605 * try to get the specified message from the file
1607 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1608 message = (char *)catgets1(catd, 1, status_code, NO_MESSAGE);
1610 message = (char *)catgets(catd, 1, status_code, NO_MESSAGE);
1613 * if everything went well, return the resulting message
1615 if (strcmp(message, NO_MESSAGE) != 0) {
1616 sprintf((char *)error_text, "%s (%s / %s)", message, facility_name,
1618 if (status != NULL) {
1624 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1631 sprintf((char *)error_text, "status %08x (%s / %s)",
1632 status_to_convert, facility_name, component_name);
1634 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1643 icl_DumpKernel(outFilep, setname)
1647 afs_int32 bufferSize = 0;
1650 afs_int32 code, retVal = 0;
1655 afs_int32 dummy, dummy2;
1656 struct logInfo *lip;
1658 /* first, enumerate the logs we're interested in */
1661 /* dump logs for a particular set */
1662 for (i = 0; i < ICL_LOGSPERSET; i++) {
1664 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname,
1665 i, (long)tname, sizeof(tname));
1667 if (errno == EBADF) {
1669 continue; /* missing slot, nothing to worry about */
1674 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1675 (long)&dummy, (long)&dummy2, 0);
1679 if (dummy > bufferSize) /* find biggest log */
1681 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1682 memset((char *)lip, 0, sizeof(*lip));
1683 lip->nextp = allInfo;
1685 lip->name = (char *)malloc(strlen(tname) + 1);
1686 strcpy(lip->name, tname);
1691 for (i = 0; i < 1000; i++) {
1693 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1694 sizeof(tname), (long)&dummy);
1697 if (dummy > bufferSize) /* find biggest log */
1699 lip = (struct logInfo *)malloc(sizeof(struct logInfo));
1700 memset((char *)lip, 0, sizeof(*lip));
1701 lip->nextp = allInfo;
1703 lip->name = (char *)malloc(strlen(tname) + 1);
1704 strcpy(lip->name, tname);
1708 if (bufferSize == 0)
1710 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
1714 fprintf(outFilep, "Found %d logs.\n", i);
1716 /* now print out the contents of each log */
1717 for (lip = allInfo; lip; lip = lip->nextp) {
1718 fprintf(outFilep, "\nContents of log %s:\n", lip->name);
1719 /* read out everything first; gets a more consistent
1722 nwords = 0; /* total words copied out */
1724 /* display all the entries in the log */
1725 if (bufferSize - nwords <= 0)
1726 break; /* filled whole buffer */
1728 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUT, (long)lip->name,
1729 (long)(bufferp + nwords), bufferSize - nwords,
1732 /* otherwise we've got an error */
1733 fprintf(outFilep, "Returned error %d dumping log.\n", errno);
1736 /* otherwise, we have flags in the high order byte, and
1737 * a length (in words) in the remainder.
1739 if ((code >> 24) & ICL_COPYOUTF_MISSEDSOME)
1740 fprintf(outFilep, "Log wrapped; data missing.\n");
1748 } /* for loop over all cookies */
1750 /* otherwise we should display all of the log entries here.
1751 * Note that a record may end in the middle, in which case
1752 * we should start over with the cookie value of the start
1755 for (ix = 0; ix < nwords;) {
1756 /* start of a record */
1757 rlength = (bufferp[ix] >> 24) & 0xff;
1759 fprintf(outFilep, "Internal error: 0 length record\n");
1763 /* ensure that entire record fits */
1764 if (ix + rlength > nwords) {
1765 /* doesn't fit, adjust cookie and break */
1768 /* print the record */
1769 DisplayRecord(outFilep, &bufferp[ix], rlength);
1772 /* obsolete: read entire buffer first */
1773 i += rlength; /* update cookie value, too */
1775 } /* for loop displaying buffer */
1776 } /* for loop over all logs */
1783 /* clear out log 'name' */
1789 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRLOG, (long)name, 0, 0, 0);
1793 /* clear out set 'name' */
1799 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRSET, (long)name, 0, 0, 0);
1803 /* clear out all logs */
1808 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRALL, 0, 0, 0, 0);
1812 /* list out all available sets to outFileP */
1814 icl_ListSets(outFileP)
1822 for (i = 0; i < 1000; i++) {
1824 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMSETS, i, (long)tname,
1825 sizeof(tname), (long)&states);
1828 (void)fprintf(outFileP, "%s %s%s%s\n", tname,
1829 (states & ICL_SETF_ACTIVE) ? "active" : "inactive",
1830 (states & ICL_SETF_FREED) ? " (dormant)" : "",
1831 (states & ICL_SETF_PERSISTENT) ? " persistent" : "");
1837 /* list out all available logs to outFileP */
1839 icl_ListLogs(outFileP, int32flg)
1849 for (i = 0; i < 1000; i++) {
1851 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS, i, (long)tname,
1852 sizeof(tname), (long)&logSize);
1856 /* get more information on the log */
1858 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1859 (long)&logSize, (long)&allocated, 0);
1862 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1864 allocated ? "allocated" : "unallocated");
1866 (void)fprintf(outFileP, "%s\n", tname);
1872 /* list out all available logs to outFileP */
1874 icl_ListLogsBySet(outFileP, setname, int32flg)
1885 for (i = 0; i < ICL_LOGSPERSET; i++) {
1887 afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET, (long)setname, i,
1888 (long)tname, sizeof(tname));
1890 if (errno == EBADF) {
1892 continue; /* missing */
1897 /* get more information on the log */
1899 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)tname,
1900 (long)&logSize, (long)&allocated, 0);
1903 (void)fprintf(outFileP, "%s : %d kbytes (%s)\n", tname,
1905 allocated ? "allocated" : "unallocated");
1907 (void)fprintf(outFileP, "%s\n", tname);
1913 /* activate/deactivate/free specified set */
1915 icl_ChangeSetState(name, op)
1921 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTAT, (long)name, op, 0, 0);
1925 /* activate/deactivate/free all sets */
1927 icl_ChangeAllSetState(op)
1932 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTATALL, op, 0, 0, 0);
1936 /* set size if log */
1938 icl_ChangeLogSize(name, logSize)
1945 afs_syscall(AFSCALL_ICL, ICL_OP_SETLOGSIZE, (long)name, logSize, 0,
1950 /* get logsize of specified log */
1952 icl_GetLogsize(logname, logSizeP, allocatedP)
1954 afs_int32 *logSizeP;
1959 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
1960 (long)logSizeP, (long)allocatedP, 0);
1964 /* get state of specified set */
1966 icl_GetSetState(setname, stateP)
1972 afs_syscall(AFSCALL_ICL, ICL_OP_GETSETINFO, (long)setname,
1973 (long)stateP, 0, 0);
1977 icl_TailKernel(outFilep, logname, waitTime)
1982 afs_int32 bufferSize = 0;
1983 afs_int32 newBufferSize;
1986 afs_int32 code, retVal = 0;
1991 struct logInfo *lip;
1993 /* get information about the specified log */
1995 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
1996 (long)&bufferSize, (long)&allocated, 0);
1998 if (errno == ENOENT)
1999 (void)fprintf(stderr, "'%s' not found\n", logname);
2001 (void)fprintf(stderr,
2002 "cannot get information on log '%s' (errno = %d)\n",
2008 (void)fprintf(stderr, "'%s' not allocated\n", logname);
2012 if (bufferSize == 0)
2014 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2016 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2021 /* start "infinite" loop */
2023 /* read out all that's currently there */
2024 nwords = 0; /* total words copied out */
2025 i = 0; /* initialize cookie */
2027 /* display all the entries in the log */
2028 if (bufferSize - nwords <= 0)
2029 break; /* filled whole buffer, clear when done */
2031 afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUTCLR, (long)logname,
2032 (long)(bufferp + nwords), bufferSize - nwords,
2035 /* otherwise we've got an error */
2036 fprintf(stderr, "returned error %d dumping log.\n", errno);
2040 /* otherwise, we have flags in the high order byte, and
2041 * a length (in words) in the remainder.
2050 } /* for loop over all cookies */
2052 /* otherwise we should display all of the log entries here.
2053 * Note that a record may end in the middle, in which case
2054 * we should start over with the cookie value of the start
2057 for (ix = 0; ix < nwords;) {
2058 /* start of a record */
2059 rlength = (bufferp[ix] >> 24) & 0xff;
2060 /* ensure that entire record fits */
2061 if (ix + rlength > nwords) {
2062 /* doesn't fit, adjust cookie and break */
2064 fprintf(stderr, "BOGUS: 0 length record\n");
2070 /* print the record */
2071 DisplayRecord(outFilep, &bufferp[ix], rlength);
2073 } /* for loop displaying buffer */
2078 /* see if things have changed */
2080 afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long)logname,
2081 (long)&newBufferSize, (long)&allocated, 0);
2083 if (errno == ENOENT)
2084 (void)fprintf(stderr, "'%s' not found\n", logname);
2086 (void)fprintf(stderr,
2087 "cannot get information on log '%s' (errno = %d)\n",
2094 (void)fprintf(stderr, "'%s' no int32er allocated\n", logname);
2099 if (bufferSize == 0) {
2100 (void)fprintf(stderr, "buffer size has become 0\n");
2104 if (bufferSize != newBufferSize) {
2105 /* have to reallocate a buffer */
2106 bufferSize = newBufferSize;
2108 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2110 (void)fprintf(stderr, "cannot allocate %d words for buffer\n",
2116 } /* infinite loop */
2123 #if !defined(AFS_SGI_ENV)
2124 afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6)
2125 long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6;
2128 #ifdef AFS_LINUX20_ENV
2129 #if defined AFS_LINUX_64BIT_KERNEL
2131 /* don't want to sign extend it to 64bit, so using ulong */
2132 eparm[0] = (unsigned long)parm3;
2133 eparm[1] = (unsigned long)parm4;
2134 eparm[2] = (unsigned long)parm5;
2135 eparm[3] = (unsigned long)parm6;
2143 /* Linux can only handle 5 arguments in the actual syscall. */
2144 if (call == AFSCALL_ICL) {
2145 rval = proc_afs_syscall(call, parm0, parm1, parm2, eparm, &code);
2147 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
2149 rval = proc_afs_syscall(call, parm0, parm1, parm2, parm3, &code);
2151 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
2153 #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
2154 /* on sparc this function returns none value, so do it myself */
2155 __asm__ __volatile__("mov %o0, %i0; ret; restore");
2158 #ifdef AFS_DARWIN80_ENV
2159 code = ioctl_afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, &rval);
2160 if (!code) code = rval;
2162 #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
2163 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3, parm4);
2165 #if defined(AFS_SGI_ENV)
2166 code = syscall(AFS_ICL, call, parm0, parm1, parm2, parm3, parm4); /* XXX */
2168 code = syscall(AFSCALL_ICL, parm0, parm1, parm2, parm3, parm4);
2172 #endif /* AFS_LINUX20_ENV */
2180 /* init function, called once, under icl_lock */
2186 /* setup signal handler, in user space */
2192 icl_CreateSet(name, baseLogp, fatalLogp, outSetpp)
2194 struct afs_icl_log *baseLogp;
2195 struct afs_icl_log *fatalLogp;
2196 struct afs_icl_set **outSetpp;
2198 return icl_CreateSetWithFlags(name, baseLogp, fatalLogp, /*flags */ 0,
2202 /* create a set, given pointers to base and fatal logs, if any.
2203 * Logs are unlocked, but referenced, and *outSetpp is returned
2204 * referenced. Function bumps reference count on logs, since it
2205 * addds references from the new icl_set. When the set is destroyed,
2206 * those references will be released.
2208 icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
2210 struct afs_icl_log *baseLogp;
2211 struct afs_icl_log *fatalLogp;
2213 struct afs_icl_set **outSetpp;
2215 register struct afs_icl_set *setp;
2217 afs_int32 states = ICL_DEFAULT_SET_STATES;
2222 for (setp = icl_allSets; setp; setp = setp->nextp) {
2223 if (strcmp(setp->name, name) == 0) {
2226 if (flags & ICL_CRSET_FLAG_PERSISTENT) {
2227 setp->states |= ICL_SETF_PERSISTENT;
2233 /* determine initial state */
2234 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2235 states = ICL_SETF_ACTIVE;
2236 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2237 states = ICL_SETF_FREED;
2238 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2239 states |= ICL_SETF_PERSISTENT;
2241 setp = (struct afs_icl_set *)osi_Alloc(sizeof(struct afs_icl_set));
2242 memset((caddr_t) setp, 0, sizeof(*setp));
2244 if (states & ICL_SETF_FREED)
2245 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2246 setp->states = states;
2248 setp->name = (char *)osi_Alloc(strlen(name) + 1);
2249 strcpy(setp->name, name);
2250 setp->nevents = ICL_DEFAULTEVENTS;
2251 setp->eventFlags = (char *)osi_Alloc(ICL_DEFAULTEVENTS);
2252 for (i = 0; i < ICL_DEFAULTEVENTS; i++)
2253 setp->eventFlags[i] = 0xff; /* default to enabled */
2255 /* update this global info under the icl_lock */
2256 setp->nextp = icl_allSets;
2259 /* set's basic lock is still held, so we can finish init */
2261 setp->logs[0] = baseLogp;
2262 icl_LogHold(baseLogp);
2263 if (!(setp->states & ICL_SETF_FREED))
2264 icl_LogUse(baseLogp); /* log is actually being used */
2267 setp->logs[1] = fatalLogp;
2268 icl_LogHold(fatalLogp);
2269 if (!(setp->states & ICL_SETF_FREED))
2270 icl_LogUse(fatalLogp); /* log is actually being used */
2277 /* function to change event enabling information for a particular set */
2278 icl_SetEnable(setp, eventID, setValue)
2279 struct afs_icl_set *setp;
2285 if (!ICL_EVENTOK(setp, eventID)) {
2288 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2290 *tp |= ICL_EVENTMASK(eventID);
2292 *tp &= ~(ICL_EVENTMASK(eventID));
2296 /* return indication of whether a particular event ID is enabled
2297 * for tracing. If *getValuep is set to 0, the event is disabled,
2298 * otherwise it is enabled. All events start out enabled by default.
2300 icl_GetEnable(setp, eventID, getValuep)
2301 struct afs_icl_set *setp;
2305 if (!ICL_EVENTOK(setp, eventID)) {
2308 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2315 /* hold and release event sets */
2317 register struct afs_icl_set *setp;
2323 /* free a set. Called with icl_lock locked */
2325 register struct afs_icl_set *setp;
2327 register struct afs_icl_set **lpp, *tp;
2329 register struct afs_icl_log *tlp;
2331 for (lpp = &icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2333 /* found the dude we want to remove */
2335 osi_Free(setp->name, 1 + strlen(setp->name));
2336 osi_Free(setp->eventFlags, ICL_EVENTBYTES(setp->nevents));
2337 for (i = 0; i < ICL_LOGSPERSET; i++) {
2338 if (tlp = setp->logs[i])
2341 osi_Free(setp, sizeof(struct afs_icl_set));
2342 break; /* won't find it twice */
2348 /* do the release, watching for deleted entries */
2350 register struct afs_icl_set *setp;
2352 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2353 icl_ZapSet(setp); /* destroys setp's lock! */
2358 /* free a set entry, dropping its reference count */
2360 register struct afs_icl_set *setp;
2362 setp->states |= ICL_SETF_DELETED;
2367 /* find a set by name, returning it held */
2368 struct afs_icl_set *
2372 register struct afs_icl_set *tp;
2374 for (tp = icl_allSets; tp; tp = tp->nextp) {
2375 if (strcmp(tp->name, name) == 0) {
2376 /* this is the dude we want */
2384 /* zero out all the logs in the set */
2386 struct afs_icl_set *setp;
2391 struct afs_icl_log *logp;
2393 for (i = 0; i < ICL_LOGSPERSET; i++) {
2394 logp = setp->logs[i];
2397 tcode = icl_ZeroLog(logp);
2399 code = tcode; /* save the last bad one */
2406 icl_EnumerateSets(aproc, arock)
2410 register struct afs_icl_set *tp, *np;
2411 register afs_int32 code;
2414 for (tp = icl_allSets; tp; tp = np) {
2415 tp->refCount++; /* hold this guy */
2416 code = (*aproc) (tp->name, arock, tp);
2417 np = tp->nextp; /* tp may disappear next, but not np */
2418 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
2426 icl_AddLogToSet(setp, newlogp)
2427 struct afs_icl_set *setp;
2428 struct afs_icl_log *newlogp;
2432 struct afs_icl_log *logp;
2434 for (i = 0; i < ICL_LOGSPERSET; i++) {
2435 if (!setp->logs[i]) {
2436 setp->logs[i] = newlogp;
2438 icl_LogHold(newlogp);
2439 if (!(setp->states & ICL_SETF_FREED)) {
2440 /* bump up the number of sets using the log */
2441 icl_LogUse(newlogp);
2449 icl_SetSetStat(setp, op)
2450 struct afs_icl_set *setp;
2455 struct afs_icl_log *logp;
2458 case ICL_OP_SS_ACTIVATE: /* activate a log */
2460 * If we are not already active, see if we have released
2461 * our demand that the log be allocated (FREED set). If
2462 * we have, reassert our desire.
2464 if (!(setp->states & ICL_SETF_ACTIVE)) {
2465 if (setp->states & ICL_SETF_FREED) {
2466 /* have to reassert desire for logs */
2467 for (i = 0; i < ICL_LOGSPERSET; i++) {
2468 logp = setp->logs[i];
2475 setp->states &= ~ICL_SETF_FREED;
2477 setp->states |= ICL_SETF_ACTIVE;
2482 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
2483 /* this doesn't require anything beyond clearing the ACTIVE flag */
2484 setp->states &= ~ICL_SETF_ACTIVE;
2488 case ICL_OP_SS_FREE: /* deassert design for log */
2490 * if we are already in this state, do nothing; otherwise
2491 * deassert desire for log
2493 if (setp->states & ICL_SETF_ACTIVE)
2496 if (!(setp->states & ICL_SETF_FREED)) {
2497 for (i = 0; i < ICL_LOGSPERSET; i++) {
2498 logp = setp->logs[i];
2501 icl_LogFreeUse(logp);
2505 setp->states |= ICL_SETF_FREED;
2518 struct afs_icl_log *afs_icl_allLogs = 0;
2520 /* hold and release logs */
2522 register struct afs_icl_log *logp;
2528 /* hold and release logs, called with lock already held */
2530 register struct afs_icl_log *logp;
2536 /* keep track of how many sets believe the log itself is allocated */
2538 register struct afs_icl_log *logp;
2540 if (logp->setCount == 0) {
2541 /* this is the first set actually using the log -- allocate it */
2542 if (logp->logSize == 0) {
2543 /* we weren't passed in a hint and it wasn't set */
2544 logp->logSize = ICL_DEFAULT_LOGSIZE;
2547 (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logp->logSize);
2553 /* decrement the number of real users of the log, free if possible */
2554 icl_LogFreeUse(logp)
2555 register struct afs_icl_log *logp;
2557 if (--logp->setCount == 0) {
2558 /* no more users -- free it (but keep log structure around) */
2559 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2560 logp->firstUsed = logp->firstFree = 0;
2561 logp->logElements = 0;
2567 /* set the size of the log to 'logSize' */
2568 icl_LogSetSize(logp, logSize)
2569 register struct afs_icl_log *logp;
2573 /* nothing to worry about since it's not allocated */
2574 logp->logSize = logSize;
2577 logp->firstUsed = logp->firstFree = 0;
2578 logp->logElements = 0;
2580 /* free and allocate a new one */
2581 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2582 logp->datap = (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logSize);
2583 logp->logSize = logSize;
2589 /* free a log. Called with icl_lock locked. */
2591 register struct afs_icl_log *logp;
2593 register struct afs_icl_log **lpp, *tp;
2595 for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2597 /* found the dude we want to remove */
2599 osi_Free(logp->name, 1 + strlen(logp->name));
2600 osi_Free(logp->datap, logp->logSize * sizeof(afs_int32));
2601 osi_Free(logp, sizeof(struct icl_log));
2602 break; /* won't find it twice */
2608 /* do the release, watching for deleted entries */
2610 register struct afs_icl_log *logp;
2612 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2613 icl_ZapLog(logp); /* destroys logp's lock! */
2618 /* do the release, watching for deleted entries, log already held */
2620 register struct afs_icl_log *logp;
2622 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2623 icl_ZapLog(logp); /* destroys logp's lock! */
2628 /* zero out the log */
2630 icl_ZeroLog(register struct afs_icl_log *logp)
2632 logp->firstUsed = logp->firstFree = 0;
2633 logp->logElements = 0;
2637 /* free a log entry, and drop its reference count */
2639 register struct afs_icl_log *logp;
2641 logp->states |= ICL_LOGF_DELETED;
2648 icl_EnumerateLogs(int (*aproc)
2649 (char *name, char *arock, struct afs_icl_log * tp),
2652 register struct afs_icl_log *tp;
2653 register afs_int32 code;
2656 for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
2657 tp->refCount++; /* hold this guy */
2658 code = (*aproc) (tp->name, arock, tp);
2659 if (--tp->refCount == 0)
2668 afs_icl_bulkSetinfo_t *
2671 unsigned int infoSize;
2674 sizeof(afs_icl_bulkSetinfo_t) + (ICL_RPC_MAX_SETS -
2675 1) * sizeof(afs_icl_setinfo_t);
2677 setInfo = (afs_icl_bulkSetinfo_t *) malloc(infoSize);
2679 (void)fprintf(stderr,
2680 "Could not allocate the memory for bulk set info structure\n");
2684 memset((char *)setInfo, 0, infoSize);
2689 afs_icl_bulkLoginfo_t *
2692 unsigned int infoSize;
2695 sizeof(afs_icl_bulkLoginfo_t) + (ICL_RPC_MAX_LOGS -
2696 1) * sizeof(afs_icl_loginfo_t);
2698 logInfo = (afs_icl_bulkLoginfo_t *) malloc(infoSize);
2700 (void)fprintf(stderr,
2701 "Could not allocate the memory for bulk log info structure\n");
2706 memset((char *)logInfo, 0, infoSize);
2712 DoDump(struct cmd_syndesc *as, void *arock)
2716 afs_int32 waitTime = 10 /* seconds */ ;
2720 FILE *outfp = stdout;
2722 struct cmd_item *itemp;
2724 if (geteuid() != 0) {
2725 printf("fstrace must be run as root\n");
2729 if (as->parms[3].items) {
2730 if (!as->parms[1].items) {
2731 (void)fprintf(stderr, "-sleep can only be used with -follow\n");
2734 waitTime = strtol(as->parms[3].items->data, NULL, 0);
2737 if (as->parms[2].items) {
2738 /* try to open the specified output file */
2739 if ((outfp = fopen(as->parms[2].items->data, "w")) == NULL) {
2740 (void)fprintf(stderr, "Cannot open file '%s' for writing\n",
2741 as->parms[2].items->data);
2745 #ifdef AFS_SGI64_ENV
2746 startTime = time((time_t *) 0);
2748 startTime = time(0);
2750 (void)fprintf(outfp, "AFS Trace Dump -\n\n Date: %s\n",
2753 if (as->parms[0].items) {
2754 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2755 tcode = icl_DumpKernel(outfp, itemp->data);
2757 (void)fprintf(stderr, "Unable to dump set %s (errno = %d)\n",
2758 itemp->data, errno);
2762 } else if (as->parms[1].items) {
2763 logname = as->parms[1].items->data;
2764 code = icl_TailKernel(outfp, logname, waitTime);
2766 (void)fprintf(stderr,
2767 "Error tailing kernel log '%s' (errno = %d)\n",
2771 code = icl_DumpKernel(outfp, NULL);
2773 (void)fprintf(outfp, "\nAFS Trace Dump - %s\n",
2774 code ? "FAILED" : "Completed");
2776 if (outfp != stdout)
2777 (void)fclose(outfp);
2785 struct cmd_syndesc *dumpSyntax;
2788 cmd_CreateSyntax("dump", DoDump, NULL, "dump AFS trace logs");
2789 (void)cmd_AddParm(dumpSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2790 (void)cmd_AddParm(dumpSyntax, "-follow", CMD_SINGLE, CMD_OPTIONAL,
2792 (void)cmd_AddParm(dumpSyntax, "-file", CMD_SINGLE, CMD_OPTIONAL,
2794 (void)cmd_AddParm(dumpSyntax, "-sleep", CMD_SINGLE, CMD_OPTIONAL,
2795 "seconds_between_reads");
2799 DoShowLog(register struct cmd_syndesc *as, void *arock)
2801 afs_int32 retVal = 0;
2806 struct cmd_item *itemp;
2808 if (geteuid() != 0) {
2809 printf("fstrace must be run as root\n");
2812 if (as->parms[2].items)
2815 if (as->parms[0].items) {
2816 /* enumerate logs for the specified sets */
2817 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2818 (void)fprintf(stdout, "Logs for set '%s':\n", itemp->data);
2819 code = icl_ListLogsBySet(stdout, itemp->data, int32flg);
2821 (void)fprintf(stderr,
2822 "Error in enumerating set %s (errno = %d)\n",
2823 itemp->data, errno);
2827 } else if (as->parms[1].items) {
2828 /* print out log information */
2829 for (itemp = as->parms[1].items; itemp; itemp = itemp->next) {
2830 code = icl_GetLogsize(itemp->data, &logSize, &allocated);
2832 (void)fprintf(stdout, "%s : %d kbytes (%s)\n", itemp->data,
2834 allocated ? "allocated" : "unallocated");
2836 (void)fprintf(stderr,
2837 "Could not find log '%s' (errno = %d)\n",
2838 itemp->data, errno);
2844 (void)fprintf(stdout, "Available logs:\n");
2845 code = icl_ListLogs(stdout, int32flg);
2847 (void)fprintf(stderr, "Error in listing logs (errno = %d)\n",
2859 struct cmd_syndesc *showSyntax;
2862 cmd_CreateSyntax("lslog", DoShowLog, NULL,
2863 "list available logs");
2864 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2865 (void)cmd_AddParm(showSyntax, "-log", CMD_LIST, CMD_OPTIONAL, "log_name");
2866 (void)cmd_AddParm(showSyntax, "-long", CMD_FLAG, CMD_OPTIONAL, "");
2870 DoShowSet(register struct cmd_syndesc *as, void *arock)
2872 afs_int32 retVal = 0;
2875 struct cmd_item *itemp;
2877 if (geteuid() != 0) {
2878 printf("fstrace must be run as root\n");
2881 if (as->parms[0].items) {
2882 /* print information on the specified sets */
2883 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2884 code = icl_GetSetState(itemp->data, &state);
2886 (void)fprintf(stderr,
2887 "Error getting status on set %s (errno = %d)\n",
2888 itemp->data, errno);
2891 (void)fprintf(stdout, "Set %s: %s%s%s\n", itemp->data,
2892 (state & ICL_SETF_ACTIVE) ? "active" :
2894 (state & ICL_SETF_FREED) ? " (dormant)" : "",
2895 (state & ICL_SETF_PERSISTENT) ? " persistent" :
2900 (void)fprintf(stdout, "Available sets:\n");
2901 code = icl_ListSets(stdout);
2903 (void)fprintf(stderr, "Error in listing sets (errno = %d)\n",
2915 struct cmd_syndesc *showSyntax;
2918 cmd_CreateSyntax("lsset", DoShowSet, NULL,
2919 "list available event sets");
2920 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2924 DoClear(register struct cmd_syndesc *as, void *arock)
2926 afs_int32 retVal = 0;
2928 struct cmd_item *itemp;
2930 if (geteuid() != 0) {
2931 printf("fstrace must be run as root\n");
2934 if (as->parms[0].items) {
2935 /* clear logs for the specified sets */
2936 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2937 code = icl_ClearSet(itemp->data);
2939 (void)fprintf(stderr,
2940 "Error in clearing set %s (errno = %d)\n",
2941 itemp->data, errno);
2945 } else if (as->parms[1].items) {
2946 /* clear specified log */
2947 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2948 code = icl_ClearLog(itemp->data);
2950 (void)fprintf(stderr,
2951 "Error in clearing log %s (errno = %d)\n",
2952 itemp->data, errno);
2957 /* clear all logs */
2958 code = icl_ClearAll();
2960 (void)fprintf(stderr, "Error in clearing logs (errno = %d)\n",
2972 struct cmd_syndesc *clearSyntax;
2975 cmd_CreateSyntax("clear", DoClear, NULL,
2976 "clear logs by logname or by event set");
2977 (void)cmd_AddParm(clearSyntax, "-set", CMD_LIST, CMD_OPTIONAL,
2979 (void)cmd_AddParm(clearSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
2984 DoSet(register struct cmd_syndesc *as, void *arock)
2986 afs_int32 retVal = 0;
2991 struct cmd_item *itemp;
2993 if (geteuid() != 0) {
2994 printf("fstrace must be run as root\n");
2997 if (as->parms[1].items) {
2998 op = ICL_OP_SS_ACTIVATE;
2999 operation = "active";
3000 } else if (as->parms[2].items) {
3001 op = ICL_OP_SS_DEACTIVATE;
3002 operation = "inactive";
3003 } else if (as->parms[3].items) {
3004 op = ICL_OP_SS_DEACTIVATE;
3005 operation = "inactive";
3008 /* assume active" */
3009 op = ICL_OP_SS_ACTIVATE;
3010 operation = "active";
3013 if (as->parms[0].items) {
3014 /* activate specified sets */
3015 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
3016 code = icl_ChangeSetState(itemp->data, op);
3018 (void)fprintf(stderr,
3019 "cannot set state of %s to %s (errno = %d)\n",
3020 itemp->data, operation, errno);
3022 } else if (doFree) {
3023 /* try to make it dormant as well */
3024 code = icl_ChangeSetState(itemp->data, ICL_OP_SS_FREE);
3026 (void)fprintf(stderr,
3027 "cannot set state of %s to dormant (errno = %d)\n",
3028 itemp->data, errno);
3035 code = icl_ChangeAllSetState(op);
3037 (void)fprintf(stderr,
3038 "cannot set the state of all sets to %s (errno = %d)\n",
3041 } else if (doFree) {
3042 /* try to make it dormant as well */
3043 code = icl_ChangeAllSetState(ICL_OP_SS_FREE);
3045 (void)fprintf(stderr,
3046 "cannot set the state of all sets to dormant (errno = %d)\n",
3059 struct cmd_syndesc *setSyntax;
3062 cmd_CreateSyntax("setset", DoSet, NULL,
3063 "set state of event sets");
3064 (void)cmd_AddParm(setSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
3065 (void)cmd_AddParm(setSyntax, "-active", CMD_FLAG, CMD_OPTIONAL, "");
3066 (void)cmd_AddParm(setSyntax, "-inactive", CMD_FLAG, CMD_OPTIONAL, "");
3067 (void)cmd_AddParm(setSyntax, "-dormant", CMD_FLAG, CMD_OPTIONAL, "");
3071 DoResize(register struct cmd_syndesc *as, void *arock)
3073 afs_int32 retVal = 0;
3075 afs_int32 bufferSize;
3076 struct cmd_item *itemp;
3078 if (geteuid() != 0) {
3079 printf("fstrace must be run as root\n");
3082 /* get buffer size */
3083 bufferSize = atoi(as->parms[1].items->data);
3084 bufferSize *= BUFFER_MULTIPLIER;
3085 if (bufferSize == 0)
3086 bufferSize = ICL_DEFAULT_LOGSIZE;
3088 /* set the size of the specified logs */
3089 if (itemp = as->parms[0].items) {
3090 for (; itemp; itemp = itemp->next) {
3091 code = icl_ChangeLogSize(itemp->data, bufferSize);
3093 (void)fprintf(stderr,
3094 "Error in changing log %s buffer size (errno = %d)\n",
3095 itemp->data, errno);
3100 /* Use the only current support log, "cmfx" */
3101 code = icl_ChangeLogSize("cmfx", bufferSize);
3103 (void)fprintf(stderr,
3104 "Error in changing log cmfx buffer size (errno = %d)\n",
3116 struct cmd_syndesc *setsizeSyntax;
3119 cmd_CreateSyntax("setlog", DoResize, NULL,
3120 "set the size of a log");
3121 (void)cmd_AddParm(setsizeSyntax, "-log", CMD_LIST, CMD_OPTIONAL,
3123 (void)cmd_AddParm(setsizeSyntax, "-buffersize", CMD_SINGLE, CMD_REQUIRED,
3124 "1-kilobyte_units");
3127 #include "AFS_component_version_number.c"
3133 setlocale(LC_ALL, "");
3134 #ifdef AFS_SGI62_ENV
3135 set_kernel_sizeof_long();
3138 /* set up user interface then dispatch */
3146 return (cmd_Dispatch(argc, argv));
3149 #include "AFS_component_version_number.c"
3153 printf("fstrace is NOT supported for this OS\n");