diff options
author | bde <bde@FreeBSD.org> | 1996-12-19 19:42:37 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1996-12-19 19:42:37 +0000 |
commit | d8370232258e75a57361cafc2243862df35d18f1 (patch) | |
tree | cc194e09ac16ca08b2ba8a58498a24e9e4347dfa | |
parent | 30805cd75c006c0be5fa92042de94702692aa910 (diff) | |
download | FreeBSD-src-d8370232258e75a57361cafc2243862df35d18f1.zip FreeBSD-src-d8370232258e75a57361cafc2243862df35d18f1.tar.gz |
Fixed lseek() on named pipes. It always succeeded but should always fail.
Broke locking on named pipes in the same way as locking on non-vnodes
(wrong errno). This will be fixed later.
The fix involves negative logic. Named pipes are now distinguished from
other types of files with vnodes, and there is additional code to handle
vnodes and named pipes in the same way only where that makes sense (not
for lseek, locking or TIOCSCTTY).
-rw-r--r-- | sys/compat/linux/linux_stats.c | 3 | ||||
-rw-r--r-- | sys/fs/fdescfs/fdesc_vnops.c | 4 | ||||
-rw-r--r-- | sys/i386/linux/linux_stats.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_descrip.c | 5 | ||||
-rw-r--r-- | sys/kern/vfs_extattr.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 8 | ||||
-rw-r--r-- | sys/miscfs/fdesc/fdesc_vnops.c | 4 | ||||
-rw-r--r-- | sys/sys/file.h | 5 |
8 files changed, 25 insertions, 15 deletions
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 8d562e0..20e7880 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_stats.c,v 1.4 1996/01/30 12:23:17 peter Exp $ + * $Id: linux_stats.c,v 1.5 1996/03/02 19:38:00 peter Exp $ */ #include <sys/param.h> @@ -192,6 +192,7 @@ linux_newfstat(struct proc *p, struct linux_newfstat_args *args, int *retval) || (fp = fdp->fd_ofiles[args->fd]) == NULL) return EBADF; switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = vn_stat((struct vnode *)fp->f_data, &buf, p); break; diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 0f4ea9b..fc14f70 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -35,7 +35,7 @@ * * @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94 * - * $Id: fdesc_vnops.c,v 1.18 1996/09/03 14:22:12 bde Exp $ + * $Id: fdesc_vnops.c,v 1.19 1996/09/20 05:56:36 nate Exp $ */ /* @@ -397,6 +397,7 @@ fdesc_attr(fd, vap, cred, p) return (EBADF); switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = VOP_GETATTR((struct vnode *) fp->f_data, vap, cred, p); if (error == 0 && vap->va_type == VDIR) { @@ -551,6 +552,7 @@ fdesc_setattr(ap) * Can setattr the underlying vnode, but not sockets! */ switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = VOP_SETATTR((struct vnode *) fp->f_data, ap->a_vap, ap->a_cred, ap->a_p); break; diff --git a/sys/i386/linux/linux_stats.c b/sys/i386/linux/linux_stats.c index 8d562e0..20e7880 100644 --- a/sys/i386/linux/linux_stats.c +++ b/sys/i386/linux/linux_stats.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_stats.c,v 1.4 1996/01/30 12:23:17 peter Exp $ + * $Id: linux_stats.c,v 1.5 1996/03/02 19:38:00 peter Exp $ */ #include <sys/param.h> @@ -192,6 +192,7 @@ linux_newfstat(struct proc *p, struct linux_newfstat_args *args, int *retval) || (fp = fdp->fd_ofiles[args->fd]) == NULL) return EBADF; switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = vn_stat((struct vnode *)fp->f_data, &buf, p); break; diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index b7a3d50..9111d46 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 - * $Id: kern_descrip.c,v 1.31 1996/08/15 16:33:32 smpatel Exp $ + * $Id: kern_descrip.c,v 1.32 1996/09/28 16:33:21 bde Exp $ */ #include <sys/param.h> @@ -417,6 +417,7 @@ ofstat(p, uap, retval) return (EBADF); switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = vn_stat((struct vnode *)fp->f_data, &ub, p); break; @@ -468,6 +469,7 @@ fstat(p, uap, retval) return (EBADF); switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = vn_stat((struct vnode *)fp->f_data, &ub, p); break; @@ -525,6 +527,7 @@ fpathconf(p, uap, retval) *retval = PIPE_BUF; return (0); + case DTYPE_FIFO: case DTYPE_VNODE: vp = (struct vnode *)fp->f_data; return (VOP_PATHCONF(vp, uap->name, retval)); diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index c4a4a7b..1337e95 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.50 1996/09/03 14:21:53 bde Exp $ + * $Id: vfs_syscalls.c,v 1.51 1996/09/19 18:20:27 nate Exp $ */ /* @@ -698,9 +698,9 @@ open(p, uap, retval) } p->p_dupfd = 0; vp = nd.ni_vp; - + fp->f_flag = flags & FMASK; - fp->f_type = DTYPE_VNODE; + fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE); fp->f_ops = &vnops; fp->f_data = (caddr_t)vp; if (flags & (O_EXLOCK | O_SHLOCK)) { @@ -2346,7 +2346,7 @@ getvnode(fdp, fd, fpp) if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) return (EBADF); - if (fp->f_type != DTYPE_VNODE) + if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) return (EINVAL); *fpp = fp; return (0); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index c4a4a7b..1337e95 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.50 1996/09/03 14:21:53 bde Exp $ + * $Id: vfs_syscalls.c,v 1.51 1996/09/19 18:20:27 nate Exp $ */ /* @@ -698,9 +698,9 @@ open(p, uap, retval) } p->p_dupfd = 0; vp = nd.ni_vp; - + fp->f_flag = flags & FMASK; - fp->f_type = DTYPE_VNODE; + fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE); fp->f_ops = &vnops; fp->f_data = (caddr_t)vp; if (flags & (O_EXLOCK | O_SHLOCK)) { @@ -2346,7 +2346,7 @@ getvnode(fdp, fd, fpp) if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) return (EBADF); - if (fp->f_type != DTYPE_VNODE) + if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) return (EINVAL); *fpp = fp; return (0); diff --git a/sys/miscfs/fdesc/fdesc_vnops.c b/sys/miscfs/fdesc/fdesc_vnops.c index 0f4ea9b..fc14f70 100644 --- a/sys/miscfs/fdesc/fdesc_vnops.c +++ b/sys/miscfs/fdesc/fdesc_vnops.c @@ -35,7 +35,7 @@ * * @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94 * - * $Id: fdesc_vnops.c,v 1.18 1996/09/03 14:22:12 bde Exp $ + * $Id: fdesc_vnops.c,v 1.19 1996/09/20 05:56:36 nate Exp $ */ /* @@ -397,6 +397,7 @@ fdesc_attr(fd, vap, cred, p) return (EBADF); switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = VOP_GETATTR((struct vnode *) fp->f_data, vap, cred, p); if (error == 0 && vap->va_type == VDIR) { @@ -551,6 +552,7 @@ fdesc_setattr(ap) * Can setattr the underlying vnode, but not sockets! */ switch (fp->f_type) { + case DTYPE_FIFO: case DTYPE_VNODE: error = VOP_SETATTR((struct vnode *) fp->f_data, ap->a_vap, ap->a_cred, ap->a_p); break; diff --git a/sys/sys/file.h b/sys/sys/file.h index 1eaa9d2..34aa794 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)file.h 8.3 (Berkeley) 1/9/95 - * $Id: file.h,v 1.7 1996/03/11 02:16:40 hsu Exp $ + * $Id: file.h,v 1.8 1996/09/03 14:25:10 bde Exp $ */ #ifndef _SYS_FILE_H_ @@ -57,7 +57,8 @@ struct file { short f_flag; /* see fcntl.h */ #define DTYPE_VNODE 1 /* file */ #define DTYPE_SOCKET 2 /* communications endpoint */ -#define DTYPE_PIPE 3 /* pipe */ +#define DTYPE_PIPE 3 /* pipe */ +#define DTYPE_FIFO 4 /* fifo (named pipe) */ short f_type; /* descriptor type */ short f_count; /* reference count */ short f_msgcount; /* references from message queue */ |