Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Enable kernel-internal symlink creation with do_sys_syml...



details:   https://anonhg.NetBSD.org/src/rev/b1e18da706a8
branches:  trunk
changeset: 755959:b1e18da706a8
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Jun 30 15:44:54 2010 +0000

description:
Enable kernel-internal symlink creation with do_sys_symlink().
I did this a while ago already, but can't remember why i didn't
commit it then.

diffstat:

 sys/kern/vfs_syscalls.c |  45 ++++++++++++++++++++++++++++-----------------
 sys/sys/vfs_syscalls.h  |   3 ++-
 2 files changed, 30 insertions(+), 18 deletions(-)

diffs (98 lines):

diff -r c8f0fc6545db -r b1e18da706a8 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Wed Jun 30 15:40:30 2010 +0000
+++ b/sys/kern/vfs_syscalls.c   Wed Jun 30 15:44:54 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.406 2010/06/24 13:03:12 hannken Exp $       */
+/*     $NetBSD: vfs_syscalls.c,v 1.407 2010/06/30 15:44:54 pooka Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.406 2010/06/24 13:03:12 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.407 2010/06/30 15:44:54 pooka Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -2024,29 +2024,24 @@
        return (error);
 }
 
-/*
- * Make a symbolic link.
- */
-/* ARGSUSED */
 int
-sys_symlink(struct lwp *l, const struct sys_symlink_args *uap, register_t *retval)
+do_sys_symlink(const char *patharg, const char *link, enum uio_seg seg)
 {
-       /* {
-               syscallarg(const char *) path;
-               syscallarg(const char *) link;
-       } */
-       struct proc *p = l->l_proc;
+       struct proc *p = curproc;
        struct vattr vattr;
        char *path;
        int error;
        struct nameidata nd;
 
        path = PNBUF_GET();
-       error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL);
-       if (error)
-               goto out;
-       NDINIT(&nd, CREATE, LOCKPARENT | TRYEMULROOT, UIO_USERSPACE,
-           SCARG(uap, link));
+       if (seg == UIO_USERSPACE) {
+               if ((error = copyinstr(patharg, path, MAXPATHLEN, NULL)) != 0)
+                       goto out;
+       } else {
+               KASSERT(strlen(patharg) < MAXPATHLEN);
+               strcpy(path, patharg);
+       }
+       NDINIT(&nd, CREATE, LOCKPARENT | TRYEMULROOT, seg, link);
        if ((error = namei(&nd)) != 0)
                goto out;
        if (nd.ni_vp) {
@@ -2072,6 +2067,22 @@
 }
 
 /*
+ * Make a symbolic link.
+ */
+/* ARGSUSED */
+int
+sys_symlink(struct lwp *l, const struct sys_symlink_args *uap, register_t *retval)
+{
+       /* {
+               syscallarg(const char *) path;
+               syscallarg(const char *) link;
+       } */
+
+       return do_sys_symlink(SCARG(uap, path), SCARG(uap, link),
+           UIO_USERSPACE);
+}
+
+/*
  * Delete a whiteout from the filesystem.
  */
 /* ARGSUSED */
diff -r c8f0fc6545db -r b1e18da706a8 sys/sys/vfs_syscalls.h
--- a/sys/sys/vfs_syscalls.h    Wed Jun 30 15:40:30 2010 +0000
+++ b/sys/sys/vfs_syscalls.h    Wed Jun 30 15:44:54 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.h,v 1.13 2009/08/09 22:49:00 haad Exp $        */
+/*     $NetBSD: vfs_syscalls.h,v 1.14 2010/06/30 15:44:55 pooka Exp $        */
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -65,6 +65,7 @@
 int    do_sys_mknod(struct lwp *, const char *, mode_t, dev_t, register_t *,
     enum uio_seg);
 int    do_sys_mkdir(const char *, mode_t, enum uio_seg);
+int    do_sys_symlink(const char *, const char *, enum uio_seg);
 
 int    chdir_lookup(const char *, int, struct vnode **, struct lwp *);
 void   change_root(struct cwdinfo *, struct vnode *, struct lwp *);



Home | Main Index | Thread Index | Old Index