ERESTART translation in kern_openat()
Jilles Tjoelker
jilles at stack.nl
Wed Feb 6 21:38:37 UTC 2013
On Mon, Feb 04, 2013 at 08:31:17PM +0200, Konstantin Belousov wrote:
> you noted somewhere that the unconditional translation of the ERESTART
> to EINTR, performed by kern_openat(), is wrong. I mostly agree with
> your statement, e.g. it is definitely wrong for fifos, but translation
> itself is useful for devfs, in my opinion. E.g., you do not want
> the tape unwind to be restarted this way.
> I propose not to remove the translation, but limit it to devfs only.
> See the patch below.
> Any comments ?
Please commit.
A note in the man page may be useful, like:
If a blocking open of a device is interrupted by a signal,
the call always fails with [EINTR] even if SA_RESTART is set for the
signal. A blocking open of a fifo is restarted as normal.
> diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
> index 9851229..7da9b11 100644
> --- a/sys/fs/devfs/devfs_vnops.c
> +++ b/sys/fs/devfs/devfs_vnops.c
> @@ -1089,8 +1089,11 @@ devfs_open(struct vop_open_args *ap)
>
> vn_lock(vp, vlocked | LK_RETRY);
> dev_relthread(dev, ref);
> - if (error)
> + if (error != 0) {
> + if (error == ERESTART)
> + error = EINTR;
> return (error);
> + }
>
> #if 0 /* /dev/console */
> KASSERT(fp != NULL, ("Could not vnode bypass device on NULL fp"));
> diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
> index 1a5f2ae..dd1232c 100644
> --- a/sys/kern/vfs_syscalls.c
> +++ b/sys/kern/vfs_syscalls.c
> @@ -1106,8 +1106,6 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
> goto success;
> }
>
> - if (error == ERESTART)
> - error = EINTR;
> goto bad;
> }
> td->td_dupfd = 0;
--
Jilles Tjoelker
More information about the freebsd-standards
mailing list