summaryrefslogtreecommitdiff
path: root/sys/compat/linux/common/linux_file.c
diff options
context:
space:
mode:
authordsl <dsl@NetBSD.org>2007-04-22 08:29:55 +0000
committerdsl <dsl@NetBSD.org>2007-04-22 08:29:55 +0000
commitb8fbaf8c4be690d029da1be20006f487e2f81b17 (patch)
tree68186d3317175dfd95f7baa39a60030c8364e661 /sys/compat/linux/common/linux_file.c
parent98e922db67056a5d00e1de9d956eb8f21f649172 (diff)
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap' - which is very LWP unfriendly. The additional code for non-emulation namei() is trivial, the reduction for the emulations is massive. The vnode for a processes emulation root is saved in the cwdi structure during process exec. If the emulation root the TRYEMULROOT flag are set, namei() will do an initial search for absolute pathnames in the emulation root, if that fails it will retry from the normal root. ".." at the emulation root will always go to the real root, even in the middle of paths and when expanding symlinks. Absolute symlinks found using absolute paths in the emulation root will be relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links inside the emulation root don't need changing). If the root of the emulation would be returned (for an emulation lookup), then the real root is returned instead (matching the behaviour of emul_lookup, but being a cheap comparison here) so that programs that scan "../.." looking for the root dircetory don't loop forever. The target for symbolic links is no longer mangled (it used to get the CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended). CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding TRYEMULROOT to the flags to NDINIT(). A lot of the emulation system call stubs could now be deleted.
Diffstat (limited to 'sys/compat/linux/common/linux_file.c')
-rw-r--r--sys/compat/linux/common/linux_file.c95
1 files changed, 4 insertions, 91 deletions
diff --git a/sys/compat/linux/common/linux_file.c b/sys/compat/linux/common/linux_file.c
index 5155925174b..0c8f811b5f6 100644
--- a/sys/compat/linux/common/linux_file.c
+++ b/sys/compat/linux/common/linux_file.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file.c,v 1.81 2007/03/10 21:40:24 dsl Exp $ */
+/* $NetBSD: linux_file.c,v 1.82 2007/04/22 08:29:57 dsl Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.81 2007/03/10 21:40:24 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.82 2007/04/22 08:29:57 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -152,12 +152,7 @@ linux_sys_creat(l, v, retval)
syscallarg(const char *) path;
syscallarg(int) mode;
} */ *uap = v;
- struct proc *p = l->l_proc;
struct sys_open_args oa;
- void *sg;
-
- sg = stackgap_init(p, 0);
- CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
SCARG(&oa, path) = SCARG(uap, path);
SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY;
@@ -186,17 +181,9 @@ linux_sys_open(l, v, retval)
struct proc *p = l->l_proc;
int error, fl;
struct sys_open_args boa;
- void *sg;
-
- sg = stackgap_init(p, 0);
fl = linux_to_bsd_ioflags(SCARG(uap, flags));
- if (fl & O_CREAT)
- CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
- else
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
-
SCARG(&boa, path) = SCARG(uap, path);
SCARG(&boa, flags) = fl;
SCARG(&boa, mode) = SCARG(uap, mode);
@@ -565,16 +552,9 @@ linux_stat1(l, v, retval, flags)
{
struct linux_stat tmplst;
struct stat tmpst;
- void *sg;
int error;
struct linux_sys_stat_args *uap = v;
- sg = stackgap_init(l->l_proc, 0);
- if (flags == NOFOLLOW)
- CHECK_ALT_SYMLINK(l, &sg, SCARG(uap, path));
- else
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
-
error = do_sys_stat(l, SCARG(uap, path), flags, &tmpst);
if (error != 0)
return error;
@@ -628,10 +608,6 @@ linux_sys_access(l, v, retval)
syscallarg(const char *) path;
syscallarg(int) flags;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
return sys_access(l, uap, retval);
}
@@ -646,13 +622,9 @@ linux_sys_unlink(l, v, retval)
struct linux_sys_unlink_args /* {
syscallarg(const char *) path;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
int error;
struct nameidata nd;
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
-
error = sys_unlink(l, uap, retval);
if (error != EPERM)
return (error);
@@ -663,7 +635,7 @@ linux_sys_unlink(l, v, retval)
* check if the path points to directory and return EISDIR if this
* is the case.
*/
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, UIO_USERSPACE,
SCARG(uap, path), l);
if (namei(&nd) == 0) {
struct stat sb;
@@ -687,10 +659,6 @@ linux_sys_chdir(l, v, retval)
struct linux_sys_chdir_args /* {
syscallarg(const char *) path;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
return sys_chdir(l, uap, retval);
}
@@ -706,10 +674,6 @@ linux_sys_mknod(l, v, retval)
syscallarg(int) mode;
syscallarg(int) dev;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
/*
* BSD handles FIFOs separately
@@ -728,7 +692,7 @@ linux_sys_mknod(l, v, retval)
/*
* Linux device numbers uses 8 bits for minor and 8 bits
* for major. Due to how we map our major and minor,
- * this just fints into our dev_t. Just mask off the
+ * this just fits into our dev_t. Just mask off the
* upper 16bit to remove any random junk.
*/
SCARG(&bma, dev) = SCARG(uap, dev) & 0xffff;
@@ -746,10 +710,6 @@ linux_sys_chmod(l, v, retval)
syscallarg(const char *) path;
syscallarg(int) mode;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
return sys_chmod(l, uap, retval);
}
@@ -767,11 +727,7 @@ linux_sys_chown16(l, v, retval)
syscallarg(int) uid;
syscallarg(int) gid;
} */ *uap = v;
- struct proc *p = l->l_proc;
struct sys___posix_chown_args bca;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
SCARG(&bca, path) = SCARG(uap, path);
SCARG(&bca, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
@@ -815,11 +771,7 @@ linux_sys_lchown16(l, v, retval)
syscallarg(int) uid;
syscallarg(int) gid;
} */ *uap = v;
- struct proc *p = l->l_proc;
struct sys___posix_lchown_args bla;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_SYMLINK(l, &sg, SCARG(uap, path));
SCARG(&bla, path) = SCARG(uap, path);
SCARG(&bla, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
@@ -843,10 +795,6 @@ linux_sys_chown(l, v, retval)
syscallarg(int) uid;
syscallarg(int) gid;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
return sys___posix_chown(l, uap, retval);
}
@@ -862,10 +810,6 @@ linux_sys_lchown(l, v, retval)
syscallarg(int) uid;
syscallarg(int) gid;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_SYMLINK(l, &sg, SCARG(uap, path));
return sys___posix_lchown(l, uap, retval);
}
@@ -881,11 +825,6 @@ linux_sys_rename(l, v, retval)
syscallarg(const char *) from;
syscallarg(const char *) to;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, from));
- CHECK_ALT_CREAT(l, &sg, SCARG(uap, to));
return sys___posix_rename(l, uap, retval);
}
@@ -900,10 +839,6 @@ linux_sys_mkdir(l, v, retval)
syscallarg(const char *) path;
syscallarg(int) mode;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
return sys_mkdir(l, uap, retval);
}
@@ -917,10 +852,6 @@ linux_sys_rmdir(l, v, retval)
struct linux_sys_rmdir_args /* {
syscallarg(const char *) path;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
return sys_rmdir(l, uap, retval);
}
@@ -935,11 +866,6 @@ linux_sys_symlink(l, v, retval)
syscallarg(const char *) path;
syscallarg(const char *) to;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
- CHECK_ALT_CREAT(l, &sg, SCARG(uap, to));
return sys_symlink(l, uap, retval);
}
@@ -954,11 +880,6 @@ linux_sys_link(l, v, retval)
syscallarg(const char *) path;
syscallarg(const char *) link;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
- CHECK_ALT_CREAT(l, &sg, SCARG(uap, link));
return sys_link(l, uap, retval);
}
@@ -974,10 +895,6 @@ linux_sys_readlink(l, v, retval)
syscallarg(char *) buf;
syscallarg(int) count;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_SYMLINK(l, &sg, SCARG(uap, name));
return sys_readlink(l, uap, retval);
}
@@ -993,10 +910,6 @@ linux_sys_truncate(l, v, retval)
syscallarg(const char *) path;
syscallarg(long) length;
} */ *uap = v;
- struct proc *p = l->l_proc;
- void *sg = stackgap_init(p, 0);
-
- CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
return compat_43_sys_truncate(l, uap, retval);
}