Пример #1
0
void procfs_rmentry(pid_t pid)
{
    vnode_t * pdir;
    char name[PROCFS_NAMELEN_MAX];
    struct procfs_file ** file;

    if (!vn_procfs)
        return; /* Not yet initialized. */

    uitoa32(name, pid);

    KERROR_DBG("%s(pid = %s)\n", __func__, name);

    vref(vn_procfs);

    if (vn_procfs->vnode_ops->lookup(vn_procfs, name, &pdir)) {
        KERROR_DBG("pid dir doesn't exist\n");
        goto out;
    }

    SET_FOREACH(file, procfs_files) {
        if ((*file)->filetype < PROCFS_KERNEL_SEPARATOR) {
            pdir->vnode_ops->unlink(pdir, (*file)->filename);
        }
    }


    vrele(pdir);
    if (vn_procfs->vnode_ops->rmdir(vn_procfs, name)) {
        KERROR_DBG("Can't rmdir(%s)\n", name);
    }

out:
    vrele(vn_procfs);
}
Пример #2
0
static int toggle_dbgmsg(char * cfg)
{
    struct _kerror_dyndebug_msg * msg_opt = &__start_set_debug_msg_sect;
    struct _kerror_dyndebug_msg * stop = &__stop_set_debug_msg_sect;
    char strbuf[DD_MAX_LINE];
    char * file = strbuf;
    char * line;

    if (msg_opt == stop)
        return -EINVAL;

    if (cfg[0] == '*') { /* Match all */
        file = NULL;
        line = NULL;
    } else { /* Match specfic file */
        strlcpy(strbuf, cfg, sizeof(strbuf));
        file = strbuf;
        line = kstrchr(strbuf, ':');

        if (line) { /* Match line number */
            line[0] = '\0';
            line++;
        }
    }

    while (msg_opt < stop) {
        if (file) {
            if (strcmp(file, msg_opt->file) != 0)
                goto next;

            if (line && *line != '\0') {
                char msgline[12];

                uitoa32(msgline, msg_opt->line);
                if (strcmp(line, msgline) != 0)
                    goto next;
            }
        }

        /* Toggle */
        msg_opt->flags ^= 1;

next:
        msg_opt++;
    }

    return 0;
}
Пример #3
0
int procfs_mkentry(const struct proc_info * proc)
{
    char name[PROCFS_NAMELEN_MAX];
    vnode_t * pdir = NULL;
    struct procfs_file ** file;
    int err;

    if (!vn_procfs)
        return 0; /* Not yet initialized. */

    uitoa32(name, proc->pid);

    KERROR_DBG("%s(pid = %s)\n", __func__, name);

    err = vn_procfs->vnode_ops->mkdir(vn_procfs, name, PROCFS_PERMS);
    if (err == -EEXIST) {
        return 0;
    } else if (err) {
        goto fail;
    }

    err = vn_procfs->vnode_ops->lookup(vn_procfs, name, &pdir);
    if (err) {
        pdir = NULL;
        goto fail;
    }

    SET_FOREACH(file, procfs_files) {
        const enum procfs_filetype filetype = (*file)->filetype;

        if (filetype < PROCFS_KERNEL_SEPARATOR) {
            const char * filename = (*file)->filename;

            err = create_proc_file(pdir, proc->pid, filename, filetype);
            if (err)
                goto fail;
        }
    }

fail:
    if (pdir)
        vrele(pdir);
    if (err)
        KERROR_DBG("Failed to create a procfs entry\n");
    return err;
}