Changeset View
Changeset View
Standalone View
Standalone View
head/sys/compat/linux/linux_emul.c
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | linux_set_default_openfiles(struct thread *td, struct proc *p) | ||||
if (rlim.rlim_cur != rlim.rlim_max || | if (rlim.rlim_cur != rlim.rlim_max || | ||||
rlim.rlim_cur <= linux_default_openfiles) | rlim.rlim_cur <= linux_default_openfiles) | ||||
return; | return; | ||||
rlim.rlim_cur = linux_default_openfiles; | rlim.rlim_cur = linux_default_openfiles; | ||||
error = kern_proc_setrlimit(td, p, RLIMIT_NOFILE, &rlim); | error = kern_proc_setrlimit(td, p, RLIMIT_NOFILE, &rlim); | ||||
KASSERT(error == 0, ("kern_proc_setrlimit failed")); | KASSERT(error == 0, ("kern_proc_setrlimit failed")); | ||||
} | } | ||||
/* | |||||
* The default stack size limit in Linux is 8MB. | |||||
*/ | |||||
static void | |||||
linux_set_default_stacksize(struct thread *td, struct proc *p) | |||||
{ | |||||
struct rlimit rlim; | |||||
int error; | |||||
if (linux_default_stacksize < 0) | |||||
return; | |||||
PROC_LOCK(p); | |||||
lim_rlimit_proc(p, RLIMIT_STACK, &rlim); | |||||
PROC_UNLOCK(p); | |||||
if (rlim.rlim_cur != rlim.rlim_max || | |||||
rlim.rlim_cur <= linux_default_stacksize) | |||||
return; | |||||
rlim.rlim_cur = linux_default_stacksize; | |||||
error = kern_proc_setrlimit(td, p, RLIMIT_STACK, &rlim); | |||||
KASSERT(error == 0, ("kern_proc_setrlimit failed")); | |||||
} | |||||
void | void | ||||
linux_proc_init(struct thread *td, struct thread *newtd, int flags) | linux_proc_init(struct thread *td, struct thread *newtd, int flags) | ||||
{ | { | ||||
struct linux_emuldata *em; | struct linux_emuldata *em; | ||||
struct linux_pemuldata *pem; | struct linux_pemuldata *pem; | ||||
struct epoll_emuldata *emd; | struct epoll_emuldata *emd; | ||||
struct proc *p; | struct proc *p; | ||||
Show All 14 Lines | if (flags & LINUX_CLONE_THREAD) { | ||||
pem = malloc(sizeof(*pem), M_LINUX, M_WAITOK | M_ZERO); | pem = malloc(sizeof(*pem), M_LINUX, M_WAITOK | M_ZERO); | ||||
sx_init(&pem->pem_sx, "lpemlk"); | sx_init(&pem->pem_sx, "lpemlk"); | ||||
p->p_emuldata = pem; | p->p_emuldata = pem; | ||||
} | } | ||||
newtd->td_emuldata = em; | newtd->td_emuldata = em; | ||||
linux_set_default_openfiles(td, p); | linux_set_default_openfiles(td, p); | ||||
linux_set_default_stacksize(td, p); | |||||
} else { | } else { | ||||
p = td->td_proc; | p = td->td_proc; | ||||
/* exec */ | /* exec */ | ||||
LINUX_CTR1(proc_init, "exec newtd(%d)", p->p_pid); | LINUX_CTR1(proc_init, "exec newtd(%d)", p->p_pid); | ||||
/* lookup the old one */ | /* lookup the old one */ | ||||
em = em_find(td); | em = em_find(td); | ||||
▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines |