diff options
author | kstailey <kstailey@cvs.openbsd.org> | 1999-09-17 15:03:19 +0000 |
---|---|---|
committer | kstailey <kstailey@cvs.openbsd.org> | 1999-09-17 15:03:19 +0000 |
commit | 457ef0ff94217f6c6731b8571aeb871aaf243adf (patch) | |
tree | 9ec4a240f74f43890620dfb9463bf90de89fc990 /sys/compat | |
parent | 3f0d662a67e3a71ad1554b74c3742cd2f3e81196 (diff) |
lcrap()
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/netbsd/netbsd_misc.c | 92 | ||||
-rw-r--r-- | sys/compat/netbsd/netbsd_types.h | 3 | ||||
-rw-r--r-- | sys/compat/netbsd/syscalls.master | 12 |
3 files changed, 98 insertions, 9 deletions
diff --git a/sys/compat/netbsd/netbsd_misc.c b/sys/compat/netbsd/netbsd_misc.c index 6eadffd8da7..737ea6f6c16 100644 --- a/sys/compat/netbsd/netbsd_misc.c +++ b/sys/compat/netbsd/netbsd_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netbsd_misc.c,v 1.4 1999/09/17 13:41:29 kstailey Exp $ */ +/* $OpenBSD: netbsd_misc.c,v 1.5 1999/09/17 15:03:18 kstailey Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -44,7 +44,9 @@ #include <sys/param.h> #include <sys/file.h> #include <sys/mount.h> +#include <sys/namei.h> #include <sys/proc.h> +#include <sys/stat.h> #include <sys/vnode.h> #include <compat/netbsd/netbsd_types.h> @@ -88,3 +90,91 @@ netbsd_sys_fdatasync(p, v, retval) VOP_UNLOCK(vp, 0, p); return (error); } + +/*ARGSUSED*/ +int +netbsd_sys_lchmod(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + register struct netbsd_sys_lchmod_args /* { + syscallarg(char *) path; + syscallarg(netbsd_mode_t) mode; + } */ *uap = v; + register struct vnode *vp; + struct vattr vattr; + int error; + struct nameidata nd; + + if (SCARG(uap, mode) & ~(S_IFMT | ALLPERMS)) + return (EINVAL); + + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + if ((error = namei(&nd)) != 0) + return (error); + vp = nd.ni_vp; + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + if (vp->v_mount->mnt_flag & MNT_RDONLY) + error = EROFS; + else { + VATTR_NULL(&vattr); + vattr.va_mode = SCARG(uap, mode) & ALLPERMS; + error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); + } + vput(vp); + return (error); +} + +/*ARGSUSED*/ +int +netbsd_sys_lutimes(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + register struct netbsd_sys_lutimes_args /* { + syscallarg(const char *) path; + syscallarg(const struct timeval *) tptr; + } */ *uap = v; + register struct vnode *vp; + struct timeval tv[2]; + struct vattr vattr; + int error; + struct nameidata nd; + + VATTR_NULL(&vattr); + if (SCARG(uap, tptr) == NULL) { + microtime(&tv[0]); + tv[1] = tv[0]; + vattr.va_vaflags |= VA_UTIMES_NULL; + } else { + error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv, + sizeof (tv)); + if (error) + return (error); + /* XXX workaround timeval matching the VFS constant VNOVAL */ + if (tv[0].tv_sec == VNOVAL) + tv[0].tv_sec = VNOVAL - 1; + if (tv[1].tv_sec == VNOVAL) + tv[1].tv_sec = VNOVAL - 1; + } + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p); + if ((error = namei(&nd)) != 0) + return (error); + vp = nd.ni_vp; + VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + if (vp->v_mount->mnt_flag & MNT_RDONLY) + error = EROFS; + else { + vattr.va_atime.tv_sec = tv[0].tv_sec; + vattr.va_atime.tv_nsec = tv[0].tv_usec * 1000; + vattr.va_mtime.tv_sec = tv[1].tv_sec; + vattr.va_mtime.tv_nsec = tv[1].tv_usec * 1000; + error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); + } + vput(vp); + return (error); +} diff --git a/sys/compat/netbsd/netbsd_types.h b/sys/compat/netbsd/netbsd_types.h index ffdbff50435..db97908588d 100644 --- a/sys/compat/netbsd/netbsd_types.h +++ b/sys/compat/netbsd/netbsd_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netbsd_types.h,v 1.2 1999/09/17 12:13:47 kstailey Exp $ */ +/* $OpenBSD: netbsd_types.h,v 1.3 1999/09/17 15:03:18 kstailey Exp $ */ /*- * Copyright (c) 1982, 1986, 1991, 1993, 1994 @@ -43,3 +43,4 @@ typedef int64_t netbsd_blkcnt_t; /* fs block count */ typedef u_int32_t netbsd_blksize_t; /* fs optimal block size */ typedef u_int32_t netbsd_nlink_t; /* link count */ +typedef u_int32_t netbsd_mode_t; /* permissions */ diff --git a/sys/compat/netbsd/syscalls.master b/sys/compat/netbsd/syscalls.master index c1b5a251691..43a6a2af343 100644 --- a/sys/compat/netbsd/syscalls.master +++ b/sys/compat/netbsd/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.7 1999/09/17 13:41:29 kstailey Exp $ +; $OpenBSD: syscalls.master,v 1.8 1999/09/17 15:03:18 kstailey Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -545,14 +545,12 @@ size_t count); } 273 NOARGS { int sys_minherit(void *addr, size_t len, \ int inherit); } -274 UNIMPL -;274 STD { int netbsd_sys_lchmod(const char *path, \ -; mode_t mode); } +274 STD { int netbsd_sys_lchmod(const char *path, \ + mode_t mode); } 275 NOARGS { int sys_lchown(const char *path, uid_t uid, \ gid_t gid); } -276 UNIMPL -;276 STD { int netbsd_sys_lutimes(const char *path, \ -; const struct timeval *tptr); } +276 STD { int netbsd_sys_lutimes(const char *path, \ + const struct timeval *tptr); } 277 NOARGS { int sys_msync(void *addr, size_t len, int flags); } 278 STD { int netbsd_sys___stat13(const char *path, \ struct netbsd_stat *ub); } |