Alexandre Julliard : ntdll: Map errno to a status also in directory functions.
Alexandre Julliard
julliard at winehq.org
Tue Jul 21 15:40:21 CDT 2020
Module: wine
Branch: master
Commit: 688799b1f7b2750b938f8da771480d2c16d1ae1d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=688799b1f7b2750b938f8da771480d2c16d1ae1d
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Jul 21 18:18:17 2020 +0200
ntdll: Map errno to a status also in directory functions.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49523
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/tests/file.c | 25 +++++++++++++++++++++++++
dlls/ntdll/unix/file.c | 13 +++++--------
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 6164b0c4bd..2fa12410c9 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -401,6 +401,31 @@ static void open_file_test(void)
CloseHandle( handle );
CloseHandle( dir );
+ attr.RootDirectory = 0;
+ wcscat( path, L"\\cmd.exe" );
+ pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
+ status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_DIRECTORY_FILE );
+ ok( status == STATUS_NOT_A_DIRECTORY, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+ CloseHandle( handle );
+ status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_NON_DIRECTORY_FILE );
+ ok( !status, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+ CloseHandle( handle );
+ pRtlFreeUnicodeString( &nameW );
+
+ wcscat( path, L"\\cmd.exe" );
+ pRtlDosPathNameToNtPathName_U( path, &nameW, NULL, NULL );
+ status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_DIRECTORY_FILE );
+ todo_wine
+ ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+ status = pNtOpenFile( &handle, GENERIC_READ, &attr, &io,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_NON_DIRECTORY_FILE );
+ todo_wine
+ ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "open %s failed %x\n", wine_dbgstr_w(nameW.Buffer), status );
+ pRtlFreeUnicodeString( &nameW );
+
GetTempPathW( MAX_PATH, path );
lstrcatW( path, testdirW );
CreateDirectoryW( path, NULL );
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 20eb6a0592..8356e08289 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -2454,7 +2454,7 @@ NTSTATUS WINAPI NtQueryDirectoryFile( HANDLE handle, HANDLE event, PIO_APC_ROUTI
}
if (cwd == -1 || fchdir( cwd ) == -1) chdir( "/" );
}
- else status = STATUS_ACCESS_DENIED;
+ else status = errno_to_status( errno );
pthread_mutex_unlock( &dir_mutex );
@@ -2557,11 +2557,8 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
}
#endif /* VFAT_IOCTL_READDIR_BOTH */
- if (!(dir = opendir( unix_name )))
- {
- if (errno == ENOENT) return STATUS_OBJECT_PATH_NOT_FOUND;
- else return STATUS_ACCESS_DENIED;
- }
+ if (!(dir = opendir( unix_name ))) return errno_to_status( errno );
+
unix_name[pos - 1] = '/';
while ((de = readdir( dir )))
{
@@ -3038,7 +3035,7 @@ static NTSTATUS file_id_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, char *
}
if (fchdir( old_cwd ) == -1) chdir( "/" );
}
- else status = STATUS_ACCESS_DENIED;
+ else status = errno_to_status( errno );
pthread_mutex_unlock( &dir_mutex );
if (old_cwd != -1) close( old_cwd );
@@ -3217,7 +3214,7 @@ static NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, char *
disposition, FALSE );
if (fchdir( old_cwd ) == -1) chdir( "/" );
}
- else status = STATUS_ACCESS_DENIED;
+ else status = errno_to_status( errno );
pthread_mutex_unlock( &dir_mutex );
if (old_cwd != -1) close( old_cwd );
if (needs_close) close( root_fd );
More information about the wine-cvs
mailing list