summaryrefslogtreecommitdiff
path: root/sys/compat/ibcs2/ibcs2_misc.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-06 20:23:17 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-06 20:23:17 +0000
commit85674180ac0b414993bec634994ea51b28390306 (patch)
tree5ce384dfed739e368b8605fc6db4ed1f26a43609 /sys/compat/ibcs2/ibcs2_misc.c
parent44f83f3e77b70fbce9f014e39cf5c97bae700213 (diff)
back out vfs lite2 till after 2.2
Diffstat (limited to 'sys/compat/ibcs2/ibcs2_misc.c')
-rw-r--r--sys/compat/ibcs2/ibcs2_misc.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c
index 97f3ab14835..72eb283d81f 100644
--- a/sys/compat/ibcs2/ibcs2_misc.c
+++ b/sys/compat/ibcs2/ibcs2_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ibcs2_misc.c,v 1.11 1997/10/06 14:57:24 csapuntz Exp $ */
+/* $OpenBSD: ibcs2_misc.c,v 1.12 1997/10/06 20:19:29 deraadt Exp $ */
/* $NetBSD: ibcs2_misc.c,v 1.23 1997/01/15 01:37:49 perry Exp $ */
/*
@@ -358,8 +358,8 @@ ibcs2_sys_getdents(p, v, retval)
struct ibcs2_dirent idb;
off_t off; /* true file offset */
int buflen, error, eofflag;
- u_long *cookiebuf = NULL, *cookie;
- int ncookies = 0;
+ u_long *cookiebuf, *cookie;
+ int ncookies;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
@@ -374,7 +374,9 @@ ibcs2_sys_getdents(p, v, retval)
buflen = min(MAXBSIZE, SCARG(uap, nbytes));
buf = malloc(buflen, M_TEMP, M_WAITOK);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
+ ncookies = buflen / 16;
+ cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
+ VOP_LOCK(vp);
off = fp->f_offset;
again:
aiov.iov_base = buf;
@@ -390,16 +392,11 @@ 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, &ncookies,
- &cookiebuf);
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
+ ncookies);
if (error)
goto out;
- if (!error && !cookiebuf) {
- error = EPERM;
- goto out;
- }
-
inp = buf;
outp = SCARG(uap, buf);
resid = SCARG(uap, nbytes);
@@ -449,9 +446,8 @@ again:
eof:
*retval = SCARG(uap, nbytes) - resid;
out:
- VOP_UNLOCK(vp, 0, p);
- if (cookiebuf)
- free(cookiebuf, M_TEMP);
+ VOP_UNLOCK(vp);
+ free(cookiebuf, M_TEMP);
free(buf, M_TEMP);
return (error);
}
@@ -482,8 +478,8 @@ ibcs2_sys_read(p, v, retval)
} idb;
off_t off; /* true file offset */
int buflen, error, eofflag, size;
- u_long *cookiebuf = NULL, *cookie;
- int ncookies = 0;
+ u_long *cookiebuf, *cookie;
+ int ncookies;
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) {
if (error == EINVAL)
@@ -499,7 +495,9 @@ ibcs2_sys_read(p, v, retval)
DPRINTF(("ibcs2_read: read directory\n"));
buflen = max(MAXBSIZE, SCARG(uap, nbytes));
buf = malloc(buflen, M_TEMP, M_WAITOK);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
+ ncookies = buflen / 16;
+ cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
+ VOP_LOCK(vp);
off = fp->f_offset;
again:
aiov.iov_base = buf;
@@ -515,16 +513,10 @@ 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, &ncookies,
- &cookiebuf);
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
+ ncookies);
if (error)
goto out;
-
- if (!error && !cookiebuf) {
- error = EPERM;
- goto out;
- }
-
inp = buf;
outp = SCARG(uap, buf);
resid = SCARG(uap, nbytes);
@@ -573,9 +565,7 @@ again:
eof:
*retval = SCARG(uap, nbytes) - resid;
out:
- VOP_UNLOCK(vp, 0, p);
- if (cookiebuf)
- free(cookiebuf, M_TEMP);
+ VOP_UNLOCK(vp);
free(buf, M_TEMP);
return (error);
}