A litte trouble with declarations of boot() and panic() resolved. gcc-2.5.8
[unix-history] / sys / kern / vfs_syscalls.c
index 7296678..08824db 100644 (file)
@@ -30,7 +30,8 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     @(#)vfs_syscalls.c      7.74 (Berkeley) 6/21/91
+ *     from: @(#)vfs_syscalls.c        7.74 (Berkeley) 6/21/91
+ *     $Id: vfs_syscalls.c,v 1.9 1994/01/19 20:27:38 guido Exp $
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -46,6 +47,9 @@
 #include "uio.h"
 #include "malloc.h"
 
 #include "uio.h"
 #include "malloc.h"
 
+static int getvnode(struct filedesc *, int, struct file **);
+static int chdirec(struct nameidata *, struct proc *);
+
 /*
  * Virtual File System System Calls
  */
 /*
  * Virtual File System System Calls
  */
 /*
  * Mount system call.
  */
 /*
  * Mount system call.
  */
+
+struct mount_args {
+       int     type;
+       char    *dir;
+       int     flags;
+       caddr_t data;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 mount(p, uap, retval)
        struct proc *p;
 mount(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int     type;
-               char    *dir;
-               int     flags;
-               caddr_t data;
-       } *uap;
+       register struct mount_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        register struct vnode *vp;
        register struct mount *mp;
        int *retval;
 {
        register struct nameidata *ndp;
        register struct vnode *vp;
        register struct mount *mp;
-       int error, flag;
+       int error, flag = 0;
        struct nameidata nd;
 
        /*
        struct nameidata nd;
 
        /*
@@ -146,26 +154,10 @@ update:
        /*
         * Set the mount level flags.
         */
        /*
         * Set the mount level flags.
         */
-       if (uap->flags & MNT_RDONLY)
-               mp->mnt_flag |= MNT_RDONLY;
-       else
-               mp->mnt_flag &= ~MNT_RDONLY;
-       if (uap->flags & MNT_NOSUID)
-               mp->mnt_flag |= MNT_NOSUID;
-       else
-               mp->mnt_flag &= ~MNT_NOSUID;
-       if (uap->flags & MNT_NOEXEC)
-               mp->mnt_flag |= MNT_NOEXEC;
-       else
-               mp->mnt_flag &= ~MNT_NOEXEC;
-       if (uap->flags & MNT_NODEV)
-               mp->mnt_flag |= MNT_NODEV;
-       else
-               mp->mnt_flag &= ~MNT_NODEV;
-       if (uap->flags & MNT_SYNCHRONOUS)
-               mp->mnt_flag |= MNT_SYNCHRONOUS;
-       else
-               mp->mnt_flag &= ~MNT_SYNCHRONOUS;
+       mp->mnt_flag &=
+               ~(MNT_RDONLY|MNT_NOSUID|MNT_NOEXEC|MNT_NODEV|MNT_SYNCHRONOUS);
+       mp->mnt_flag |= uap->flags &
+               (MNT_RDONLY|MNT_NOSUID|MNT_NOEXEC|MNT_NODEV|MNT_SYNCHRONOUS);
        /*
         * Mount the filesystem.
         */
        /*
         * Mount the filesystem.
         */
@@ -203,13 +195,17 @@ update:
  * Note: unmount takes a path to the vnode mounted on as argument,
  * not special file (as before).
  */
  * Note: unmount takes a path to the vnode mounted on as argument,
  * not special file (as before).
  */
+
+struct umount_args {
+       char    *pathp;
+       int     flags;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 unmount(p, uap, retval)
        struct proc *p;
 unmount(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *pathp;
-               int     flags;
-       } *uap;
+       register struct umount_args *uap;
        int *retval;
 {
        register struct vnode *vp;
        int *retval;
 {
        register struct vnode *vp;
@@ -246,6 +242,7 @@ unmount(p, uap, retval)
 /*
  * Do an unmount.
  */
 /*
  * Do an unmount.
  */
+int
 dounmount(mp, flags, p)
        register struct mount *mp;
        int flags;
 dounmount(mp, flags, p)
        register struct mount *mp;
        int flags;
@@ -282,6 +279,7 @@ dounmount(mp, flags, p)
  * Sync each mounted filesystem.
  */
 /* ARGSUSED */
  * Sync each mounted filesystem.
  */
 /* ARGSUSED */
+int
 sync(p, uap, retval)
        struct proc *p;
        void *uap;
 sync(p, uap, retval)
        struct proc *p;
        void *uap;
@@ -290,7 +288,8 @@ sync(p, uap, retval)
        register struct mount *mp;
        struct mount *omp;
 
        register struct mount *mp;
        struct mount *omp;
 
-       mp = rootfs;
+       if ((mp = rootfs) == NULL)
+               return (0);
        do {
                /*
                 * The lock check below is to avoid races with mount
        do {
                /*
                 * The lock check below is to avoid races with mount
@@ -311,15 +310,19 @@ sync(p, uap, retval)
 /*
  * Operate on filesystem quotas.
  */
 /*
  * Operate on filesystem quotas.
  */
+
+struct quotactl_args {
+       char *path;
+       int cmd;
+       int uid;
+       caddr_t arg;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 quotactl(p, uap, retval)
        struct proc *p;
 quotactl(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char *path;
-               int cmd;
-               int uid;
-               caddr_t arg;
-       } *uap;
+       register struct quotactl_args *uap;
        int *retval;
 {
        register struct mount *mp;
        int *retval;
 {
        register struct mount *mp;
@@ -341,13 +344,17 @@ quotactl(p, uap, retval)
 /*
  * Get filesystem statistics.
  */
 /*
  * Get filesystem statistics.
  */
+
+struct statfs_args {
+       char *path;
+       struct statfs *buf;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 statfs(p, uap, retval)
        struct proc *p;
 statfs(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char *path;
-               struct statfs *buf;
-       } *uap;
+       register struct statfs_args *uap;
        int *retval;
 {
        register struct mount *mp;
        int *retval;
 {
        register struct mount *mp;
@@ -374,13 +381,17 @@ statfs(p, uap, retval)
 /*
  * Get filesystem statistics.
  */
 /*
  * Get filesystem statistics.
  */
+
+struct fstatfs_args {
+       int fd;
+       struct statfs *buf;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 fstatfs(p, uap, retval)
        struct proc *p;
 fstatfs(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int fd;
-               struct statfs *buf;
-       } *uap;
+       register struct fstatfs_args *uap;
        int *retval;
 {
        struct file *fp;
        int *retval;
 {
        struct file *fp;
@@ -401,13 +412,17 @@ fstatfs(p, uap, retval)
 /*
  * Get statistics on all filesystems.
  */
 /*
  * Get statistics on all filesystems.
  */
+
+struct getfsstat_args {
+       struct statfs *buf;
+       long bufsize;
+       int flags;
+};
+
+int
 getfsstat(p, uap, retval)
        struct proc *p;
 getfsstat(p, uap, retval)
        struct proc *p;
-       register struct args {
-               struct statfs *buf;
-               long bufsize;
-               int flags;
-       } *uap;
+       register struct getfsstat_args *uap;
        int *retval;
 {
        register struct mount *mp;
        int *retval;
 {
        register struct mount *mp;
@@ -451,12 +466,16 @@ getfsstat(p, uap, retval)
 /*
  * Change current working directory to a given file descriptor.
  */
 /*
  * Change current working directory to a given file descriptor.
  */
+
+struct fchdir_args {
+       int     fd;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 fchdir(p, uap, retval)
        struct proc *p;
 fchdir(p, uap, retval)
        struct proc *p;
-       struct args {
-               int     fd;
-       } *uap;
+       struct fchdir_args *uap;
        int *retval;
 {
        register struct filedesc *fdp = p->p_fd;
        int *retval;
 {
        register struct filedesc *fdp = p->p_fd;
@@ -484,12 +503,16 @@ fchdir(p, uap, retval)
 /*
  * Change current working directory (``.'').
  */
 /*
  * Change current working directory (``.'').
  */
+
+struct chdir_args {
+       char    *fname;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 chdir(p, uap, retval)
        struct proc *p;
 chdir(p, uap, retval)
        struct proc *p;
-       struct args {
-               char    *fname;
-       } *uap;
+       struct chdir_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -511,12 +534,16 @@ chdir(p, uap, retval)
 /*
  * Change notion of root (``/'') directory.
  */
 /*
  * Change notion of root (``/'') directory.
  */
+
+struct chroot_args {
+       char    *fname;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 chroot(p, uap, retval)
        struct proc *p;
 chroot(p, uap, retval)
        struct proc *p;
-       struct args {
-               char    *fname;
-       } *uap;
+       struct chroot_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -541,6 +568,7 @@ chroot(p, uap, retval)
 /*
  * Common routine for chroot and chdir.
  */
 /*
  * Common routine for chroot and chdir.
  */
+static int
 chdirec(ndp, p)
        struct nameidata *ndp;
        struct proc *p;
 chdirec(ndp, p)
        struct nameidata *ndp;
        struct proc *p;
@@ -566,13 +594,17 @@ chdirec(ndp, p)
  * Check permissions, allocate an open file structure,
  * and call the device open routine if any.
  */
  * Check permissions, allocate an open file structure,
  * and call the device open routine if any.
  */
+
+struct open_args {
+       char    *fname;
+       int     mode;
+       int     crtmode;
+};
+
+int
 open(p, uap, retval)
        struct proc *p;
 open(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     mode;
-               int     crtmode;
-       } *uap;
+       register struct open_args *uap;
        int *retval;
 {
        struct nameidata *ndp;
        int *retval;
 {
        struct nameidata *ndp;
@@ -598,7 +630,7 @@ open(p, uap, retval)
        if (error = vn_open(ndp, p, fmode, cmode)) {
                ffree(fp);
                if (error == ENODEV &&          /* XXX from fdopen */
        if (error = vn_open(ndp, p, fmode, cmode)) {
                ffree(fp);
                if (error == ENODEV &&          /* XXX from fdopen */
-                   p->p_dupfd >= 0 &&
+                   ((short) p->p_dupfd) >= 0 &&
                    (error = dupfdopen(fdp, indx, p->p_dupfd, fmode)) == 0) {
                        *retval = indx;
                        return (0);
                    (error = dupfdopen(fdp, indx, p->p_dupfd, fmode)) == 0) {
                        *retval = indx;
                        return (0);
@@ -609,6 +641,7 @@ open(p, uap, retval)
                return (error);
        }
        vp = ndp->ni_vp;
                return (error);
        }
        vp = ndp->ni_vp;
+       VOP_UNLOCK(vp);
        fp->f_flag = fmode & FMASK;
        if (fmode & (O_EXLOCK | O_SHLOCK)) {
                lf.l_whence = SEEK_SET;
        fp->f_flag = fmode & FMASK;
        if (fmode & (O_EXLOCK | O_SHLOCK)) {
                lf.l_whence = SEEK_SET;
@@ -622,7 +655,6 @@ open(p, uap, retval)
                if ((fmode & FNONBLOCK) == 0)
                        type |= F_WAIT;
                if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
                if ((fmode & FNONBLOCK) == 0)
                        type |= F_WAIT;
                if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
-                       VOP_UNLOCK(vp);
                        (void) vn_close(vp, fp->f_flag, fp->f_cred, p);
                        ffree(fp);
                        fdp->fd_ofiles[indx] = NULL;
                        (void) vn_close(vp, fp->f_flag, fp->f_cred, p);
                        ffree(fp);
                        fdp->fd_ofiles[indx] = NULL;
@@ -630,7 +662,6 @@ open(p, uap, retval)
                }
                fp->f_flag |= FHASLOCK;
        }
                }
                fp->f_flag |= FHASLOCK;
        }
-       VOP_UNLOCK(vp);
        fp->f_type = DTYPE_VNODE;
        fp->f_ops = &vnops;
        fp->f_data = (caddr_t)vp;
        fp->f_type = DTYPE_VNODE;
        fp->f_ops = &vnops;
        fp->f_data = (caddr_t)vp;
@@ -642,12 +673,16 @@ open(p, uap, retval)
 /*
  * Creat system call.
  */
 /*
  * Creat system call.
  */
+
+struct ocreat_args {
+       char    *fname;
+       int     fmode;
+};
+
+int
 ocreat(p, uap, retval)
        struct proc *p;
 ocreat(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     fmode;
-       } *uap;
+       register struct ocreat_args *uap;
        int *retval;
 {
        struct newargs {
        int *retval;
 {
        struct newargs {
@@ -666,14 +701,18 @@ ocreat(p, uap, retval)
 /*
  * Mknod system call.
  */
 /*
  * Mknod system call.
  */
+
+struct mknod_args {
+       char    *fname;
+       int     fmode;
+       int     dev;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 mknod(p, uap, retval)
        struct proc *p;
 mknod(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     fmode;
-               int     dev;
-       } *uap;
+       register struct mknod_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -731,13 +770,17 @@ out:
 /*
  * Mkfifo system call.
  */
 /*
  * Mkfifo system call.
  */
+
+struct mkfifo_args {
+       char    *fname;
+       int     fmode;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 mkfifo(p, uap, retval)
        struct proc *p;
 mkfifo(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     fmode;
-       } *uap;
+       register struct mkfifo_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -773,13 +816,17 @@ mkfifo(p, uap, retval)
 /*
  * Link system call.
  */
 /*
  * Link system call.
  */
+
+struct link_args {
+       char    *target;
+       char    *linkname;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 link(p, uap, retval)
        struct proc *p;
 link(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *target;
-               char    *linkname;
-       } *uap;
+       register struct link_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -829,13 +876,17 @@ out1:
 /*
  * Make a symbolic link.
  */
 /*
  * Make a symbolic link.
  */
+
+struct symlink_args {
+       char    *target;
+       char    *linkname;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 symlink(p, uap, retval)
        struct proc *p;
 symlink(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *target;
-               char    *linkname;
-       } *uap;
+       register struct symlink_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -874,12 +925,16 @@ out:
 /*
  * Delete a name from the filesystem.
  */
 /*
  * Delete a name from the filesystem.
  */
+
+struct unlink_args {
+       char    *fname;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 unlink(p, uap, retval)
        struct proc *p;
 unlink(p, uap, retval)
        struct proc *p;
-       struct args {
-               char    *fname;
-       } *uap;
+       struct unlink_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -922,13 +977,17 @@ out:
 /*
  * Seek system call.
  */
 /*
  * Seek system call.
  */
+
+struct lseek_args {
+       int     fdes;
+       off_t   off;
+       int     sbase;
+};
+
+int
 lseek(p, uap, retval)
        struct proc *p;
 lseek(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int     fdes;
-               off_t   off;
-               int     sbase;
-       } *uap;
+       register struct lseek_args *uap;
        off_t *retval;
 {
        struct ucred *cred = p->p_ucred;
        off_t *retval;
 {
        struct ucred *cred = p->p_ucred;
@@ -969,13 +1028,17 @@ lseek(p, uap, retval)
 /*
  * Check access permissions.
  */
 /*
  * Check access permissions.
  */
+
+struct saccess_args {
+       char    *fname;
+       int     fmode;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 saccess(p, uap, retval)
        struct proc *p;
 saccess(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     fmode;
-       } *uap;
+       register struct saccess_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1020,13 +1083,17 @@ out1:
  * Stat system call.
  * This version follows links.
  */
  * Stat system call.
  * This version follows links.
  */
+
+struct stat_args {
+       char    *fname;
+       struct stat *ub;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 stat(p, uap, retval)
        struct proc *p;
 stat(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               struct stat *ub;
-       } *uap;
+       register struct stat_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1052,13 +1119,17 @@ stat(p, uap, retval)
  * Lstat system call.
  * This version does not follow links.
  */
  * Lstat system call.
  * This version does not follow links.
  */
+
+struct lstat_args {
+       char    *fname;
+       struct stat *ub;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 lstat(p, uap, retval)
        struct proc *p;
 lstat(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               struct stat *ub;
-       } *uap;
+       register struct lstat_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1083,14 +1154,18 @@ lstat(p, uap, retval)
 /*
  * Return target name of a symbolic link.
  */
 /*
  * Return target name of a symbolic link.
  */
+
+struct readlink_args {
+       char    *name;
+       char    *buf;
+       int     count;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 readlink(p, uap, retval)
        struct proc *p;
 readlink(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *name;
-               char    *buf;
-               int     count;
-       } *uap;
+       register struct readlink_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1130,13 +1205,17 @@ out:
 /*
  * Change flags of a file given path name.
  */
 /*
  * Change flags of a file given path name.
  */
+
+struct chflags_args {
+       char    *fname;
+       int     flags;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 chflags(p, uap, retval)
        struct proc *p;
 chflags(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     flags;
-       } *uap;
+       register struct chflags_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1167,13 +1246,17 @@ out:
 /*
  * Change flags of a file given a file descriptor.
  */
 /*
  * Change flags of a file given a file descriptor.
  */
+
+struct fdchflags_args {
+       int     fd;
+       int     flags;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 fchflags(p, uap, retval)
        struct proc *p;
 fchflags(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int     fd;
-               int     flags;
-       } *uap;
+       register struct fdchflags_args *uap;
        int *retval;
 {
        struct vattr vattr;
        int *retval;
 {
        struct vattr vattr;
@@ -1200,13 +1283,17 @@ out:
 /*
  * Change mode of a file given path name.
  */
 /*
  * Change mode of a file given path name.
  */
+
+struct chmod_args {
+       char    *fname;
+       int     fmode;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 chmod(p, uap, retval)
        struct proc *p;
 chmod(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     fmode;
-       } *uap;
+       register struct chmod_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1237,13 +1324,17 @@ out:
 /*
  * Change mode of a file given a file descriptor.
  */
 /*
  * Change mode of a file given a file descriptor.
  */
+
+struct fchmod_args {
+       int     fd;
+       int     fmode;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 fchmod(p, uap, retval)
        struct proc *p;
 fchmod(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int     fd;
-               int     fmode;
-       } *uap;
+       register struct fchmod_args *uap;
        int *retval;
 {
        struct vattr vattr;
        int *retval;
 {
        struct vattr vattr;
@@ -1270,14 +1361,18 @@ out:
 /*
  * Set ownership given a path name.
  */
 /*
  * Set ownership given a path name.
  */
+
+struct chown_args {
+       char    *fname;
+       int     uid;
+       int     gid;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 chown(p, uap, retval)
        struct proc *p;
 chown(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               int     uid;
-               int     gid;
-       } *uap;
+       register struct chown_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1309,14 +1404,18 @@ out:
 /*
  * Set ownership given a file descriptor.
  */
 /*
  * Set ownership given a file descriptor.
  */
+
+struct fchown_args {
+       int     fd;
+       int     uid;
+       int     gid;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 fchown(p, uap, retval)
        struct proc *p;
 fchown(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int     fd;
-               int     uid;
-               int     gid;
-       } *uap;
+       register struct fchown_args *uap;
        int *retval;
 {
        struct vattr vattr;
        int *retval;
 {
        struct vattr vattr;
@@ -1344,13 +1443,17 @@ out:
 /*
  * Set the access and modification times of a file.
  */
 /*
  * Set the access and modification times of a file.
  */
+
+struct utimes_args {
+       char    *fname;
+       struct  timeval *tptr;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 utimes(p, uap, retval)
        struct proc *p;
 utimes(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               struct  timeval *tptr;
-       } *uap;
+       register struct utimes_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1360,7 +1463,12 @@ utimes(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
-       if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
+       VATTR_NULL(&vattr);
+       if ((caddr_t)uap->tptr == NULL) {
+               microtime(&tv[0]);
+               tv[1] = tv[0];
+               vattr.va_vaflags |= VA_UTIMES_NULL;
+       } else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
                return (error);
        ndp = &nd;
        ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
                return (error);
        ndp = &nd;
        ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
@@ -1373,7 +1481,6 @@ utimes(p, uap, retval)
                error = EROFS;
                goto out;
        }
                error = EROFS;
                goto out;
        }
-       VATTR_NULL(&vattr);
        vattr.va_atime = tv[0];
        vattr.va_mtime = tv[1];
        error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
        vattr.va_atime = tv[0];
        vattr.va_mtime = tv[1];
        error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
@@ -1385,13 +1492,17 @@ out:
 /*
  * Truncate a file given its path name.
  */
 /*
  * Truncate a file given its path name.
  */
+
+struct truncate_args {
+       char    *fname;
+       off_t   length;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 truncate(p, uap, retval)
        struct proc *p;
 truncate(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-               off_t   length;
-       } *uap;
+       register struct truncate_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1425,13 +1536,17 @@ out:
 /*
  * Truncate a file given a file descriptor.
  */
 /*
  * Truncate a file given a file descriptor.
  */
+
+struct ftruncate_args {
+       int     fd;
+       off_t   length;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 ftruncate(p, uap, retval)
        struct proc *p;
 ftruncate(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int     fd;
-               off_t   length;
-       } *uap;
+       register struct ftruncate_args *uap;
        int *retval;
 {
        struct vattr vattr;
        int *retval;
 {
        struct vattr vattr;
@@ -1462,12 +1577,16 @@ out:
 /*
  * Synch an open file.
  */
 /*
  * Synch an open file.
  */
+
+struct fsync_args {
+       int     fd;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 fsync(p, uap, retval)
        struct proc *p;
 fsync(p, uap, retval)
        struct proc *p;
-       struct args {
-               int     fd;
-       } *uap;
+       struct fsync_args *uap;
        int *retval;
 {
        register struct vnode *vp;
        int *retval;
 {
        register struct vnode *vp;
@@ -1489,13 +1608,17 @@ fsync(p, uap, retval)
  * Source and destination must either both be directories, or both
  * not be directories.  If target is a directory, it must be empty.
  */
  * Source and destination must either both be directories, or both
  * not be directories.  If target is a directory, it must be empty.
  */
+
+struct rename_args {
+       char    *from;
+       char    *to;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 rename(p, uap, retval)
        struct proc *p;
 rename(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *from;
-               char    *to;
-       } *uap;
+       register struct rename_args *uap;
        int *retval;
 {
        register struct vnode *tvp, *fvp, *tdvp;
        int *retval;
 {
        register struct vnode *tvp, *fvp, *tdvp;
@@ -1565,7 +1688,8 @@ out:
        vrele(tond.ni_startdir);
        FREE(tond.ni_pnbuf, M_NAMEI);
 out1:
        vrele(tond.ni_startdir);
        FREE(tond.ni_pnbuf, M_NAMEI);
 out1:
-       vrele(fromnd.ni_startdir);
+       if (fromnd.ni_startdir)
+               vrele(fromnd.ni_startdir);
        FREE(fromnd.ni_pnbuf, M_NAMEI);
        if (error == -1)
                return (0);
        FREE(fromnd.ni_pnbuf, M_NAMEI);
        if (error == -1)
                return (0);
@@ -1575,13 +1699,17 @@ out1:
 /*
  * Mkdir system call.
  */
 /*
  * Mkdir system call.
  */
+
+struct mkdir_args {
+       char    *name;
+       int     dmode;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 mkdir(p, uap, retval)
        struct proc *p;
 mkdir(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *name;
-               int     dmode;
-       } *uap;
+       register struct mkdir_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1618,12 +1746,16 @@ mkdir(p, uap, retval)
 /*
  * Rmdir system call.
  */
 /*
  * Rmdir system call.
  */
+
+struct rmdir_args {
+       char    *name;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 rmdir(p, uap, retval)
        struct proc *p;
 rmdir(p, uap, retval)
        struct proc *p;
-       struct args {
-               char    *name;
-       } *uap;
+       struct rmdir_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1671,14 +1803,18 @@ out:
 /*
  * Read a block of directory entries in a file system independent format.
  */
 /*
  * Read a block of directory entries in a file system independent format.
  */
+
+struct getdirentries_args {
+       int     fd;
+       char    *buf;
+       unsigned count;
+       long    *basep;
+};
+
+int
 getdirentries(p, uap, retval)
        struct proc *p;
 getdirentries(p, uap, retval)
        struct proc *p;
-       register struct args {
-               int     fd;
-               char    *buf;
-               unsigned count;
-               long    *basep;
-       } *uap;
+       register struct getdirentries_args *uap;
        int *retval;
 {
        register struct vnode *vp;
        int *retval;
 {
        register struct vnode *vp;
@@ -1718,12 +1854,15 @@ getdirentries(p, uap, retval)
 /*
  * Set the mode mask for creation of filesystem nodes.
  */
 /*
  * Set the mode mask for creation of filesystem nodes.
  */
+
+struct umask_args {
+       int     mask;
+};
+
 mode_t
 umask(p, uap, retval)
        struct proc *p;
 mode_t
 umask(p, uap, retval)
        struct proc *p;
-       struct args {
-               int     mask;
-       } *uap;
+       struct umask_args *uap;
        int *retval;
 {
        register struct filedesc *fdp = p->p_fd;
        int *retval;
 {
        register struct filedesc *fdp = p->p_fd;
@@ -1737,12 +1876,16 @@ umask(p, uap, retval)
  * Void all references to file by ripping underlying filesystem
  * away from vnode.
  */
  * Void all references to file by ripping underlying filesystem
  * away from vnode.
  */
+
+struct revoke_args {
+       char    *fname;
+};
+
 /* ARGSUSED */
 /* ARGSUSED */
+int
 revoke(p, uap, retval)
        struct proc *p;
 revoke(p, uap, retval)
        struct proc *p;
-       register struct args {
-               char    *fname;
-       } *uap;
+       register struct revoke_args *uap;
        int *retval;
 {
        register struct nameidata *ndp;
        int *retval;
 {
        register struct nameidata *ndp;
@@ -1777,10 +1920,11 @@ out:
 /*
  * Convert a user file descriptor to a kernel file entry.
  */
 /*
  * Convert a user file descriptor to a kernel file entry.
  */
+static int
 getvnode(fdp, fdes, fpp)
        struct filedesc *fdp;
 getvnode(fdp, fdes, fpp)
        struct filedesc *fdp;
-       struct file **fpp;
        int fdes;
        int fdes;
+       struct file **fpp;
 {
        struct file *fp;
 
 {
        struct file *fp;