Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux_util.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
LIN_SDT_PROVIDER_DEFINE(linuxulator32); | LIN_SDT_PROVIDER_DEFINE(linuxulator32); | ||||
char linux_emul_path[MAXPATHLEN] = "/compat/linux"; | char linux_emul_path[MAXPATHLEN] = "/compat/linux"; | ||||
SYSCTL_STRING(_compat_linux, OID_AUTO, emul_path, CTLFLAG_RWTUN, | SYSCTL_STRING(_compat_linux, OID_AUTO, emul_path, CTLFLAG_RWTUN, | ||||
linux_emul_path, sizeof(linux_emul_path), | linux_emul_path, sizeof(linux_emul_path), | ||||
"Linux runtime environment path"); | "Linux runtime environment path"); | ||||
/* | |||||
* Search an alternate path before passing pathname arguments on to | |||||
* system calls. Useful for keeping a separate 'emulation tree'. | |||||
* | |||||
* If cflag is set, we check if an attempt can be made to create the | |||||
* named file, i.e. we check if the directory it should be in exists. | |||||
*/ | |||||
int | int | ||||
linux_emul_convpath(const char *path, enum uio_seg pathseg, | linux_pwd_onexec(struct thread *td) | ||||
char **pbuf, int cflag, int dfd) | |||||
{ | { | ||||
int retval; | struct nameidata nd; | ||||
struct pwd *pwd; | |||||
int error; | |||||
retval = kern_alternate_path(linux_emul_path, path, pathseg, pbuf, | NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path); | ||||
cflag, dfd); | error = namei(&nd); | ||||
if (error != 0) { | |||||
/* | |||||
* Do not bother if we are in chroot or jail. | |||||
*/ | |||||
pwd = pwd_hold(td); | |||||
if (pwd->pwd_rdir != rootvnode) { | |||||
pwd_drop(pwd); | |||||
return (0); | |||||
} | |||||
pwd_drop(pwd); | |||||
return (error); | |||||
} | |||||
NDFREE_PNBUF(&nd); | |||||
pwd_exec(td, nd.ni_vp); | |||||
vrele(nd.ni_vp); | |||||
return (0); | |||||
} | |||||
return (retval); | void | ||||
linux_pwd_onexec_native(struct thread *td) | |||||
{ | |||||
pwd_exec(td, NULL); | |||||
} | } | ||||
void | void | ||||
linux_msg(const struct thread *td, const char *fmt, ...) | linux_msg(const struct thread *td, const char *fmt, ...) | ||||
{ | { | ||||
va_list ap; | va_list ap; | ||||
struct proc *p; | struct proc *p; | ||||
if (linux_debug == 0) | if (linux_debug == 0) | ||||
return; | return; | ||||
p = td->td_proc; | p = td->td_proc; | ||||
printf("linux: jid %d pid %d (%s): ", p->p_ucred->cr_prison->pr_id, | printf("linux: jid %d pid %d (%s): ", p->p_ucred->cr_prison->pr_id, | ||||
(int)p->p_pid, p->p_comm); | (int)p->p_pid, p->p_comm); | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
vprintf(fmt, ap); | vprintf(fmt, ap); | ||||
va_end(ap); | va_end(ap); | ||||
printf("\n"); | printf("\n"); | ||||
} | } | ||||
kib: Why do you need ncp? Why not move cp content further up and then directly put linux_emul_path… | |||||
struct device_element | struct device_element | ||||
{ | { | ||||
TAILQ_ENTRY(device_element) list; | TAILQ_ENTRY(device_element) list; | ||||
struct linux_device_handler entry; | struct linux_device_handler entry; | ||||
}; | }; | ||||
static TAILQ_HEAD(, device_element) devices = | static TAILQ_HEAD(, device_element) devices = | ||||
TAILQ_HEAD_INITIALIZER(devices); | TAILQ_HEAD_INITIALIZER(devices); | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |
Why do you need ncp? Why not move cp content further up and then directly put linux_emul_path into the right place?