server: Use the file_pos_t type for file sizes and offsets in the protocol structures.

This commit is contained in:
Alexandre Julliard 2007-10-10 14:06:25 +02:00
parent 54a471732f
commit 235532ce28
10 changed files with 67 additions and 88 deletions

View File

@ -2095,10 +2095,8 @@ NTSTATUS WINAPI NtLockFile( HANDLE hFile, HANDLE lock_granted_event,
SERVER_START_REQ( lock_file )
{
req->handle = hFile;
req->offset_low = offset->u.LowPart;
req->offset_high = offset->u.HighPart;
req->count_low = count->u.LowPart;
req->count_high = count->u.HighPart;
req->offset = offset->QuadPart;
req->count = count->QuadPart;
req->shared = !exclusive;
req->wait = !dont_wait;
ret = wine_server_call( req );
@ -2158,11 +2156,9 @@ NTSTATUS WINAPI NtUnlockFile( HANDLE hFile, PIO_STATUS_BLOCK io_status,
SERVER_START_REQ( unlock_file )
{
req->handle = hFile;
req->offset_low = offset->u.LowPart;
req->offset_high = offset->u.HighPart;
req->count_low = count->u.LowPart;
req->count_high = count->u.HighPart;
req->handle = hFile;
req->offset = offset->QuadPart;
req->count = count->QuadPart;
status = wine_server_call( req );
}
SERVER_END_REQ;

View File

@ -754,8 +754,7 @@ static BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
result->type = call->type;
result->map_view.addr = call->map_view.addr;
result->map_view.size = call->map_view.size;
offset.u.LowPart = call->map_view.offset_low;
offset.u.HighPart = call->map_view.offset_high;
offset.QuadPart = call->map_view.offset;
result->map_view.status = NtMapViewOfSection( call->map_view.handle, NtCurrentProcess(),
&result->map_view.addr, call->map_view.zero_bits,
0, &offset, &result->map_view.size, ViewShare,

View File

@ -1877,8 +1877,7 @@ NTSTATUS WINAPI NtCreateSection( HANDLE *handle, ACCESS_MASK access, const OBJEC
req->attributes = (attr) ? attr->Attributes : 0;
req->rootdir = attr ? attr->RootDirectory : 0;
req->file_handle = file;
req->size_high = size ? size->u.HighPart : 0;
req->size_low = size ? size->u.LowPart : 0;
req->size = size ? size->QuadPart : 0;
req->protect = vprot;
if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
ret = wine_server_call( req );
@ -1922,13 +1921,14 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
SECTION_INHERIT inherit, ULONG alloc_type, ULONG protect )
{
NTSTATUS res;
ULONGLONG full_size;
SIZE_T size = 0;
SIZE_T mask = get_mask( zero_bits );
int unix_handle = -1, needs_close;
int prot;
void *base;
struct file_view *view;
DWORD size_low, size_high, header_size, shared_size;
DWORD header_size;
HANDLE dup_mapping, shared_file;
LARGE_INTEGER offset;
sigset_t sigset;
@ -1952,8 +1952,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
call.map_view.handle = handle;
call.map_view.addr = *addr_ptr;
call.map_view.size = *size_ptr;
call.map_view.offset_low = offset.u.LowPart;
call.map_view.offset_high = offset.u.HighPart;
call.map_view.offset = offset.QuadPart;
call.map_view.zero_bits = zero_bits;
call.map_view.alloc_type = alloc_type;
call.map_view.prot = protect;
@ -1974,19 +1973,18 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
res = wine_server_call( req );
prot = reply->protect;
base = reply->base;
size_low = reply->size_low;
size_high = reply->size_high;
full_size = reply->size;
header_size = reply->header_size;
dup_mapping = reply->mapping;
shared_file = reply->shared_file;
shared_size = reply->shared_size;
}
SERVER_END_REQ;
if (res) return res;
size = ((ULONGLONG)size_high << 32) | size_low;
if (sizeof(size) == sizeof(size_low) && size_high)
ERR( "Sizes larger than 4Gb (%x%08x) not supported on this platform\n", size_high, size_low );
size = full_size;
if (sizeof(size) < sizeof(full_size) && (size != full_size))
ERR( "Sizes larger than 4Gb (%x%08x) not supported on this platform\n",
(DWORD)(full_size >> 32), (DWORD)full_size );
if ((res = server_get_unix_fd( handle, 0, &unix_handle, &needs_close, NULL, NULL ))) goto done;

View File

@ -22,6 +22,7 @@ typedef unsigned int process_id_t;
typedef unsigned int thread_id_t;
typedef unsigned int data_size_t;
typedef unsigned int ioctl_code_t;
typedef unsigned __int64 file_pos_t;
struct request_header
{
@ -317,8 +318,7 @@ typedef union
obj_handle_t handle;
void *addr;
unsigned long size;
unsigned int offset_low;
unsigned int offset_high;
file_pos_t offset;
unsigned int zero_bits;
unsigned int alloc_type;
unsigned int prot;
@ -1094,10 +1094,8 @@ struct lock_file_request
{
struct request_header __header;
obj_handle_t handle;
unsigned int offset_low;
unsigned int offset_high;
unsigned int count_low;
unsigned int count_high;
file_pos_t offset;
file_pos_t count;
int shared;
int wait;
};
@ -1114,10 +1112,8 @@ struct unlock_file_request
{
struct request_header __header;
obj_handle_t handle;
unsigned int offset_low;
unsigned int offset_high;
unsigned int count_low;
unsigned int count_high;
file_pos_t offset;
file_pos_t count;
};
struct unlock_file_reply
{
@ -1665,8 +1661,7 @@ struct create_mapping_request
unsigned int access;
unsigned int attributes;
obj_handle_t rootdir;
int size_high;
int size_low;
file_pos_t size;
int protect;
obj_handle_t file_handle;
/* VARARG(name,unicode_str); */
@ -1712,14 +1707,12 @@ struct get_mapping_info_request
struct get_mapping_info_reply
{
struct reply_header __header;
int size_high;
int size_low;
file_pos_t size;
int protect;
int header_size;
void* base;
obj_handle_t mapping;
obj_handle_t shared_file;
int shared_size;
};
@ -4880,6 +4873,6 @@ union generic_reply
struct set_completion_info_reply set_completion_info_reply;
};
#define SERVER_PROTOCOL_VERSION 316
#define SERVER_PROTOCOL_VERSION 317
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -657,12 +657,10 @@ DECL_HANDLER(alloc_file_handle)
DECL_HANDLER(lock_file)
{
struct file *file;
file_pos_t offset = ((file_pos_t)req->offset_high << 32) | req->offset_low;
file_pos_t count = ((file_pos_t)req->count_high << 32) | req->count_low;
if ((file = get_file_obj( current->process, req->handle, 0 )))
{
reply->handle = lock_fd( file->fd, offset, count, req->shared, req->wait );
reply->handle = lock_fd( file->fd, req->offset, req->count, req->shared, req->wait );
reply->overlapped = is_overlapped( file );
release_object( file );
}
@ -672,12 +670,10 @@ DECL_HANDLER(lock_file)
DECL_HANDLER(unlock_file)
{
struct file *file;
file_pos_t offset = ((file_pos_t)req->offset_high << 32) | req->offset_low;
file_pos_t count = ((file_pos_t)req->count_high << 32) | req->count_low;
if ((file = get_file_obj( current->process, req->handle, 0 )))
{
unlock_fd( file->fd, offset, count );
unlock_fd( file->fd, req->offset, req->count );
release_object( file );
}
}

View File

@ -27,8 +27,6 @@ struct fd;
struct async_queue;
struct completion;
typedef unsigned __int64 file_pos_t;
/* operations valid on file descriptor objects */
struct fd_ops
{

View File

@ -47,7 +47,6 @@ struct mapping
int header_size; /* size of headers (for PE image mapping) */
void *base; /* default base addr (for PE image mapping) */
struct file *shared_file; /* temp file for shared PE mapping */
int shared_size; /* shared mapping total size */
struct list shared_entry; /* entry in global shared PE mappings list */
};
@ -141,7 +140,8 @@ static int build_shared_mapping( struct mapping *mapping, int fd,
IMAGE_SECTION_HEADER *sec, unsigned int nb_sec )
{
unsigned int i;
size_t file_size, map_size, max_size, total_size;
file_pos_t total_size;
size_t file_size, map_size, max_size;
off_t shared_pos, read_pos, write_pos;
char *buffer = NULL;
int shared_fd;
@ -160,7 +160,7 @@ static int build_shared_mapping( struct mapping *mapping, int fd,
total_size += map_size;
}
}
if (!(mapping->shared_size = total_size)) return 1; /* nothing to do */
if (!total_size) return 1; /* nothing to do */
if ((mapping->shared_file = get_shared_file( mapping ))) return 1;
@ -296,7 +296,6 @@ static struct object *create_mapping( struct directory *root, const struct unico
mapping->header_size = 0;
mapping->base = NULL;
mapping->shared_file = NULL;
mapping->shared_size = 0;
if (protect & VPROT_READ) access |= FILE_READ_DATA;
if (protect & VPROT_WRITE) access |= FILE_WRITE_DATA;
@ -348,10 +347,10 @@ static void mapping_dump( struct object *obj, int verbose )
struct mapping *mapping = (struct mapping *)obj;
assert( obj->ops == &mapping_ops );
fprintf( stderr, "Mapping size=%08x%08x prot=%08x file=%p header_size=%08x base=%p "
"shared_file=%p shared_size=%08x ",
"shared_file=%p ",
(unsigned int)(mapping->size >> 32), (unsigned int)mapping->size,
mapping->protect, mapping->file, mapping->header_size,
mapping->base, mapping->shared_file, mapping->shared_size );
mapping->base, mapping->shared_file );
dump_object_name( &mapping->obj );
fputc( '\n', stderr );
}
@ -395,14 +394,13 @@ DECL_HANDLER(create_mapping)
struct object *obj;
struct unicode_str name;
struct directory *root = NULL;
file_pos_t size = ((file_pos_t)req->size_high << 32) | req->size_low;
reply->handle = 0;
get_req_unicode_str( &name );
if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 )))
return;
if ((obj = create_mapping( root, &name, req->attributes, size, req->protect, req->file_handle )))
if ((obj = create_mapping( root, &name, req->attributes, req->size, req->protect, req->file_handle )))
{
reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
release_object( obj );
@ -440,13 +438,11 @@ DECL_HANDLER(get_mapping_info)
if ((mapping = (struct mapping *)get_handle_obj( current->process, req->handle,
0, &mapping_ops )))
{
reply->size_high = (unsigned int)(mapping->size >> 32);
reply->size_low = (unsigned int)mapping->size;
reply->size = mapping->size;
reply->protect = mapping->protect;
reply->header_size = mapping->header_size;
reply->base = mapping->base;
reply->shared_file = 0;
reply->shared_size = mapping->shared_size;
if ((fd = get_obj_fd( &mapping->obj )))
{
if (!is_fd_removable(fd))

View File

@ -38,6 +38,7 @@ typedef unsigned int process_id_t;
typedef unsigned int thread_id_t;
typedef unsigned int data_size_t;
typedef unsigned int ioctl_code_t;
typedef unsigned __int64 file_pos_t;
struct request_header
{
@ -333,8 +334,7 @@ typedef union
obj_handle_t handle; /* mapping handle */
void *addr; /* requested address */
unsigned long size; /* allocation size */
unsigned int offset_low;/* file offset */
unsigned int offset_high;
file_pos_t offset; /* file offset */
unsigned int zero_bits; /* allocation alignment */
unsigned int alloc_type;/* allocation type */
unsigned int prot; /* memory protection flags */
@ -906,10 +906,8 @@ enum server_fd_type
/* Lock a region of a file */
@REQ(lock_file)
obj_handle_t handle; /* handle to the file */
unsigned int offset_low; /* offset of start of lock */
unsigned int offset_high; /* offset of start of lock */
unsigned int count_low; /* count of bytes to lock */
unsigned int count_high; /* count of bytes to lock */
file_pos_t offset; /* offset of start of lock */
file_pos_t count; /* count of bytes to lock */
int shared; /* shared or exclusive lock? */
int wait; /* do we want to wait? */
@REPLY
@ -921,10 +919,8 @@ enum server_fd_type
/* Unlock a region of a file */
@REQ(unlock_file)
obj_handle_t handle; /* handle to the file */
unsigned int offset_low; /* offset of start of unlock */
unsigned int offset_high; /* offset of start of unlock */
unsigned int count_low; /* count of bytes to unlock */
unsigned int count_high; /* count of bytes to unlock */
file_pos_t offset; /* offset of start of unlock */
file_pos_t count; /* count of bytes to unlock */
@END
@ -1310,8 +1306,7 @@ enum char_info_mode
unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */
obj_handle_t rootdir; /* root directory */
int size_high; /* mapping size */
int size_low; /* mapping size */
file_pos_t size; /* mapping size */
int protect; /* protection flags (see below) */
obj_handle_t file_handle; /* file handle */
VARARG(name,unicode_str); /* object name */
@ -1344,14 +1339,12 @@ enum char_info_mode
@REQ(get_mapping_info)
obj_handle_t handle; /* handle to the mapping */
@REPLY
int size_high; /* mapping size */
int size_low; /* mapping size */
file_pos_t size; /* mapping size */
int protect; /* protection flags */
int header_size; /* header size (for VPROT_IMAGE mapping) */
void* base; /* default base addr (for VPROT_IMAGE mapping) */
obj_handle_t mapping; /* duplicate mapping handle unless removable */
obj_handle_t shared_file; /* shared mapping file handle */
int shared_size; /* shared mapping size */
@END

View File

@ -70,6 +70,11 @@ static void dump_timeout( const timeout_t *time )
fprintf( stderr, get_timeout_str(*time) );
}
static void dump_file_pos( const file_pos_t *pos )
{
fprintf( stderr, "%x%08x", (unsigned int)(*pos >> 32), (unsigned int)*pos );
}
static void dump_rectangle( const rectangle_t *rect )
{
fprintf( stderr, "{%d,%d;%d,%d}",
@ -153,8 +158,8 @@ static void dump_apc_call( const apc_call_t *call )
case APC_MAP_VIEW:
fprintf( stderr, "APC_MAP_VIEW,handle=%p,addr=%p,size=%lu,offset=%x%08x,zero_bits=%u,alloc_type=%x,prot=%x",
call->map_view.handle, call->map_view.addr, call->map_view.size,
call->map_view.offset_high, call->map_view.offset_low, call->map_view.zero_bits,
call->map_view.alloc_type, call->map_view.prot );
(unsigned int)(call->map_view.offset >> 32), (unsigned int)call->map_view.offset,
call->map_view.zero_bits, call->map_view.alloc_type, call->map_view.prot );
break;
case APC_UNMAP_VIEW:
fprintf( stderr, "APC_UNMAP_VIEW,addr=%p", call->unmap_view.addr );
@ -1308,10 +1313,12 @@ static void dump_flush_file_reply( const struct flush_file_reply *req )
static void dump_lock_file_request( const struct lock_file_request *req )
{
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " offset_low=%08x,", req->offset_low );
fprintf( stderr, " offset_high=%08x,", req->offset_high );
fprintf( stderr, " count_low=%08x,", req->count_low );
fprintf( stderr, " count_high=%08x,", req->count_high );
fprintf( stderr, " offset=" );
dump_file_pos( &req->offset );
fprintf( stderr, "," );
fprintf( stderr, " count=" );
dump_file_pos( &req->count );
fprintf( stderr, "," );
fprintf( stderr, " shared=%d,", req->shared );
fprintf( stderr, " wait=%d", req->wait );
}
@ -1325,10 +1332,11 @@ static void dump_lock_file_reply( const struct lock_file_reply *req )
static void dump_unlock_file_request( const struct unlock_file_request *req )
{
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " offset_low=%08x,", req->offset_low );
fprintf( stderr, " offset_high=%08x,", req->offset_high );
fprintf( stderr, " count_low=%08x,", req->count_low );
fprintf( stderr, " count_high=%08x", req->count_high );
fprintf( stderr, " offset=" );
dump_file_pos( &req->offset );
fprintf( stderr, "," );
fprintf( stderr, " count=" );
dump_file_pos( &req->count );
}
static void dump_create_socket_request( const struct create_socket_request *req )
@ -1691,8 +1699,9 @@ static void dump_create_mapping_request( const struct create_mapping_request *re
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " attributes=%08x,", req->attributes );
fprintf( stderr, " rootdir=%p,", req->rootdir );
fprintf( stderr, " size_high=%d,", req->size_high );
fprintf( stderr, " size_low=%d,", req->size_low );
fprintf( stderr, " size=" );
dump_file_pos( &req->size );
fprintf( stderr, "," );
fprintf( stderr, " protect=%d,", req->protect );
fprintf( stderr, " file_handle=%p,", req->file_handle );
fprintf( stderr, " name=" );
@ -1725,14 +1734,14 @@ static void dump_get_mapping_info_request( const struct get_mapping_info_request
static void dump_get_mapping_info_reply( const struct get_mapping_info_reply *req )
{
fprintf( stderr, " size_high=%d,", req->size_high );
fprintf( stderr, " size_low=%d,", req->size_low );
fprintf( stderr, " size=" );
dump_file_pos( &req->size );
fprintf( stderr, "," );
fprintf( stderr, " protect=%d,", req->protect );
fprintf( stderr, " header_size=%d,", req->header_size );
fprintf( stderr, " base=%p,", req->base );
fprintf( stderr, " mapping=%p,", req->mapping );
fprintf( stderr, " shared_file=%p,", req->shared_file );
fprintf( stderr, " shared_size=%d", req->shared_size );
fprintf( stderr, " shared_file=%p", req->shared_file );
}
static void dump_create_snapshot_request( const struct create_snapshot_request *req )

View File

@ -47,6 +47,7 @@ my %formats =
"async_data_t" => "&dump_async_data",
"luid_t" => "&dump_luid",
"ioctl_code_t" => "&dump_ioctl_code",
"file_pos_t" => "&dump_file_pos",
);
my @requests = ();