Beispiel #1
0
int
bc_ProcessDumpSchedule(struct bc_config *aconfig)
{
    struct bc_dumpSchedule *tds;
    struct bc_dumpSchedule *parentptr, *nodeptr;
    int retval;

    /* first, clear all the links on all entries so that this function
     * may be called any number of times with no ill effects
     */
    for (tds = aconfig->dsched; tds; tds = tds->next) {
	tds->parent = (struct bc_dumpSchedule *)0;
	tds->nextSibling = (struct bc_dumpSchedule *)0;
	tds->firstChild = (struct bc_dumpSchedule *)0;
    }

    for (tds = aconfig->dsched; tds; tds = tds->next) {
	retval = FindDump(aconfig, tds->name, &parentptr, &nodeptr);
	if (retval != 0) {
	    printf("bc_processdumpschedule: finddump returns %d\n", retval);
	    exit(1);
	}

	/* only need to do work if it is not a root node */
	if (parentptr != 0) {
	    nodeptr->parent = parentptr;
	    nodeptr->nextSibling = parentptr->firstChild;
	    parentptr->firstChild = nodeptr;
	}
    }
    return 0;
}
Beispiel #2
0
int
bc_CreateDumpSchedule(struct bc_config *aconfig, char *adumpName,
		      afs_int32 expDate, afs_int32 expType)
{
    struct bc_dumpSchedule *tdump;
    struct bc_dumpSchedule *parent, *node;
    afs_int32 code;

    if (strcmp(adumpName, "none") == 0)
	return -2;		/* invalid name */

    code = FindDump(aconfig, adumpName, &parent, &node);
    if (code == 0)
	return -1;		/* node already exists */
    else if (code != -1)
	return -2;		/* name specification error */

    tdump = (struct bc_dumpSchedule *)malloc(sizeof(struct bc_dumpSchedule));
    memset(tdump, 0, sizeof(*tdump));

    /* prepend this node to the dump schedule list */
    tdump->next = aconfig->dsched;
    aconfig->dsched = tdump;

    /* save the name of this dump node */
    tdump->name = (char *)malloc(strlen(adumpName) + 1);
    strcpy(tdump->name, adumpName);

    /* expiration information */
    tdump->expDate = expDate;
    tdump->expType = expType;

    bc_ProcessDumpSchedule(aconfig);	/* redo tree */
    return 0;
}
Beispiel #3
0
int
bc_SetExpCmd(struct cmd_syndesc *as, void *arock)
{
    register char *dname;	/* dump schedule name */
    register struct cmd_item *ti;
    struct bc_dumpSchedule *node, *parent;
    afs_int32 expType, expDate;
    udbClientTextP ctPtr;
    register int code;

    /* if an expiration date has been specified */
    if (as->parms[1].items) {
	code = bc_ParseExpiration(&as->parms[1], &expType, &expDate);
	if (code) {
	    printf("Invalid expiration date syntax\n");
	    return (1);
	}
    } else {
	/* no expiration date specified */
	expDate = 0;
	expType = BC_NO_EXPDATE;
    }

    /* lock schedules and check validity */
    ctPtr = &bc_globalConfig->configText[TB_DUMPSCHEDULE];

    code = bc_LockText(ctPtr);
    if (code)
	ERROR(code);

    code = bc_UpdateDumpSchedule();
    if (code) {
	afs_com_err(whoami, code, "; Can't retrieve dump schedule");
	return (code);
    }

    /* process each dump name using the expiration date computed above */
    for (ti = as->parms[0].items; ti != 0; ti = ti->next) {
	/* get next dump name to process */
	dname = ti->data;

	/* validate the name dump name length */
	if (strlen(dname) >= BU_MAX_DUMP_PATH) {
	    code = -1;
	    afs_com_err(whoami, 0, "Dump names must be < %d characters",
		    BU_MAX_DUMP_PATH);
	    afs_com_err(whoami, 0, "Dump %s not added", dname);
	    continue;
	}

	code = FindDump(bc_globalConfig, dname, &parent, &node);
	if (code) {
	    afs_com_err(whoami, 0, "Dump level %s not found", dname);
	    continue;
	}

	node->expDate = expDate;
	node->expType = expType;
    }

    code = bc_SaveDumpSchedule();
    if (code) {
	afs_com_err(whoami, code, "Cannot save dump schedule");
	afs_com_err(whoami, 0,
		"Expiration changes effective for this session only");
    }

  error_exit:
    if (ctPtr->lockHandle)
	bc_UnlockText(ctPtr);
    return (code);
}