#include <miscfs/devfs/devfs.h>
#include <miscfs/devfs/devfsdefs.h>
-/* XXX should be prototyped in header for here, kern_descrip.c */
-extern int soo_stat(struct socket *so, void *ub, int isstat64);
-
#define FDL_WANT 0x01
#define FDL_LOCKED 0x02
static int fdcache_lock;
vid = vnode_vid(fd->fd_vnode);
fdesc_unlock();
- if (vnode_getwithvid(fd->fd_vnode, vid))
+ if (vnode_getwithvid(fd->fd_vnode, vid)) {
+ fdesc_lock();
goto loop;
+ }
*vpp = fd->fd_vnode;
(*vpp)->v_type = vtype;
if ((error = fp_lookup(p, fd, &fp, 0)))
return (error);
- switch (fp->f_fglob->fg_type) {
+ switch (FILEGLOB_DTYPE(fp->f_fglob)) {
case DTYPE_VNODE:
if((error = vnode_getwithref((struct vnode *) fp->f_fglob->fg_data)) != 0) {
break;
case DTYPE_SOCKET:
case DTYPE_PIPE:
#if SOCKETS
- if (fp->f_fglob->fg_type == DTYPE_SOCKET)
+ if (FILEGLOB_DTYPE(fp->f_fglob) == DTYPE_SOCKET)
error = soo_stat((struct socket *)fp->f_fglob->fg_data, (void *)&stb, 0);
else
#endif /* SOCKETS */
error = pipe_stat((struct pipe *)fp->f_fglob->fg_data, (void *)&stb, 0);
if (error == 0) {
- if (fp->f_fglob->fg_type == DTYPE_SOCKET)
+ if (FILEGLOB_DTYPE(fp->f_fglob) == DTYPE_SOCKET)
VATTR_RETURN(vap, va_type, VSOCK);
else
VATTR_RETURN(vap, va_type, VFIFO);
/*
* Can setattr the underlying vnode, but not sockets!
*/
- switch (fp->f_fglob->fg_type) {
+ switch (FILEGLOB_DTYPE(fp->f_fglob)) {
case DTYPE_VNODE:
{
if ((error = vnode_getwithref((struct vnode *) fp->f_fglob->fg_data)) != 0)
break;
default:
- kprintf("fp->f_fglob->fg_type = %d\n", fp->f_fglob->fg_type);
- error = EBADF;
+ error = EBADF;
break;
}
if (ap->a_flags & (VNODE_READDIR_EXTENDED | VNODE_READDIR_REQSEEKOFF))
return (EINVAL);
+ /*
+ * There needs to be space for at least one entry.
+ */
+ if (uio_resid(uio) < UIO_MX)
+ return (EINVAL);
+
i = uio->uio_offset / UIO_MX;
error = 0;
- while (uio_resid(uio) > 0) {
+ while (uio_resid(uio) >= UIO_MX) {
if (i >= p->p_fd->fd_nfiles)
break;