ERESTART translation in kern_openat()

Konstantin Belousov kostikbel at gmail.com
Mon Feb 4 18:31:22 UTC 2013


Hi,
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 ?

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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-standards/attachments/20130204/5ed35c50/attachment.sig>


More information about the freebsd-standards mailing list