From ffcd2c3f894413870b4431677d94044ca0336c1b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 4 Apr 2012 12:45:24 +0000 Subject: [PATCH] * fhandler_nodevice.cc (fhandler_nodevice::open): Convert EROFS to ENOENT if non-existent file got opened for reading only. Explain why. * path.cc (path_conv::check): Stick to ENOENT if file has been opened for informational purposes only. Add to comment. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/fhandler_nodevice.cc | 6 +++++- winsup/cygwin/path.cc | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5ebc53dc1..57f411250 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2012-04-04 Corinna Vinschen + + * fhandler_nodevice.cc (fhandler_nodevice::open): Convert EROFS to + ENOENT if non-existent file got opened for reading only. Explain why. + * path.cc (path_conv::check): Stick to ENOENT if file has been opened + for informational purposes only. Add to comment. + 2012-04-04 Corinna Vinschen * path.cc (path_conv::check): Convert device type to FH_FS for diff --git a/winsup/cygwin/fhandler_nodevice.cc b/winsup/cygwin/fhandler_nodevice.cc index 4ffe2c447..39842d394 100644 --- a/winsup/cygwin/fhandler_nodevice.cc +++ b/winsup/cygwin/fhandler_nodevice.cc @@ -15,10 +15,14 @@ details. */ #include "fhandler.h" int -fhandler_nodevice::open (int, mode_t) +fhandler_nodevice::open (int flags, mode_t) { if (!pc.error) set_errno (ENXIO); + /* Fixup EROFS error returned from path_conv if /dev is not backed by real + directory on disk and the file doesn't exist. */ + else if (pc.error == EROFS && (flags & O_ACCMODE) == O_RDONLY) + set_errno (ENOENT); return 0; } diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 4fee713ae..6c848fc6f 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -889,8 +889,11 @@ is_virtual_symlink: subsequent code handles the file correctly. Unless /dev itself doesn't exist on disk. In that case /dev is handled as virtual filesystem, and virtual filesystems are - read-only. */ - if (sym.error == ENOENT) + read-only. The PC_KEEP_HANDLE check allows to check for + a call from an informational system call. In that case we + just stick to ENOENT, and the device type doesn't matter + anyway. */ + if (sym.error == ENOENT && !(opt & PC_KEEP_HANDLE)) sym.error = EROFS; else dev.d.devn = FH_FS; -- 2.43.5