summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_misc.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1997-10-06 20:19:26 +0000
committerderaadt <deraadt@openbsd.org>1997-10-06 20:19:26 +0000
commitf6d35f956ac60c4dbcc91b018b2bcefd71ad933f (patch)
tree918af077b7c363fb7d19243c4ecb7f0165b3bc65 /sys/compat/linux/linux_misc.c
parentBuild generic and genericsbc kernels into snapshot and distribute them (diff)
downloadwireguard-openbsd-f6d35f956ac60c4dbcc91b018b2bcefd71ad933f.tar.xz
wireguard-openbsd-f6d35f956ac60c4dbcc91b018b2bcefd71ad933f.zip
back out vfs lite2 till after 2.2
Diffstat (limited to 'sys/compat/linux/linux_misc.c')
-rw-r--r--sys/compat/linux/linux_misc.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 2a71810913a..7206ca027eb 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_misc.c,v 1.8 1997/10/06 15:05:18 csapuntz Exp $ */
+/* $OpenBSD: linux_misc.c,v 1.9 1997/10/06 20:19:31 deraadt Exp $ */
/* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */
/*
@@ -768,8 +768,8 @@ linux_sys_getdents(p, v, retval)
off_t off; /* true file offset */
int buflen, error, eofflag, nbytes, oldcall;
struct vattr va;
- 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);
@@ -795,7 +795,9 @@ linux_sys_getdents(p, v, retval)
oldcall = 0;
}
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;
@@ -811,14 +813,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)
- goto out;
-
inp = buf;
outp = SCARG(uap, dent);
resid = nbytes;
@@ -882,9 +881,8 @@ again:
eof:
*retval = 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;
}