* fhandler_disk_file.cc (fhandler_disk_file::opendir): Use NtOpenFile to open

the directory.
(fhandler_disk_file::readdir): Use NT_SUCCESS to determine if status represents
success.
This commit is contained in:
Christopher Faylor 2006-02-19 21:18:36 +00:00
parent 84a447aa08
commit 6d61866578
2 changed files with 25 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2006-02-19 Christopher Faylor <cgf@timesys.com>
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Use NtOpenFile
to open the directory.
(fhandler_disk_file::readdir): Use NT_SUCCESS to determine if status
represents success.
2006-02-19 Corinna Vinschen <corinna@vinschen.de> 2006-02-19 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Drop generating * fhandler_disk_file.cc (fhandler_disk_file::opendir): Drop generating

View File

@ -1461,14 +1461,26 @@ fhandler_disk_file::opendir ()
dir->__flags = (pc.normalized_path[0] == '/' && pc.normalized_path[1] == '\0') ? dirent_isroot : 0; dir->__flags = (pc.normalized_path[0] == '/' && pc.normalized_path[1] == '\0') ? dirent_isroot : 0;
if (!pc.isspecial () && wincap.is_winnt ()) if (!pc.isspecial () && wincap.is_winnt ())
{ {
dir->__handle = CreateFile (get_win32_name (), GENERIC_READ, OBJECT_ATTRIBUTES attr;
wincap.shared (), NULL, OPEN_EXISTING, WCHAR wpath[CYG_MAX_PATH + 10];
FILE_FLAG_BACKUP_SEMANTICS, NULL); UNICODE_STRING upath = {0, sizeof (wpath), wpath};
if (dir->__handle == INVALID_HANDLE_VALUE) IO_STATUS_BLOCK io;
NTSTATUS status;
SECURITY_ATTRIBUTES sa = sec_none;
pc.get_nt_native_path (upath);
InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
NULL, sa.lpSecurityDescriptor);
status = NtOpenFile (&dir->__handle,
SYNCHRONIZE | FILE_LIST_DIRECTORY,
&attr, &io, wincap.shared (),
FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE);
if (!NT_SUCCESS (status))
{ {
__seterrno (); __seterrno_from_nt_status (status);
goto free_dirent; goto free_dirent;
} }
/* FileIdBothDirectoryInformation is apparently unsupported on XP /* FileIdBothDirectoryInformation is apparently unsupported on XP
when accessing directories on UDF. When trying to use it so, when accessing directories on UDF. When trying to use it so,
NtQueryDirectoryFile returns with STATUS_ACCESS_VIOLATION. It's NtQueryDirectoryFile returns with STATUS_ACCESS_VIOLATION. It's
@ -1669,7 +1681,7 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
FALSE, NULL, dir->__d_position == 0); FALSE, NULL, dir->__d_position == 0);
} }
if (!status) if (NT_SUCCESS (status))
{ {
buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir) + d_cachepos (dir)); buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir) + d_cachepos (dir));
if (buf->NextEntryOffset == 0) if (buf->NextEntryOffset == 0)