diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-01-22 23:06:35 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-01-22 23:06:35 +0000 |
commit | cb57849f50dda2a6cbe9456152cf3e6c2a3cce22 (patch) | |
tree | 2a8c2bdd0409ad2085144c0fce514877921f8ad7 /sys/compat/sunos | |
parent | 829af5acc62854b7cd90ccd9f4584f7fca13b511 (diff) |
minor getdents cleanup:
o return ENOTDIR, not EINVAL for v_type != VDIR (SunOS behavior)
o return EINVAL for values of nbytes too small to hold a single dir entry
o remove a redundant check for error != 0
Diffstat (limited to 'sys/compat/sunos')
-rw-r--r-- | sys/compat/sunos/sunos_misc.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c index c7afdbe8b4d..55c328313c5 100644 --- a/sys/compat/sunos/sunos_misc.c +++ b/sys/compat/sunos/sunos_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunos_misc.c,v 1.21 1999/02/10 00:16:12 niklas Exp $ */ +/* $OpenBSD: sunos_misc.c,v 1.22 2000/01/22 23:06:34 millert Exp $ */ /* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */ /* @@ -382,7 +382,11 @@ sunos_sys_getdents(p, v, retval) void *v; register_t *retval; { - struct sunos_sys_getdents_args *uap = v; + struct sunos_sys_getdents_args /* { + syscallarg(int) fd; + syscallarg(char *) buf; + syscallarg(int) nbytes; + } */ *uap = v; struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ @@ -400,13 +404,14 @@ sunos_sys_getdents(p, v, retval) if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) return (error); - if ((fp->f_flag & FREAD) == 0) return (EBADF); - vp = (struct vnode *)fp->f_data; - if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */ + /* SunOS returns ENOTDIR here, BSD would use EINVAL */ + if (vp->v_type != VDIR) + return (ENOTDIR); + if (SCARG(uap, nbytes) < sizeof(struct sunos_dirent)) return (EINVAL); buflen = min(MAXBSIZE, SCARG(uap, nbytes)); @@ -431,8 +436,7 @@ again: &ncookies, &cookiebuf); if (error) goto out; - - if (!error && !cookiebuf) { + if (!cookiebuf) { error = EPERM; goto out; } |