From e1a993d549f9f3047d31de7aeeaa0f49efdb738b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 28 Nov 2000 18:45:42 +0000 Subject: [PATCH] * fhandler.cc (fhandler_disk_file::open): Check for buggy CreateFile condition. * path.cc (path_conv::check): Get file system type in call to GetVolumeInformation to check for file systems with buggy CreateFile. * path.h (enum path_types): Add PATH_HASBUGGYOPEN. (class path_conv): Add methods `has_buggy_open' and `set_has_buggy_open'. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/fhandler.cc | 15 +++++++++++++++ winsup/cygwin/path.cc | 8 +++++++- winsup/cygwin/path.h | 7 +++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5e272dd43..5a10c65f7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +Tue Nov 28 18:08:00 2000 Corinna Vinschen + + * fhandler.cc (fhandler_disk_file::open): Check for buggy CreateFile + condition. + * path.cc (path_conv::check): Get file system type in call to + GetVolumeInformation to check for file systems with buggy CreateFile. + * path.h (enum path_types): Add PATH_HASBUGGYOPEN. + (class path_conv): Add methods `has_buggy_open' and + `set_has_buggy_open'. + Sun Nov 26 16:26:14 2000 Christopher Faylor * fhandler.cc (is_at_eof): New function. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index ed0ebb42f..d2480df17 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1238,6 +1238,21 @@ fhandler_disk_file::open (path_conv& real_path, int flags, mode_t mode) if (!res) goto out; + /* This is for file systems known for having a buggy CreateFile call + which might return a valid HANDLE without having actually opened + the file. + The only known file system to date is the SUN NFS Solstice Client 3.1 + which returns a valid handle when trying to open a file in a non + existant directory. */ + if (real_path.has_buggy_open () + && GetFileAttributes (win32_path_name_) == (DWORD) -1) + { + debug_printf ("Buggy open detected."); + close (); + set_errno (ENOENT); + return 0; + } + extern BOOL allow_ntea; extern BOOL allow_ntsec; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 836ba85f6..060bb9a4e 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -389,20 +389,26 @@ out: return; } DWORD serial, volflags; + char fs_name[16]; strcpy (tmp_buf, full_path); if (!rootdir (tmp_buf) || - !GetVolumeInformation (tmp_buf, NULL, 0, &serial, NULL, &volflags, NULL, 0)) + !GetVolumeInformation (tmp_buf, NULL, 0, &serial, NULL, + &volflags, fs_name, 16)) { debug_printf ("GetVolumeInformation(%s) = ERR, full_path(%s), set_has_acls(FALSE)", tmp_buf, full_path, GetLastError ()); set_has_acls (FALSE); + set_has_buggy_open (FALSE); } else { debug_printf ("GetVolumeInformation(%s) = OK, full_path(%s), set_has_acls(%d)", tmp_buf, full_path, volflags & FS_PERSISTENT_ACLS); set_has_acls (volflags & FS_PERSISTENT_ACLS); + /* Known file systems with buggy open calls. Further explanation + in fhandler.cc (fhandler_disk_file::open). */ + set_has_buggy_open (strcmp (fs_name, "SUNWNFS") == 0); } #if 0 diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 89eaad72c..ca039e200 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -37,8 +37,9 @@ enum path_types PATH_EXEC = MOUNT_EXEC, PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC, PATH_ALL_EXEC = PATH_CYGWIN_EXEC | PATH_EXEC, - PATH_SOCKET = 0x40000000, - PATH_HASACLS = 0x80000000 + PATH_HASBUGGYOPEN = 0x20000000, + PATH_SOCKET = 0x40000000, + PATH_HASACLS = 0x80000000 }; class path_conv @@ -50,6 +51,7 @@ class path_conv int has_acls () {return path_flags & PATH_HASACLS;} int hasgood_inode () {return path_flags & PATH_HASACLS;} // Not strictly correct + int has_buggy_open () {return path_flags & PATH_HASBUGGYOPEN;} int isbinary () {return path_flags & PATH_BINARY;} int issymlink () {return path_flags & PATH_SYMLINK;} int issocket () {return path_flags & PATH_SOCKET;} @@ -60,6 +62,7 @@ class path_conv void set_symlink () {path_flags |= PATH_SYMLINK;} void set_exec (int x = 1) {path_flags |= x ? PATH_EXEC : PATH_NOTHING;} void set_has_acls (int x = 1) {path_flags |= x ? PATH_HASACLS : PATH_NOTHING;} + void set_has_buggy_open (int x = 1) {path_flags |= x ? PATH_HASBUGGYOPEN : PATH_NOTHING;} char *known_suffix;