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>
19 #include <sys/types.h>
20 #if !defined(AFS_SUN3_ENV) && !defined(sys_vax_ul43) && !defined(AFS_DARWIN_ENV)
22 /*#ifdef AFS_AIX_ENV*/
39 #include <afs/afs_args.h>
41 #include <afs/afsutil.h>
43 #if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
44 /* For SGI 6.2, this is changed to 1 if it's a 32 bit kernel. */
45 int afs_icl_sizeofLong = 2;
47 int afs_icl_sizeofLong = 1;
51 int afs_64bit_kernel = 1; /* Default for 6.2+, and always for 6.1 */
52 extern int afs_icl_sizeofLong; /* Used in ICL_SIZEHACK() */
56 /* If _SC_KERN_POINTERS not in sysconf, then we can assume a 32 bit abi. */
57 void set_kernel_sizeof_long(void)
62 retval = sysconf(_SC_KERN_POINTERS);
65 afs_icl_sizeofLong = 2;
69 afs_icl_sizeofLong = 1;
73 #endif /* AFS_SGI62_ENV */
74 #endif /* AFS_SGI61_ENV */
76 #define BUFFER_MULTIPLIER 1024
78 /* make it big enough to snapshot everything at once, since
79 * decoding takes so long.
81 #define IBSIZE 100000 /* default size */
84 struct logInfo *nextp;
88 char dumpFileName[256] = "";
89 RegisterIclDumpFileName(name)
92 (void) sprintf(dumpFileName, "icl.%.250s", name);
95 /* define globals to use for bulk info */
96 afs_icl_bulkSetinfo_t *setInfo = (afs_icl_bulkSetinfo_t *)0;
97 afs_icl_bulkLoginfo_t *logInfo = (afs_icl_bulkLoginfo_t *)0;
99 struct afs_icl_set *icl_allSets = 0;
103 /* given a type and an address, get the size of the thing
106 static icl_GetSize(type, addr)
114 ICL_SIZEHACK(type, addr);
118 /* Check types in printf string "bufferp", making sure that each
119 * is compatible with the corresponding parameter type described
120 * by typesp. Also watch for prematurely running out of parameters
121 * before the string is gone.
124 static int CheckTypes(bufferp, typesp, typeCount, outMsgBuffer)
136 for(tc = *bufferp;; outMsgBuffer++, tc = *(++bufferp)) {
139 /* hit end of string. We win as long as we aren't
142 if (inPercent) return 0;
147 inPercent = 1 - inPercent;
151 if (tc >= '0' && tc <= '9') {
152 /* skip digits in % string */
157 /* 'l' is a type modifier. */
161 /* otherwise, we've finally gotten to the type-describing
162 * character. Make sure there's a type descriptor, and then
163 * check the type descriptor.
167 return 0; /* no more type descriptors left */
169 if (typesp[tix] != 1) /* not a string descriptor */
172 *outMsgBuffer = (char)1;
174 if (tc == 'u' || tc == 'x' || tc == 'd'
176 if (typesp[tix] != 0)
177 return 0; /* not an integer descriptor */
181 *outMsgBuffer = (char)2;
184 *outMsgBuffer = (char)3;
187 *outMsgBuffer = (char)4;
191 *outMsgBuffer = (char)5;
195 /* otherwise we're fine, so eat this descriptor */
201 #else /* AFS_SGI61_ENV */
202 static CheckTypes(bufferp, typesp, typeCount)
213 for(tc = *bufferp;; tc = *(++bufferp)) {
215 /* hit end of string. We win as long as we aren't
218 if (inPercent) return 0;
222 inPercent = 1 - inPercent;
226 if (tc >= '0' && tc <= '9') continue; /* skip digits in % string */
227 /* otherwise, we've finally gotten to the type-describing
228 * character. Make sure there's a type descriptor, and then
229 * check the type descriptor.
233 return 0; /* no more type descriptors left */
234 if (tc == 's' && typesp[tix] != 1) /* not a string descriptor */
236 if ((tc == 'u' || tc == 'l' || tc == 'x' || tc == 'd')
237 && (typesp[tix] != 0))
238 return 0; /* not an integer descriptor */
239 /* otherwise we're fine, so eat this descriptor */
245 #endif /* AFS_SGI61_ENV */
247 /* display a single record.
248 * alp points at the first word in the array to be interpreted
249 * rsize gives the # of words in the array
251 #if defined(AFS_SGI61_ENV) && !defined(AFS_SGI62_ENV)
252 #define uint64_t long long
254 static DisplayRecord(outFilep, alp, rsize)
256 register afs_int32 *alp;
259 char msgBuffer[1024];
261 char outMsgBuffer[1024];
263 uint64_t printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
264 char *printfStrings[ICL_MAXEXPANSION * /* max parms */ 4];
265 #else /* AFS_SGI61_ENV */
266 long printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
267 #endif /* AFS_SGI61_ENV */
268 int printfTypes[ICL_MAXEXPANSION * 4];
274 int pix; /* index in alp */
275 int pfpix; /* index in printfParms */
276 int pftix; /* index in printfTypes */
278 int printed; /* did we print the string yet? */
281 /* decode parameters */
282 temp = alp[0]; /* type encoded in low-order 24 bits, t0 high */
288 for(i=0; i<4*ICL_MAXEXPANSION; i++)
290 /* decode each parameter, getting addrs for afs_hyper_t and strings */
291 for(i=0; !done && i<4; i++) {
292 type = (temp >> (18 - i*6)) & 0x3f;
298 case ICL_TYPE_POINTER:
299 printfTypes[pftix++] = 0;
301 printfParms[pfpix] = alp[pix];
302 printfParms[pfpix] &= 0xffffffff;
303 if (afs_64bit_kernel) {
304 printfParms[pfpix] <<= 32;
305 printfParms[pfpix] |= alp[pix+1];
307 #else /* AFS_SGI61_ENV */
309 printfParms[pfpix] = alp[pix+1];
310 printfParms[pfpix] |= (alp[pix] <<= 32);
311 #else /* AFS_ALPHA_ENV */
312 printfParms[pfpix] = alp[pix];
313 #endif /* AFS_ALPHA_ENV */
314 #endif /* AFS_SGI61_ENV */
318 printfTypes[pftix++] = 0;
319 printfParms[pfpix++] = alp[pix];
323 printfTypes[pftix++] = 0;
324 printfParms[pfpix++] = alp[pix];
325 printfTypes[pftix++] = 0;
326 printfParms[pfpix++] = alp[pix+1];
329 printfTypes[pftix++] = 0;
330 printfParms[pfpix++] = alp[pix];
331 printfTypes[pftix++] = 0;
332 printfParms[pfpix++] = alp[pix+1];
333 printfTypes[pftix++] = 0;
334 printfParms[pfpix++] = alp[pix+2];
335 printfTypes[pftix++] = 0;
336 printfParms[pfpix++] = alp[pix+3];
338 case ICL_TYPE_STRING:
339 printfTypes[pftix++] = 1;
341 printfStrings[pfpix++] = (char*) &alp[pix];
342 #else /* AFS_SGI64_ENV */
344 printfStrings[pfpix++] = (char *) &alp[pix];
345 #else /* AFS_SGI61_ENV */
346 printfParms[pfpix++] = (long) &alp[pix];
347 #endif /* AFS_SGI61_ENV */
348 #endif /* AFS_SGI64_ENV */
350 case ICL_TYPE_UNIXDATE:
351 printfParms[pfpix++] = (long) ctime((time_t *)&alp[pix]);
354 printf("DisplayRecord: Bad type %d in decode switch.\n", type);
361 pix += icl_GetSize(type, (char *) &alp[pix]);
364 /* next, try to decode the opcode into a printf string */
365 dce1_error_inq_text(alp[1], msgBuffer, &status);
367 /* if we got a string back, and it is compatible with the
368 * parms we've got, then print it.
373 if (CheckTypes(msgBuffer, printfTypes, pftix, outMsgBuffer)) {
374 /* we have a string to use, but it ends "(dfs / zcm)",
375 * so we remove the extra gunk.
377 j = strlen(outMsgBuffer);
379 outMsgBuffer[j-11] = 0;
383 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3]/1000000,
384 alp[3] % 1000000, alp[2]);
385 for (i=0; i<j; i++) {
386 if ((int)outMsgBuffer[i] > 5)
387 fputc(outMsgBuffer[i], outFilep);
389 switch (outMsgBuffer[i]) {
393 fprintf(outFilep, "%s", printfStrings[pfpix++]);
395 case 2: /* signed integer */
396 fprintf(outFilep, "%lld", printfParms[pfpix++]);
398 case 3: /* unsigned integer */
399 fprintf(outFilep, "%llu", printfParms[pfpix++]);
401 case 4: /* octal integer */
402 fprintf(outFilep, "%llo", printfParms[pfpix++]);
404 case 5: /* hex integer */
405 fprintf(outFilep, "%llx", printfParms[pfpix++]);
409 "fstrace: Bad char %d in outMsgBuffer for parm %d\n",
410 outMsgBuffer[i], pfpix);
411 fprintf(outFilep, "fstrace: msgBuffer='%s'\n",
417 fprintf(outFilep, "\n");
420 #else /* AFS_SGI61_ENV */
421 if (CheckTypes(msgBuffer, printfTypes, pftix)) {
422 /* we have a string to use, but it ends "(dfs / zcm)",
423 * so we remove the extra gunk.
425 j = strlen(msgBuffer);
426 if (j > 12) msgBuffer[j-11] = 0;
427 fprintf(outFilep, "time %d.%06d, pid %u: ", alp[3]/1000000,
428 alp[3] % 1000000, alp[2]);
429 fprintf(outFilep, msgBuffer, printfParms[0], printfParms[1],
430 printfParms[2], printfParms[3], printfParms[4],
431 printfParms[5], printfParms[6], printfParms[7],
432 printfParms[8], printfParms[9], printfParms[10],
433 printfParms[11], printfParms[12], printfParms[13],
434 printfParms[14], printfParms[15]);
435 fprintf(outFilep, "\n");
438 #endif /* AFS_SGI61_ENV */
440 fprintf(outFilep, "Type mismatch, using raw print.\n");
441 fprintf(outFilep, "%s", msgBuffer);
445 if (alp[1] == ICL_INFO_TIMESTAMP) {
446 fprintf(outFilep, "time %d.%06d, pid %u: %s\n",
447 alp[3]/1000000, alp[3] % 1000000, alp[2],
448 ctime((time_t *)&alp[4]));
450 fprintf(outFilep, "raw op %d, time %d.%06d, pid %u\n",
451 alp[1], alp[3]/1000000, alp[3] % 1000000, alp[2]);
452 /* now decode each parameter and print it */
455 for(i=0; !done && i<4; i++) {
456 type = (temp >> (18 - i*6)) & 0x3f;
462 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
466 tempParam = alp[pix];
468 tempParam |= alp[pix+1];
469 fprintf(outFilep, "p%d:%lld ", i, tempParam);
470 #else /* AFS_SGI61_ENV */
471 fprintf(outFilep, "p%d:%d ", i, alp[pix]);
472 #endif /* AFS_SGI61_ENV */
474 case ICL_TYPE_POINTER:
476 tempParam = alp[pix];
478 tempParam |= alp[pix+1];
479 fprintf(outFilep, "p%d:0x%llx ", i, tempParam);
480 #else /* AFS_SGI61_ENV */
481 fprintf(outFilep, "p%d:0x%x ", i, alp[pix]);
482 #endif /* AFS_SGI61_ENV */
486 fprintf(outFilep, "p%d:%x.%x ", i, alp[pix], alp[pix+1]);
489 fprintf(outFilep, "p%d:%d.%d.%d.%d ", i, alp[pix],
490 alp[pix+1], alp[pix+2], alp[pix+3]);
492 case ICL_TYPE_STRING:
493 fprintf(outFilep, "p%d:%s ", i, (char *) &alp[pix]);
495 case ICL_TYPE_UNIXDATE:
496 fprintf(outFilep, "p%d:%s ", i, ctime((time_t *)&alp[pix]));
499 printf("DisplayRecord: Bad type %d in raw print switch.\n",
507 pix += icl_GetSize(type, (char *) &alp[pix]);
510 fprintf(outFilep, "\n"); /* done with line */
520 #include <nl_types.h>
522 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
524 static nl_catd catopen1();
526 static nl_catd _do1_open();
527 static nl_catd cat_already_open();
528 static int make_sets();
529 static FILE *open1catfile();
530 static void add_open_cat();
531 static void cat_hard_close();
532 extern char *strchr();
534 static int catpid[NL_MAXOPEN];
535 static CATD *catsopen[NL_MAXOPEN];
536 #define PATH_FORMAT "/usr/lib/nls/msg/%L/%N:/etc/nls/msg/%L/%N"
537 #define DEFAULT_LANG "C"
538 #define TOO_MANY_HOLES(num_holes, num_non_holes) \
539 (((num_holes) > 100) && ((num_holes) > (num_non_holes)))
544 /*---- n: the number of bytes to be malloc'ed ----*/
548 t = (char *) malloc(n);
550 printf("Failed to get mem\n");
555 nl_catd catopen1 (cat, dummy)
558 /*---- char *cat: the name of the cat to be opened ----*/
559 /*---- int dummy: dummy variable ----*/
563 nl_catd _do_open(); /*---- routine that actually opens
570 if (catd = cat_already_open(cat)) {
571 catd->_count = catd->_count + 1;
575 catd = (CATD *)rmalloc (sizeof(CATD));
578 catd->_name = (char *)rmalloc(strlen(cat) + 1);
579 if ( catd->_name == NULL )
581 strcpy(catd->_name,cat);
583 catd->_magic = CAT_MAGIC;
585 #ifndef AFS_OSF20_ENV
586 catd->_pid = getpid();
589 if (_do1_open(catd) != CATD_ERR)
600 nl_catd _do1_open(catd)
603 /*---- pointer to the partially set up cat descriptor ----*/
606 int make_sets(); /*---- routine to unpack the sets into
607 fast acccess mode ----*/
608 void add_open_cat(); /*---- routine to keep a list of
611 int i; /*---- Misc counter(s) used for loop */
618 catd->_fd = open1catfile( catd->_name );
622 fread((void *)&magic,(size_t)4,(size_t)1,catd->_fd);
623 if (magic != CAT_MAGIC){
624 printf("Magic was %x instead of %x -> %x\n", magic, CAT_MAGIC, CATD_ERR);
631 /* if ((catd->_mem = shmat((int)fileno(catd->_fd), NULL, SHM_MAP | SHM_RDONLY))
632 == (char * )ERR ) { */
634 if (1) { /* disable the shmat, share memory segemnt */
636 /*______________________________________________________________________
637 If the file can not be mapped then simulate mapping for the index
638 table so that make_sets cat set things up. (rmalloc an area big
639 enough for the index table and read the whole thing in)
640 ______________________________________________________________________*/
642 /* reset the file pointer to the beginning of catalog */
643 fseek(catd->_fd,(long)0,0);
645 /* malloc the header, if fails return error */
646 catd->_hd = (struct _header *) rmalloc(sizeof(struct _header));
647 if ( catd->_hd == NULL )
650 /* read in the whole header */
651 fread((void *)catd->_hd,(size_t)sizeof(struct _header),(size_t)1,catd->_fd);
653 /* cs is a dummpy to hold a set temperorily. The purpose of */
654 /* this for loop is to fread the whole catalog so that the */
655 /* file pointer will be moved to the end of the catalog. */
656 for (i = 0 ; i < catd->_hd->_n_sets ; i++) {
657 fread((void *)&cs,(size_t)4,(size_t)1,catd->_fd);
658 fseek(catd->_fd, (long)(cs._n_msgs * sizeof(struct _msgptr)),1);
661 /* after the for loop, ftell returns the byte offset of the */
662 /* end of the catalog relative to the begining of the file. */
663 /* i.e. i contains the byte offset of the whole catalog. */
664 i = ftell(catd->_fd);
666 /* malloc _mem as a temp pointer to hold the entire catalog. */
667 catd->_mem = (char *)rmalloc(i);
668 if ( catd->_mem == NULL )
671 /* reset the file pointer to the begining. */
672 fseek(catd->_fd,(long)0,0);
674 /* read in the whole catalog into _mem */
675 fread((void *)catd->_mem,(size_t)i,(size_t)1,catd->_fd);
678 * If there aren't many holes in the set numbers,
679 * fully expand the compacted set array from the
680 * catalog. Then in catgets(), we'll be able to use
681 * the set number to index directly into the expanded
684 * If there are a lot of holes, leave the set array
685 * compacted. In catgets(), we'll search through it
686 * for the requested set.
689 num_holes = catd->_hd->_setmax - catd->_hd->_n_sets;
690 if (!TOO_MANY_HOLES(num_holes, catd->_hd->_n_sets)) {
691 catd->_sets_expanded = TRUE;
692 catd->_n_sets = catd->_hd->_setmax;
695 catd->_sets_expanded = FALSE;
696 catd->_n_sets = catd->_hd->_n_sets - 1;
699 /* malloc one extra set more than the max. set index */
700 catd->_set = (struct _catset *) rmalloc((catd->_n_sets+1)*
701 sizeof (struct _catset));
702 if ( catd->_set == NULL )
705 /* save the max. set number in catd->_setmax */
706 catd->_setmax = catd->_hd->_setmax;
707 /* call make_set to malloc memory for every message */
708 if(make_sets(catd) == -1)
717 /*______________________________________________________________________
718 Normal mapping has occurred, set a few things up and call make_sets
719 ______________________________________________________________________*/
721 catd->_hd =( struct _header * )( catd->_mem );
722 catd->_setmax = catd->_hd->_setmax;
723 catd->_set = (struct _catset *) rmalloc((catd->_hd->_setmax+1)*
724 sizeof (struct _catset));
725 if ( catd->_set == NULL )
727 if(make_sets(catd) == -1)
735 static void add_open_cat(catd)
737 /*---- catd to be added to the list of catalogs ----*/
740 int i = 0; /*---- Misc counter(s) used for loops ----*/
741 while (i < NL_MAXOPEN && catsopen[i]) {
742 if (!strcmp(catd->_name,catsopen[i]->_name)
743 #ifndef AFS_OSF20_ENV
744 && getpid()==catsopen[i]->_pid)
749 return; /*---- The catalog is already here ----*/
753 if (i < NL_MAXOPEN) {
755 catpid[i] = getpid();
764 * FUNCTION: Expands the compacted version of the catalog index table into
765 * the fast access memory version.
767 * EXECUTION ENVIRONMENT:
769 * Make_set executes under a process.
775 static int make_sets(catd)
778 struct _catset *cset;
779 char *base = catd->_mem;
780 int n_sets = catd->_hd->_n_sets;
781 int i; /*---- Misc counter(s) used for loops ----*/
782 int j; /*---- Misc counter(s) used for loops ----*/
783 int msgmax; /*---- The maximum number of _messages in a set ----*/
784 char *cmpct_set_ptr; /*---- pointer into the index table ----*/
785 struct _catset cs; /*---- used to look at the sets in the table -*/
788 cmpct_set_ptr = base + sizeof(struct _header);
790 for (i = 0 ; i < n_sets ; i++) {
791 /* loop through each compacted set */
793 cs = *(struct _catset *)cmpct_set_ptr;
794 /* set the _catset ptr to the base of the current
797 cs._mp = (struct _msgptr *)(cmpct_set_ptr +
798 2 * sizeof(unsigned short));
799 /* set the ms array ptr to the base of
800 compacted array of _msgptr's */
802 cset = (catd->_sets_expanded) ?
803 &catd->_set[cs._setno] : &catd->_set[i];
806 * If there aren't many holes in the message numbers,
807 * fully expand the compacted message array from the
808 * catalog. Then in catgets(), we'll be able to use
809 * the message number to index directly into the
812 * If there are many holes, leave the message array
813 * compacted. In catgets(), we'll search through it
814 * for the requested message.
817 msgmax = cs._mp[cs._n_msgs - 1]._msgno;
818 num_holes = msgmax - cs._n_msgs;
819 if (!TOO_MANY_HOLES(num_holes, cs._n_msgs)) {
820 cset->_msgs_expanded = TRUE;
821 cset->_n_msgs = msgmax;
824 cset->_msgs_expanded = FALSE;
825 cset->_n_msgs = cs._n_msgs - 1;
828 cset->_mp = (struct _msgptr *) rmalloc((1 + cset->_n_msgs) *
829 sizeof(struct _msgptr));
830 if (cset->_mp == NULL)
833 cset->_msgtxt = (char **) rmalloc((1 + cset->_n_msgs) *
835 if (cset->_msgtxt == NULL)
838 if (cset->_msgs_expanded) {
839 for (j = 0 ; j < cs._n_msgs ; j++) {
840 cset->_mp[cs._mp[j]._msgno] = cs._mp[j];
844 for (j = 0 ; j < cs._n_msgs ; j++) {
845 cset->_mp[j] = cs._mp[j];
849 cset->_setno = cs._setno;
850 /* Superfluous but should have the correct data. Increment
851 the base of the set pointer. */
853 cmpct_set_ptr += 2 * sizeof(unsigned short) + cs._n_msgs *
854 sizeof(struct _msgptr);
865 * FUNCTION: Opens a catalog file, looking in the language path first (if
866 * there is no slash) and returns a pointer to the file stream.
868 * EXECUTION ENVIRONMENT:
870 * Opencatfile executes under a process.
872 * RETURNS: Returns a pointer to the file stream, and a NULL pointer on
876 static FILE *open1catfile(file)
879 extern char *getenv();
880 char fl[PATH_MAX]; /*---- place to hold full path ----*/
881 char *nlspath; /*---- pointer to the nlspath val ----*/
882 FILE *fp; /*---- file pointer ----*/
883 char cpth[PATH_MAX]; /*---- current value of nlspath ----*/
885 char *fulllang; /* %L language value */
886 char lang[PATH_MAX]; /* %l language value */
887 char *territory; /* %t language value */
888 char *codeset; /* %c language value */
889 char *ptr; /* for decompose of $LANG */
894 char outptr[PATH_MAX];
897 if (strchr(file,'/')) {
898 if ((fp = fopen(file,"r")))
899 { fcntl(fileno(fp),F_SETFD,1);
900 /* set the close-on-exec flag for
906 if (!(nlspath = getenv("NLSPATH")))
907 nlspath = PATH_FORMAT;
908 if (!(fulllang = getenv("LANG")))
909 fulllang = DEFAULT_LANG;
910 if (fulllang == DEFAULT_LANG)
911 nlspath = PATH_FORMAT; /* if fullang is C, use the
912 the default nlspath: */
915 ** LANG is a composite of three fields:
916 ** language_territory.codeset
917 ** and we're going to break it into those
921 strcpy(lang, fulllang);
926 ptr = strchr( lang, '_' );
930 ptr = strchr(territory, '.');
936 ptr = strchr( lang, '.' );
946 while (*np && *np != ':')
949 if (*np) /*---- iff on a colon then advance --*/
957 while (*ptr != '\0') {
958 while ((*ptr != '\0') && (*ptr != '%')
959 && (nchars < PATH_MAX)) {
960 *(optr++) = *(ptr++);
988 lenstr = strlen(str);
990 if (nchars < PATH_MAX) {
998 if (nchars >= PATH_MAX) {
1004 strcpy(cpth, outptr);
1006 else { /*---- iff leading | trailing |
1007 adjacent colons ... --*/
1011 if (valid == 1 && (fp = fopen(cpth,"r")))
1012 { fcntl(fileno(fp),F_SETFD,1);
1013 /* set the close-on-exec flag for
1018 if (fp = fopen(file,"r"))
1019 { fcntl(fileno(fp),F_SETFD,1);
1020 /* set the close-on-exec flag for
1034 * NAME: cat_already_open
1036 * FUNCTION: Checkes to see if a specific cat has already been opened.
1038 * EXECUTION ENVIRONMENT:
1040 * Cat_already_open executes under a process.
1042 * RETURNS: Returns a pointer to the existing CATD if one exists, and
1043 * a NULL pointer if no CATD exists.
1046 static nl_catd cat_already_open(cat)
1048 /*---- name of the catalog to be opened ----*/
1051 int i; /*---- Misc counter(s) used for loops ----*/
1053 for (i = 0 ; i < NL_MAXOPEN && catsopen[i] ; i++) {
1054 #ifndef AFS_OSF20_ENV
1055 if (!strcmp(cat,catsopen[i]->_name) && getpid()==catsopen[i]->_pid) {
1057 if (!strcmp(cat,catsopen[i]->_name)) {
1059 return(catsopen[i]);
1066 int catclose1(catd) /*---- the catd to be closed ----*/
1067 nl_catd catd; /*---- the catd to be closed ----*/
1073 if (catd == CATD_ERR)
1075 for (i=0; i< NL_MAXOPEN && catsopen[i]; i++) {
1076 #ifndef AFS_OSF20_ENV
1077 if (catd == catsopen[i] && getpid()==catsopen[i]->_pid)
1079 if (catd == catsopen[i])
1083 if (i == NL_MAXOPEN || catsopen[i] == NULL)
1085 if (catd->_fd == (FILE *)NULL)
1086 /*---- return if this is an extra open or
1087 a bad catalog discriptor ----*/
1089 if (cat_already_open(catd->_name)) {
1090 if (catd->_count == 1) {
1091 cat_hard_close(catd);
1092 return (0); /*--- the last legal clsoe ---*/
1094 else if (catd->_count > 1) {
1095 catd->_count = catd->_count - 1;
1096 return(0); /*--- a legal close ---*/
1099 return (-1); /*--- an extra illegal close ---*/
1106 static void cat_hard_close(catd)
1108 /*---- the catd to be closed ----*/
1111 int i; /*---- Misc counter(s) used for loops ----*/
1112 int j; /*---- Misc counter ----*/
1114 if (catd == CATD_ERR)
1117 /*______________________________________________________________________
1118 remove any entry for the catalog in the catsopen array
1119 ______________________________________________________________________*/
1121 for (i = 0 ; i < NL_MAXOPEN && catsopen[i] ; i++) {
1122 if (catd == catsopen[i]) {
1123 for (; i < NL_MAXOPEN-1; i++) {
1124 catsopen[i] = catsopen[i+1];
1125 catpid[i] = catpid[i+1];
1132 /*______________________________________________________________________
1133 close the cat and free up the memory
1134 ______________________________________________________________________*/
1135 if (catd->_mem == FALSE)
1137 for (i = 0 ; i <= catd->_n_sets ; i++) {
1138 if (catd->_set[i]._mp)
1139 free(catd->_set[i]._mp);
1140 /*---- free the _message pointer arrays ----*/
1142 if (catd->_set[i]._msgtxt) {
1143 for (j = 0 ; j <= catd->_set[i]._n_msgs ; j++) {
1144 if (catd->_set[i]._msgtxt[j]) {
1145 /* free(catd->_set[i]._msgtxt[j]);*/
1148 if (catd->_set[i]._msgtxt)
1149 free(catd->_set[i]._msgtxt);
1155 fclose(catd->_fd); /*---- close the ctatlog ----*/
1157 free(catd->_set); /*---- free the sets ----*/
1159 free(catd->_name); /*---- free the name ----*/
1161 free(catd->_hd); /*---- free the header ----*/
1163 free(catd); /*---- free the catd ----*/
1166 static char *_do1_read_msg(nl_catd catd,int setno,int msgno)
1168 /*---- catd: the catd of the catalog to be read from ----*/
1169 /*---- setno: the set number of the message ----*/
1170 /*---- msgno: the msgno of the message ----*/
1173 nl_catd catd1; /*--- catd for different process ----*/
1176 #ifndef AFS_OSF20_ENV
1177 if (getpid() == catd->_pid)
1181 return (_read1_msg (catd, setno, msgno));
1184 * Since our pid is different from the one in
1185 * catd, catd must have come from a catopen()
1186 * in our parent. We need a catd of our own.
1187 * The first time through here, the call to
1188 * catopen() creates a new catd and we try to
1189 * open its message catalog. After that, the
1190 * catopen() just retrieves the catd.
1192 if (((catd1 = catopen1(catd->_name, 0)) != CATD_ERR) &&
1193 ((catd1->_fd == NL_FILE_CLOSED &&
1194 _do1_open(catd1) != CATD_ERR) ||
1195 (catd1->_fd != NL_FILE_UNUSED)))
1196 return (_read1_msg(catd1,setno,msgno));
1203 struct _catset *_cat1_get_catset();
1204 static struct _msgptr *_cat1_get_msgptr();
1205 static char *_read1_msg(nl_catd catd,int setno,int msgno)
1208 struct _catset *set; /*--- ptr to set's _catset structure ---*/
1209 struct _msgptr *msg; /*--- ptr to msg's _msgptr structure ---*/
1210 char **msgtxt; /*--- temporary pointer to the message text
1213 set = _cat1_get_catset(catd, setno);
1215 msg = _cat1_get_msgptr(set, msgno);
1217 msgtxt = &set->_msgtxt[msg - set->_mp];
1218 if (1/*!*msgtxt*/) {
1219 *msgtxt = (char *) malloc(msg->_msglen + 1);
1223 fseek(catd->_fd, (long) msg->_offset, 0);
1224 if (fread((void *) *msgtxt,
1225 (size_t) (msg->_msglen + 1),
1226 (size_t) 1, catd->_fd) != 1)
1237 * NAME: compare_sets
1239 * FUNCTION: Compare function used by bsearch() in _cat_get_catset().
1242 * key - pointer to set number we're searching for
1243 * element - pointer to current _catset structure
1245 * RETURNS: Returns -1, 0, or 1, depending on whether the set number
1246 * is less than, equal to, or greater than the set number of
1247 * the _catset structure.
1252 compare_sets(const void *key, const void *element)
1254 int *setno = (int *) key;
1255 struct _catset *set = (struct _catset *) element;
1257 if (*setno < set->_setno)
1259 if (*setno > set->_setno)
1267 * NAME: _cat_get_catset
1269 * FUNCTION: Find a set in the catd->_set array. Assumes that the
1270 * sets in the array are sorted by increasing set number.
1273 * catd - catalog descripter obtained from catopen()
1274 * setno - message catalogue set number
1276 * RETURNS: Returns a pointer to the set on success.
1277 * On any error, returns NULL.
1281 struct _catset *_cat1_get_catset(nl_catd catd, int setno)
1283 struct _catset *set;
1285 if ((catd == (nl_catd) NULL) || (catd == CATD_ERR))
1286 return (struct _catset *) NULL;
1288 if (catd->_sets_expanded) {
1289 if ((setno < 0) || (setno > catd->_n_sets))
1290 return (struct _catset *) NULL;
1292 set = &catd->_set[setno];
1295 * Catch empty elements in the array. They aren't
1299 if (set->_mp == (struct _msgptr *) NULL)
1300 return (struct _catset *) NULL;
1303 set = (struct _catset *) bsearch((void *) &setno,
1304 catd->_set, catd->_n_sets + 1,
1305 sizeof(struct _catset),
1309 * Since the sets are compacted, there aren't any
1310 * empty elements in the array to check for.
1319 * NAME: compare_msgs
1321 * FUNCTION: Compare function used by bsearch() in _cat_get_msgptr().
1324 * key - pointer to message number we're searching for
1325 * element - pointer to current _msgptr structure
1327 * RETURNS: Returns -1, 0, or 1, depending on whether the message
1328 * number is less than, equal to, or greater than the message
1329 * number of the _msgptr structure.
1334 compare_msgs(const void *key, const void *element)
1336 int *msgno = (int *) key;
1337 struct _msgptr *msg = (struct _msgptr *) element;
1339 if (*msgno < msg->_msgno)
1341 if (*msgno > msg->_msgno)
1348 * NAME: _cat1_get_msgptr
1350 * FUNCTION: Find a message in a set's set->_mp array. Assumes that
1351 * the messages in the array are sorted by increasing
1355 * set - ptr to _catset structure
1356 * msgno - message catalogue message number
1358 * RETURNS: Returns a pointer to the message on success.
1359 * On any error, returns NULL.
1362 static struct _msgptr *_cat1_get_msgptr(struct _catset *set, int msgno)
1364 struct _msgptr *msg;
1366 if (set == (struct _catset *) NULL)
1367 return (struct _msgptr *) NULL;
1369 if (set->_mp == (struct _msgptr *) NULL) /* empty set */
1370 return (struct _msgptr *) NULL;
1372 if (set->_msgs_expanded) {
1373 if ((msgno < 0) || (msgno > set->_n_msgs))
1374 return (struct _msgptr *) NULL;
1376 msg = &set->_mp[msgno];
1379 * Catch empty elements in the array. They aren't
1384 return (struct _msgptr *) NULL;
1387 msg = (struct _msgptr *) bsearch((void *) &msgno,
1388 set->_mp, set->_n_msgs + 1,
1389 sizeof(struct _msgptr),
1393 * Since the messages are compacted, there aren't any
1394 * empty elements in the array to check for.
1401 char *catgets1(nl_catd catd,int setno,int msgno,char *def)
1402 /*---- catd: the catd to get the message from ----*/
1403 /*---- setno: the set number of the message ----*/
1404 /*---- msgno: the message number of the message ----*/
1405 /*---- def: the default string to be returned ----*/
1409 char *_do_read_msg();
1413 if (catd == NULL || catd == CATD_ERR ||
1414 catd->_magic != CAT_MAGIC || catd->_fd == NL_FILE_UNUSED) {
1417 if (catd->_fd == NL_FILE_CLOSED) {
1418 catd = _do1_open(catd);
1419 if (catd == CATD_ERR)
1423 if (catd->_mem) { /*---- for mapped files ----*/
1424 if (setno <= catd->_hd->_setmax) {
1425 if (msgno < catd->_set[setno]._n_msgs) {
1426 if (catd->_set[setno]._mp[msgno]._offset) {
1428 catd->_set[setno]._mp[msgno]._offset);
1434 else { /*---- for unmapped files ----*/
1435 m = _do1_read_msg(catd,setno,msgno);
1445 #define FACILITY_CODE_MASK 0xF0000000
1446 #define FACILITY_CODE_SHIFT 28
1448 #define COMPONENT_CODE_MASK 0x0FFFF000
1449 #define COMPONENT_CODE_SHIFT 12
1451 #define STATUS_CODE_MASK 0x00000FFF
1452 #define STATUS_CODE_SHIFT 0
1454 #define NO_MESSAGE "THIS IS NOT A MESSAGE"
1457 * The system-dependant location for the catalog files is defined in sysconf.h
1458 * RPC_DEFAULT_NLSPATH should be defined in sysconf.h. Otherwise we use
1459 * /usr/afs/etc/C/%s.cat
1462 #ifndef RPC_NLS_FORMAT
1463 #define RPC_NLS_FORMAT "%s.cat"
1466 dce1_error_inq_text (status_to_convert, error_text, status)
1467 afs_uint32 status_to_convert;
1468 unsigned char *error_text;
1472 unsigned short facility_code;
1473 unsigned short component_code;
1474 unsigned short status_code;
1475 unsigned short i, failed=0;
1477 char component_name[4];
1478 char *facility_name;
1479 char filename_prefix[7];
1480 char nls_filename[11];
1481 char alt_filename[80];
1484 static char *facility_names[] = {
1490 * set up output status for future error returns
1497 * check for ok input status
1499 if (status_to_convert == 0)
1505 strcpy ((char *)error_text, "successful completion");
1510 * extract the component, facility and status codes
1512 facility_code = (status_to_convert & FACILITY_CODE_MASK) >> FACILITY_CODE_SHIFT;
1513 component_code = (status_to_convert & COMPONENT_CODE_MASK) >> COMPONENT_CODE_SHIFT;
1514 status_code = (status_to_convert & STATUS_CODE_MASK) >> STATUS_CODE_SHIFT;
1517 * see if this is a recognized facility
1519 if (facility_code == 0 || facility_code > sizeof (facility_names) / sizeof (char *))
1521 sprintf ((char *) error_text, "status %08x (unknown facility)", status_to_convert);
1524 facility_name = facility_names[facility_code - 1];
1526 * Convert component name from RAD-50 component code. (Mapping is:
1527 * 0 => 'a', ..., 25 => 'z', 26 => '{', 27 => '0', ..., 36 => '9'.)
1529 component_name[3] = 0;
1530 component_name[2] = component_code % 40;
1531 component_code /= 40;
1532 component_name[1] = component_code % 40;
1533 component_name[0] = component_code / 40;
1534 for (i = 0; i < 3; i++)
1536 component_name[i] += (component_name[i] <= 26) ? 'a' : ('0' - 27);
1538 sprintf (filename_prefix, "%3s%3s", facility_name, component_name);
1539 sprintf (nls_filename, RPC_NLS_FORMAT, filename_prefix);
1542 * Open the message file
1544 #if defined(AFS_OSF_ENV)
1545 #if defined(AFS_OSF20_ENV)
1546 catd = (nl_catd) catopen (nls_filename, 0);
1548 catd = (nl_catd) catopen1 (nls_filename, 0);
1551 J = (int) catopen (nls_filename, 0);
1554 if (catd == (nl_catd) -1)
1557 * If we did not succeed in opening message file using NLSPATH,
1558 * try to open the message file in a well-known default area
1561 #ifndef RPC_DEFAULT_NLSPATH
1562 sprintf(alt_filename, "%s/C/%s.cat", AFSDIR_CLIENT_ETC_DIRPATH, filename_prefix);
1564 sprintf (alt_filename, RPC_DEFAULT_NLSPATH, filename_prefix);
1567 #if defined(AFS_OSF_ENV)
1568 #if defined(AFS_OSF20_ENV)
1569 catd = (nl_catd) catopen (alt_filename, 0);
1571 catd = (nl_catd) catopen1 (alt_filename, 0);
1574 J = (int) catopen (alt_filename, 0);
1577 if (catd == (nl_catd) -1)
1579 sprintf ((char *) error_text, "status %08x (%s / %s)",
1580 status_to_convert, facility_name, component_name);
1585 * try to get the specified message from the file
1587 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1588 message = (char *) catgets1 (catd, 1, status_code, NO_MESSAGE);
1590 message = (char *) catgets (catd, 1, status_code, NO_MESSAGE);
1593 * if everything went well, return the resulting message
1595 if (strcmp (message, NO_MESSAGE) != 0)
1597 sprintf ((char *) error_text, "%s (%s / %s)",
1598 message, facility_name, component_name);
1608 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1615 sprintf ((char *) error_text, "status %08x (%s / %s)",
1616 status_to_convert, facility_name, component_name);
1618 #if defined(AFS_OSF_ENV) && !defined(AFS_OSF20_ENV)
1627 icl_DumpKernel(outFilep, setname)
1631 afs_int32 bufferSize = 0;
1634 afs_int32 code, retVal = 0;
1639 afs_int32 dummy, dummy2;
1640 struct logInfo *lip;
1642 /* first, enumerate the logs we're interested in */
1646 /* dump logs for a particular set */
1647 for(i=0; i < ICL_LOGSPERSET; i++) {
1648 code = afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET,
1649 (long) setname, i, (long) tname, sizeof(tname));
1651 if (errno == EBADF) {
1653 continue; /* missing slot, nothing to worry about */
1657 code = afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO,
1658 (long) tname, (long) &dummy, (long) &dummy2, 0);
1662 if (dummy > bufferSize) /* find biggest log */
1664 lip = (struct logInfo *) malloc(sizeof(struct logInfo));
1665 memset((char *)lip, 0, sizeof(*lip));
1666 lip->nextp = allInfo;
1668 lip->name = (char *) malloc(strlen(tname)+1);
1669 strcpy(lip->name, tname);
1676 for(i=0;i<1000;i++) {
1677 code = afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS,
1678 i, (long) tname, sizeof(tname), (long) &dummy);
1680 if (dummy > bufferSize) /* find biggest log */
1682 lip = (struct logInfo *) malloc(sizeof(struct logInfo));
1683 memset((char *)lip, 0, sizeof(*lip));
1684 lip->nextp = allInfo;
1686 lip->name = (char *) malloc(strlen(tname)+1);
1687 strcpy(lip->name, tname);
1691 if (bufferSize == 0) return -1;
1692 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
1693 if (!bufferp) return -1;
1695 fprintf(outFilep, "Found %d logs.\n", i);
1697 /* now print out the contents of each log */
1698 for(lip = allInfo; lip; lip=lip->nextp) {
1699 fprintf(outFilep, "\nContents of log %s:\n", lip->name);
1700 /* read out everything first; gets a more consistent
1703 nwords = 0; /* total words copied out */
1705 /* display all the entries in the log */
1706 if (bufferSize - nwords <= 0) break; /* filled whole buffer */
1707 code = afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUT,
1708 (long) lip->name, (long) (bufferp+nwords),
1709 bufferSize - nwords, (long) &i);
1711 /* otherwise we've got an error */
1712 fprintf(outFilep, "Returned error %d dumping log.\n", errno);
1715 /* otherwise, we have flags in the high order byte, and
1716 * a length (in words) in the remainder.
1718 if ((code >> 24) & ICL_COPYOUTF_MISSEDSOME)
1719 fprintf(outFilep, "Log wrapped; data missing.\n");
1727 } /* for loop over all cookies */
1729 /* otherwise we should display all of the log entries here.
1730 * Note that a record may end in the middle, in which case
1731 * we should start over with the cookie value of the start
1734 for(ix = 0; ix<nwords;) {
1735 /* start of a record */
1736 rlength = (bufferp[ix] >> 24) & 0xff;
1738 fprintf(outFilep, "Internal error: 0 length record\n");
1742 /* ensure that entire record fits */
1743 if (ix+rlength > nwords) {
1744 /* doesn't fit, adjust cookie and break */
1747 /* print the record */
1748 DisplayRecord(outFilep, &bufferp[ix], rlength);
1751 /* obsolete: read entire buffer first */
1752 i += rlength; /* update cookie value, too */
1754 } /* for loop displaying buffer */
1755 } /* for loop over all logs */
1762 /* clear out log 'name' */
1768 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRLOG, (long)name, 0, 0, 0);
1772 /* clear out set 'name' */
1778 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRSET, (long) name, 0, 0, 0);
1782 /* clear out all logs */
1787 code = afs_syscall(AFSCALL_ICL, ICL_OP_CLRALL, 0, 0, 0, 0);
1791 /* list out all available sets to outFileP */
1792 int icl_ListSets(outFileP)
1800 for(i=0;i<1000;i++) {
1801 code = afs_syscall(AFSCALL_ICL, ICL_OP_ENUMSETS,
1802 i, (long) tname, sizeof(tname), (long) &states);
1804 (void) fprintf(outFileP, "%s %s%s%s\n", tname,
1805 (states & ICL_SETF_ACTIVE) ? "active" : "inactive",
1806 (states & ICL_SETF_FREED) ? " (dormant)" : "",
1807 (states & ICL_SETF_PERSISTENT) ? " persistent" : "");
1813 /* list out all available logs to outFileP */
1814 int icl_ListLogs(outFileP, int32flg)
1824 for(i=0;i<1000;i++) {
1825 code = afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGS,
1826 i, (long) tname, sizeof(tname), (long) &logSize);
1830 /* get more information on the log */
1831 code = afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long) tname,
1832 (long) &logSize, (long) &allocated, 0);
1835 (void) fprintf(outFileP, "%s : %d kbytes (%s)\n", tname, logSize/1024,
1836 allocated ? "allocated" : "unallocated");
1839 (void) fprintf(outFileP, "%s\n", tname);
1845 /* list out all available logs to outFileP */
1846 int icl_ListLogsBySet(outFileP, setname, int32flg)
1857 for(i=0; i < ICL_LOGSPERSET; i++) {
1858 code = afs_syscall(AFSCALL_ICL, ICL_OP_ENUMLOGSBYSET,
1859 (long) setname, i, (long) tname, sizeof(tname));
1861 if (errno == EBADF) {
1863 continue; /* missing */
1869 /* get more information on the log */
1870 code = afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long) tname,
1871 (long) &logSize, (long) &allocated, 0);
1874 (void) fprintf(outFileP, "%s : %d kbytes (%s)\n", tname, logSize/1024,
1875 allocated ? "allocated" : "unallocated");
1878 (void) fprintf(outFileP, "%s\n", tname);
1884 /* activate/deactivate/free specified set */
1885 int icl_ChangeSetState(name, op)
1891 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTAT, (long) name, op, 0, 0);
1895 /* activate/deactivate/free all sets */
1896 int icl_ChangeAllSetState(op)
1901 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETSTATALL, op, 0, 0, 0);
1905 /* set size if log */
1906 int icl_ChangeLogSize(name, logSize)
1912 code = afs_syscall(AFSCALL_ICL, ICL_OP_SETLOGSIZE, (long)name, logSize, 0, 0);
1916 /* get logsize of specified log */
1917 int icl_GetLogsize(logname, logSizeP, allocatedP)
1919 afs_int32 *logSizeP;
1923 code = afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO, (long) logname,
1924 (long) logSizeP, (long) allocatedP, 0);
1928 /* get state of specified set */
1929 int icl_GetSetState(setname, stateP)
1934 code = afs_syscall(AFSCALL_ICL, ICL_OP_GETSETINFO, (long) setname,
1935 (long) stateP, 0, 0);
1939 icl_TailKernel(outFilep, logname, waitTime)
1944 afs_int32 bufferSize = 0;
1945 afs_int32 newBufferSize;
1948 afs_int32 code, retVal = 0;
1953 struct logInfo *lip;
1955 /* get information about the specified log */
1956 code = afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO,
1957 (long) logname, (long) &bufferSize, (long) &allocated, 0);
1960 if (errno == ENOENT)
1961 (void) fprintf(stderr, "'%s' not found\n", logname);
1963 (void) fprintf(stderr, "cannot get information on log '%s' (errno = %d)\n",
1970 (void) fprintf(stderr, "'%s' not allocated\n", logname);
1974 if (bufferSize == 0) return -1;
1975 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
1978 (void) fprintf(stderr, "cannot allocate %d words for buffer\n",
1983 /* start "infinite" loop */
1986 /* read out all that's currently there */
1987 nwords = 0; /* total words copied out */
1988 i = 0; /* initialize cookie */
1990 /* display all the entries in the log */
1991 if (bufferSize - nwords <= 0)
1992 break; /* filled whole buffer, clear when done */
1993 code = afs_syscall(AFSCALL_ICL, ICL_OP_COPYOUTCLR,
1994 (long) logname, (long) (bufferp+nwords),
1995 bufferSize - nwords, (long) &i);
1997 /* otherwise we've got an error */
1998 fprintf(stderr, "returned error %d dumping log.\n", errno);
2002 /* otherwise, we have flags in the high order byte, and
2003 * a length (in words) in the remainder.
2012 } /* for loop over all cookies */
2014 /* otherwise we should display all of the log entries here.
2015 * Note that a record may end in the middle, in which case
2016 * we should start over with the cookie value of the start
2019 for(ix = 0; ix<nwords;) {
2020 /* start of a record */
2021 rlength = (bufferp[ix] >> 24) & 0xff;
2022 /* ensure that entire record fits */
2023 if (ix+rlength > nwords) {
2024 /* doesn't fit, adjust cookie and break */
2026 fprintf(stderr, "BOGUS: 0 length record\n");
2032 /* print the record */
2033 DisplayRecord(outFilep, &bufferp[ix], rlength);
2035 } /* for loop displaying buffer */
2040 /* see if things have changed */
2041 code = afs_syscall(AFSCALL_ICL, ICL_OP_GETLOGINFO,
2042 (long) logname, (long) &newBufferSize,
2043 (long) &allocated, 0);
2046 if (errno == ENOENT)
2047 (void) fprintf(stderr, "'%s' not found\n", logname);
2049 (void) fprintf(stderr, "cannot get information on log '%s' (errno = %d)\n",
2057 (void) fprintf(stderr, "'%s' no int32er allocated\n", logname);
2062 if (bufferSize == 0)
2064 (void) fprintf(stderr, "buffer size has become 0\n");
2068 if (bufferSize != newBufferSize)
2070 /* have to reallocate a buffer */
2071 bufferSize = newBufferSize;
2073 bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
2076 (void) fprintf(stderr, "cannot allocate %d words for buffer\n",
2082 } /* infinite loop */
2089 #if !defined(AFS_SGI_ENV)
2090 afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6)
2091 long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6;
2094 #ifdef AFS_LINUX20_ENV
2095 #if defined AFS_LINUX_64BIT_KERNEL
2097 /* don't want to sign extend it to 64bit, so using ulong */
2098 eparm[0] = (unsigned long)parm3;
2099 eparm[1] = (unsigned long)parm4;
2100 eparm[2] = (unsigned long)parm5;
2101 eparm[3] = (unsigned long)parm6;
2109 /* Linux can only handle 5 arguments in the actual syscall. */
2110 if (call == AFSCALL_ICL) {
2111 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
2114 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
2116 #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
2117 /* on sparc this function returns none value, so do it myself */
2118 __asm__ __volatile__ ("
2125 #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
2126 code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3, parm4);
2128 #if defined(AFS_SGI_ENV)
2129 code = syscall(AFS_ICL, call, parm0, parm1, parm2, parm3, parm4); /* XXX */
2131 code = syscall(AFSCALL_ICL, parm0, parm1, parm2, parm3, parm4);
2135 #endif /* AFS_LINUX20_ENV */
2142 /* init function, called once, under icl_lock */
2148 /* setup signal handler, in user space */
2154 icl_CreateSet(name, baseLogp, fatalLogp, outSetpp)
2156 struct afs_icl_log *baseLogp;
2157 struct afs_icl_log *fatalLogp;
2158 struct afs_icl_set **outSetpp;
2160 return icl_CreateSetWithFlags(name, baseLogp, fatalLogp, /*flags*/0, outSetpp);
2163 /* create a set, given pointers to base and fatal logs, if any.
2164 * Logs are unlocked, but referenced, and *outSetpp is returned
2165 * referenced. Function bumps reference count on logs, since it
2166 * addds references from the new icl_set. When the set is destroyed,
2167 * those references will be released.
2169 icl_CreateSetWithFlags(name, baseLogp, fatalLogp, flags, outSetpp)
2171 struct afs_icl_log *baseLogp;
2172 struct afs_icl_log *fatalLogp;
2174 struct afs_icl_set **outSetpp;
2176 register struct afs_icl_set *setp;
2178 afs_int32 states = ICL_DEFAULT_SET_STATES;
2180 if (!icl_inited) icl_Init();
2182 for (setp = icl_allSets; setp; setp = setp->nextp) {
2183 if (strcmp(setp->name, name) == 0) {
2186 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2188 setp->states |= ICL_SETF_PERSISTENT;
2194 /* determine initial state */
2195 if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
2196 states = ICL_SETF_ACTIVE;
2197 else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
2198 states = ICL_SETF_FREED;
2199 if (flags & ICL_CRSET_FLAG_PERSISTENT)
2200 states |= ICL_SETF_PERSISTENT;
2202 setp = (struct afs_icl_set *) osi_Alloc(sizeof(struct afs_icl_set));
2203 memset((caddr_t)setp, 0, sizeof(*setp));
2205 if (states & ICL_SETF_FREED)
2206 states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
2207 setp->states = states;
2209 setp->name = (char *)osi_Alloc(strlen(name)+1);
2210 strcpy(setp->name, name);
2211 setp->nevents = ICL_DEFAULTEVENTS;
2212 setp->eventFlags = (char *)osi_Alloc(ICL_DEFAULTEVENTS);
2213 for(i=0; i<ICL_DEFAULTEVENTS; i++)
2214 setp->eventFlags[i] = 0xff; /* default to enabled */
2216 /* update this global info under the icl_lock */
2217 setp->nextp = icl_allSets;
2220 /* set's basic lock is still held, so we can finish init */
2222 setp->logs[0] = baseLogp;
2223 icl_LogHold(baseLogp);
2224 if (!(setp->states & ICL_SETF_FREED))
2225 icl_LogUse(baseLogp); /* log is actually being used */
2228 setp->logs[1] = fatalLogp;
2229 icl_LogHold(fatalLogp);
2230 if (!(setp->states & ICL_SETF_FREED))
2231 icl_LogUse(fatalLogp); /* log is actually being used */
2238 /* function to change event enabling information for a particular set */
2239 icl_SetEnable(setp, eventID, setValue)
2240 struct afs_icl_set *setp;
2246 if (!ICL_EVENTOK(setp, eventID)) {
2249 tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
2251 *tp |= ICL_EVENTMASK(eventID);
2253 *tp &= ~(ICL_EVENTMASK(eventID));
2257 /* return indication of whether a particular event ID is enabled
2258 * for tracing. If *getValuep is set to 0, the event is disabled,
2259 * otherwise it is enabled. All events start out enabled by default.
2261 icl_GetEnable(setp, eventID, getValuep)
2262 struct afs_icl_set *setp;
2266 if (!ICL_EVENTOK(setp, eventID)) {
2269 if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
2276 /* hold and release event sets */
2278 register struct afs_icl_set *setp;
2284 /* free a set. Called with icl_lock locked */
2286 register struct afs_icl_set *setp;
2288 register struct afs_icl_set **lpp, *tp;
2290 register struct afs_icl_log *tlp;
2292 for(lpp = &icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2294 /* found the dude we want to remove */
2296 osi_Free(setp->name, 1+strlen(setp->name));
2297 osi_Free(setp->eventFlags, ICL_EVENTBYTES(setp->nevents));
2298 for(i=0; i < ICL_LOGSPERSET; i++) {
2299 if (tlp = setp->logs[i])
2302 osi_Free(setp, sizeof(struct afs_icl_set));
2303 break; /* won't find it twice */
2309 /* do the release, watching for deleted entries */
2311 register struct afs_icl_set *setp;
2313 if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
2314 icl_ZapSet(setp); /* destroys setp's lock! */
2319 /* free a set entry, dropping its reference count */
2321 register struct afs_icl_set *setp;
2323 setp->states |= ICL_SETF_DELETED;
2328 /* find a set by name, returning it held */
2329 struct afs_icl_set *icl_FindSet(name)
2332 register struct afs_icl_set *tp;
2334 for(tp = icl_allSets; tp; tp=tp->nextp) {
2335 if (strcmp(tp->name, name) == 0) {
2336 /* this is the dude we want */
2344 /* zero out all the logs in the set */
2346 struct afs_icl_set *setp;
2351 struct afs_icl_log *logp;
2353 for(i = 0; i < ICL_LOGSPERSET; i++) {
2354 logp = setp->logs[i];
2357 tcode = icl_ZeroLog(logp);
2358 if (tcode != 0) code = tcode; /* save the last bad one */
2365 icl_EnumerateSets(aproc, arock)
2369 register struct afs_icl_set *tp, *np;
2370 register afs_int32 code;
2373 for(tp = icl_allSets; tp; tp=np) {
2374 tp->refCount++; /* hold this guy */
2375 code = (*aproc)(tp->name, arock, tp);
2376 np = tp->nextp; /* tp may disappear next, but not np */
2377 if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
2384 icl_AddLogToSet(setp, newlogp)
2385 struct afs_icl_set *setp;
2386 struct afs_icl_log *newlogp;
2390 struct afs_icl_log *logp;
2392 for(i = 0; i < ICL_LOGSPERSET; i++) {
2393 if (!setp->logs[i]) {
2394 setp->logs[i] = newlogp;
2396 icl_LogHold(newlogp);
2397 if (!(setp->states & ICL_SETF_FREED)) {
2398 /* bump up the number of sets using the log */
2399 icl_LogUse(newlogp);
2407 icl_SetSetStat(setp, op)
2408 struct afs_icl_set *setp;
2413 struct afs_icl_log *logp;
2416 case ICL_OP_SS_ACTIVATE: /* activate a log */
2418 * If we are not already active, see if we have released
2419 * our demand that the log be allocated (FREED set). If
2420 * we have, reassert our desire.
2422 if (!(setp->states & ICL_SETF_ACTIVE)) {
2423 if (setp->states & ICL_SETF_FREED) {
2424 /* have to reassert desire for logs */
2425 for(i = 0; i < ICL_LOGSPERSET; i++) {
2426 logp = setp->logs[i];
2433 setp->states &= ~ICL_SETF_FREED;
2435 setp->states |= ICL_SETF_ACTIVE;
2440 case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
2441 /* this doesn't require anything beyond clearing the ACTIVE flag */
2442 setp->states &= ~ICL_SETF_ACTIVE;
2446 case ICL_OP_SS_FREE: /* deassert design for log */
2448 * if we are already in this state, do nothing; otherwise
2449 * deassert desire for log
2451 if (setp->states & ICL_SETF_ACTIVE)
2454 if (!(setp->states & ICL_SETF_FREED)) {
2455 for(i = 0; i < ICL_LOGSPERSET; i++) {
2456 logp = setp->logs[i];
2459 icl_LogFreeUse(logp);
2463 setp->states |= ICL_SETF_FREED;
2476 struct afs_icl_log *afs_icl_allLogs = 0;
2478 /* hold and release logs */
2480 register struct afs_icl_log *logp;
2486 /* hold and release logs, called with lock already held */
2488 register struct afs_icl_log *logp;
2494 /* keep track of how many sets believe the log itself is allocated */
2496 register struct afs_icl_log *logp;
2498 if (logp->setCount == 0) {
2499 /* this is the first set actually using the log -- allocate it */
2500 if (logp->logSize == 0) {
2501 /* we weren't passed in a hint and it wasn't set */
2502 logp->logSize = ICL_DEFAULT_LOGSIZE;
2504 logp->datap = (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logp->logSize);
2510 /* decrement the number of real users of the log, free if possible */
2511 icl_LogFreeUse(logp)
2512 register struct afs_icl_log *logp;
2514 if (--logp->setCount == 0) {
2515 /* no more users -- free it (but keep log structure around)*/
2516 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2517 logp->firstUsed = logp->firstFree = 0;
2518 logp->logElements = 0;
2524 /* set the size of the log to 'logSize' */
2525 icl_LogSetSize(logp, logSize)
2526 register struct afs_icl_log *logp;
2530 /* nothing to worry about since it's not allocated */
2531 logp->logSize = logSize;
2535 logp->firstUsed = logp->firstFree = 0;
2536 logp->logElements = 0;
2538 /* free and allocate a new one */
2539 osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
2540 logp->datap = (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logSize);
2541 logp->logSize = logSize;
2547 /* free a log. Called with icl_lock locked. */
2549 register struct afs_icl_log *logp;
2551 register struct afs_icl_log **lpp, *tp;
2553 for(lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
2555 /* found the dude we want to remove */
2557 osi_Free(logp->name, 1+strlen(logp->name));
2558 osi_Free(logp->datap, logp->logSize * sizeof(afs_int32));
2559 osi_Free(logp, sizeof(struct icl_log));
2560 break; /* won't find it twice */
2566 /* do the release, watching for deleted entries */
2568 register struct afs_icl_log *logp;
2570 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2571 icl_ZapLog(logp); /* destroys logp's lock! */
2576 /* do the release, watching for deleted entries, log already held */
2578 register struct afs_icl_log *logp;
2580 if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
2581 icl_ZapLog(logp); /* destroys logp's lock! */
2586 /* zero out the log */
2588 register struct afs_icl_log *logp;
2590 logp->firstUsed = logp->firstFree = 0;
2591 logp->logElements = 0;
2595 /* free a log entry, and drop its reference count */
2597 register struct afs_icl_log *logp;
2599 logp->states |= ICL_LOGF_DELETED;
2605 icl_EnumerateLogs(aproc, arock)
2609 register struct afs_icl_log *tp;
2610 register afs_int32 code;
2613 for(tp = afs_icl_allLogs; tp; tp=tp->nextp) {
2614 tp->refCount++; /* hold this guy */
2615 code = (*aproc)(tp->name, arock, tp);
2616 if (--tp->refCount == 0)
2624 afs_icl_bulkSetinfo_t *GetBulkSetInfo()
2626 unsigned int infoSize;
2628 infoSize = sizeof(afs_icl_bulkSetinfo_t) +
2629 (ICL_RPC_MAX_SETS-1) * sizeof(afs_icl_setinfo_t);
2632 setInfo = (afs_icl_bulkSetinfo_t *)malloc(infoSize);
2635 (void) fprintf(stderr, "Could not allocate the memory for bulk set info structure\n");
2639 memset((char *)setInfo, 0, infoSize);
2644 afs_icl_bulkLoginfo_t *GetBulkLogInfo()
2645 { unsigned int infoSize;
2647 infoSize = sizeof(afs_icl_bulkLoginfo_t) +
2648 (ICL_RPC_MAX_LOGS-1) * sizeof(afs_icl_loginfo_t);
2651 logInfo = (afs_icl_bulkLoginfo_t *)malloc(infoSize);
2654 (void) fprintf(stderr, "Could not allocate the memory for bulk log info structure\n");
2659 memset((char *)logInfo, 0, infoSize);
2664 static DoDump(as, arock)
2665 register struct cmd_syndesc *as;
2670 afs_int32 waitTime = 10 /* seconds */;
2674 FILE *outfp = stdout;
2676 struct cmd_item * itemp;
2678 if (geteuid() != 0) {
2679 printf("fstrace must be run as root\n");
2683 if (as->parms[3].items) {
2684 if (!as->parms[1].items)
2686 (void) fprintf(stderr, "-sleep can only be used with -follow\n");
2689 waitTime = strtol(as->parms[3].items->data,
2693 if (as->parms[2].items)
2695 /* try to open the specified output file */
2696 if ((outfp = fopen(as->parms[2].items->data, "w")) == NULL)
2698 (void) fprintf(stderr, "Cannot open file '%s' for writing\n",
2699 as->parms[2].items->data);
2703 #ifdef AFS_SGI64_ENV
2704 startTime = time((time_t *) 0);
2706 startTime = time(0);
2708 (void) fprintf(outfp, "AFS Trace Dump -\n\n Date: %s\n",
2711 if (as->parms[0].items)
2713 for (itemp = as->parms[0].items; itemp; itemp = itemp->next)
2715 tcode = icl_DumpKernel(outfp, itemp->data);
2718 (void) fprintf(stderr, "Unable to dump set %s (errno = %d)\n",
2719 itemp->data, errno);
2723 } else if (as->parms[1].items) {
2724 logname = as->parms[1].items->data;
2725 code = icl_TailKernel(outfp, logname, waitTime);
2727 (void) fprintf(stderr, "Error tailing kernel log '%s' (errno = %d)\n",
2731 code = icl_DumpKernel(outfp, NULL);
2733 (void) fprintf(outfp, "\nAFS Trace Dump - %s\n",
2734 code ? "FAILED" : "Completed");
2736 if (outfp != stdout)
2737 (void) fclose(outfp);
2742 static void SetUpDump()
2744 struct cmd_syndesc *dumpSyntax;
2746 dumpSyntax = cmd_CreateSyntax("dump", DoDump, (char *)NULL, "dump AFS trace logs");
2747 (void)cmd_AddParm(dumpSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2748 (void)cmd_AddParm(dumpSyntax, "-follow", CMD_SINGLE, CMD_OPTIONAL, "log_name");
2749 (void)cmd_AddParm(dumpSyntax, "-file", CMD_SINGLE, CMD_OPTIONAL, "output_filename");
2750 (void)cmd_AddParm(dumpSyntax, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds_between_reads");
2753 static DoShowLog(as, arock)
2754 register struct cmd_syndesc *as;
2757 afs_int32 retVal = 0;
2762 struct cmd_item * itemp;
2764 if (geteuid() != 0) {
2765 printf("fstrace must be run as root\n");
2768 if (as->parms[2].items) int32flg = 1;
2770 if (as->parms[0].items) {
2771 /* enumerate logs for the specified sets */
2772 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2773 (void) fprintf(stdout, "Logs for set '%s':\n", itemp->data);
2774 code = icl_ListLogsBySet(stdout, itemp->data, int32flg);
2776 (void) fprintf(stderr, "Error in enumerating set %s (errno = %d)\n",
2777 itemp->data, errno);
2782 else if (as->parms[1].items) {
2783 /* print out log information */
2784 for (itemp = as->parms[1].items; itemp; itemp = itemp->next) {
2785 code = icl_GetLogsize(itemp->data, &logSize, &allocated);
2787 (void) fprintf(stdout, "%s : %d kbytes (%s)\n", itemp->data,
2788 logSize/1024, allocated ? "allocated" : "unallocated");
2790 (void) fprintf(stderr, "Could not find log '%s' (errno = %d)\n",
2791 itemp->data, errno);
2798 (void) fprintf(stdout, "Available logs:\n");
2799 code = icl_ListLogs(stdout, int32flg);
2801 (void) fprintf(stderr, "Error in listing logs (errno = %d)\n", errno);
2809 static void SetUpShowLog()
2811 struct cmd_syndesc *showSyntax;
2813 showSyntax = cmd_CreateSyntax("lslog", DoShowLog, (char *)NULL,"list available logs");
2814 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL,"set_name");
2815 (void)cmd_AddParm(showSyntax, "-log", CMD_LIST, CMD_OPTIONAL,"log_name");
2816 (void)cmd_AddParm(showSyntax, "-long", CMD_FLAG, CMD_OPTIONAL,"");
2819 static DoShowSet(as, arock)
2820 register struct cmd_syndesc *as;
2823 afs_int32 retVal = 0;
2826 struct cmd_item * itemp;
2828 if (geteuid() != 0) {
2829 printf("fstrace must be run as root\n");
2832 if (as->parms[0].items) {
2833 /* print information on the specified sets */
2834 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2835 code = icl_GetSetState(itemp->data, &state);
2837 (void) fprintf(stderr, "Error getting status on set %s (errno = %d)\n",
2838 itemp->data, errno);
2842 (void) fprintf(stdout, "Set %s: %s%s%s\n", itemp->data,
2843 (state & ICL_SETF_ACTIVE) ? "active" : "inactive",
2844 (state & ICL_SETF_FREED) ? " (dormant)" : "",
2845 (state & ICL_SETF_PERSISTENT) ? " persistent" : "");
2850 (void) fprintf(stdout, "Available sets:\n");
2851 code = icl_ListSets(stdout);
2853 (void) fprintf(stderr, "Error in listing sets (errno = %d)\n", errno);
2861 static void SetUpShowSet()
2863 struct cmd_syndesc *showSyntax;
2865 showSyntax = cmd_CreateSyntax("lsset", DoShowSet, (char *)NULL, "list available event sets");
2866 (void)cmd_AddParm(showSyntax, "-set", CMD_LIST, CMD_OPTIONAL, "set_name");
2869 static DoClear(as, arock)
2870 register struct cmd_syndesc *as;
2873 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 /* clear logs for the specified sets */
2883 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2884 code = icl_ClearSet(itemp->data);
2886 (void) fprintf(stderr, "Error in clearing set %s (errno = %d)\n",
2887 itemp->data, errno);
2891 } else if (as->parms[1].items) {
2892 /* clear specified log */
2893 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2894 code = icl_ClearLog(itemp->data);
2896 (void) fprintf(stderr, "Error in clearing log %s (errno = %d)\n",
2897 itemp->data, errno);
2903 /* clear all logs */
2904 code = icl_ClearAll();
2906 (void) fprintf(stderr, "Error in clearing logs (errno = %d)\n", errno);
2914 static void SetUpClear()
2916 struct cmd_syndesc *clearSyntax;
2918 clearSyntax = cmd_CreateSyntax("clear", DoClear, (char *)NULL, "clear logs by logname or by event set");
2919 (void)cmd_AddParm(clearSyntax, "-set", CMD_LIST, CMD_OPTIONAL,"set_name");
2920 (void)cmd_AddParm(clearSyntax, "-log", CMD_LIST, CMD_OPTIONAL, "log_name");
2923 static DoSet(as, arock)
2924 register struct cmd_syndesc *as;
2927 afs_int32 retVal = 0;
2932 struct cmd_item * itemp;
2934 if (geteuid() != 0) {
2935 printf("fstrace must be run as root\n");
2938 if (as->parms[1].items) {
2939 op = ICL_OP_SS_ACTIVATE;
2940 operation = "active";
2941 } else if (as->parms[2].items) {
2942 op = ICL_OP_SS_DEACTIVATE;
2943 operation = "inactive";
2944 } else if (as->parms[3].items) {
2945 op = ICL_OP_SS_DEACTIVATE;
2946 operation = "inactive";
2949 /* assume active" */
2950 op = ICL_OP_SS_ACTIVATE;
2951 operation = "active";
2954 if (as->parms[0].items) {
2955 /* activate specified sets */
2956 for (itemp = as->parms[0].items; itemp; itemp = itemp->next) {
2957 code = icl_ChangeSetState(itemp->data, op);
2959 (void) fprintf(stderr, "cannot set state of %s to %s (errno = %d)\n",
2960 itemp->data, operation, errno);
2964 /* try to make it dormant as well */
2965 code = icl_ChangeSetState(itemp->data, ICL_OP_SS_FREE);
2967 (void) fprintf(stderr, "cannot set state of %s to dormant (errno = %d)\n",
2968 itemp->data, errno);
2976 code = icl_ChangeAllSetState(op);
2978 (void) fprintf(stderr, "cannot set the state of all sets to %s (errno = %d)\n",
2983 /* try to make it dormant as well */
2984 code = icl_ChangeAllSetState(ICL_OP_SS_FREE);
2986 (void) fprintf(stderr, "cannot set the state of all sets to dormant (errno = %d)\n", errno);
2995 static void SetUpSet()
2997 struct cmd_syndesc *setSyntax;
2999 setSyntax = cmd_CreateSyntax("setset", DoSet, (char *)NULL,"set state of event sets");
3000 (void)cmd_AddParm(setSyntax, "-set", CMD_LIST, CMD_OPTIONAL,"set_name");
3001 (void)cmd_AddParm(setSyntax, "-active", CMD_FLAG, CMD_OPTIONAL,"");
3002 (void)cmd_AddParm(setSyntax, "-inactive", CMD_FLAG, CMD_OPTIONAL, "");
3003 (void)cmd_AddParm(setSyntax, "-dormant", CMD_FLAG, CMD_OPTIONAL,"");
3006 static DoResize(as, arock)
3007 register struct cmd_syndesc *as;
3010 afs_int32 retVal = 0;
3012 afs_int32 bufferSize;
3013 struct cmd_item * itemp;
3015 if (geteuid() != 0) {
3016 printf("fstrace must be run as root\n");
3019 /* get buffer size */
3020 bufferSize = atoi(as->parms[1].items->data);
3021 bufferSize *= BUFFER_MULTIPLIER;
3022 if (bufferSize == 0)
3023 bufferSize = ICL_DEFAULT_LOGSIZE;
3025 /* set the size of the specified logs */
3026 if (itemp = as->parms[0].items) {
3027 for (; itemp; itemp = itemp->next) {
3028 code = icl_ChangeLogSize(itemp->data, bufferSize);
3030 (void) fprintf(stderr, "Error in changing log %s buffer size (errno = %d)\n",
3031 itemp->data, errno);
3036 /* Use the only current support log, "cmfx" */
3037 code = icl_ChangeLogSize("cmfx", bufferSize);
3039 (void) fprintf(stderr, "Error in changing log cmfx buffer size (errno = %d)\n", errno);
3047 static void SetUpResize()
3049 struct cmd_syndesc *setsizeSyntax;
3051 setsizeSyntax = cmd_CreateSyntax("setlog", DoResize, (char *)NULL, "set the size of a log");
3052 (void)cmd_AddParm(setsizeSyntax, "-log", CMD_LIST, CMD_OPTIONAL,"log_name");
3053 (void)cmd_AddParm(setsizeSyntax, "-buffersize", CMD_SINGLE, CMD_REQUIRED, "1-kilobyte_units");
3056 #include "AFS_component_version_number.c"
3062 setlocale(LC_ALL, "");
3063 #ifdef AFS_SGI62_ENV
3064 set_kernel_sizeof_long();
3067 /* set up user interface then dispatch */
3075 return(cmd_Dispatch(argc, argv));
3078 #include "AFS_component_version_number.c"
3081 printf("fstrace is NOT supported for this OS\n");