cleanup declaration of parameters; note required padding to align
[unix-history] / usr / src / sys / kern / vfs_syscalls.c
index 083aff3..39bcbbc 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_syscalls.c      7.78 (Berkeley) %G%
+ *     @(#)vfs_syscalls.c      7.92 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 #include "proc.h"
 #include "uio.h"
 #include "malloc.h"
 #include "proc.h"
 #include "uio.h"
 #include "malloc.h"
+#include "dirent.h"
+#include <vm/vm.h>
+
+#ifdef REF_DIAGNOSTIC
+#define CURCOUNT (curproc ? curproc->p_spare[0] : 0)
+#define CHECKPOINTREF int oldrefcount = CURCOUNT;
+#define CHECKREFS(F) if (oldrefcount != CURCOUNT) \
+       printf("REFCOUNT: %s, old=%d, new=%d\n", (F), oldrefcount, CURCOUNT);
+#else
+#define CHECKPOINTREF
+#define CHECKREFS(D)
+#endif
 
 /*
  * Virtual File System System Calls
 
 /*
  * Virtual File System System Calls
@@ -75,11 +87,12 @@ mount(p, uap, retval)
                VOP_UNLOCK(vp);
                goto update;
        }
                VOP_UNLOCK(vp);
                goto update;
        }
-       vinvalbuf(vp, 1);
        if (vp->v_usecount != 1) {
                vput(vp);
                return (EBUSY);
        }
        if (vp->v_usecount != 1) {
                vput(vp);
                return (EBUSY);
        }
+       if (error = vinvalbuf(vp, 1, p->p_ucred, p))
+               return (error);
        if (vp->v_type != VDIR) {
                vput(vp);
                return (ENOTDIR);
        if (vp->v_type != VDIR) {
                vput(vp);
                return (ENOTDIR);
@@ -95,9 +108,8 @@ mount(p, uap, retval)
         */
        mp = (struct mount *)malloc((u_long)sizeof(struct mount),
                M_MOUNT, M_WAITOK);
         */
        mp = (struct mount *)malloc((u_long)sizeof(struct mount),
                M_MOUNT, M_WAITOK);
+       bzero((char *)mp, (u_long)sizeof(struct mount));
        mp->mnt_op = vfssw[uap->type];
        mp->mnt_op = vfssw[uap->type];
-       mp->mnt_flag = 0;
-       mp->mnt_mounth = NULLVP;
        if (error = vfs_lock(mp)) {
                free((caddr_t)mp, M_MOUNT);
                vput(vp);
        if (error = vfs_lock(mp)) {
                free((caddr_t)mp, M_MOUNT);
                vput(vp);
@@ -228,7 +240,8 @@ dounmount(mp, flags, p)
 
        vnode_pager_umount(mp); /* release cached vnodes */
        cache_purgevfs(mp);     /* remove cache entries for this file sys */
 
        vnode_pager_umount(mp); /* release cached vnodes */
        cache_purgevfs(mp);     /* remove cache entries for this file sys */
-       if ((error = VFS_SYNC(mp, MNT_WAIT)) == 0 || (flags & MNT_FORCE))
+       if ((error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0 ||
+           (flags & MNT_FORCE))
                error = VFS_UNMOUNT(mp, flags, p);
        mp->mnt_flag &= ~MNT_UNMOUNT;
        vfs_unbusy(mp);
                error = VFS_UNMOUNT(mp, flags, p);
        mp->mnt_flag &= ~MNT_UNMOUNT;
        vfs_unbusy(mp);
@@ -265,7 +278,7 @@ sync(p, uap, retval)
                 */
                if ((mp->mnt_flag & (MNT_MLOCK|MNT_RDONLY|MNT_MPBUSY)) == 0 &&
                    !vfs_busy(mp)) {
                 */
                if ((mp->mnt_flag & (MNT_MLOCK|MNT_RDONLY|MNT_MPBUSY)) == 0 &&
                    !vfs_busy(mp)) {
-                       VFS_SYNC(mp, MNT_NOWAIT);
+                       VFS_SYNC(mp, MNT_NOWAIT, p->p_ucred, p);
                        omp = mp;
                        mp = mp->mnt_next;
                        vfs_unbusy(omp);
                        omp = mp;
                        mp = mp->mnt_next;
                        vfs_unbusy(omp);
@@ -456,7 +469,7 @@ chdir(p, uap, retval)
        struct nameidata nd;
 
        NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
        struct nameidata nd;
 
        NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
-       if (error = chdirec(&nd))
+       if (error = chdirec(&nd, p))
                return (error);
        vrele(fdp->fd_cdir);
        fdp->fd_cdir = nd.ni_vp;
                return (error);
        vrele(fdp->fd_cdir);
        fdp->fd_cdir = nd.ni_vp;
@@ -481,7 +494,7 @@ chroot(p, uap, retval)
        if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
        NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
        if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
        NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
-       if (error = chdirec(&nd))
+       if (error = chdirec(&nd, p))
                return (error);
        if (fdp->fd_rdir != NULL)
                vrele(fdp->fd_rdir);
                return (error);
        if (fdp->fd_rdir != NULL)
                vrele(fdp->fd_rdir);
@@ -545,9 +558,10 @@ open(p, uap, retval)
        p->p_dupfd = -indx - 1;                 /* XXX check for fdopen */
        if (error = vn_open(&nd, fmode, cmode)) {
                ffree(fp);
        p->p_dupfd = -indx - 1;                 /* XXX check for fdopen */
        if (error = vn_open(&nd, fmode, cmode)) {
                ffree(fp);
-               if (error == ENODEV &&          /* XXX from fdopen */
-                   p->p_dupfd >= 0 &&
-                   (error = dupfdopen(fdp, indx, p->p_dupfd, fmode)) == 0) {
+               if ((error == ENODEV || error == ENXIO) &&
+                   p->p_dupfd >= 0 &&                  /* XXX from fdopen */
+                   (error = dupfdopen(fdp, indx, p->p_dupfd,
+                                       fmode, error)) == 0) {
                        *retval = indx;
                        return (0);
                }
                        *retval = indx;
                        return (0);
                }
@@ -556,8 +570,12 @@ open(p, uap, retval)
                fdp->fd_ofiles[indx] = NULL;
                return (error);
        }
                fdp->fd_ofiles[indx] = NULL;
                return (error);
        }
+       p->p_dupfd = 0;
        vp = nd.ni_vp;
        fp->f_flag = fmode & FMASK;
        vp = nd.ni_vp;
        fp->f_flag = fmode & FMASK;
+       fp->f_type = DTYPE_VNODE;
+       fp->f_ops = &vnops;
+       fp->f_data = (caddr_t)vp;
        if (fmode & (O_EXLOCK | O_SHLOCK)) {
                lf.l_whence = SEEK_SET;
                lf.l_start = 0;
        if (fmode & (O_EXLOCK | O_SHLOCK)) {
                lf.l_whence = SEEK_SET;
                lf.l_start = 0;
@@ -579,9 +597,6 @@ open(p, uap, retval)
                fp->f_flag |= FHASLOCK;
        }
        VOP_UNLOCK(vp);
                fp->f_flag |= FHASLOCK;
        }
        VOP_UNLOCK(vp);
-       fp->f_type = DTYPE_VNODE;
-       fp->f_ops = &vnops;
-       fp->f_data = (caddr_t)vp;
        *retval = indx;
        return (0);
 }
        *retval = indx;
        return (0);
 }
@@ -598,7 +613,7 @@ ocreat(p, uap, retval)
        } *uap;
        int *retval;
 {
        } *uap;
        int *retval;
 {
-       struct args {
+       struct nargs {
                char    *fname;
                int     mode;
                int     crtmode;
                char    *fname;
                int     mode;
                int     crtmode;
@@ -629,6 +644,7 @@ mknod(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINTREF;
        if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
        NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->fname, p);
        if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
        NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->fname, p);
@@ -670,6 +686,7 @@ out:
                if (vp)
                        vrele(vp);
        }
                if (vp)
                        vrele(vp);
        }
+       CHECKREFS("mknod");
        return (error);
 }
 
        return (error);
 }
 
@@ -728,6 +745,7 @@ link(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINTREF;
        NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->target, p);
        if (error = namei(&nd))
                return (error);
        NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->target, p);
        if (error = namei(&nd))
                return (error);
