Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Feb 2013 22:38:20 +0100
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        standards@freebsd.org
Subject:   Re: ERESTART translation in kern_openat()
Message-ID:  <20130206213819.GA82715@stack.nl>
In-Reply-To: <20130204183117.GD2522@kib.kiev.ua>
References:  <20130204183117.GD2522@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130206213819.GA82715>