Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136022978
D1046.id2295.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D1046.id2295.diff
View Options
Index: sys/amd64/linux32/linux32_dummy.c
===================================================================
--- sys/amd64/linux32/linux32_dummy.c
+++ sys/amd64/linux32/linux32_dummy.c
@@ -84,7 +84,6 @@
DUMMY(mq_notify);
DUMMY(mq_getsetattr);
DUMMY(kexec_load);
-DUMMY(waitid);
/* linux 2.6.11: */
DUMMY(add_key);
DUMMY(request_key);
Index: sys/amd64/linux32/linux32_machdep.c
===================================================================
--- sys/amd64/linux32/linux32_machdep.c
+++ sys/amd64/linux32/linux32_machdep.c
@@ -1049,3 +1049,66 @@
return (error);
}
+
+int
+linux_waitid(struct thread *td, struct linux_waitid_args *args)
+{
+ int status, options, sig;
+ struct __wrusage wru;
+ struct l_rusage lru;
+ siginfo_t siginfo;
+ l_siginfo_t lsi;
+ idtype_t idtype;
+ struct proc *p;
+ int error;
+
+ options = 0;
+ linux_to_bsd_waitopts(args->options, &options);
+
+ if (options & ~(WNOHANG | WNOWAIT | WEXITED | WUNTRACED | WCONTINUED))
+ return (EINVAL);
+ if (!(options & (WEXITED | WUNTRACED | WCONTINUED)))
+ return (EINVAL);
+
+ switch (args->idtype) {
+ case LINUX_P_ALL:
+ idtype = P_ALL;
+ break;
+ case LINUX_P_PID:
+ if (args->id <= 0)
+ return (EINVAL);
+ idtype = P_PID;
+ break;
+ case LINUX_P_PGID:
+ if (args->id <= 0)
+ return (EINVAL);
+ idtype = P_PGID;
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ error = kern_wait6(td, idtype, args->id, &status, options,
+ &wru, &siginfo);
+ if (error)
+ return (error);
+ if (args->rusage != NULL) {
+ bsd_to_linux_rusage(&wru.wru_children, &lru);
+ error = copyout(&lru, args->rusage, sizeof(lru));
+ if (error)
+ return (error);
+ }
+ if (args->info != NULL) {
+ p = td->td_proc;
+ if (td->td_retval[0] == 0)
+ bzero(&lsi, sizeof(lsi));
+ else {
+ sig = BSD_TO_LINUX_SIGNAL(siginfo.si_signo);
+ siginfo_to_lsiginfo(&siginfo, &lsi, sig);
+ }
+ error = copyout(&lsi, args->info, sizeof(lsi));
+ }
+ td->td_retval[0] = 0;
+
+ return (error);
+}
Index: sys/amd64/linux32/syscalls.master
===================================================================
--- sys/amd64/linux32/syscalls.master
+++ sys/amd64/linux32/syscalls.master
@@ -466,7 +466,8 @@
281 AUE_NULL STD { int linux_mq_notify(void); }
282 AUE_NULL STD { int linux_mq_getsetattr(void); }
283 AUE_NULL STD { int linux_kexec_load(void); }
-284 AUE_NULL STD { int linux_waitid(void); }
+284 AUE_WAIT6 STD { int linux_waitid(int idtype, l_pid_t id, l_siginfo_t *info, \
+ int options, struct l_rusage *rusage); }
285 AUE_NULL UNIMPL
; linux 2.6.11:
286 AUE_NULL STD { int linux_add_key(void); }
Index: sys/compat/linux/linux_misc.h
===================================================================
--- sys/compat/linux/linux_misc.h
+++ sys/compat/linux/linux_misc.h
@@ -122,6 +122,12 @@
#define __WALL 0x40000000
#define __WCLONE 0x80000000
+/* Linux waitid idtype */
+#define LINUX_P_ALL 0
+#define LINUX_P_PID 1
+#define LINUX_P_PGID 2
+
+
int linux_common_wait(struct thread *td, int pid, int *status,
int options, struct rusage *ru);
void linux_to_bsd_waitopts(int options, int *bsdopts);
Index: sys/i386/linux/linux_dummy.c
===================================================================
--- sys/i386/linux/linux_dummy.c
+++ sys/i386/linux/linux_dummy.c
@@ -80,7 +80,6 @@
DUMMY(get_mempolicy);
DUMMY(set_mempolicy);
DUMMY(kexec_load);
-DUMMY(waitid);
/* linux 2.6.11: */
DUMMY(add_key);
DUMMY(request_key);
Index: sys/i386/linux/linux_machdep.c
===================================================================
--- sys/i386/linux/linux_machdep.c
+++ sys/i386/linux/linux_machdep.c
@@ -1069,3 +1069,66 @@
return (error);
}
+
+int
+linux_waitid(struct thread *td, struct linux_waitid_args *args)
+{
+ int status, options, sig;
+ struct __wrusage wru;
+ siginfo_t siginfo;
+ l_siginfo_t lsi;
+ idtype_t idtype;
+ struct proc *p;
+ int error;
+
+ options = 0;
+ linux_to_bsd_waitopts(args->options, &options);
+
+ if (options & ~(WNOHANG | WNOWAIT | WEXITED | WUNTRACED | WCONTINUED))
+ return (EINVAL);
+ if (!(options & (WEXITED | WUNTRACED | WCONTINUED)))
+ return (EINVAL);
+
+ switch (args->idtype) {
+ case LINUX_P_ALL:
+ idtype = P_ALL;
+ break;
+ case LINUX_P_PID:
+ if (args->id <= 0)
+ return (EINVAL);
+ idtype = P_PID;
+ break;
+ case LINUX_P_PGID:
+ if (args->id <= 0)
+ return (EINVAL);
+ idtype = P_PGID;
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ error = kern_wait6(td, idtype, args->id, &status, options,
+ &wru, &siginfo);
+ if (error)
+ return (error);
+ if (args->rusage != NULL) {
+ error = copyout(&wru.wru_children, args->rusage,
+ sizeof(wru.wru_children));
+ if (error)
+ return (error);
+ }
+ if (args->info != NULL) {
+ p = td->td_proc;
+ if (td->td_retval[0] == 0)
+ bzero(&lsi, sizeof(lsi));
+ else {
+ sig = BSD_TO_LINUX_SIGNAL(siginfo.si_signo);
+ siginfo_to_lsiginfo(&siginfo, &lsi, sig);
+ }
+ siginfo_to_lsiginfo(&siginfo, &lsi, sig);
+ error = copyout(&lsi, args->info, sizeof(lsi));
+ }
+ td->td_retval[0] = 0;
+
+ return (error);
+}
Index: sys/i386/linux/syscalls.master
===================================================================
--- sys/i386/linux/syscalls.master
+++ sys/i386/linux/syscalls.master
@@ -474,7 +474,8 @@
282 AUE_NULL STD { int linux_mq_getsetattr(l_mqd_t mqd, const struct mq_attr *attr, \
struct mq_attr *oattr); }
283 AUE_NULL STD { int linux_kexec_load(void); }
-284 AUE_NULL STD { int linux_waitid(void); }
+284 AUE_WAIT6 STD { int linux_waitid(int idtype, l_pid_t id, l_siginfo_t *info, \
+ int options, struct l_rusage *rusage); }
285 AUE_NULL UNIMPL
; linux 2.6.11:
286 AUE_NULL STD { int linux_add_key(void); }
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 16, 4:26 AM (11 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25352502
Default Alt Text
D1046.id2295.diff (5 KB)
Attached To
Mode
D1046: Implement waitid() system call.
Attached
Detach File
Event Timeline
Log In to Comment