server: Store the Unix name in the fd.
This commit is contained in:
parent
10b0b86cbc
commit
27705d51e1
|
@ -1207,6 +1207,21 @@ struct alloc_file_handle_reply
|
|||
|
||||
|
||||
|
||||
struct get_handle_unix_name_request
|
||||
{
|
||||
struct request_header __header;
|
||||
obj_handle_t handle;
|
||||
};
|
||||
struct get_handle_unix_name_reply
|
||||
{
|
||||
struct reply_header __header;
|
||||
data_size_t name_len;
|
||||
/* VARARG(name,string); */
|
||||
char __pad_12[4];
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct get_handle_fd_request
|
||||
{
|
||||
struct request_header __header;
|
||||
|
@ -4678,6 +4693,7 @@ enum request
|
|||
REQ_create_file,
|
||||
REQ_open_file_object,
|
||||
REQ_alloc_file_handle,
|
||||
REQ_get_handle_unix_name,
|
||||
REQ_get_handle_fd,
|
||||
REQ_flush_file,
|
||||
REQ_lock_file,
|
||||
|
@ -4925,6 +4941,7 @@ union generic_request
|
|||
struct create_file_request create_file_request;
|
||||
struct open_file_object_request open_file_object_request;
|
||||
struct alloc_file_handle_request alloc_file_handle_request;
|
||||
struct get_handle_unix_name_request get_handle_unix_name_request;
|
||||
struct get_handle_fd_request get_handle_fd_request;
|
||||
struct flush_file_request flush_file_request;
|
||||
struct lock_file_request lock_file_request;
|
||||
|
@ -5170,6 +5187,7 @@ union generic_reply
|
|||
struct create_file_reply create_file_reply;
|
||||
struct open_file_object_reply open_file_object_reply;
|
||||
struct alloc_file_handle_reply alloc_file_handle_reply;
|
||||
struct get_handle_unix_name_reply get_handle_unix_name_reply;
|
||||
struct get_handle_fd_reply get_handle_fd_reply;
|
||||
struct flush_file_reply flush_file_reply;
|
||||
struct lock_file_reply lock_file_reply;
|
||||
|
@ -5375,6 +5393,6 @@ union generic_reply
|
|||
struct free_user_handle_reply free_user_handle_reply;
|
||||
};
|
||||
|
||||
#define SERVER_PROTOCOL_VERSION 392
|
||||
#define SERVER_PROTOCOL_VERSION 393
|
||||
|
||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||
|
|
25
server/fd.c
25
server/fd.c
|
@ -190,6 +190,7 @@ struct fd
|
|||
unsigned int access; /* file access (FILE_READ_DATA etc.) */
|
||||
unsigned int options; /* file options (FILE_DELETE_ON_CLOSE, FILE_SYNCHRONOUS...) */
|
||||
unsigned int sharing; /* file sharing mode */
|
||||
char *unix_name; /* unix file name */
|
||||
int unix_fd; /* unix file descriptor */
|
||||
unsigned int no_fd_status;/* status to return when unix_fd is -1 */
|
||||
unsigned int signaled :1; /* is the fd signaled? */
|
||||
|
@ -1368,6 +1369,7 @@ static void fd_destroy( struct object *obj )
|
|||
|
||||
if (fd->completion) release_object( fd->completion );
|
||||
remove_fd_locks( fd );
|
||||
free( fd->unix_name );
|
||||
list_remove( &fd->inode_entry );
|
||||
if (fd->poll_index != -1) remove_poll_user( fd, fd->poll_index );
|
||||
if (fd->inode)
|
||||
|
@ -1438,6 +1440,7 @@ static struct fd *alloc_fd_object(void)
|
|||
fd->options = 0;
|
||||
fd->sharing = 0;
|
||||
fd->unix_fd = -1;
|
||||
fd->unix_name = NULL;
|
||||
fd->signaled = 1;
|
||||
fd->fs_locks = 1;
|
||||
fd->poll_index = -1;
|
||||
|
@ -1470,6 +1473,7 @@ struct fd *alloc_pseudo_fd( const struct fd_ops *fd_user_ops, struct object *use
|
|||
fd->access = 0;
|
||||
fd->options = options;
|
||||
fd->sharing = 0;
|
||||
fd->unix_name = NULL;
|
||||
fd->unix_fd = -1;
|
||||
fd->signaled = 0;
|
||||
fd->fs_locks = 0;
|
||||
|
@ -1577,6 +1581,9 @@ struct fd *open_fd( const char *name, int flags, mode_t *mode, unsigned int acce
|
|||
}
|
||||
else rw_mode = O_RDONLY;
|
||||
|
||||
if (!(fd->unix_name = mem_alloc( strlen(name) + 1 ))) goto error;
|
||||
strcpy( fd->unix_name, name );
|
||||
|
||||
if ((fd->unix_fd = open( name, rw_mode | (flags & ~O_TRUNC), *mode )) == -1)
|
||||
{
|
||||
/* if we tried to open a directory for write access, retry read-only */
|
||||
|
@ -2003,6 +2010,24 @@ DECL_HANDLER(open_file_object)
|
|||
if (root) release_object( root );
|
||||
}
|
||||
|
||||
/* get the Unix name from a file handle */
|
||||
DECL_HANDLER(get_handle_unix_name)
|
||||
{
|
||||
struct fd *fd;
|
||||
|
||||
if ((fd = get_handle_fd_obj( current->process, req->handle, 0 )))
|
||||
{
|
||||
if (fd->unix_name)
|
||||
{
|
||||
data_size_t name_len = strlen( fd->unix_name );
|
||||
reply->name_len = name_len;
|
||||
if (name_len <= get_reply_max_size()) set_reply_data( fd->unix_name, name_len );
|
||||
else set_error( STATUS_BUFFER_OVERFLOW );
|
||||
}
|
||||
release_object( fd );
|
||||
}
|
||||
}
|
||||
|
||||
/* get a Unix fd to access a file */
|
||||
DECL_HANDLER(get_handle_fd)
|
||||
{
|
||||
|
|
|
@ -1003,6 +1003,15 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
|
|||
@END
|
||||
|
||||
|
||||
/* Get the Unix name from a file handle */
|
||||
@REQ(get_handle_unix_name)
|
||||
obj_handle_t handle; /* file handle */
|
||||
@REPLY
|
||||
data_size_t name_len; /* unix name length */
|
||||
VARARG(name,string); /* unix name */
|
||||
@END
|
||||
|
||||
|
||||
/* Get a Unix fd to access a file */
|
||||
@REQ(get_handle_fd)
|
||||
obj_handle_t handle; /* handle to the file */
|
||||
|
|
|
@ -148,6 +148,7 @@ DECL_HANDLER(open_semaphore);
|
|||
DECL_HANDLER(create_file);
|
||||
DECL_HANDLER(open_file_object);
|
||||
DECL_HANDLER(alloc_file_handle);
|
||||
DECL_HANDLER(get_handle_unix_name);
|
||||
DECL_HANDLER(get_handle_fd);
|
||||
DECL_HANDLER(flush_file);
|
||||
DECL_HANDLER(lock_file);
|
||||
|
@ -394,6 +395,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
|
|||
(req_handler)req_create_file,
|
||||
(req_handler)req_open_file_object,
|
||||
(req_handler)req_alloc_file_handle,
|
||||
(req_handler)req_get_handle_unix_name,
|
||||
(req_handler)req_get_handle_fd,
|
||||
(req_handler)req_flush_file,
|
||||
(req_handler)req_lock_file,
|
||||
|
@ -846,6 +848,9 @@ C_ASSERT( FIELD_OFFSET(struct alloc_file_handle_request, attributes) == 16 );
|
|||
C_ASSERT( FIELD_OFFSET(struct alloc_file_handle_request, fd) == 20 );
|
||||
C_ASSERT( FIELD_OFFSET(struct alloc_file_handle_reply, handle) == 8 );
|
||||
C_ASSERT( sizeof(struct alloc_file_handle_reply) == 16 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_handle_unix_name_request, handle) == 12 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_handle_unix_name_reply, name_len) == 8 );
|
||||
C_ASSERT( sizeof(struct get_handle_unix_name_reply) == 16 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_request, handle) == 12 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, type) == 8 );
|
||||
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, removable) == 12 );
|
||||
|
|
|
@ -1457,6 +1457,17 @@ static void dump_alloc_file_handle_reply( const struct alloc_file_handle_reply *
|
|||
fprintf( stderr, " handle=%04x", req->handle );
|
||||
}
|
||||
|
||||
static void dump_get_handle_unix_name_request( const struct get_handle_unix_name_request *req )
|
||||
{
|
||||
fprintf( stderr, " handle=%04x", req->handle );
|
||||
}
|
||||
|
||||
static void dump_get_handle_unix_name_reply( const struct get_handle_unix_name_reply *req )
|
||||
{
|
||||
fprintf( stderr, " name_len=%u", req->name_len );
|
||||
dump_varargs_string( ", name=", cur_size );
|
||||
}
|
||||
|
||||
static void dump_get_handle_fd_request( const struct get_handle_fd_request *req )
|
||||
{
|
||||
fprintf( stderr, " handle=%04x", req->handle );
|
||||
|
@ -3832,6 +3843,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
|
|||
(dump_func)dump_create_file_request,
|
||||
(dump_func)dump_open_file_object_request,
|
||||
(dump_func)dump_alloc_file_handle_request,
|
||||
(dump_func)dump_get_handle_unix_name_request,
|
||||
(dump_func)dump_get_handle_fd_request,
|
||||
(dump_func)dump_flush_file_request,
|
||||
(dump_func)dump_lock_file_request,
|
||||
|
@ -4075,6 +4087,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
|
|||
(dump_func)dump_create_file_reply,
|
||||
(dump_func)dump_open_file_object_reply,
|
||||
(dump_func)dump_alloc_file_handle_reply,
|
||||
(dump_func)dump_get_handle_unix_name_reply,
|
||||
(dump_func)dump_get_handle_fd_reply,
|
||||
(dump_func)dump_flush_file_reply,
|
||||
(dump_func)dump_lock_file_reply,
|
||||
|
@ -4318,6 +4331,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
|
|||
"create_file",
|
||||
"open_file_object",
|
||||
"alloc_file_handle",
|
||||
"get_handle_unix_name",
|
||||
"get_handle_fd",
|
||||
"flush_file",
|
||||
"lock_file",
|
||||
|
|
Loading…
Reference in New Issue