long parm4, long parm5, long parm6);
void dce1_error_inq_text(afs_uint32 status_to_convert,
char *error_text, int *status);
-int icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
- struct afs_icl_log *fatalLogp, afs_uint32 flags,
- struct afs_icl_set **outSetpp);
-int icl_LogHold(struct afs_icl_log *logp);
-int icl_LogUse(struct afs_icl_log *logp);
-int icl_LogReleNL(struct afs_icl_log *logp);
-int icl_LogRele(struct afs_icl_log *logp);
-int icl_ZeroLog(struct afs_icl_log *logp);
-int icl_LogFreeUse(struct afs_icl_log *logp);
#define BUFFER_MULTIPLIER 1024
-/* make it big enough to snapshot everything at once, since
- * decoding takes so long.
- */
-#define IBSIZE 100000 /* default size */
-
struct logInfo {
struct logInfo *nextp;
char *name;
} *allInfo = 0;
-char dumpFileName[256] = "";
-void
-RegisterIclDumpFileName(char *name)
-{
- (void)sprintf(dumpFileName, "icl.%.250s", name);
-}
-
-/* define globals to use for bulk info */
-afs_icl_bulkSetinfo_t *setInfo = (afs_icl_bulkSetinfo_t *) 0;
-afs_icl_bulkLoginfo_t *logInfo = (afs_icl_bulkLoginfo_t *) 0;
-struct afs_icl_set *icl_allSets = 0;
-
-char *name;
/* given a type and an address, get the size of the thing
* in words.
*/
}
#endif
-
-int icl_inited = 0;
-
-/* init function, called once, under icl_lock */
-int
-icl_Init(void)
-{
- icl_inited = 1;
-
-#ifndef KERNEL
- /* setup signal handler, in user space */
-#endif /* KERNEL */
-
- return 0;
-}
-
-int
-icl_CreateSet(char *name, struct afs_icl_log *baseLogp,
- struct afs_icl_log *fatalLogp, struct afs_icl_set **outSetpp)
-{
- return icl_CreateSetWithFlags(name, baseLogp, fatalLogp, /*flags */ 0,
- outSetpp);
-}
-
-/* create a set, given pointers to base and fatal logs, if any.
- * Logs are unlocked, but referenced, and *outSetpp is returned
- * referenced. Function bumps reference count on logs, since it
- * addds references from the new icl_set. When the set is destroyed,
- * those references will be released.
- */
-int
-icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
- struct afs_icl_log *fatalLogp, afs_uint32 flags,
- struct afs_icl_set **outSetpp)
-{
- struct afs_icl_set *setp;
- int i;
- afs_int32 states = ICL_DEFAULT_SET_STATES;
-
- if (!icl_inited)
- icl_Init();
-
- for (setp = icl_allSets; setp; setp = setp->nextp) {
- if (strcmp(setp->name, name) == 0) {
- setp->refCount++;
- *outSetpp = setp;
- if (flags & ICL_CRSET_FLAG_PERSISTENT) {
- setp->states |= ICL_SETF_PERSISTENT;
- }
- return 0;
- }
- }
-
- /* determine initial state */
- if (flags & ICL_CRSET_FLAG_DEFAULT_ON)
- states = ICL_SETF_ACTIVE;
- else if (flags & ICL_CRSET_FLAG_DEFAULT_OFF)
- states = ICL_SETF_FREED;
- if (flags & ICL_CRSET_FLAG_PERSISTENT)
- states |= ICL_SETF_PERSISTENT;
-
- setp = osi_Alloc(sizeof(struct afs_icl_set));
- memset((caddr_t) setp, 0, sizeof(*setp));
- setp->refCount = 1;
- if (states & ICL_SETF_FREED)
- states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
- setp->states = states;
-
- setp->name = osi_Alloc(strlen(name) + 1);
- strcpy(setp->name, name);
- setp->nevents = ICL_DEFAULTEVENTS;
- setp->eventFlags = osi_Alloc(ICL_DEFAULTEVENTS);
- for (i = 0; i < ICL_DEFAULTEVENTS; i++)
- setp->eventFlags[i] = 0xff; /* default to enabled */
-
- /* update this global info under the icl_lock */
- setp->nextp = icl_allSets;
- icl_allSets = setp;
-
- /* set's basic lock is still held, so we can finish init */
- if (baseLogp) {
- setp->logs[0] = baseLogp;
- icl_LogHold(baseLogp);
- if (!(setp->states & ICL_SETF_FREED))
- icl_LogUse(baseLogp); /* log is actually being used */
- }
- if (fatalLogp) {
- setp->logs[1] = fatalLogp;
- icl_LogHold(fatalLogp);
- if (!(setp->states & ICL_SETF_FREED))
- icl_LogUse(fatalLogp); /* log is actually being used */
- }
-
- *outSetpp = setp;
- return 0;
-}
-
-/* function to change event enabling information for a particular set */
-int
-icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue)
-{
- char *tp;
-
- if (!ICL_EVENTOK(setp, eventID)) {
- return -1;
- }
- tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
- if (setValue)
- *tp |= ICL_EVENTMASK(eventID);
- else
- *tp &= ~(ICL_EVENTMASK(eventID));
- return 0;
-}
-
-/* return indication of whether a particular event ID is enabled
- * for tracing. If *getValuep is set to 0, the event is disabled,
- * otherwise it is enabled. All events start out enabled by default.
- */
-int
-icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, int *getValuep)
-{
- if (!ICL_EVENTOK(setp, eventID)) {
- return -1;
- }
- if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
- *getValuep = 1;
- else
- *getValuep = 0;
- return 0;
-}
-
-/* hold and release event sets */
-int
-icl_SetHold(struct afs_icl_set *setp)
-{
- setp->refCount++;
- return 0;
-}
-
-/* free a set. Called with icl_lock locked */
-int
-icl_ZapSet(struct afs_icl_set *setp)
-{
- struct afs_icl_set **lpp, *tp;
- int i;
- struct afs_icl_log *tlp;
-
- for (lpp = &icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
- if (tp == setp) {
- /* found the dude we want to remove */
- *lpp = setp->nextp;
- osi_Free(setp->name, 1 + strlen(setp->name));
- osi_Free(setp->eventFlags, ICL_EVENTBYTES(setp->nevents));
- for (i = 0; i < ICL_LOGSPERSET; i++) {
- if ((tlp = setp->logs[i]))
- icl_LogReleNL(tlp);
- }
- osi_Free(setp, sizeof(struct afs_icl_set));
- break; /* won't find it twice */
- }
- }
- return 0;
-}
-
-/* do the release, watching for deleted entries */
-int
-icl_SetRele(struct afs_icl_set *setp)
-{
- if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
- icl_ZapSet(setp); /* destroys setp's lock! */
- }
- return 0;
-}
-
-/* free a set entry, dropping its reference count */
-int
-icl_SetFree(struct afs_icl_set *setp)
-{
- setp->states |= ICL_SETF_DELETED;
- icl_SetRele(setp);
- return 0;
-}
-
-/* find a set by name, returning it held */
-struct afs_icl_set *
-icl_FindSet(char *name)
-{
- struct afs_icl_set *tp;
-
- for (tp = icl_allSets; tp; tp = tp->nextp) {
- if (strcmp(tp->name, name) == 0) {
- /* this is the dude we want */
- tp->refCount++;
- break;
- }
- }
- return tp;
-}
-
-/* zero out all the logs in the set */
-int
-icl_ZeroSet(struct afs_icl_set *setp)
-{
- int i;
- int code = 0;
- int tcode;
- struct afs_icl_log *logp;
-
- for (i = 0; i < ICL_LOGSPERSET; i++) {
- logp = setp->logs[i];
- if (logp) {
- icl_LogHold(logp);
- tcode = icl_ZeroLog(logp);
- if (tcode != 0)
- code = tcode; /* save the last bad one */
- icl_LogRele(logp);
- }
- }
- return code;
-}
-
-int
-icl_EnumerateSets(int (*aproc) (char *, void *, struct afs_icl_set *),
- void *arock)
-{
- struct afs_icl_set *tp, *np;
- afs_int32 code;
-
- code = 0;
- for (tp = icl_allSets; tp; tp = np) {
- tp->refCount++; /* hold this guy */
- code = (*aproc) (tp->name, arock, tp);
- np = tp->nextp; /* tp may disappear next, but not np */
- if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
- icl_ZapSet(tp);
- if (code)
- break;
- }
- return code;
-}
-
-int
-icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
-{
- int i;
- int code = -1;
-
- for (i = 0; i < ICL_LOGSPERSET; i++) {
- if (!setp->logs[i]) {
- setp->logs[i] = newlogp;
- code = i;
- icl_LogHold(newlogp);
- if (!(setp->states & ICL_SETF_FREED)) {
- /* bump up the number of sets using the log */
- icl_LogUse(newlogp);
- }
- break;
- }
- }
- return code;
-}
-
-int
-icl_SetSetStat(struct afs_icl_set *setp, int op)
-{
- int i;
- afs_int32 code;
- struct afs_icl_log *logp;
-
- switch (op) {
- case ICL_OP_SS_ACTIVATE: /* activate a log */
- /*
- * If we are not already active, see if we have released
- * our demand that the log be allocated (FREED set). If
- * we have, reassert our desire.
- */
- if (!(setp->states & ICL_SETF_ACTIVE)) {
- if (setp->states & ICL_SETF_FREED) {
- /* have to reassert desire for logs */
- for (i = 0; i < ICL_LOGSPERSET; i++) {
- logp = setp->logs[i];
- if (logp) {
- icl_LogHold(logp);
- icl_LogUse(logp);
- icl_LogRele(logp);
- }
- }
- setp->states &= ~ICL_SETF_FREED;
- }
- setp->states |= ICL_SETF_ACTIVE;
- }
- code = 0;
- break;
-
- case ICL_OP_SS_DEACTIVATE: /* deactivate a log */
- /* this doesn't require anything beyond clearing the ACTIVE flag */
- setp->states &= ~ICL_SETF_ACTIVE;
- code = 0;
- break;
-
- case ICL_OP_SS_FREE: /* deassert design for log */
- /*
- * if we are already in this state, do nothing; otherwise
- * deassert desire for log
- */
- if (setp->states & ICL_SETF_ACTIVE)
- code = EINVAL;
- else {
- if (!(setp->states & ICL_SETF_FREED)) {
- for (i = 0; i < ICL_LOGSPERSET; i++) {
- logp = setp->logs[i];
- if (logp) {
- icl_LogHold(logp);
- icl_LogFreeUse(logp);
- icl_LogRele(logp);
- }
- }
- setp->states |= ICL_SETF_FREED;
- }
- code = 0;
- }
- break;
-
- default:
- code = EINVAL;
- }
-
- return code;
-}
-
-struct afs_icl_log *afs_icl_allLogs = 0;
-
-/* hold and release logs */
-int
-icl_LogHold(struct afs_icl_log *logp)
-{
- logp->refCount++;
- return 0;
-}
-
-/* hold and release logs, called with lock already held */
-int
-icl_LogHoldNL(struct afs_icl_log *logp)
-{
- logp->refCount++;
- return 0;
-}
-
-/* keep track of how many sets believe the log itself is allocated */
-int
-icl_LogUse(struct afs_icl_log *logp)
-{
- if (logp->setCount == 0) {
- /* this is the first set actually using the log -- allocate it */
- if (logp->logSize == 0) {
- /* we weren't passed in a hint and it wasn't set */
- logp->logSize = ICL_DEFAULT_LOGSIZE;
- }
- logp->datap = osi_Alloc(sizeof(afs_int32) * logp->logSize);
- }
- logp->setCount++;
- return 0;
-}
-
-/* decrement the number of real users of the log, free if possible */
-int
-icl_LogFreeUse(struct afs_icl_log *logp)
-{
- if (--logp->setCount == 0) {
- /* no more users -- free it (but keep log structure around) */
- osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
- logp->firstUsed = logp->firstFree = 0;
- logp->logElements = 0;
- logp->datap = NULL;
- }
- return 0;
-}
-
-/* set the size of the log to 'logSize' */
-int
-icl_LogSetSize(struct afs_icl_log *logp, afs_int32 logSize)
-{
- if (!logp->datap) {
- /* nothing to worry about since it's not allocated */
- logp->logSize = logSize;
- } else {
- /* reset log */
- logp->firstUsed = logp->firstFree = 0;
- logp->logElements = 0;
-
- /* free and allocate a new one */
- osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
- logp->datap = osi_Alloc(sizeof(afs_int32) * logSize);
- logp->logSize = logSize;
- }
-
- return 0;
-}
-
-/* free a log. Called with icl_lock locked. */
-int
-icl_ZapLog(struct afs_icl_log *logp)
-{
- struct afs_icl_log **lpp, *tp;
-
- for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
- if (tp == logp) {
- /* found the dude we want to remove */
- *lpp = logp->nextp;
- osi_Free(logp->name, 1 + strlen(logp->name));
- osi_Free(logp->datap, logp->logSize * sizeof(afs_int32));
- osi_Free(logp, sizeof(struct icl_log));
- break; /* won't find it twice */
- }
- }
- return 0;
-}
-
-/* do the release, watching for deleted entries */
-int
-icl_LogRele(struct afs_icl_log *logp)
-{
- if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
- icl_ZapLog(logp); /* destroys logp's lock! */
- }
- return 0;
-}
-
-/* do the release, watching for deleted entries, log already held */
-int
-icl_LogReleNL(struct afs_icl_log *logp)
-{
- if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
- icl_ZapLog(logp); /* destroys logp's lock! */
- }
- return 0;
-}
-
-/* zero out the log */
-int
-icl_ZeroLog(struct afs_icl_log *logp)
-{
- logp->firstUsed = logp->firstFree = 0;
- logp->logElements = 0;
- return 0;
-}
-
-/* free a log entry, and drop its reference count */
-int
-icl_LogFree(struct afs_icl_log *logp)
-{
- logp->states |= ICL_LOGF_DELETED;
- icl_LogRele(logp);
- return 0;
-}
-
-
-int
-icl_EnumerateLogs(int (*aproc)
- (char *name, void *arock, struct afs_icl_log * tp),
- void *arock)
-{
- struct afs_icl_log *tp, *np;
- afs_int32 code;
-
- code = 0;
- for (tp = afs_icl_allLogs; tp; tp = np) {
- tp->refCount++; /* hold this guy */
- np = tp->nextp;
- code = (*aproc) (tp->name, arock, tp);
- if (--tp->refCount == 0)
- icl_ZapLog(tp);
- if (code)
- break;
- }
- return code;
-}
-
-
-afs_icl_bulkSetinfo_t *
-GetBulkSetInfo(void)
-{
- unsigned int infoSize;
-
- infoSize =
- sizeof(afs_icl_bulkSetinfo_t) + (ICL_RPC_MAX_SETS -
- 1) * sizeof(afs_icl_setinfo_t);
- if (!setInfo) {
- setInfo = calloc(1, infoSize);
- if (!setInfo) {
- (void)fprintf(stderr,
- "Could not allocate the memory for bulk set info structure\n");
- exit(1);
- }
- }
-
- return setInfo;
-}
-
-afs_icl_bulkLoginfo_t *
-GetBulkLogInfo(void)
-{
- unsigned int infoSize;
-
- infoSize =
- sizeof(afs_icl_bulkLoginfo_t) + (ICL_RPC_MAX_LOGS -
- 1) * sizeof(afs_icl_loginfo_t);
- if (!logInfo) {
- logInfo = calloc(1, infoSize);
- if (!logInfo) {
- (void)fprintf(stderr,
- "Could not allocate the memory for bulk log info structure\n");
- exit(1);
- }
- }
-
- return logInfo;
-}
-
-
static int
DoDump(struct cmd_syndesc *as, void *arock)
{