Subject: kern/30: fsync on pipe fails
To: None <gnats-admin>
From: None <sommerfeld@orchard.medford.ma.us>
List: netbsd-bugs
Date: 11/29/1993 20:35:03
>Number: 30
>Category: kern
>Synopsis: fsync() on pipe fails with EINVAL
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: gnats-admin (Kernel Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Nov 29 20:35:02 1993
>Originator: Bill Sommerfeld
>Organization:
Self
>Release: NetBSD 0.9, NetBSD-current
>Environment:
i[34]86
System: NetBSD orchard.medford.ma.us 0.9a ORCHARD#11 i386
>Description:
fsync() on a pipe fails, returning EINVAL.
This breaks RCS, which expects to fsync all of its I/O before
closing it.
>How-To-Repeat:
rlog foo,v | cat
Note that rlog fails with an "output error"
This problem was first seen with emacs 19 "vc" (version-control) mode, which
runs RCS commands in subprocesses, connected to the main emacs using a pipe.
>Fix:
Apply following patch to /sys/kern/vfs_syscalls.c
alternatively:
(more work)
fix rlog and anything else which might fsync() a pipe/socket
or (even more work)
implement fsync() on sockets -> wait until all queued output is drained.
*** 1.1 1993/11/24 22:06:05
--- 1.2 1993/11/28 17:33:35
***************
*** 1565,1572 ****
struct file *fp;
int error;
! if (error = getvnode(p->p_fd, uap->fd, &fp))
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
error = VOP_FSYNC(vp, fp->f_flag, fp->f_cred, MNT_WAIT, p);
--- 1565,1575 ----
struct file *fp;
int error;
! if (error = getvnode(p->p_fd, uap->fd, &fp)) {
! if (error == EINVAL)
! error = 0;
return (error);
+ }
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
error = VOP_FSYNC(vp, fp->f_flag, fp->f_cred, MNT_WAIT, p);
>Audit-Trail:
>Unformatted:
------------------------------------------------------------------------------