@@ -746,13 +764,11 @@ link(p, uap, retval)
                goto out;
        }
        xp = nd.ni_dvp;
                goto out;
        }
        xp = nd.ni_dvp;
-       if (vp->v_mount != xp->v_mount)
-               error = EXDEV;
 out:
        if (!error) {
                LEASE_CHECK(xp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
 out:
        if (!error) {
                LEASE_CHECK(xp, p, p->p_ucred, LEASE_WRITE);
                LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
-               error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd);
+               error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
        } else {
                VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                if (nd.ni_dvp == nd.ni_vp)
        } else {
                VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
                if (nd.ni_dvp == nd.ni_vp)
@@ -764,6 +780,7 @@ out:
        }
 out1:
        vrele(vp);
        }
 out1:
        vrele(vp);
+       CHECKREFS("link");
        return (error);
 }
 
        return (error);
 }
 
@@ -784,6 +801,7 @@ symlink(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINTREF;
        MALLOC(target, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
        if (error = copyinstr(uap->target, target, MAXPATHLEN, (u_int *)0))
                goto out;
        MALLOC(target, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
        if (error = copyinstr(uap->target, target, MAXPATHLEN, (u_int *)0))
                goto out;
@@ -806,6 +824,7 @@ symlink(p, uap, retval)
        error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, target);
 out:
        FREE(target, M_NAMEI);
        error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, target);
 out:
        FREE(target, M_NAMEI);
+       CHECKREFS("symlink");
        return (error);
 }
 
        return (error);
 }
 
