Date: Tue, 31 Jan 2017 15:11:23 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313015 - in head/sys: compat/freebsd32 kern sys Message-ID: <201701311511.v0VFBN6F012666@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Tue Jan 31 15:11:23 2017 New Revision: 313015 URL: https://svnweb.freebsd.org/changeset/base/313015 Log: 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 Modified: head/sys/compat/freebsd32/freebsd32_misc.c head/sys/kern/kern_cpuset.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- head/sys/compat/freebsd32/freebsd32_misc.c Tue Jan 31 14:36:06 2017 (r313014) +++ head/sys/compat/freebsd32/freebsd32_misc.c Tue Jan 31 15:11:23 2017 (r313015) @@ -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 Modified: head/sys/kern/kern_cpuset.c ============================================================================== --- head/sys/kern/kern_cpuset.c Tue Jan 31 14:36:06 2017 (r313014) +++ head/sys/kern/kern_cpuset.c Tue Jan 31 15:11:23 2017 (r313015) @@ -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, stru 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, stru 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); } Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Tue Jan 31 14:36:06 2017 (r313014) +++ head/sys/sys/syscallsubr.h Tue Jan 31 15:11:23 2017 (r313015) @@ -86,6 +86,10 @@ int kern_clock_settime(struct thread *td 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701311511.v0VFBN6F012666>