Exemplo n.º 1
0
/*
 * MPALMOSTSAFE
 */
int
sys_modfnext(struct modfnext_args *uap)
{
    module_t mod;
    int error;

    lwkt_gettoken(&mod_token);
    uap->sysmsg_result = -1;

    mod = module_lookupbyid(uap->modid);
    if (!mod) {
	error = ENOENT;
	goto done;
    }

    if (TAILQ_NEXT(mod, flink))
	uap->sysmsg_result = TAILQ_NEXT(mod, flink)->id;
    else
	uap->sysmsg_result = 0;
    error = 0;
done:
    lwkt_reltoken(&mod_token);

    return error;
}
Exemplo n.º 2
0
/*
 * Syscalls.
 */
int
modnext(struct proc* p, struct modnext_args* uap)
{
    module_t mod;

    p->p_retval[0] = -1;
    if (SCARG(uap, modid) == 0) {
	mod = TAILQ_FIRST(&modules);
	if (mod) {
	    p->p_retval[0] = mod->id;
	    return 0;
	} else
	    return ENOENT;
    }

    mod = module_lookupbyid(SCARG(uap, modid));
    if (!mod)
	return ENOENT;

    if (TAILQ_NEXT(mod, link))
	p->p_retval[0] = TAILQ_NEXT(mod, link)->id;
    else
	p->p_retval[0] = 0;
    return 0;
}
Exemplo n.º 3
0
/*
 * MPALMOSTSAFE
 */
int
sys_modstat(struct modstat_args *uap)
{
    module_t mod;
    int error;
    int namelen;
    int version;
    struct module_stat* stat;

    lwkt_gettoken(&mod_token);
    mod = module_lookupbyid(uap->modid);
    if (!mod) {
	error = ENOENT;
	goto out;
    }

    stat = uap->stat;

    /*
     * Check the version of the user's structure.
     */
    if ((error = copyin(&stat->version, &version, sizeof(version))) != 0)
	goto out;
    if (version != sizeof(struct module_stat_v1)
	&& version != sizeof(struct module_stat)) {
	error = EINVAL;
	goto out;
    }

    namelen = strlen(mod->name) + 1;
    if (namelen > MAXMODNAME)
	namelen = MAXMODNAME;
    if ((error = copyout(mod->name, &stat->name[0], namelen)) != 0)
	goto out;

    if ((error = copyout(&mod->refs, &stat->refs, sizeof(int))) != 0)
	goto out;
    if ((error = copyout(&mod->id, &stat->id, sizeof(int))) != 0)
	goto out;

    /*
     * >v1 stat includes module data.
     */
    if (version == sizeof(struct module_stat)) {
	if ((error = copyout(&mod->data, &stat->data, sizeof(mod->data))) != 0)
	    goto out;
    }

    uap->sysmsg_result = 0;

out:
    lwkt_reltoken(&mod_token);

    return error;
}
Exemplo n.º 4
0
int
modstat(struct proc* p, struct modstat_args* uap)
{
    module_t mod;
    int error = 0;
    int namelen;
    int version;
    struct module_stat* stat;

    mod = module_lookupbyid(SCARG(uap, modid));
    if (!mod)
	return ENOENT;

    stat = SCARG(uap, stat);

    /*
     * Check the version of the user's structure.
     */
    if ((error = copyin(&stat->version, &version, sizeof(version))) != 0)
	goto out;
    if (version != sizeof(struct module_stat_v1)
	&& version != sizeof(struct module_stat)) {
	error = EINVAL;
	goto out;
    }

    namelen = strlen(mod->name) + 1;
    if (namelen > MAXMODNAME)
	namelen = MAXMODNAME;
    if ((error = copyout(mod->name, &stat->name[0], namelen)) != 0)
	goto out;

    if ((error = copyout(&mod->refs, &stat->refs, sizeof(int))) != 0)
	goto out;
    if ((error = copyout(&mod->id, &stat->id, sizeof(int))) != 0)
	goto out;

    /*
     * >v1 stat includes module data.
     */
    if (version == sizeof(struct module_stat)) {
	if ((error = copyout(&mod->data, &stat->data, sizeof(mod->data))) != 0)
	    goto out;
    }

    p->p_retval[0] = 0;

out:
    return error;
}
Exemplo n.º 5
0
int
modfnext(struct proc* p, struct modfnext_args* uap)
{
    module_t mod;

    p->p_retval[0] = -1;

    mod = module_lookupbyid(SCARG(uap, modid));
    if (!mod)
	return ENOENT;

    if (TAILQ_NEXT(mod, flink))
	p->p_retval[0] = TAILQ_NEXT(mod, flink)->id;
    else
	p->p_retval[0] = 0;
    return 0;
}