@@ -824,6 +843,7 @@ unlink(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINTREF;
        NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
        NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
@@ -852,9 +872,18 @@ out:
                        vput(nd.ni_dvp);
                vput(vp);
        }
                        vput(nd.ni_dvp);
                vput(vp);
        }
+       CHECKREFS("unlink");
        return (error);
 }
 
        return (error);
 }
 
+struct args_lseek {
+       int     fdes;
+       int     pad;
+       off_t   off;
+       int     sbase;
+};
+
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
 /*
  * Seek system call.
  */
 /*
  * Seek system call.
  */
@@ -862,9 +891,30 @@ lseek(p, uap, retval)
        struct proc *p;
        register struct args {
                int     fdes;
        struct proc *p;
        register struct args {
                int     fdes;
-               off_t   off;
+               long    off;
                int     sbase;
        } *uap;
                int     sbase;
        } *uap;
+       long *retval;
+{
+       struct args_lseek nuap;
+       off_t qret;
+       int error;
+
+       nuap.fdes = uap->fdes;
+       nuap.off = uap->off;
+       nuap.sbase = uap->sbase;
+       error = __lseek(p, &nuap, &qret);
+       *retval = qret;
+       return (error);
+}
+#endif /* COMPAT_43 || COMPAT_SUNOS */
+
+/*
+ * Seek system call.
+ */
+__lseek(p, uap, retval)
+       struct proc *p;
+       register struct args_lseek *uap;
        off_t *retval;
 {
        struct ucred *cred = p->p_ucred;
        off_t *retval;
 {
        struct ucred *cred = p->p_ucred;
@@ -948,6 +998,96 @@ out1:
        return (error);
 }
 
        return (error);
 }
 
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+/*
+ * Stat system call.
+ * This version follows links.
+ */
+/* ARGSUSED */
+ostat(p, uap, retval)
+       struct proc *p;
+       register struct args {
+               char    *fname;
+               struct ostat *ub;
+       } *uap;
+       int *retval;
+{
+       struct stat sb;
+       struct ostat osb;
+       int error;
+       struct nameidata nd;
+
+       NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+       if (error = namei(&nd))
+               return (error);
+       error = vn_stat(nd.ni_vp, &sb, p);
+       vput(nd.ni_vp);
+       if (error)
+               return (error);
+       cvtstat(&sb, &osb);
+       error = copyout((caddr_t)&osb, (caddr_t)uap->ub, sizeof (osb));
+       return (error);
+}
+
+/*
+ * Lstat system call.
+ * This version does not follow links.
+ */
+/* ARGSUSED */
+olstat(p, uap, retval)
+       struct proc *p;
+       register struct args {
+               char    *fname;
+               struct ostat *ub;
+       } *uap;
+       int *retval;
+{
+       struct stat sb;
+       struct ostat osb;
+       int error;
+       struct nameidata nd;
+
+       NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+       if (error = namei(&nd))
+               return (error);
+       error = vn_stat(nd.ni_vp, &sb, p);
+       vput(nd.ni_vp);
+       if (error)
+               return (error);
+       cvtstat(&sb, &osb);
+       error = copyout((caddr_t)&osb, (caddr_t)uap->ub, sizeof (osb));
+       return (error);
+}
+
+/*
+ * convert from an old to a new stat structure.
+ */
+cvtstat(st, ost)
+       struct stat *st;
+       struct ostat *ost;
+{
+
+       ost->st_dev = st->st_dev;
+       ost->st_ino = st->st_ino;
+       ost->st_mode = st->st_mode;
+       ost->st_nlink = st->st_nlink;
+       ost->st_uid = st->st_uid;
+       ost->st_gid = st->st_gid;
+       ost->st_rdev = st->st_rdev;
+       if (st->st_size < (quad_t)1 << 32)
+               ost->st_size = st->st_size;
+       else
+               ost->st_size = -2;
+       ost->st_atime = st->st_atime;
+       ost->st_mtime = st->st_mtime;
+       ost->st_ctime = st->st_ctime;
+       ost->st_blksize = st->st_blksize;
+       ost->st_blocks = st->st_blocks;
+       ost->st_flags = st->st_flags;
+       ost->st_gen = st->st_gen;
+}
+#endif /* COMPAT_43 || COMPAT_SUNOS */
+
 /*
  * Stat system call.
  * This version follows links.
 /*
  * Stat system call.
  * This version follows links.
@@ -1023,6 +1163,7 @@ readlink(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINTREF;
        NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
        NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
@@ -1044,6 +1185,7 @@ readlink(p, uap, retval)
 out:
        vput(vp);
        *retval = uap->count - auio.uio_resid;
 out:
        vput(vp);
        *retval = uap->count - auio.uio_resid;
+       CHECKREFS("readlink");
        return (error);
 }
 
        return (error);
 }
 
@@ -1284,8 +1426,10 @@ utimes(p, uap, retval)
                goto out;
        }
        VATTR_NULL(&vattr);
                goto out;
        }
        VATTR_NULL(&vattr);
-       vattr.va_atime = tv[0];
-       vattr.va_mtime = tv[1];
+       vattr.va_atime.ts_sec = tv[0].tv_sec;
+       vattr.va_atime.ts_nsec = tv[0].tv_usec * 1000;
+       vattr.va_mtime.ts_sec = tv[1].tv_sec;
+       vattr.va_mtime.ts_nsec = tv[1].tv_usec * 1000;
        LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
        error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
 out:
        LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
        error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
 out:
@@ -1293,16 +1437,19 @@ out:
        return (error);
 }
 
        return (error);
 }
 
+struct args_truncate {
+       char    *fname;
+       int     pad;
+       off_t   length;
+};
+
 /*
  * Truncate a file given its path name.
  */
 /* ARGSUSED */
 /*
  * Truncate a file given its path name.
  */
 /* ARGSUSED */
-truncate(p, uap, retval)
+__truncate(p, uap, retval)
        struct proc *p;
        struct proc *p;
-       register struct args {
-               char    *fname;
-               off_t   length;
-       } *uap;
+       register struct args_truncate *uap;
        int *retval;
 {
        register struct vnode *vp;
        int *retval;
 {
        register struct vnode *vp;
@@ -1330,16 +1477,19 @@ out:
        return (error);
 }
 
        return (error);
 }
 
+struct args_ftruncate {
+       int     fd;
+       int     pad;
+       off_t   length;
+};
+
 /*
  * Truncate a file given a file descriptor.
  */
 /* ARGSUSED */
 /*
  * Truncate a file given a file descriptor.
  */
 /* ARGSUSED */
-ftruncate(p, uap, retval)
+__ftruncate(p, uap, retval)
        struct proc *p;
        struct proc *p;
-       register struct args {
-               int     fd;
-               off_t   length;
-       } *uap;
+       register struct args_ftruncate *uap;
        int *retval;
 {
        struct vattr vattr;
        int *retval;
 {
        struct vattr vattr;
@@ -1368,6 +1518,46 @@ out:
        return (error);
 }
 
        return (error);
 }
 
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+/*
+ * Truncate a file given its path name.
+ */
+/* ARGSUSED */
+truncate(p, uap, retval)
+       struct proc *p;
+       register struct args {
+               char    *fname;
+               long    length;
+       } *uap;
+       int *retval;
+{
+       struct args_truncate nuap;
+
+       nuap.fname = uap->fname;
+       nuap.length = uap->length;
+       return (__truncate(p, &nuap, retval));
+}
+
+/*
+ * Truncate a file given a file descriptor.
+ */
+/* ARGSUSED */
+ftruncate(p, uap, retval)
+       struct proc *p;
+       register struct args {
+               int     fd;
+               long    length;
+       } *uap;
+       int *retval;
+{
+       struct args_ftruncate nuap;
+
+       nuap.fd = uap->fd;
+       nuap.length = uap->length;
+       return (__ftruncate(p, &nuap, retval));
+}
+#endif /* COMPAT_43 || COMPAT_SUNOS */
+
 /*
  * Synch an open file.
  */
 /*
  * Synch an open file.
  */
@@ -1387,7 +1577,7 @@ fsync(p, uap, retval)
                return (error);
        vp = (struct vnode *)fp->f_data;
        VOP_LOCK(vp);
                return (error);
        vp = (struct vnode *)fp->f_data;
        VOP_LOCK(vp);
-       error = VOP_FSYNC(vp, fp->f_flag, fp->f_cred, MNT_WAIT, p);
+       error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p);
        VOP_UNLOCK(vp);
        return (error);
 }
        VOP_UNLOCK(vp);
        return (error);
 }
@@ -1411,6 +1601,7 @@ rename(p, uap, retval)
        struct nameidata fromnd, tond;
        int error;
 
        struct nameidata fromnd, tond;
        int error;
 
+       CHECKPOINTREF;
        NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
                uap->from, p);
        if (error = namei(&fromnd))
        NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
                uap->from, p);
        if (error = namei(&fromnd))
@@ -1434,14 +1625,6 @@ rename(p, uap, retval)
                        error = EISDIR;
                        goto out;
                }
                        error = EISDIR;
                        goto out;
                }
-               if (fvp->v_mount != tvp->v_mount) {
-                       error = EXDEV;
-                       goto out;
-               }
-       }
-       if (fvp->v_mount != tdvp->v_mount) {
-               error = EXDEV;
-               goto out;
        }
        if (fvp == tdvp)
                error = EINVAL;
        }
        if (fvp == tdvp)
                error = EINVAL;
@@ -1483,6 +1666,7 @@ out1:
        p->p_spare[1]--;
        vrele(fromnd.ni_startdir);
        FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI);
        p->p_spare[1]--;
        vrele(fromnd.ni_startdir);
        FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI);
+       CHECKREFS("rename");
        if (error == -1)
                return (0);
        return (error);
        if (error == -1)
                return (0);
        return (error);
@@ -1505,6 +1689,7 @@ mkdir(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINTREF;
        NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
        NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
@@ -1516,6 +1701,7 @@ mkdir(p, uap, retval)
                else
                        vput(nd.ni_dvp);
                vrele(vp);
                else
                        vput(nd.ni_dvp);
                vrele(vp);
+               CHECKREFS("mkdir1");
                return (EEXIST);
        }
        VATTR_NULL(&vattr);
                return (EEXIST);
        }
        VATTR_NULL(&vattr);
@@ -1525,6 +1711,7 @@ mkdir(p, uap, retval)
        error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
        if (!error)
                vput(nd.ni_vp);
        error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
        if (!error)
                vput(nd.ni_vp);
+       CHECKREFS("mkdir2");
        return (error);
 }
 
        return (error);
 }
 
@@ -1543,6 +1730,7 @@ rmdir(p, uap, retval)
        int error;
        struct nameidata nd;
 
        int error;
        struct nameidata nd;
 
+       CHECKPOINTREF;
        NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
        NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->name, p);
        if (error = namei(&nd))
                return (error);
@@ -1576,9 +1764,96 @@ out:
                        vput(nd.ni_dvp);
                vput(vp);
        }
                        vput(nd.ni_dvp);
                vput(vp);
        }
+       CHECKREFS("rmdir");
        return (error);
 }
 
        return (error);
 }
 
