Commit e0fca945 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move the directory functions to the Unix library.

parent 573be7e6
...@@ -52,6 +52,7 @@ C_SRCS = \ ...@@ -52,6 +52,7 @@ C_SRCS = \
time.c \ time.c \
unix/debug.c \ unix/debug.c \
unix/env.c \ unix/env.c \
unix/file.c \
unix/loader.c \ unix/loader.c \
unix/process.c \ unix/process.c \
unix/server.c \ unix/server.c \
......
...@@ -215,9 +215,9 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT ...@@ -215,9 +215,9 @@ static NTSTATUS FILE_CreateFile( PHANDLE handle, ACCESS_MASK access, POBJECT_ATT
if (alloc_size) FIXME( "alloc_size not supported\n" ); if (alloc_size) FIXME( "alloc_size not supported\n" );
if (options & FILE_OPEN_BY_FILE_ID) if (options & FILE_OPEN_BY_FILE_ID)
io->u.Status = file_id_to_unix_file_name( attr, &unix_name ); io->u.Status = unix_funcs->file_id_to_unix_file_name( attr, &unix_name );
else else
io->u.Status = nt_to_unix_file_name_attr( attr, &unix_name, disposition ); io->u.Status = unix_funcs->nt_to_unix_file_name_attr( attr, &unix_name, disposition );
if (io->u.Status == STATUS_BAD_DEVICE_TYPE) if (io->u.Status == STATUS_BAD_DEVICE_TYPE)
{ {
...@@ -1704,7 +1704,7 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc ...@@ -1704,7 +1704,7 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
case FSCTL_DISMOUNT_VOLUME: case FSCTL_DISMOUNT_VOLUME:
status = server_ioctl_file( handle, event, apc, apc_context, io, code, status = server_ioctl_file( handle, event, apc, apc_context, io, code,
in_buffer, in_size, out_buffer, out_size ); in_buffer, in_size, out_buffer, out_size );
if (!status) status = DIR_unmount_device( handle ); if (!status) status = unix_funcs->unmount_device( handle );
return status; return status;
case FSCTL_PIPE_IMPERSONATE: case FSCTL_PIPE_IMPERSONATE:
...@@ -2929,7 +2929,7 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -2929,7 +2929,7 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
attr.RootDirectory = info->RootDirectory; attr.RootDirectory = info->RootDirectory;
attr.Attributes = OBJ_CASE_INSENSITIVE; attr.Attributes = OBJ_CASE_INSENSITIVE;
io->u.Status = nt_to_unix_file_name_attr( &attr, &unix_name, FILE_OPEN_IF ); io->u.Status = unix_funcs->nt_to_unix_file_name_attr( &attr, &unix_name, FILE_OPEN_IF );
if (io->u.Status != STATUS_SUCCESS && io->u.Status != STATUS_NO_SUCH_FILE) if (io->u.Status != STATUS_SUCCESS && io->u.Status != STATUS_NO_SUCH_FILE)
break; break;
...@@ -2966,7 +2966,7 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io, ...@@ -2966,7 +2966,7 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
attr.RootDirectory = info->RootDirectory; attr.RootDirectory = info->RootDirectory;
attr.Attributes = OBJ_CASE_INSENSITIVE; attr.Attributes = OBJ_CASE_INSENSITIVE;
io->u.Status = nt_to_unix_file_name_attr( &attr, &unix_name, FILE_OPEN_IF ); io->u.Status = unix_funcs->nt_to_unix_file_name_attr( &attr, &unix_name, FILE_OPEN_IF );
if (io->u.Status != STATUS_SUCCESS && io->u.Status != STATUS_NO_SUCH_FILE) if (io->u.Status != STATUS_SUCCESS && io->u.Status != STATUS_NO_SUCH_FILE)
break; break;
...@@ -3005,7 +3005,7 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr, ...@@ -3005,7 +3005,7 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
ANSI_STRING unix_name; ANSI_STRING unix_name;
NTSTATUS status; NTSTATUS status;
if (!(status = nt_to_unix_file_name_attr( attr, &unix_name, FILE_OPEN ))) if (!(status = unix_funcs->nt_to_unix_file_name_attr( attr, &unix_name, FILE_OPEN )))
{ {
ULONG attributes; ULONG attributes;
struct stat st; struct stat st;
...@@ -3048,7 +3048,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC ...@@ -3048,7 +3048,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
ANSI_STRING unix_name; ANSI_STRING unix_name;
NTSTATUS status; NTSTATUS status;
if (!(status = nt_to_unix_file_name_attr( attr, &unix_name, FILE_OPEN ))) if (!(status = unix_funcs->nt_to_unix_file_name_attr( attr, &unix_name, FILE_OPEN )))
{ {
ULONG attributes; ULONG attributes;
struct stat st; struct stat st;
......
...@@ -147,12 +147,8 @@ extern NTSTATUS fill_file_info( const struct stat *st, ULONG attr, void *ptr, ...@@ -147,12 +147,8 @@ extern NTSTATUS fill_file_info( const struct stat *st, ULONG attr, void *ptr,
extern NTSTATUS server_get_unix_name( HANDLE handle, ANSI_STRING *unix_name ) DECLSPEC_HIDDEN; extern NTSTATUS server_get_unix_name( HANDLE handle, ANSI_STRING *unix_name ) DECLSPEC_HIDDEN;
extern void init_directories(void) DECLSPEC_HIDDEN; extern void init_directories(void) DECLSPEC_HIDDEN;
extern BOOL DIR_is_hidden_file( const UNICODE_STRING *name ) DECLSPEC_HIDDEN; extern BOOL DIR_is_hidden_file( const UNICODE_STRING *name ) DECLSPEC_HIDDEN;
extern NTSTATUS DIR_unmount_device( HANDLE handle ) DECLSPEC_HIDDEN;
extern NTSTATUS DIR_get_unix_cwd( char **cwd ) DECLSPEC_HIDDEN; extern NTSTATUS DIR_get_unix_cwd( char **cwd ) DECLSPEC_HIDDEN;
extern unsigned int DIR_get_drives_info( struct drive_info info[MAX_DOS_DRIVES] ) DECLSPEC_HIDDEN; extern unsigned int DIR_get_drives_info( struct drive_info info[MAX_DOS_DRIVES] ) DECLSPEC_HIDDEN;
extern NTSTATUS file_id_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *unix_name_ret ) DECLSPEC_HIDDEN;
extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *unix_name_ret,
UINT disposition ) DECLSPEC_HIDDEN;
/* virtual memory */ /* virtual memory */
extern void virtual_fill_image_information( const pe_image_info_t *pe_info, extern void virtual_fill_image_information( const pe_image_info_t *pe_info,
......
...@@ -450,7 +450,7 @@ static void test_NtQueryDirectoryFile(void) ...@@ -450,7 +450,7 @@ static void test_NtQueryDirectoryFile(void)
{ {
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
UNICODE_STRING ntdirname, mask; UNICODE_STRING ntdirname, mask;
char testdirA[MAX_PATH]; char testdirA[MAX_PATH], buffer[MAX_PATH];
WCHAR testdirW[MAX_PATH]; WCHAR testdirW[MAX_PATH];
int i; int i;
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
...@@ -462,7 +462,7 @@ static void test_NtQueryDirectoryFile(void) ...@@ -462,7 +462,7 @@ static void test_NtQueryDirectoryFile(void)
FILE_NAMES_INFORMATION *names; FILE_NAMES_INFORMATION *names;
const WCHAR *filename = fbdi->FileName; const WCHAR *filename = fbdi->FileName;
NTSTATUS status; NTSTATUS status;
HANDLE dirh; HANDLE dirh, h;
/* Clean up from prior aborted run, if any, then set up test files */ /* Clean up from prior aborted run, if any, then set up test files */
ok(GetTempPathA(MAX_PATH, testdirA), "couldn't get temp dir\n"); ok(GetTempPathA(MAX_PATH, testdirA), "couldn't get temp dir\n");
...@@ -728,6 +728,18 @@ static void test_NtQueryDirectoryFile(void) ...@@ -728,6 +728,18 @@ static void test_NtQueryDirectoryFile(void)
ok(status == STATUS_INVALID_HANDLE, "wrong status %x\n", status); ok(status == STATUS_INVALID_HANDLE, "wrong status %x\n", status);
ok(U(io).Status == 0xdeadbeef, "wrong status %x\n", U(io).Status); ok(U(io).Status == 0xdeadbeef, "wrong status %x\n", U(io).Status);
GetModuleFileNameA( 0, buffer, sizeof(buffer) );
h = CreateFileA( buffer, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
if (h != INVALID_HANDLE_VALUE)
{
U(io).Status = 0xdeadbeef;
status = pNtQueryDirectoryFile( h, 0, NULL, NULL, &io, data, data_size,
FileBothDirectoryInformation, TRUE, NULL, TRUE );
ok(status == STATUS_INVALID_PARAMETER, "wrong status %x\n", status);
ok(U(io).Status == 0xdeadbeef, "wrong status %x\n", U(io).Status);
CloseHandle ( h );
}
done: done:
test_directory_sort( testdirW ); test_directory_sort( testdirW );
tear_down_attribute_test( testdirW ); tear_down_attribute_test( testdirW );
......
...@@ -849,6 +849,7 @@ static struct unix_funcs unix_funcs = ...@@ -849,6 +849,7 @@ static struct unix_funcs unix_funcs =
NtOpenTimer, NtOpenTimer,
NtProtectVirtualMemory, NtProtectVirtualMemory,
NtPulseEvent, NtPulseEvent,
NtQueryDirectoryFile,
NtQueryEvent, NtQueryEvent,
NtQueryMutant, NtQueryMutant,
NtQueryPerformanceCounter, NtQueryPerformanceCounter,
...@@ -934,6 +935,11 @@ static struct unix_funcs unix_funcs = ...@@ -934,6 +935,11 @@ static struct unix_funcs unix_funcs =
server_handle_to_fd, server_handle_to_fd,
server_release_fd, server_release_fd,
server_init_process_done, server_init_process_done,
file_id_to_unix_file_name,
nt_to_unix_file_name_attr,
nt_to_unix_file_name,
unmount_device,
set_show_dot_files,
__wine_dbg_get_channel_flags, __wine_dbg_get_channel_flags,
__wine_dbg_strdup, __wine_dbg_strdup,
__wine_dbg_output, __wine_dbg_output,
...@@ -1201,6 +1207,7 @@ void __wine_main( int argc, char *argv[], char *envp[] ) ...@@ -1201,6 +1207,7 @@ void __wine_main( int argc, char *argv[], char *envp[] )
fixup_ntdll_imports( &__wine_spec_nt_header, module ); fixup_ntdll_imports( &__wine_spec_nt_header, module );
init_environment( argc, argv, envp ); init_environment( argc, argv, envp );
init_files();
#ifdef __APPLE__ #ifdef __APPLE__
apple_main_thread(); apple_main_thread();
...@@ -1235,6 +1242,7 @@ NTSTATUS __cdecl __wine_init_unix_lib( HMODULE module, const void *ptr_in, void ...@@ -1235,6 +1242,7 @@ NTSTATUS __cdecl __wine_init_unix_lib( HMODULE module, const void *ptr_in, void
map_so_dll( nt, module ); map_so_dll( nt, module );
fixup_ntdll_imports( &__wine_spec_nt_header, module ); fixup_ntdll_imports( &__wine_spec_nt_header, module );
init_environment( __wine_main_argc, __wine_main_argv, envp ); init_environment( __wine_main_argc, __wine_main_argv, envp );
init_files();
*(struct unix_funcs **)ptr_out = &unix_funcs; *(struct unix_funcs **)ptr_out = &unix_funcs;
wine_mmap_enum_reserved_areas( add_area, NULL, 0 ); wine_mmap_enum_reserved_areas( add_area, NULL, 0 );
return STATUS_SUCCESS; return STATUS_SUCCESS;
......
...@@ -74,10 +74,6 @@ ...@@ -74,10 +74,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(sync); WINE_DEFAULT_DEBUG_CHANNEL(sync);
#define TICKSPERSEC 10000000
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)86400)
#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
HANDLE keyed_event = 0; HANDLE keyed_event = 0;
static const LARGE_INTEGER zero_timeout; static const LARGE_INTEGER zero_timeout;
......
...@@ -120,6 +120,14 @@ extern NTSTATUS CDECL exec_process( const UNICODE_STRING *cmdline, const pe_imag ...@@ -120,6 +120,14 @@ extern NTSTATUS CDECL exec_process( const UNICODE_STRING *cmdline, const pe_imag
extern NTSTATUS CDECL fork_and_exec( const char *unix_name, const char *unix_dir, extern NTSTATUS CDECL fork_and_exec( const char *unix_name, const char *unix_dir,
const RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HIDDEN; const RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL file_id_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *unix_name ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *unix_name_ret,
UINT disposition ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
UINT disposition, BOOLEAN check_case ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL unmount_device( HANDLE handle ) DECLSPEC_HIDDEN;
extern void CDECL set_show_dot_files( BOOL enable ) DECLSPEC_HIDDEN;
extern const char *data_dir DECLSPEC_HIDDEN; extern const char *data_dir DECLSPEC_HIDDEN;
extern const char *build_dir DECLSPEC_HIDDEN; extern const char *build_dir DECLSPEC_HIDDEN;
extern const char *config_dir DECLSPEC_HIDDEN; extern const char *config_dir DECLSPEC_HIDDEN;
...@@ -186,8 +194,20 @@ extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE ent ...@@ -186,8 +194,20 @@ extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE ent
BOOL suspend, void *relay, TEB *teb ) DECLSPEC_HIDDEN; BOOL suspend, void *relay, TEB *teb ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN;
extern void init_files(void) DECLSPEC_HIDDEN;
extern void dbg_init(void) DECLSPEC_HIDDEN; extern void dbg_init(void) DECLSPEC_HIDDEN;
#define TICKSPERSEC 10000000
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)86400)
#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
static inline const char *debugstr_us( const UNICODE_STRING *us )
{
if (!us) return "<null>";
return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) );
}
static inline size_t ntdll_wcslen( const WCHAR *str ) static inline size_t ntdll_wcslen( const WCHAR *str )
{ {
const WCHAR *s = str; const WCHAR *s = str;
......
...@@ -3069,6 +3069,50 @@ BOOL CDECL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) ...@@ -3069,6 +3069,50 @@ BOOL CDECL virtual_check_buffer_for_write( void *ptr, SIZE_T size )
} }
/*************************************************************
* IsBadStringPtrA
*
* IsBadStringPtrA replacement for ntdll, to catch exception in debug traces.
*/
BOOL WINAPI IsBadStringPtrA( LPCSTR str, UINT_PTR max )
{
if (!str) return TRUE;
__TRY
{
volatile const char *p = str;
while (p != str + max) if (!*p++) break;
}
__EXCEPT_PAGE_FAULT
{
return TRUE;
}
__ENDTRY
return FALSE;
}
/*************************************************************
* IsBadStringPtrW
*
* IsBadStringPtrW replacement for ntdll, to catch exception in debug traces.
*/
BOOL WINAPI IsBadStringPtrW( LPCWSTR str, UINT_PTR max )
{
if (!str) return TRUE;
__TRY
{
volatile const WCHAR *p = str;
while (p != str + max) if (!*p++) break;
}
__EXCEPT_PAGE_FAULT
{
return TRUE;
}
__ENDTRY
return FALSE;
}
/*********************************************************************** /***********************************************************************
* virtual_uninterrupted_read_memory * virtual_uninterrupted_read_memory
* *
......
...@@ -28,7 +28,7 @@ struct ldt_copy; ...@@ -28,7 +28,7 @@ struct ldt_copy;
struct msghdr; struct msghdr;
/* increment this when you change the function table */ /* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 41 #define NTDLL_UNIXLIB_VERSION 42
struct unix_funcs struct unix_funcs
{ {
...@@ -92,6 +92,11 @@ struct unix_funcs ...@@ -92,6 +92,11 @@ struct unix_funcs
NTSTATUS (WINAPI *NtProtectVirtualMemory)( HANDLE process, PVOID *addr_ptr, SIZE_T *size_ptr, NTSTATUS (WINAPI *NtProtectVirtualMemory)( HANDLE process, PVOID *addr_ptr, SIZE_T *size_ptr,
ULONG new_prot, ULONG *old_prot ); ULONG new_prot, ULONG *old_prot );
NTSTATUS (WINAPI *NtPulseEvent)( HANDLE handle, LONG *prev_state ); NTSTATUS (WINAPI *NtPulseEvent)( HANDLE handle, LONG *prev_state );
NTSTATUS (WINAPI *NtQueryDirectoryFile)( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc_routine,
void *apc_context, IO_STATUS_BLOCK *io, void *buffer,
ULONG length, FILE_INFORMATION_CLASS info_class,
BOOLEAN single_entry, UNICODE_STRING *mask,
BOOLEAN restart_scan );
NTSTATUS (WINAPI *NtQueryEvent)( HANDLE handle, EVENT_INFORMATION_CLASS class, NTSTATUS (WINAPI *NtQueryEvent)( HANDLE handle, EVENT_INFORMATION_CLASS class,
void *info, ULONG len, ULONG *ret_len ); void *info, ULONG len, ULONG *ret_len );
NTSTATUS (WINAPI *NtQueryMutant)( HANDLE handle, MUTANT_INFORMATION_CLASS class, NTSTATUS (WINAPI *NtQueryMutant)( HANDLE handle, MUTANT_INFORMATION_CLASS class,
...@@ -223,6 +228,16 @@ struct unix_funcs ...@@ -223,6 +228,16 @@ struct unix_funcs
void (CDECL *server_release_fd)( HANDLE handle, int unix_fd ); void (CDECL *server_release_fd)( HANDLE handle, int unix_fd );
void (CDECL *server_init_process_done)( void *relay ); void (CDECL *server_init_process_done)( void *relay );
/* file functions */
NTSTATUS (CDECL *file_id_to_unix_file_name)( const OBJECT_ATTRIBUTES *attr,
ANSI_STRING *unix_name );
NTSTATUS (CDECL *nt_to_unix_file_name_attr)( const OBJECT_ATTRIBUTES *attr,
ANSI_STRING *unix_name_ret, UINT disposition );
NTSTATUS (CDECL *nt_to_unix_file_name)( const UNICODE_STRING *nameW, ANSI_STRING *unix_name_ret,
UINT disposition, BOOLEAN check_case );
NTSTATUS (CDECL *unmount_device)( HANDLE handle );
void (CDECL *set_show_dot_files)( BOOL enable );
/* debugging functions */ /* debugging functions */
unsigned char (CDECL *dbg_get_channel_flags)( struct __wine_debug_channel *channel ); unsigned char (CDECL *dbg_get_channel_flags)( struct __wine_debug_channel *channel );
const char * (CDECL *dbg_strdup)( const char *str ); const char * (CDECL *dbg_strdup)( const char *str );
......
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