diff --git a/files/dos_fs.c b/files/dos_fs.c index c30347232c6..c79133a734a 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -766,7 +766,7 @@ HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSEC if (!strcmp(DOSFS_Devices[i].name,"NUL")) return FILE_CreateFile( "/dev/null", access, FILE_SHARE_READ|FILE_SHARE_WRITE, sa, - OPEN_EXISTING, 0, 0, TRUE ); + OPEN_EXISTING, 0, 0, TRUE, DRIVE_UNKNOWN ); if (!strcmp(DOSFS_Devices[i].name,"CON")) { HANDLE to_dup; switch (access & (GENERIC_READ|GENERIC_WRITE)) { diff --git a/files/file.c b/files/file.c index ec3363732f5..b9e3fb00d6d 100644 --- a/files/file.c +++ b/files/file.c @@ -281,7 +281,8 @@ static HANDLE FILE_OpenConsole( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES */ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing, LPSECURITY_ATTRIBUTES sa, DWORD creation, - DWORD attributes, HANDLE template, BOOL fail_read_only ) + DWORD attributes, HANDLE template, BOOL fail_read_only, + UINT drive_type ) { DWORD err; HANDLE ret; @@ -297,11 +298,12 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing, restart: SERVER_START_VAR_REQ( create_file, len ) { - req->access = access; - req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); - req->sharing = sharing; - req->create = creation; - req->attrs = attributes; + req->access = access; + req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); + req->sharing = sharing; + req->create = creation; + req->attrs = attributes; + req->drive_type = drive_type; memcpy( server_data_ptr(req), filename, len ); SetLastError(0); err = SERVER_CALL(); @@ -509,7 +511,8 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing, ret = FILE_CreateFile( full_name.long_name, access, sharing, sa, creation, attributes, template, - DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY ); + DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY, + GetDriveTypeA( full_name.short_name ) ); done: if (!ret) ret = INVALID_HANDLE_VALUE; return ret; @@ -977,7 +980,8 @@ found: hFileRet = FILE_CreateFile( full_name.long_name, access, sharing, NULL, OPEN_EXISTING, 0, 0, - DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY ); + DRIVE_GetFlags(full_name.drive) & DRIVE_FAIL_READ_ONLY, + GetDriveTypeA( full_name.short_name ) ); if (!hFileRet) goto not_found; GetFileTime( hFileRet, NULL, NULL, &filetime ); diff --git a/include/file.h b/include/file.h index 5613351d2f5..260f8dd113a 100644 --- a/include/file.h +++ b/include/file.h @@ -77,7 +77,8 @@ extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info ); extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 ); extern HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing, LPSECURITY_ATTRIBUTES sa, DWORD creation, - DWORD attributes, HANDLE template, BOOL fail_read_only ); + DWORD attributes, HANDLE template, BOOL fail_read_only, + UINT drive_type ); extern HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa ); extern LONG WINAPI WIN16_hread(HFILE16,SEGPTR,LONG); diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 375667c1980..fe437e90682 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -566,6 +566,7 @@ struct create_file_request unsigned int sharing; int create; unsigned int attrs; + int drive_type; /* VARARG(filename,string); */ handle_t handle; }; @@ -907,6 +908,7 @@ struct get_mapping_info_request void* base; handle_t shared_file; int shared_size; + int drive_type; }; @@ -2054,6 +2056,6 @@ union generic_request struct get_window_properties_request get_window_properties; }; -#define SERVER_PROTOCOL_VERSION 61 +#define SERVER_PROTOCOL_VERSION 62 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/misc/registry.c b/misc/registry.c index d24dcb0a8d7..818cd6567f8 100644 --- a/misc/registry.c +++ b/misc/registry.c @@ -1184,7 +1184,7 @@ static void load_wine_registry(HKEY hkey,LPCSTR fn) case WINE_REG_VER_2: { HANDLE file; if ((file = FILE_CreateFile( fn, GENERIC_READ, 0, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, 0, TRUE ))) + FILE_ATTRIBUTE_NORMAL, 0, TRUE, DRIVE_UNKNOWN ))) { SERVER_START_REQ( load_registry ) { diff --git a/server/file.c b/server/file.c index a9725766cf7..4ed9eac4c3d 100644 --- a/server/file.c +++ b/server/file.c @@ -38,6 +38,7 @@ struct file unsigned int access; /* file access (GENERIC_READ/WRITE) */ unsigned int flags; /* flags (FILE_FLAG_*) */ unsigned int sharing; /* file sharing mode */ + int drive_type; /* type of drive the file is on */ }; #define NAME_HASH_SIZE 37 @@ -103,23 +104,25 @@ static int check_sharing( const char *name, int hash, unsigned int access, /* create a file from a file descriptor */ /* if the function fails the fd is closed */ static struct file *create_file_for_fd( int fd, unsigned int access, unsigned int sharing, - unsigned int attrs ) + unsigned int attrs, int drive_type ) { struct file *file; if ((file = alloc_object( &file_ops, fd ))) { - file->name = NULL; - file->next = NULL; - file->access = access; - file->flags = attrs; - file->sharing = sharing; + file->name = NULL; + file->next = NULL; + file->access = access; + file->flags = attrs; + file->sharing = sharing; + file->drive_type = drive_type; } return file; } static struct file *create_file( const char *nameptr, size_t len, unsigned int access, - unsigned int sharing, int create, unsigned int attrs ) + unsigned int sharing, int create, unsigned int attrs, + int drive_type ) { struct file *file; int hash, flags; @@ -169,7 +172,7 @@ static struct file *create_file( const char *nameptr, size_t len, unsigned int a goto error; } - if (!(file = create_file_for_fd( fd, access, sharing, attrs ))) + if (!(file = create_file_for_fd( fd, access, sharing, attrs, drive_type ))) { free( name ); return NULL; @@ -193,6 +196,12 @@ int is_same_file( struct file *file1, struct file *file2 ) return !strcmp( file1->name, file2->name ); } +/* get the type of drive the file is on */ +int get_file_drive_type( struct file *file ) +{ + return file->drive_type; +} + /* Create an anonymous Unix file */ int create_anonymous_file(void) { @@ -223,7 +232,7 @@ struct file *create_temp_file( int access ) int fd; if ((fd = create_anonymous_file()) == -1) return NULL; - return create_file_for_fd( fd, access, 0, 0 ); + return create_file_for_fd( fd, access, 0, 0, DRIVE_FIXED ); } static void file_dump( struct object *obj, int verbose ) @@ -463,7 +472,7 @@ DECL_HANDLER(create_file) req->handle = 0; if ((file = create_file( get_req_data(req), get_req_data_size(req), req->access, - req->sharing, req->create, req->attrs ))) + req->sharing, req->create, req->attrs, req->drive_type ))) { req->handle = alloc_handle( current->process, file, req->access, req->inherit ); release_object( file ); @@ -482,7 +491,8 @@ DECL_HANDLER(alloc_file_handle) set_error( STATUS_INVALID_HANDLE ); return; } - if ((file = create_file_for_fd( fd, req->access, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 ))) + if ((file = create_file_for_fd( fd, req->access, FILE_SHARE_READ | FILE_SHARE_WRITE, + 0, DRIVE_UNKNOWN ))) { req->handle = alloc_handle( current->process, file, req->access, 0 ); release_object( file ); diff --git a/server/mapping.c b/server/mapping.c index f4049f00300..fd8194a64bc 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -380,6 +380,7 @@ DECL_HANDLER(get_mapping_info) req->base = mapping->base; req->shared_file = 0; req->shared_size = mapping->shared_size; + req->drive_type = get_file_drive_type( mapping->file ); if (mapping->shared_file) req->shared_file = alloc_handle( current->process, mapping->shared_file, GENERIC_READ|GENERIC_WRITE, 0 ); diff --git a/server/object.h b/server/object.h index 84557208745..32fa3461595 100644 --- a/server/object.h +++ b/server/object.h @@ -145,6 +145,7 @@ extern void abandon_mutexes( struct thread *thread ); extern struct file *get_file_obj( struct process *process, handle_t handle, unsigned int access ); extern int is_same_file( struct file *file1, struct file *file2 ); +extern int get_file_drive_type( struct file *file ); extern int grow_file( struct file *file, int size_high, int size_low ); extern int create_anonymous_file(void); extern struct file *create_temp_file( int access ); diff --git a/server/protocol.def b/server/protocol.def index be779ea8e99..07c7f79fc09 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -523,6 +523,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT }; unsigned int sharing; /* sharing flags */ int create; /* file create action */ unsigned int attrs; /* file attributes for creation */ + int drive_type; /* type of drive the file is on */ VARARG(filename,string); /* file name */ @REPLY handle_t handle; /* handle to the file */ @@ -825,6 +826,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT }; void* base; /* default base addr (for VPROT_IMAGE mapping) */ handle_t shared_file; /* shared mapping file handle */ int shared_size; /* shared mapping size */ + int drive_type; /* type of drive the file is on */ @END diff --git a/server/trace.c b/server/trace.c index 7c68db26aef..ba98c0a7ed1 100644 --- a/server/trace.c +++ b/server/trace.c @@ -709,6 +709,7 @@ static void dump_create_file_request( const struct create_file_request *req ) fprintf( stderr, " sharing=%08x,", req->sharing ); fprintf( stderr, " create=%d,", req->create ); fprintf( stderr, " attrs=%08x,", req->attrs ); + fprintf( stderr, " drive_type=%d,", req->drive_type ); fprintf( stderr, " filename=" ); cur_pos += dump_varargs_string( req ); } @@ -1032,7 +1033,8 @@ static void dump_get_mapping_info_reply( const struct get_mapping_info_request * fprintf( stderr, " header_size=%d,", req->header_size ); fprintf( stderr, " base=%p,", req->base ); fprintf( stderr, " shared_file=%d,", req->shared_file ); - fprintf( stderr, " shared_size=%d", req->shared_size ); + fprintf( stderr, " shared_size=%d,", req->shared_size ); + fprintf( stderr, " drive_type=%d", req->drive_type ); } static void dump_create_device_request( const struct create_device_request *req )