diff options
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_event.c | 4 | ||||
-rw-r--r-- | sys/compat/linux/linux_event.h | 2 | ||||
-rw-r--r-- | sys/compat/linux/linux_file.c | 3 | ||||
-rw-r--r-- | sys/compat/linux/linux_fork.c | 2 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.c | 14 | ||||
-rw-r--r-- | sys/compat/svr4/imgact_svr4.c | 2 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 30 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_resource.c | 16 |
8 files changed, 25 insertions, 48 deletions
diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index 4031588..fcb5753 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -260,6 +260,8 @@ epoll_to_kevent(struct thread *td, struct file *epfp, *kev_flags |= EV_CLEAR; if ((levents & LINUX_EPOLLERR) != 0) *kev_flags |= EV_ERROR; + if ((levents & LINUX_EPOLLRDHUP) != 0) + *kev_flags |= EV_EOF; /* flags related to what event is registered */ if ((levents & LINUX_EPOLL_EVRD) != 0) { @@ -309,6 +311,8 @@ kevent_to_epoll(struct kevent *kevent, struct epoll_event *l_event) switch (kevent->filter) { case EVFILT_READ: l_event->events = LINUX_EPOLLIN|LINUX_EPOLLRDNORM|LINUX_EPOLLPRI; + if ((kevent->flags & EV_EOF) != 0) + l_event->events |= LINUX_EPOLLRDHUP; break; case EVFILT_WRITE: l_event->events = LINUX_EPOLLOUT|LINUX_EPOLLWRNORM; diff --git a/sys/compat/linux/linux_event.h b/sys/compat/linux/linux_event.h index 0c030ad..9b7d37b 100644 --- a/sys/compat/linux/linux_event.h +++ b/sys/compat/linux/linux_event.h @@ -49,7 +49,7 @@ |LINUX_EPOLLHUP|LINUX_EPOLLERR|LINUX_EPOLLPRI) #define LINUX_EPOLL_EVWR (LINUX_EPOLLOUT|LINUX_EPOLLWRNORM) #define LINUX_EPOLL_EVSUP (LINUX_EPOLLET|LINUX_EPOLLONESHOT \ - |LINUX_EPOLL_EVRD|LINUX_EPOLL_EVWR) + |LINUX_EPOLL_EVRD|LINUX_EPOLL_EVWR|LINUX_EPOLLRDHUP) #define LINUX_EPOLL_CTL_ADD 1 #define LINUX_EPOLL_CTL_DEL 2 diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 9251a20..1e5e37a 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -348,8 +348,7 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args, } else justone = 0; - error = getvnode(td->td_proc->p_fd, args->fd, - cap_rights_init(&rights, CAP_READ), &fp); + error = getvnode(td, args->fd, cap_rights_init(&rights, CAP_READ), &fp); if (error != 0) return (error); diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index 0fd47fd..394c26f 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -298,7 +298,7 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args) __rangeof(struct thread, td_startcopy, td_endcopy)); newtd->td_proc = p; - newtd->td_ucred = crhold(td->td_ucred); + thread_cow_get(newtd, td); /* create the emuldata */ linux_proc_init(td, newtd, args->flags); diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 65d27ba..fa5feaf 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -383,7 +383,7 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args) */ PROC_LOCK(td->td_proc); if (a_out->a_text > maxtsiz || - a_out->a_data + bss_size > lim_cur(td->td_proc, RLIMIT_DATA) || + a_out->a_data + bss_size > lim_cur_proc(td->td_proc, RLIMIT_DATA) || racct_set(td->td_proc, RACCT_DATA, a_out->a_data + bss_size) != 0) { PROC_UNLOCK(td->td_proc); @@ -1420,7 +1420,6 @@ int linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args) { struct l_rlimit rlim; - struct proc *p = td->td_proc; struct rlimit bsd_rlim; u_int which; @@ -1437,9 +1436,7 @@ linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args) if (which == -1) return (EINVAL); - PROC_LOCK(p); - lim_rlimit(p, which, &bsd_rlim); - PROC_UNLOCK(p); + lim_rlimit(td, which, &bsd_rlim); #ifdef COMPAT_LINUX32 rlim.rlim_cur = (unsigned int)bsd_rlim.rlim_cur; @@ -1464,7 +1461,6 @@ int linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args) { struct l_rlimit rlim; - struct proc *p = td->td_proc; struct rlimit bsd_rlim; u_int which; @@ -1481,9 +1477,7 @@ linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args) if (which == -1) return (EINVAL); - PROC_LOCK(p); - lim_rlimit(p, which, &bsd_rlim); - PROC_UNLOCK(p); + lim_rlimit(td, which, &bsd_rlim); rlim.rlim_cur = (l_ulong)bsd_rlim.rlim_cur; rlim.rlim_max = (l_ulong)bsd_rlim.rlim_max; @@ -2204,7 +2198,7 @@ linux_prlimit64(struct thread *td, struct linux_prlimit64_args *args) if (args->old != NULL) { PROC_LOCK(p); - lim_rlimit(p, which, &rlim); + lim_rlimit_proc(p, which, &rlim); PROC_UNLOCK(p); if (rlim.rlim_cur == RLIM_INFINITY) lrlim.rlim_cur = LINUX_RLIM_INFINITY; diff --git a/sys/compat/svr4/imgact_svr4.c b/sys/compat/svr4/imgact_svr4.c index f3bb09e..e61b49b 100644 --- a/sys/compat/svr4/imgact_svr4.c +++ b/sys/compat/svr4/imgact_svr4.c @@ -109,7 +109,7 @@ exec_svr4_imgact(imgp) */ PROC_LOCK(imgp->proc); if (a_out->a_text > maxtsiz || - a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA) || + a_out->a_data + bss_size > lim_cur_proc(imgp->proc, RLIMIT_DATA) || racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) { PROC_UNLOCK(imgp->proc); return (ENOMEM); diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index c0da170..ec4504e 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -262,8 +262,7 @@ svr4_sys_getdents64(td, uap) DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n", uap->fd, uap->nbytes)); - error = getvnode(td->td_proc->p_fd, uap->fd, - cap_rights_init(&rights, CAP_READ), &fp); + error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp); if (error != 0) return (error); @@ -442,8 +441,7 @@ svr4_sys_getdents(td, uap) if (uap->nbytes < 0) return (EINVAL); - error = getvnode(td->td_proc->p_fd, uap->fd, - cap_rights_init(&rights, CAP_READ), &fp); + error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp); if (error != 0) return (error); @@ -622,7 +620,7 @@ svr4_sys_fchroot(td, uap) struct thread *td; struct svr4_sys_fchroot_args *uap; { - struct filedesc *fdp = td->td_proc->p_fd; + cap_rights_t rights; struct vnode *vp; struct file *fp; int error; @@ -630,7 +628,7 @@ svr4_sys_fchroot(td, uap) if ((error = priv_check(td, PRIV_VFS_FCHROOT)) != 0) return error; /* XXX: we have the chroot priv... what cap might we need? all? */ - if ((error = getvnode(fdp, uap->fd, 0, &fp)) != 0) + if ((error = getvnode(td, uap->fd, cap_rights_init(&rights), &fp)) != 0) return error; vp = fp->f_vnode; VREF(vp); @@ -910,9 +908,7 @@ svr4_sys_ulimit(td, uap) switch (uap->cmd) { case SVR4_GFILLIM: - PROC_LOCK(td->td_proc); - *retval = lim_cur(td->td_proc, RLIMIT_FSIZE) / 512; - PROC_UNLOCK(td->td_proc); + *retval = lim_cur(td, RLIMIT_FSIZE) / 512; if (*retval == -1) *retval = 0x7fffffff; return 0; @@ -922,17 +918,13 @@ svr4_sys_ulimit(td, uap) struct rlimit krl; krl.rlim_cur = uap->newlimit * 512; - PROC_LOCK(td->td_proc); - krl.rlim_max = lim_max(td->td_proc, RLIMIT_FSIZE); - PROC_UNLOCK(td->td_proc); + krl.rlim_max = lim_max(td, RLIMIT_FSIZE); error = kern_setrlimit(td, RLIMIT_FSIZE, &krl); if (error) return error; - PROC_LOCK(td->td_proc); - *retval = lim_cur(td->td_proc, RLIMIT_FSIZE); - PROC_UNLOCK(td->td_proc); + *retval = lim_cur(td, RLIMIT_FSIZE); if (*retval == -1) *retval = 0x7fffffff; return 0; @@ -943,9 +935,7 @@ svr4_sys_ulimit(td, uap) struct vmspace *vm = td->td_proc->p_vmspace; register_t r; - PROC_LOCK(td->td_proc); - r = lim_cur(td->td_proc, RLIMIT_DATA); - PROC_UNLOCK(td->td_proc); + r = lim_cur(td, RLIMIT_DATA); if (r == -1) r = 0x7fffffff; @@ -957,9 +947,7 @@ svr4_sys_ulimit(td, uap) } case SVR4_GDESLIM: - PROC_LOCK(td->td_proc); - *retval = lim_cur(td->td_proc, RLIMIT_NOFILE); - PROC_UNLOCK(td->td_proc); + *retval = lim_cur(td, RLIMIT_NOFILE); if (*retval == -1) *retval = 0x7fffffff; return 0; diff --git a/sys/compat/svr4/svr4_resource.c b/sys/compat/svr4/svr4_resource.c index efa0bcf..667ee88 100644 --- a/sys/compat/svr4/svr4_resource.c +++ b/sys/compat/svr4/svr4_resource.c @@ -130,9 +130,7 @@ svr4_sys_getrlimit(td, uap) if (rl == -1) return EINVAL; - PROC_LOCK(td->td_proc); - lim_rlimit(td->td_proc, rl, &blim); - PROC_UNLOCK(td->td_proc); + lim_rlimit(td, rl, &blim); /* * Our infinity, is their maxfiles. @@ -181,9 +179,7 @@ svr4_sys_setrlimit(td, uap) if ((error = copyin(uap->rlp, &slim, sizeof(slim))) != 0) return error; - PROC_LOCK(td->td_proc); - lim_rlimit(td->td_proc, rl, &curlim); - PROC_UNLOCK(td->td_proc); + lim_rlimit(td, rl, &curlim); /* * if the limit is SVR4_RLIM_INFINITY, then we set it to our @@ -228,9 +224,7 @@ svr4_sys_getrlimit64(td, uap) if (rl == -1) return EINVAL; - PROC_LOCK(td->td_proc); - lim_rlimit(td->td_proc, rl, &blim); - PROC_UNLOCK(td->td_proc); + lim_rlimit(td, rl, &blim); /* * Our infinity, is their maxfiles. @@ -279,9 +273,7 @@ svr4_sys_setrlimit64(td, uap) if ((error = copyin(uap->rlp, &slim, sizeof(slim))) != 0) return error; - PROC_LOCK(td->td_proc); - lim_rlimit(td->td_proc, rl, &curlim); - PROC_UNLOCK(td->td_proc); + lim_rlimit(td, rl, &curlim); /* * if the limit is SVR4_RLIM64_INFINITY, then we set it to our |