Commit 716878c5 authored by Alexandre Julliard's avatar Alexandre Julliard

Fixed a number of NT status values to be closer to NT behavior.

parent 46b1d49a
...@@ -1129,7 +1129,7 @@ static int fork_and_exec( const char *filename, const WCHAR *cmdline, ...@@ -1129,7 +1129,7 @@ static int fork_and_exec( const char *filename, const WCHAR *cmdline,
if (pipe(fd) == -1) if (pipe(fd) == -1)
{ {
FILE_SetDosError(); SetLastError( ERROR_TOO_MANY_OPEN_FILES );
return -1; return -1;
} }
fcntl( fd[1], F_SETFD, 1 ); /* set close on exec */ fcntl( fd[1], F_SETFD, 1 ); /* set close on exec */
...@@ -1247,14 +1247,14 @@ static BOOL create_process( HANDLE hFile, LPCWSTR filename, LPWSTR cmd_line, LPW ...@@ -1247,14 +1247,14 @@ static BOOL create_process( HANDLE hFile, LPCWSTR filename, LPWSTR cmd_line, LPW
if (pipe( startfd ) == -1) if (pipe( startfd ) == -1)
{ {
FILE_SetDosError(); SetLastError( ERROR_TOO_MANY_OPEN_FILES );
RtlDestroyProcessParameters( params ); RtlDestroyProcessParameters( params );
if (extra_env) HeapFree( GetProcessHeap(), 0, extra_env ); if (extra_env) HeapFree( GetProcessHeap(), 0, extra_env );
return FALSE; return FALSE;
} }
if (pipe( execfd ) == -1) if (pipe( execfd ) == -1)
{ {
FILE_SetDosError(); SetLastError( ERROR_TOO_MANY_OPEN_FILES );
close( startfd[0] ); close( startfd[0] );
close( startfd[1] ); close( startfd[1] );
RtlDestroyProcessParameters( params ); RtlDestroyProcessParameters( params );
......
...@@ -711,7 +711,11 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i ...@@ -711,7 +711,11 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
} }
#endif /* VFAT_IOCTL_READDIR_BOTH */ #endif /* VFAT_IOCTL_READDIR_BOTH */
if (!(dir = opendir( unix_name ))) return FILE_GetNtStatus(); if (!(dir = opendir( unix_name )))
{
if (errno == ENOENT) return STATUS_OBJECT_PATH_NOT_FOUND;
else return FILE_GetNtStatus();
}
unix_name[pos - 1] = '/'; unix_name[pos - 1] = '/';
str.Buffer = buffer; str.Buffer = buffer;
str.MaximumLength = sizeof(buffer); str.MaximumLength = sizeof(buffer);
...@@ -756,7 +760,7 @@ not_found: ...@@ -756,7 +760,7 @@ not_found:
} }
} }
unix_name[pos - 1] = 0; unix_name[pos - 1] = 0;
return is_last ? STATUS_NO_SUCH_FILE : STATUS_OBJECT_PATH_NOT_FOUND; return is_last ? STATUS_OBJECT_NAME_NOT_FOUND : STATUS_OBJECT_PATH_NOT_FOUND;
} }
...@@ -789,9 +793,9 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret ...@@ -789,9 +793,9 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret
static const WCHAR uncW[] = {'U','N','C','\\'}; static const WCHAR uncW[] = {'U','N','C','\\'};
static const WCHAR invalid_charsW[] = { INVALID_NT_CHARS, 0 }; static const WCHAR invalid_charsW[] = { INVALID_NT_CHARS, 0 };
NTSTATUS status = STATUS_NO_SUCH_FILE; NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND;
const char *config_dir = wine_get_config_dir(); const char *config_dir = wine_get_config_dir();
const WCHAR *end, *name, *p; const WCHAR *name, *p;
struct stat st; struct stat st;
char *unix_name; char *unix_name;
int pos, ret, name_len, unix_len, used_default; int pos, ret, name_len, unix_len, used_default;
...@@ -810,12 +814,12 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret ...@@ -810,12 +814,12 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret
if (name_len > 4 && !memicmpW( name, uncW, 4 )) if (name_len > 4 && !memicmpW( name, uncW, 4 ))
{ {
FIXME( "UNC name %s not supported\n", debugstr_us(nameW) ); FIXME( "UNC name %s not supported\n", debugstr_us(nameW) );
return STATUS_NO_SUCH_FILE; return STATUS_OBJECT_NAME_NOT_FOUND;
} }
/* make sure we have a drive letter */ /* make sure we have a drive letter */
if (name_len < 3 || !isalphaW(name[0]) || name[1] != ':' || !IS_SEPARATOR(name[2])) if (name_len < 3 || !isalphaW(name[0]) || name[1] != ':' || !IS_SEPARATOR(name[2]))
return STATUS_NO_SUCH_FILE; return STATUS_OBJECT_NAME_NOT_FOUND;
name += 2; /* skip drive letter */ name += 2; /* skip drive letter */
name_len -= 2; name_len -= 2;
...@@ -835,7 +839,7 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret ...@@ -835,7 +839,7 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret
} }
else /* no DOS prefix, assume NT native name, map directly to Unix */ else /* no DOS prefix, assume NT native name, map directly to Unix */
{ {
if (!name_len || !IS_SEPARATOR(name[0])) return STATUS_NO_SUCH_FILE; if (!name_len || !IS_SEPARATOR(name[0])) return STATUS_OBJECT_NAME_INVALID;
unix_len = ntdll_wcstoumbs( 0, name, name_len, NULL, 0, NULL, NULL ); unix_len = ntdll_wcstoumbs( 0, name, name_len, NULL, 0, NULL, NULL );
unix_len += MAX_DIR_ENTRY_LEN + 3; unix_len += MAX_DIR_ENTRY_LEN + 3;
if (!(unix_name = RtlAllocateHeap( GetProcessHeap(), 0, unix_len ))) if (!(unix_name = RtlAllocateHeap( GetProcessHeap(), 0, unix_len )))
...@@ -854,25 +858,33 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret ...@@ -854,25 +858,33 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret
for (p = unix_name + pos ; *p; p++) if (*p == '\\') *p = '/'; for (p = unix_name + pos ; *p; p++) if (*p == '\\') *p = '/';
if (!stat( unix_name, &st )) goto done; if (!stat( unix_name, &st )) goto done;
} }
while (name_len && IS_SEPARATOR(*name))
{
name++;
name_len--;
}
if (!name_len) /* empty name -> drive root doesn't exist */
{
RtlFreeHeap( GetProcessHeap(), 0, unix_name );
return STATUS_OBJECT_PATH_NOT_FOUND;
}
if (check_case && check_last) if (check_case && check_last)
{ {
RtlFreeHeap( GetProcessHeap(), 0, unix_name ); RtlFreeHeap( GetProcessHeap(), 0, unix_name );
return STATUS_NO_SUCH_FILE; return STATUS_OBJECT_NAME_NOT_FOUND;
} }
/* now do it component by component */ /* now do it component by component */
for (;;) while (name_len)
{
while (name_len && IS_SEPARATOR(*name))
{ {
name++; const WCHAR *end, *next;
name_len--;
}
if (!name_len) break;
end = name; end = name;
while (end < name + name_len && !IS_SEPARATOR(*end)) end++; while (end < name + name_len && !IS_SEPARATOR(*end)) end++;
next = end;
while (next < name + name_len && IS_SEPARATOR(*next)) next++;
/* grow the buffer if needed */ /* grow the buffer if needed */
...@@ -889,7 +901,7 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret ...@@ -889,7 +901,7 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret
} }
status = find_file_in_dir( unix_name, pos, name, end - name, status = find_file_in_dir( unix_name, pos, name, end - name,
(end - name == name_len), check_last, check_case ); (next - name == name_len), check_last, check_case );
if (status != STATUS_SUCCESS) if (status != STATUS_SUCCESS)
{ {
/* couldn't find it at all, fail */ /* couldn't find it at all, fail */
...@@ -899,8 +911,8 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret ...@@ -899,8 +911,8 @@ NTSTATUS DIR_nt_to_unix( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret
} }
pos += strlen( unix_name + pos ); pos += strlen( unix_name + pos );
name_len -= end - name; name_len -= next - name;
name = end; name = next;
} }
WARN( "%s -> %s required a case-insensitive search\n", WARN( "%s -> %s required a case-insensitive search\n",
......
...@@ -222,33 +222,32 @@ static void fileio_async_cleanup( struct async_private *ovp ) ...@@ -222,33 +222,32 @@ static void fileio_async_cleanup( struct async_private *ovp )
NTSTATUS FILE_GetNtStatus(void) NTSTATUS FILE_GetNtStatus(void)
{ {
int err = errno; int err = errno;
DWORD nt;
TRACE( "errno = %d\n", errno ); TRACE( "errno = %d\n", errno );
switch (err) switch (err)
{ {
case EAGAIN: nt = STATUS_SHARING_VIOLATION; break; case EAGAIN: return STATUS_SHARING_VIOLATION;
case EBADF: nt = STATUS_INVALID_HANDLE; break; case EBADF: return STATUS_INVALID_HANDLE;
case ENOSPC: nt = STATUS_DISK_FULL; break; case ENOSPC: return STATUS_DISK_FULL;
case EPERM: case EPERM:
case EROFS: case EROFS:
case EACCES: nt = STATUS_ACCESS_DENIED; break; case EACCES: return STATUS_ACCESS_DENIED;
case ENOENT: nt = STATUS_OBJECT_NAME_NOT_FOUND; break; case ENOTDIR: return STATUS_OBJECT_PATH_NOT_FOUND;
case EISDIR: nt = STATUS_FILE_IS_A_DIRECTORY; break; case ENOENT: return STATUS_OBJECT_NAME_NOT_FOUND;
case EISDIR: return STATUS_FILE_IS_A_DIRECTORY;
case EMFILE: case EMFILE:
case ENFILE: nt = STATUS_NO_MORE_FILES; break; case ENFILE: return STATUS_TOO_MANY_OPENED_FILES;
case EINVAL: case EINVAL: return STATUS_INVALID_PARAMETER;
case ENOTEMPTY: nt = STATUS_DIRECTORY_NOT_EMPTY; break; case ENOTEMPTY: return STATUS_DIRECTORY_NOT_EMPTY;
case EPIPE: nt = STATUS_PIPE_BROKEN; break; case EPIPE: return STATUS_PIPE_BROKEN;
case EIO: nt = STATUS_DEVICE_NOT_READY; break; case EIO: return STATUS_DEVICE_NOT_READY;
case ENOEXEC: /* ?? */ case ENOEXEC: /* ?? */
case ESPIPE: /* ?? */ case ESPIPE: /* ?? */
case EEXIST: /* ?? */ case EEXIST: /* ?? */
default: default:
FIXME( "Converting errno %d to STATUS_UNSUCCESSFUL\n", err ); FIXME( "Converting errno %d to STATUS_UNSUCCESSFUL\n", err );
nt = STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
return nt;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -353,7 +353,7 @@ void file_set_error(void) ...@@ -353,7 +353,7 @@ void file_set_error(void)
case EROFS: set_error( STATUS_MEDIA_WRITE_PROTECTED ); break; case EROFS: set_error( STATUS_MEDIA_WRITE_PROTECTED ); break;
case EBUSY: set_error( STATUS_FILE_LOCK_CONFLICT ); break; case EBUSY: set_error( STATUS_FILE_LOCK_CONFLICT ); break;
case ENOENT: set_error( STATUS_NO_SUCH_FILE ); break; case ENOENT: set_error( STATUS_NO_SUCH_FILE ); break;
case EISDIR: set_win32_error( ERROR_CANNOT_MAKE ); break; case EISDIR: set_error( STATUS_FILE_IS_A_DIRECTORY ); break;
case ENFILE: case ENFILE:
case EMFILE: set_error( STATUS_NO_MORE_FILES ); break; case EMFILE: set_error( STATUS_NO_MORE_FILES ); break;
case EEXIST: set_error( STATUS_OBJECT_NAME_COLLISION ); break; case EEXIST: set_error( STATUS_OBJECT_NAME_COLLISION ); break;
......
...@@ -3115,7 +3115,6 @@ static const char *get_status_name( unsigned int status ) ...@@ -3115,7 +3115,6 @@ static const char *get_status_name( unsigned int status )
NAME(TIMEOUT), NAME(TIMEOUT),
NAME(USER_APC), NAME(USER_APC),
NAME(WAS_LOCKED), NAME(WAS_LOCKED),
NAME_WIN32(ERROR_CANNOT_MAKE),
NAME_WIN32(ERROR_INVALID_INDEX), NAME_WIN32(ERROR_INVALID_INDEX),
NAME_WIN32(ERROR_NEGATIVE_SEEK), NAME_WIN32(ERROR_NEGATIVE_SEEK),
NAME_WIN32(ERROR_SEEK), NAME_WIN32(ERROR_SEEK),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment