summaryrefslogtreecommitdiff
path: root/sys/compat/svr4
diff options
context:
space:
mode:
authorConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-11-06 05:59:40 +0000
committerConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-11-06 05:59:40 +0000
commit4e165724f1631d1deee6fd89b941fabdbcc855d4 (patch)
tree3aca36af68e90377984b00e9f0050674b0763db5 /sys/compat/svr4
parentfec1be888534eb37405f6bf7a195f28670e1392b (diff)
Updates for VFS Lite 2 + soft update.
Diffstat (limited to 'sys/compat/svr4')
-rw-r--r--sys/compat/svr4/svr4_misc.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 56017605bb0..0831753d335 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_misc.c,v 1.13 1997/10/06 20:19:35 deraadt Exp $ */
+/* $OpenBSD: svr4_misc.c,v 1.14 1997/11/06 05:58:06 csapuntz Exp $ */
/* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */
/*
@@ -227,8 +227,8 @@ svr4_sys_getdents(p, v, retval)
struct svr4_dirent idb;
off_t off; /* true file offset */
int buflen, error, eofflag;
- u_long *cookiebuf, *cookie;
- int ncookies;
+ u_long *cookiebuf = NULL, *cookie;
+ int ncookies = 0;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
@@ -243,9 +243,7 @@ svr4_sys_getdents(p, v, retval)
buflen = min(MAXBSIZE, SCARG(uap, nbytes));
buf = malloc(buflen, M_TEMP, M_WAITOK);
- ncookies = buflen / 16;
- cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
- VOP_LOCK(vp);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
off = fp->f_offset;
again:
aiov.iov_base = buf;
@@ -261,11 +259,16 @@ again:
* First we read into the malloc'ed buffer, then
* we massage it into user space, one record at a time.
*/
- error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
- ncookies);
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
+ &cookiebuf);
if (error)
goto out;
+ if (!error && !cookiebuf) {
+ error = EPERM;
+ goto out;
+ }
+
inp = buf;
outp = SCARG(uap, buf);
resid = SCARG(uap, nbytes);
@@ -314,8 +317,9 @@ again:
eof:
*retval = SCARG(uap, nbytes) - resid;
out:
- VOP_UNLOCK(vp);
- free(cookiebuf, M_TEMP);
+ VOP_UNLOCK(vp, 0, p);
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
free(buf, M_TEMP);
return error;
}
@@ -371,12 +375,12 @@ svr4_sys_fchroot(p, v, retval)
if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
return error;
vp = (struct vnode *) fp->f_data;
- VOP_LOCK(vp);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
if (vp->v_type != VDIR)
error = ENOTDIR;
else
error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
- VOP_UNLOCK(vp);
+ VOP_UNLOCK(vp, 0, p);
if (error)
return error;
VREF(vp);