* 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.
This commit is contained in:
Corinna Vinschen 2010-09-21 16:32:22 +00:00
parent 7ba1698ed9
commit 4c9d01fdad
7 changed files with 50 additions and 28 deletions

View File

@ -1,3 +1,20 @@
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> 2010-09-21 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::open): Always open NFS files with * fhandler.cc (fhandler_base::open): Always open NFS files with

View File

@ -636,13 +636,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
file. Either the file is not opened for reading, or the file. Either the file is not opened for reading, or the
read will change the file position. */ read will change the file position. */
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
if (pc.fs_is_nwfs ()) pc.init_reopen_attr (&attr, h);
InitializeObjectAttributes (&attr, pc.get_nt_native_path (),
OBJ_CASE_INSENSITIVE,
NULL, NULL)
else
InitializeObjectAttributes (&attr, &ro_u_empty, 0,
get_handle (), NULL);
status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA, status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA,
&attr, &io, FILE_SHARE_VALID_FLAGS, &attr, &io, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT FILE_OPEN_FOR_BACKUP_INTENT
@ -874,7 +868,7 @@ fhandler_disk_file::fchmod (mode_t mode)
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
HANDLE fh; 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, if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io,
FILE_SHARE_VALID_FLAGS, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT))) FILE_OPEN_FOR_BACKUP_INTENT)))
@ -1353,7 +1347,7 @@ fhandler_base::utimens_fs (const struct timespec *tvp)
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
HANDLE fh; 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, if (NT_SUCCESS (NtOpenFile (&fh, FILE_WRITE_ATTRIBUTES, &attr, &io,
FILE_SHARE_VALID_FLAGS, FILE_SHARE_VALID_FLAGS,
FILE_OPEN_FOR_BACKUP_INTENT))) FILE_OPEN_FOR_BACKUP_INTENT)))
@ -2157,8 +2151,7 @@ fhandler_disk_file::rewinddir (DIR *dir)
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
HANDLE new_dir; HANDLE new_dir;
InitializeObjectAttributes (&attr, &ro_u_empty, pc.objcaseinsensitive (), pc.init_reopen_attr (&attr, get_handle ());
get_handle (), NULL);
status = NtOpenFile (&new_dir, SYNCHRONIZE | FILE_LIST_DIRECTORY, status = NtOpenFile (&new_dir, SYNCHRONIZE | FILE_LIST_DIRECTORY,
&attr, &io, FILE_SHARE_VALID_FLAGS, &attr, &io, FILE_SHARE_VALID_FLAGS,
FILE_SYNCHRONOUS_IO_NONALERT FILE_SYNCHRONOUS_IO_NONALERT

View File

@ -389,6 +389,10 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol)
clients. We subsume CIFS into this class of filesystems right clients. We subsume CIFS into this class of filesystems right
away since at least some of them are not capable either. */ away since at least some of them are not capable either. */
has_dos_filenames_only (is_netapp () || is_nwfs () || is_cifs ()); 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 () if (!got_fs ()

View File

@ -54,6 +54,7 @@ class fs_info
unsigned hasgood_inode : 1; unsigned hasgood_inode : 1;
unsigned caseinsensitive : 1; unsigned caseinsensitive : 1;
unsigned has_buggy_open : 1; unsigned has_buggy_open : 1;
unsigned has_buggy_reopen : 1;
unsigned has_buggy_fileid_dirinfo : 1; unsigned has_buggy_fileid_dirinfo : 1;
unsigned has_buggy_basic_info : 1; unsigned has_buggy_basic_info : 1;
unsigned has_dos_filenames_only : 1; unsigned has_dos_filenames_only : 1;
@ -79,6 +80,7 @@ class fs_info
IMPLEMENT_STATUS_FLAG (bool, hasgood_inode) IMPLEMENT_STATUS_FLAG (bool, hasgood_inode)
IMPLEMENT_STATUS_FLAG (bool, caseinsensitive) IMPLEMENT_STATUS_FLAG (bool, caseinsensitive)
IMPLEMENT_STATUS_FLAG (bool, has_buggy_open) 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_fileid_dirinfo)
IMPLEMENT_STATUS_FLAG (bool, has_buggy_basic_info) IMPLEMENT_STATUS_FLAG (bool, has_buggy_basic_info)
IMPLEMENT_STATUS_FLAG (bool, has_dos_filenames_only) IMPLEMENT_STATUS_FLAG (bool, has_dos_filenames_only)

View File

@ -470,18 +470,6 @@ path_conv::get_nt_native_path ()
return &uni_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 PWCHAR
path_conv::get_wide_win32_path (PWCHAR wc) path_conv::get_wide_win32_path (PWCHAR wc)
{ {

View File

@ -158,6 +158,7 @@ class path_conv
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;} int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
int has_dos_filenames_only () const {return path_flags & PATH_DOS;} int has_dos_filenames_only () const {return path_flags & PATH_DOS;}
int has_buggy_open () const {return fs.has_buggy_open ();} 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_fileid_dirinfo () const {return fs.has_buggy_fileid_dirinfo ();}
int has_buggy_basic_info () const {return fs.has_buggy_basic_info ();} int has_buggy_basic_info () const {return fs.has_buggy_basic_info ();}
int binmode () const int binmode () const
@ -253,8 +254,26 @@ class path_conv
~path_conv (); ~path_conv ();
inline const char *get_win32 () { return path; } inline const char *get_win32 () { return path; }
PUNICODE_STRING get_nt_native_path (); PUNICODE_STRING get_nt_native_path ();
POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr, inline POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
SECURITY_ATTRIBUTES &sa); 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 () inline size_t get_wide_win32_path_len ()
{ {
get_nt_native_path (); get_nt_native_path ();

View File

@ -569,8 +569,7 @@ unlink_nt (path_conv &pc)
{ {
NtSetAttributesFile (fh_ro, pc.file_attributes () NtSetAttributesFile (fh_ro, pc.file_attributes ()
& ~FILE_ATTRIBUTE_READONLY); & ~FILE_ATTRIBUTE_READONLY);
InitializeObjectAttributes (&attr, &ro_u_empty, pc.init_reopen_attr (&attr, fh_ro);
pc.objcaseinsensitive (), fh_ro, NULL);
} }
if (pc.is_lnk_symlink ()) 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 /* Re-open from handle so we open the correct file no matter if it
has been moved to the bin or not. */ 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, status = NtOpenFile (&fh2, DELETE, &attr, &io,
bin_stat == move_to_bin ? FILE_SHARE_VALID_FLAGS bin_stat == move_to_bin ? FILE_SHARE_VALID_FLAGS
: FILE_SHARE_DELETE, : FILE_SHARE_DELETE,