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).
This commit is contained in:
Bruce Evans 1996-12-19 19:42:37 +00:00
parent 63c6440041
commit bb65f5a1cc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20691
8 changed files with 25 additions and 15 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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 */