Ejemplo n.º 1
0
int runlevel_register_attrs (runlevel_t *r, attr_t *attrs)
{
    const char *val;

    if (attr_add_active (attrs, "init.run-level",
                         FLUX_ATTRFLAG_READONLY,
                         runlevel_attr_get, NULL, r) < 0)
        return -1;

    if (attr_get (attrs, "init.mode", &val, NULL) == 0) {

        if (runlevel_set_mode (r, val) < 0
                || attr_delete (attrs, "init.mode", true) < 0)
            return -1;
    }
    if (attr_add_active (attrs, "init.mode", 0,
                         runlevel_attr_get, runlevel_attr_set, r) < 0)
        return -1;

    if (attr_get (attrs, "init.rc2_timeout", &val, NULL) == 0) {
        if ((fsd_parse_duration (val, &r->rc[2].timeout) < 0)
                || attr_delete (attrs, "init.rc2_timeout", true) < 0)
            return -1;
    }
    if (attr_add_active (attrs, "init.rc2_timeout", 0,
                         runlevel_attr_get, runlevel_attr_set, r) < 0)
        return -1;

    return 0;
}
Ejemplo n.º 2
0
static int runlevel_attr_set (const char *name, const char *val, void *arg)
{
    runlevel_t *r = arg;

    if (!strcmp (name, "init.mode")) {
        if (runlevel_set_mode (r, val) < 0)
            goto error;
    } else {
        errno = EINVAL;
        goto error;
    }
    return 0;
error:
    return -1;
}
Ejemplo n.º 3
0
static int runlevel_attr_set (const char *name, const char *val, void *arg)
{
    runlevel_t *r = arg;

    if (!strcmp (name, "init.mode")) {
        if (runlevel_set_mode (r, val) < 0)
            goto error;
    } else if (!strcmp (name, "init.rc2_timeout")) {
        if (fsd_parse_duration (val, &r->rc[2].timeout) < 0) {
            errno = EINVAL;
            goto error;
        }
    } else {
        errno = EINVAL;
        goto error;
    }
    return 0;
error:
    return -1;
}
Ejemplo n.º 4
0
int runlevel_register_attrs (runlevel_t *r, attr_t *attrs)
{
    const char *val;

    if (attr_add_active (attrs, "init.run-level",
                         FLUX_ATTRFLAG_READONLY,
                         runlevel_attr_get, NULL, r) < 0)
        return -1;

    if (attr_get (attrs, "init.mode", &val, NULL) == 0) {

        if (runlevel_set_mode (r, val) < 0
                || attr_delete (attrs, "init.mode", true) < 0)
            return -1;
    }
    if (attr_add_active (attrs, "init.mode", 0,
                         runlevel_attr_get, runlevel_attr_set, r) < 0)
        return -1;

    return 0;
}