Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2010-09-21 20:32:22 +0400
committerCorinna Vinschen <corinna@vinschen.de>2010-09-21 20:32:22 +0400
commit4c9d01fdad2acbfb5d0594dbe5fb6f0f402cff72 (patch)
treea8b522f688140bb24462bc8e0c8790aba434b7c5
parent7ba1698ed99abca171d2beb9091168e20cdd8b34 (diff)
* mount.h (class fs_info): Add has_buggy_reopen flag and accessor
methods. * mount.cc (fs_info::update): Set has_buggy_reopen flag for NWFS. Add comment. * path.h (path_conv::get_object_attr) Make inline method. (path_conv::init_reopen_attr): New inline method. * path.cc (path_conv::get_object_attr): Remove. * fhandler_disk_file.cc (fhandler_base::fstat_helper): Use path_conv::init_reopen_attr method to initialize OBJECT_ATTRIBUTE for reopening file. (fhandler_disk_file::fchmod): Ditto. (fhandler_base::utimens_fs): Ditto. (fhandler_disk_file::rewinddir): Ditto. * syscalls.cc (unlink_nt): Ditto.
-rw-r--r--winsup/cygwin/ChangeLog17
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc15
-rw-r--r--winsup/cygwin/mount.cc4
-rw-r--r--winsup/cygwin/mount.h2
-rw-r--r--winsup/cygwin/path.cc12
-rw-r--r--winsup/cygwin/path.h23
-rw-r--r--winsup/cygwin/syscalls.cc5
7 files changed, 50 insertions, 28 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 9788adef9..13741ebbb 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,22 @@
2010-09-21 Corinna Vinschen <corinna@vinschen.de>
+ * mount.h (class fs_info): Add has_buggy_reopen flag and accessor
+ methods.
+ * mount.cc (fs_info::update): Set has_buggy_reopen flag for NWFS.
+ Add comment.
+ * path.h (path_conv::get_object_attr) Make inline method.
+ (path_conv::init_reopen_attr): New inline method.
+ * path.cc (path_conv::get_object_attr): Remove.
+ * fhandler_disk_file.cc (fhandler_base::fstat_helper): Use
+ path_conv::init_reopen_attr method to initialize OBJECT_ATTRIBUTE for
+ reopening file.
+ (fhandler_disk_file::fchmod): Ditto.
+ (fhandler_base::utimens_fs): Ditto.
+ (fhandler_disk_file::rewinddir): Ditto.
+ * syscalls.cc (unlink_nt): Ditto.
+
+2010-09-21 Corinna Vinschen <corinna@vinschen.de>
+
* fhandler.cc (fhandler_base::open): Always open NFS files with
FILE_READ_EA, even when opening with O_WRONLY to allow fstat.
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Call
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index cff345d31..6a28ac15c 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -636,13 +636,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
file. Either the file is not opened for reading, or the
read will change the file position. */
OBJECT_ATTRIBUTES attr;
- if (pc.fs_is_nwfs ())
- InitializeObjectAttributes (&attr, pc.get_nt_native_path (),
- OBJ_CASE_INSENSITIVE,
- NULL, NULL)
- else
- InitializeObjectAttributes (&attr, &ro_u_empty, 0,
- get_handle (), NULL);
+ pc.init_reopen_attr (&attr, h);
status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA,
&attr, &io, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT
@@ -874,7 +868,7 @@ fhandler_disk_file::fchmod (mode_t mode)
OBJECT_ATTRIBUTES attr;
HANDLE fh;
- InitializeObjectAttributes (&attr, &ro_u_empty, 0, get_handle (), NULL);
+ pc.init_reopen_attr (&attr, get_handle ());
if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io,
FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT)))
@@ -1353,7 +1347,7 @@ fhandler_base::utimens_fs (const struct timespec *tvp)
OBJECT_ATTRIBUTES attr;
HANDLE fh;
- InitializeObjectAttributes (&attr, &ro_u_empty, 0, get_handle (), NULL);
+ pc.init_reopen_attr (&attr, get_handle ());
if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io,
FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT)))
@@ -2157,8 +2151,7 @@ fhandler_disk_file::rewinddir (DIR *dir)
IO_STATUS_BLOCK io;
HANDLE new_dir;
- InitializeObjectAttributes (&attr, &ro_u_empty, pc.objcaseinsensitive (),
- get_handle (), NULL);
+ pc.init_reopen_attr (&attr, get_handle ());
status = NtOpenFile (&new_dir, SYNCHRONIZE | FILE_LIST_DIRECTORY,
&attr, &io, FILE_SHARE_VALID_FLAGS,
FILE_SYNCHRONOUS_IO_NONALERT
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index 6c58849b8..74db057dd 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -389,6 +389,10 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol)
clients. We subsume CIFS into this class of filesystems right
away since at least some of them are not capable either. */
has_dos_filenames_only (is_netapp () || is_nwfs () || is_cifs ());
+ /* NWFS does not grok re-opening a file by handle. It only
+ supports this if the filename is non-null and the handle is
+ the handle to a directory. */
+ has_buggy_reopen (is_nwfs ());
}
}
if (!got_fs ()
diff --git a/winsup/cygwin/mount.h b/winsup/cygwin/mount.h
index 7c229bb2e..35fce96d9 100644
--- a/winsup/cygwin/mount.h
+++ b/winsup/cygwin/mount.h
@@ -54,6 +54,7 @@ class fs_info
unsigned hasgood_inode : 1;
unsigned caseinsensitive : 1;
unsigned has_buggy_open : 1;
+ unsigned has_buggy_reopen : 1;
unsigned has_buggy_fileid_dirinfo : 1;
unsigned has_buggy_basic_info : 1;
unsigned has_dos_filenames_only : 1;
@@ -79,6 +80,7 @@ class fs_info
IMPLEMENT_STATUS_FLAG (bool, hasgood_inode)
IMPLEMENT_STATUS_FLAG (bool, caseinsensitive)
IMPLEMENT_STATUS_FLAG (bool, has_buggy_open)
+ IMPLEMENT_STATUS_FLAG (bool, has_buggy_reopen)
IMPLEMENT_STATUS_FLAG (bool, has_buggy_fileid_dirinfo)
IMPLEMENT_STATUS_FLAG (bool, has_buggy_basic_info)
IMPLEMENT_STATUS_FLAG (bool, has_dos_filenames_only)
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 32bb4c0a9..9eac51b63 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -470,18 +470,6 @@ path_conv::get_nt_native_path ()
return &uni_path;
}
-POBJECT_ATTRIBUTES
-path_conv::get_object_attr (OBJECT_ATTRIBUTES &attr, SECURITY_ATTRIBUTES &sa)
-{
- if (!get_nt_native_path ())
- return NULL;
- InitializeObjectAttributes (&attr, &uni_path,
- objcaseinsensitive ()
- | (sa.bInheritHandle ? OBJ_INHERIT : 0),
- NULL, sa.lpSecurityDescriptor);
- return &attr;
-}
-
PWCHAR
path_conv::get_wide_win32_path (PWCHAR wc)
{
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index f832016e5..a53cf169a 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -158,6 +158,7 @@ class path_conv
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
int has_dos_filenames_only () const {return path_flags & PATH_DOS;}
int has_buggy_open () const {return fs.has_buggy_open ();}
+ int has_buggy_reopen () const {return fs.has_buggy_reopen ();}
int has_buggy_fileid_dirinfo () const {return fs.has_buggy_fileid_dirinfo ();}
int has_buggy_basic_info () const {return fs.has_buggy_basic_info ();}
int binmode () const
@@ -253,8 +254,26 @@ class path_conv
~path_conv ();
inline const char *get_win32 () { return path; }
PUNICODE_STRING get_nt_native_path ();
- POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
- SECURITY_ATTRIBUTES &sa);
+ inline POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
+ SECURITY_ATTRIBUTES &sa)
+ {
+ if (!get_nt_native_path ())
+ return NULL;
+ InitializeObjectAttributes (&attr, &uni_path,
+ objcaseinsensitive ()
+ | (sa.bInheritHandle ? OBJ_INHERIT : 0),
+ NULL, sa.lpSecurityDescriptor);
+ return &attr;
+ }
+ inline void init_reopen_attr (POBJECT_ATTRIBUTES attr, HANDLE h)
+ {
+ if (has_buggy_reopen ())
+ InitializeObjectAttributes (attr, get_nt_native_path (),
+ objcaseinsensitive (), NULL, NULL)
+ else
+ InitializeObjectAttributes (attr, &ro_u_empty, objcaseinsensitive (),
+ h, NULL);
+ }
inline size_t get_wide_win32_path_len ()
{
get_nt_native_path ();
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index acd0fa5f6..190d1d68f 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -569,8 +569,7 @@ unlink_nt (path_conv &pc)
{
NtSetAttributesFile (fh_ro, pc.file_attributes ()
& ~FILE_ATTRIBUTE_READONLY);
- InitializeObjectAttributes (&attr, &ro_u_empty,
- pc.objcaseinsensitive (), fh_ro, NULL);
+ pc.init_reopen_attr (&attr, fh_ro);
}
if (pc.is_lnk_symlink ())
{
@@ -688,7 +687,7 @@ unlink_nt (path_conv &pc)
/* Re-open from handle so we open the correct file no matter if it
has been moved to the bin or not. */
- InitializeObjectAttributes (&attr, &ro_u_empty, 0, fh, NULL);
+ pc.init_reopen_attr (&attr, fh);
status = NtOpenFile (&fh2, DELETE, &attr, &io,
bin_stat == move_to_bin ? FILE_SHARE_VALID_FLAGS
: FILE_SHARE_DELETE,