Add kern_cpuset_getid() and kern_cpuset_setid(), and use them
in compat32 instead of their sub_*() counterparts. Reviewed by: jhb@, kib@ MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9382
This commit is contained in:
parent
265c594a2c
commit
ea2ebdc19e
@ -2556,27 +2556,18 @@ int
|
||||
freebsd32_cpuset_setid(struct thread *td,
|
||||
struct freebsd32_cpuset_setid_args *uap)
|
||||
{
|
||||
struct cpuset_setid_args ap;
|
||||
|
||||
ap.which = uap->which;
|
||||
ap.id = PAIR32TO64(id_t,uap->id);
|
||||
ap.setid = uap->setid;
|
||||
|
||||
return (sys_cpuset_setid(td, &ap));
|
||||
return (kern_cpuset_setid(td, uap->which,
|
||||
PAIR32TO64(id_t, uap->id), uap->setid));
|
||||
}
|
||||
|
||||
int
|
||||
freebsd32_cpuset_getid(struct thread *td,
|
||||
struct freebsd32_cpuset_getid_args *uap)
|
||||
{
|
||||
struct cpuset_getid_args ap;
|
||||
|
||||
ap.level = uap->level;
|
||||
ap.which = uap->which;
|
||||
ap.id = PAIR32TO64(id_t,uap->id);
|
||||
ap.setid = uap->setid;
|
||||
|
||||
return (sys_cpuset_getid(td, &ap));
|
||||
return (kern_cpuset_getid(td, uap->level, uap->which,
|
||||
PAIR32TO64(id_t, uap->id), uap->setid));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -975,6 +975,14 @@ struct cpuset_setid_args {
|
||||
#endif
|
||||
int
|
||||
sys_cpuset_setid(struct thread *td, struct cpuset_setid_args *uap)
|
||||
{
|
||||
|
||||
return (kern_cpuset_setid(td, uap->which, uap->id, uap->setid));
|
||||
}
|
||||
|
||||
int
|
||||
kern_cpuset_setid(struct thread *td, cpuwhich_t which,
|
||||
id_t id, cpusetid_t setid)
|
||||
{
|
||||
struct cpuset *set;
|
||||
int error;
|
||||
@ -982,12 +990,12 @@ sys_cpuset_setid(struct thread *td, struct cpuset_setid_args *uap)
|
||||
/*
|
||||
* Presently we only support per-process sets.
|
||||
*/
|
||||
if (uap->which != CPU_WHICH_PID)
|
||||
if (which != CPU_WHICH_PID)
|
||||
return (EINVAL);
|
||||
set = cpuset_lookup(uap->setid, td);
|
||||
set = cpuset_lookup(setid, td);
|
||||
if (set == NULL)
|
||||
return (ESRCH);
|
||||
error = cpuset_setproc(uap->id, set, NULL);
|
||||
error = cpuset_setproc(id, set, NULL);
|
||||
cpuset_rel(set);
|
||||
return (error);
|
||||
}
|
||||
@ -1002,20 +1010,29 @@ struct cpuset_getid_args {
|
||||
#endif
|
||||
int
|
||||
sys_cpuset_getid(struct thread *td, struct cpuset_getid_args *uap)
|
||||
{
|
||||
|
||||
return (kern_cpuset_getid(td, uap->level, uap->which, uap->id,
|
||||
uap->setid));
|
||||
}
|
||||
|
||||
int
|
||||
kern_cpuset_getid(struct thread *td, cpulevel_t level, cpuwhich_t which,
|
||||
id_t id, cpusetid_t *setid)
|
||||
{
|
||||
struct cpuset *nset;
|
||||
struct cpuset *set;
|
||||
struct thread *ttd;
|
||||
struct proc *p;
|
||||
cpusetid_t id;
|
||||
cpusetid_t tmpid;
|
||||
int error;
|
||||
|
||||
if (uap->level == CPU_LEVEL_WHICH && uap->which != CPU_WHICH_CPUSET)
|
||||
if (level == CPU_LEVEL_WHICH && which != CPU_WHICH_CPUSET)
|
||||
return (EINVAL);
|
||||
error = cpuset_which(uap->which, uap->id, &p, &ttd, &set);
|
||||
error = cpuset_which(which, id, &p, &ttd, &set);
|
||||
if (error)
|
||||
return (error);
|
||||
switch (uap->which) {
|
||||
switch (which) {
|
||||
case CPU_WHICH_TID:
|
||||
case CPU_WHICH_PID:
|
||||
thread_lock(ttd);
|
||||
@ -1030,7 +1047,7 @@ sys_cpuset_getid(struct thread *td, struct cpuset_getid_args *uap)
|
||||
case CPU_WHICH_DOMAIN:
|
||||
return (EINVAL);
|
||||
}
|
||||
switch (uap->level) {
|
||||
switch (level) {
|
||||
case CPU_LEVEL_ROOT:
|
||||
nset = cpuset_refroot(set);
|
||||
cpuset_rel(set);
|
||||
@ -1041,10 +1058,10 @@ sys_cpuset_getid(struct thread *td, struct cpuset_getid_args *uap)
|
||||
case CPU_LEVEL_WHICH:
|
||||
break;
|
||||
}
|
||||
id = set->cs_id;
|
||||
tmpid = set->cs_id;
|
||||
cpuset_rel(set);
|
||||
if (error == 0)
|
||||
error = copyout(&id, uap->setid, sizeof(id));
|
||||
error = copyout(&tmpid, setid, sizeof(id));
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
@ -86,6 +86,10 @@ int kern_clock_settime(struct thread *td, clockid_t clock_id,
|
||||
int kern_close(struct thread *td, int fd);
|
||||
int kern_connectat(struct thread *td, int dirfd, int fd,
|
||||
struct sockaddr *sa);
|
||||
int kern_cpuset_getid(struct thread *td, cpulevel_t level,
|
||||
cpuwhich_t which, id_t id, cpusetid_t *setid);
|
||||
int kern_cpuset_setid(struct thread *td, cpuwhich_t which,
|
||||
id_t id, cpusetid_t setid);
|
||||
int kern_dup(struct thread *td, u_int mode, int flags, int old, int new);
|
||||
int kern_execve(struct thread *td, struct image_args *args,
|
||||
struct mac *mac_p);
|
||||
|
Loading…
Reference in New Issue
Block a user