+#ifdef COMPAT_43
+/*
+ * Read a block of directory entries in a file system independent format.
+ */
+ogetdirentries(p, uap, retval)
+       struct proc *p;
+       register struct args {
+               int     fd;
+               char    *buf;
+               unsigned count;
+               long    *basep;
+       } *uap;
+       int *retval;
+{
+       register struct vnode *vp;
+       struct file *fp;
+       struct uio auio, kuio;
+       struct iovec aiov, kiov;
+       struct dirent *dp, *edp;
+       caddr_t dirbuf;
+       int error, readcnt;
+       off_t off;
+
+       if (error = getvnode(p->p_fd, uap->fd, &fp))
+               return (error);
+       if ((fp->f_flag & FREAD) == 0)
+               return (EBADF);
+       vp = (struct vnode *)fp->f_data;
+       if (vp->v_type != VDIR)
+               return (EINVAL);
+       aiov.iov_base = uap->buf;
+       aiov.iov_len = uap->count;
+       auio.uio_iov = &aiov;
+       auio.uio_iovcnt = 1;
+       auio.uio_rw = UIO_READ;
+       auio.uio_segflg = UIO_USERSPACE;
+       auio.uio_procp = p;
+       auio.uio_resid = uap->count;
+       VOP_LOCK(vp);
+       auio.uio_offset = off = fp->f_offset;
+#      if (BYTE_ORDER != LITTLE_ENDIAN)
+               if (vp->v_mount->mnt_maxsymlinklen <= 0)
+                       error = VOP_READDIR(vp, &auio, fp->f_cred);
+               else
+#      endif
+       {
+               kuio = auio;
+               kuio.uio_iov = &kiov;
+               kuio.uio_segflg = UIO_SYSSPACE;
+               kiov.iov_len = uap->count;
+               MALLOC(dirbuf, caddr_t, uap->count, M_TEMP, M_WAITOK);
+               kiov.iov_base = dirbuf;
+               error = VOP_READDIR(vp, &kuio, fp->f_cred);
+               if (error == 0) {
+                       readcnt = uap->count - kuio.uio_resid;
+                       edp = (struct dirent *)&dirbuf[readcnt];
+                       for (dp = (struct dirent *)dirbuf; dp < edp; ) {
+                               dp->d_type = 0;
+#                              if (BYTE_ORDER == LITTLE_ENDIAN)
+                                       { u_char tmp = dp->d_namlen;
+                                       dp->d_namlen = dp->d_type;
+                                       dp->d_type = tmp; }
+#                              endif
+                               if (dp->d_reclen > 0) {
+                                       dp = (struct dirent *)
+                                           ((char *)dp + dp->d_reclen);
+                               } else {
+                                       error = EIO;
+                                       break;
+                               }
+                       }
+                       if (dp >= edp)
+                               error = uiomove(dirbuf, readcnt, &auio);
+               }
+               FREE(dirbuf, M_TEMP);
+       }
+       fp->f_offset = auio.uio_offset;
+       VOP_UNLOCK(vp);
+       if (error)
+               return (error);
+       error = copyout((caddr_t)&off, (caddr_t)uap->basep, sizeof(long));
+       *retval = uap->count - auio.uio_resid;
+       return (error);
+}
+#endif
+
 /*
  * Read a block of directory entries in a file system independent format.
  */
 /*
  * Read a block of directory entries in a file system independent format.
  */
@@ -1597,7 +1872,7 @@ getdirentries(p, uap, retval)
        struct uio auio;
        struct iovec aiov;
        off_t off;
        struct uio auio;
        struct iovec aiov;
        off_t off;
-       int error, eofflag;
+       int error;
 
        if (error = getvnode(p->p_fd, uap->fd, &fp))
                return (error);
 
        if (error = getvnode(p->p_fd, uap->fd, &fp))
                return (error);
@@ -1616,7 +1891,7 @@ getdirentries(p, uap, retval)
        auio.uio_resid = uap->count;
        VOP_LOCK(vp);
        auio.uio_offset = off = fp->f_offset;
        auio.uio_resid = uap->count;
        VOP_LOCK(vp);
        auio.uio_offset = off = fp->f_offset;
-       error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag);
+       error = VOP_READDIR(vp, &auio, fp->f_cred);
        fp->f_offset = auio.uio_offset;
        VOP_UNLOCK(vp);
        if (error)
        fp->f_offset = auio.uio_offset;
        VOP_UNLOCK(vp);
        if (error)