diff options
author | trasz <trasz@FreeBSD.org> | 2017-03-19 15:07:30 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2017-03-19 15:07:30 +0000 |
commit | 5ec65527ada093e90047edf47beabdcc95d99b95 (patch) | |
tree | 2c0fe57fef54938528607a68167dc531ce28c577 | |
parent | a43cc8b98dc6738add7832af5e872a83d666a0de (diff) | |
download | FreeBSD-src-5ec65527ada093e90047edf47beabdcc95d99b95.zip FreeBSD-src-5ec65527ada093e90047edf47beabdcc95d99b95.tar.gz |
MFC r313015:
Add kern_cpuset_getid() and kern_cpuset_setid(), and use them
in compat32 instead of their sub_*() counterparts.
Sponsored by: DARPA, AFRL
-rw-r--r-- | sys/compat/freebsd32/freebsd32_misc.c | 17 | ||||
-rw-r--r-- | sys/kern/kern_cpuset.c | 37 | ||||
-rw-r--r-- | sys/sys/syscallsubr.h | 4 |
3 files changed, 35 insertions, 23 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 8857e91..2905c14 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2526,27 +2526,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 diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index f0f184b..a78b684 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -976,18 +976,26 @@ struct cpuset_setid_args { 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; /* * 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); } @@ -1003,19 +1011,28 @@ struct cpuset_getid_args { 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); } diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index f9cb3ed..f783b90 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -87,6 +87,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); |