server: Change the removable fd flag to a cacheable flag to make it possible for fd users to set it dynamically.
This commit is contained in:
parent
70d8fce222
commit
a2ca2ebd50
|
@ -564,7 +564,7 @@ int server_get_unix_fd( HANDLE handle, unsigned int wanted_access, int *unix_fd,
|
||||||
if ((fd = receive_fd( &fd_handle )) != -1)
|
if ((fd = receive_fd( &fd_handle )) != -1)
|
||||||
{
|
{
|
||||||
assert( wine_server_ptr_handle(fd_handle) == handle );
|
assert( wine_server_ptr_handle(fd_handle) == handle );
|
||||||
*needs_close = (reply->removable ||
|
*needs_close = (!reply->cacheable ||
|
||||||
!add_fd_to_cache( handle, fd, reply->type,
|
!add_fd_to_cache( handle, fd, reply->type,
|
||||||
reply->access, reply->options ));
|
reply->access, reply->options ));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1242,7 +1242,7 @@ struct get_handle_fd_reply
|
||||||
{
|
{
|
||||||
struct reply_header __header;
|
struct reply_header __header;
|
||||||
int type;
|
int type;
|
||||||
int removable;
|
int cacheable;
|
||||||
unsigned int access;
|
unsigned int access;
|
||||||
unsigned int options;
|
unsigned int options;
|
||||||
};
|
};
|
||||||
|
@ -5487,6 +5487,6 @@ union generic_reply
|
||||||
struct set_cursor_reply set_cursor_reply;
|
struct set_cursor_reply set_cursor_reply;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SERVER_PROTOCOL_VERSION 402
|
#define SERVER_PROTOCOL_VERSION 403
|
||||||
|
|
||||||
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
|
||||||
|
|
14
server/fd.c
14
server/fd.c
|
@ -197,6 +197,7 @@ struct fd
|
||||||
char *unix_name; /* unix file name */
|
char *unix_name; /* unix file name */
|
||||||
int unix_fd; /* unix file descriptor */
|
int unix_fd; /* unix file descriptor */
|
||||||
unsigned int no_fd_status;/* status to return when unix_fd is -1 */
|
unsigned int no_fd_status;/* status to return when unix_fd is -1 */
|
||||||
|
unsigned int cacheable :1;/* can the fd be cached on the client side? */
|
||||||
unsigned int signaled :1; /* is the fd signaled? */
|
unsigned int signaled :1; /* is the fd signaled? */
|
||||||
unsigned int fs_locks :1; /* can we use filesystem locks for this fd? */
|
unsigned int fs_locks :1; /* can we use filesystem locks for this fd? */
|
||||||
int poll_index; /* index of fd in poll array */
|
int poll_index; /* index of fd in poll array */
|
||||||
|
@ -1546,6 +1547,7 @@ static struct fd *alloc_fd_object(void)
|
||||||
fd->sharing = 0;
|
fd->sharing = 0;
|
||||||
fd->unix_fd = -1;
|
fd->unix_fd = -1;
|
||||||
fd->unix_name = NULL;
|
fd->unix_name = NULL;
|
||||||
|
fd->cacheable = 0;
|
||||||
fd->signaled = 1;
|
fd->signaled = 1;
|
||||||
fd->fs_locks = 1;
|
fd->fs_locks = 1;
|
||||||
fd->poll_index = -1;
|
fd->poll_index = -1;
|
||||||
|
@ -1580,6 +1582,7 @@ struct fd *alloc_pseudo_fd( const struct fd_ops *fd_user_ops, struct object *use
|
||||||
fd->sharing = 0;
|
fd->sharing = 0;
|
||||||
fd->unix_name = NULL;
|
fd->unix_name = NULL;
|
||||||
fd->unix_fd = -1;
|
fd->unix_fd = -1;
|
||||||
|
fd->cacheable = 0;
|
||||||
fd->signaled = 0;
|
fd->signaled = 0;
|
||||||
fd->fs_locks = 0;
|
fd->fs_locks = 0;
|
||||||
fd->poll_index = -1;
|
fd->poll_index = -1;
|
||||||
|
@ -1608,6 +1611,7 @@ struct fd *dup_fd_object( struct fd *orig, unsigned int access, unsigned int sha
|
||||||
fd->options = options;
|
fd->options = options;
|
||||||
fd->sharing = sharing;
|
fd->sharing = sharing;
|
||||||
fd->unix_fd = -1;
|
fd->unix_fd = -1;
|
||||||
|
fd->cacheable = orig->cacheable;
|
||||||
fd->signaled = 0;
|
fd->signaled = 0;
|
||||||
fd->fs_locks = 0;
|
fd->fs_locks = 0;
|
||||||
fd->poll_index = -1;
|
fd->poll_index = -1;
|
||||||
|
@ -1823,6 +1827,7 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
|
||||||
}
|
}
|
||||||
fd->inode = inode;
|
fd->inode = inode;
|
||||||
fd->closed = closed_fd;
|
fd->closed = closed_fd;
|
||||||
|
fd->cacheable = !inode->device->removable;
|
||||||
list_add_head( &inode->open, &fd->inode_entry );
|
list_add_head( &inode->open, &fd->inode_entry );
|
||||||
|
|
||||||
/* check directory options */
|
/* check directory options */
|
||||||
|
@ -1869,6 +1874,7 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
free( closed_fd );
|
free( closed_fd );
|
||||||
|
fd->cacheable = 1;
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
|
@ -1922,6 +1928,12 @@ int is_same_file_fd( struct fd *fd1, struct fd *fd2 )
|
||||||
return fd1->inode == fd2->inode;
|
return fd1->inode == fd2->inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* allow the fd to be cached (can't be reset once set) */
|
||||||
|
void allow_fd_caching( struct fd *fd )
|
||||||
|
{
|
||||||
|
fd->cacheable = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if fd is on a removable device */
|
/* check if fd is on a removable device */
|
||||||
int is_fd_removable( struct fd *fd )
|
int is_fd_removable( struct fd *fd )
|
||||||
{
|
{
|
||||||
|
@ -2269,7 +2281,7 @@ DECL_HANDLER(get_handle_fd)
|
||||||
if (unix_fd != -1)
|
if (unix_fd != -1)
|
||||||
{
|
{
|
||||||
reply->type = fd->fd_ops->get_fd_type( fd );
|
reply->type = fd->fd_ops->get_fd_type( fd );
|
||||||
reply->removable = is_fd_removable(fd);
|
reply->cacheable = fd->cacheable;
|
||||||
reply->options = fd->options;
|
reply->options = fd->options;
|
||||||
reply->access = get_handle_access( current->process, req->handle );
|
reply->access = get_handle_access( current->process, req->handle );
|
||||||
send_client_fd( current->process, unix_fd, req->handle );
|
send_client_fd( current->process, unix_fd, req->handle );
|
||||||
|
|
|
@ -136,6 +136,7 @@ struct file *create_file_for_fd( int fd, unsigned int access, unsigned int shari
|
||||||
release_object( file );
|
release_object( file );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
allow_fd_caching( file->fd );
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ extern int check_fd_events( struct fd *fd, int events );
|
||||||
extern void set_fd_events( struct fd *fd, int events );
|
extern void set_fd_events( struct fd *fd, int events );
|
||||||
extern obj_handle_t lock_fd( struct fd *fd, file_pos_t offset, file_pos_t count, int shared, int wait );
|
extern obj_handle_t lock_fd( struct fd *fd, file_pos_t offset, file_pos_t count, int shared, int wait );
|
||||||
extern void unlock_fd( struct fd *fd, file_pos_t offset, file_pos_t count );
|
extern void unlock_fd( struct fd *fd, file_pos_t offset, file_pos_t count );
|
||||||
|
extern void allow_fd_caching( struct fd *fd );
|
||||||
extern void set_fd_signaled( struct fd *fd, int signaled );
|
extern void set_fd_signaled( struct fd *fd, int signaled );
|
||||||
extern int is_fd_signaled( struct fd *fd );
|
extern int is_fd_signaled( struct fd *fd );
|
||||||
|
|
||||||
|
|
|
@ -297,6 +297,7 @@ static struct object *mailslot_open_file( struct object *obj, unsigned int acces
|
||||||
release_object( writer );
|
release_object( writer );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
allow_fd_caching( writer->fd );
|
||||||
return &writer->obj;
|
return &writer->obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,9 +443,12 @@ static struct mailslot *create_mailslot( struct directory *root,
|
||||||
fcntl( fds[1], F_SETFL, O_NONBLOCK );
|
fcntl( fds[1], F_SETFL, O_NONBLOCK );
|
||||||
shutdown( fds[0], SHUT_RD );
|
shutdown( fds[0], SHUT_RD );
|
||||||
mailslot->write_fd = fds[0];
|
mailslot->write_fd = fds[0];
|
||||||
mailslot->fd = create_anonymous_fd( &mailslot_fd_ops, fds[1], &mailslot->obj,
|
if ((mailslot->fd = create_anonymous_fd( &mailslot_fd_ops, fds[1], &mailslot->obj,
|
||||||
FILE_SYNCHRONOUS_IO_NONALERT );
|
FILE_SYNCHRONOUS_IO_NONALERT )))
|
||||||
if (mailslot->fd) return mailslot;
|
{
|
||||||
|
allow_fd_caching( mailslot->fd );
|
||||||
|
return mailslot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else file_set_error();
|
else file_set_error();
|
||||||
|
|
||||||
|
|
|
@ -515,6 +515,7 @@ static struct object *create_mapping( struct directory *root, const struct unico
|
||||||
if ((unix_fd = create_temp_file( size )) == -1) goto error;
|
if ((unix_fd = create_temp_file( size )) == -1) goto error;
|
||||||
if (!(mapping->fd = create_anonymous_fd( &mapping_fd_ops, unix_fd, &mapping->obj,
|
if (!(mapping->fd = create_anonymous_fd( &mapping_fd_ops, unix_fd, &mapping->obj,
|
||||||
FILE_SYNCHRONOUS_IO_NONALERT ))) goto error;
|
FILE_SYNCHRONOUS_IO_NONALERT ))) goto error;
|
||||||
|
allow_fd_caching( mapping->fd );
|
||||||
}
|
}
|
||||||
mapping->size = (size + page_mask) & ~((mem_size_t)page_mask);
|
mapping->size = (size + page_mask) & ~((mem_size_t)page_mask);
|
||||||
mapping->protect = protect;
|
mapping->protect = protect;
|
||||||
|
|
|
@ -838,6 +838,8 @@ static struct object *named_pipe_open_file( struct object *obj, unsigned int acc
|
||||||
server->fd = create_anonymous_fd( &pipe_server_fd_ops, fds[0], &server->obj, server->options );
|
server->fd = create_anonymous_fd( &pipe_server_fd_ops, fds[0], &server->obj, server->options );
|
||||||
if (client->fd && server->fd)
|
if (client->fd && server->fd)
|
||||||
{
|
{
|
||||||
|
allow_fd_caching( client->fd );
|
||||||
|
allow_fd_caching( server->fd );
|
||||||
fd_copy_completion( server->ioctl_fd, server->fd );
|
fd_copy_completion( server->ioctl_fd, server->fd );
|
||||||
if (server->state == ps_wait_open)
|
if (server->state == ps_wait_open)
|
||||||
fd_async_wake_up( server->ioctl_fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
|
fd_async_wake_up( server->ioctl_fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
|
||||||
|
|
|
@ -1018,7 +1018,7 @@ enum event_op { PULSE_EVENT, SET_EVENT, RESET_EVENT };
|
||||||
obj_handle_t handle; /* handle to the file */
|
obj_handle_t handle; /* handle to the file */
|
||||||
@REPLY
|
@REPLY
|
||||||
int type; /* file type (see below) */
|
int type; /* file type (see below) */
|
||||||
int removable; /* is file removable? */
|
int cacheable; /* can fd be cached in the client? */
|
||||||
unsigned int access; /* file access rights */
|
unsigned int access; /* file access rights */
|
||||||
unsigned int options; /* file open options */
|
unsigned int options; /* file open options */
|
||||||
@END
|
@END
|
||||||
|
|
|
@ -888,7 +888,7 @@ 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_request, handle) == 12 );
|
||||||
C_ASSERT( sizeof(struct get_handle_fd_request) == 16 );
|
C_ASSERT( sizeof(struct get_handle_fd_request) == 16 );
|
||||||
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, type) == 8 );
|
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, type) == 8 );
|
||||||
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, removable) == 12 );
|
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, cacheable) == 12 );
|
||||||
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, access) == 16 );
|
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, access) == 16 );
|
||||||
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, options) == 20 );
|
C_ASSERT( FIELD_OFFSET(struct get_handle_fd_reply, options) == 20 );
|
||||||
C_ASSERT( sizeof(struct get_handle_fd_reply) == 24 );
|
C_ASSERT( sizeof(struct get_handle_fd_reply) == 24 );
|
||||||
|
|
|
@ -646,6 +646,7 @@ static struct object *create_socket( int family, int type, int protocol, unsigne
|
||||||
release_object( sock );
|
release_object( sock );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
allow_fd_caching( sock->fd );
|
||||||
sock_reselect( sock );
|
sock_reselect( sock );
|
||||||
clear_error();
|
clear_error();
|
||||||
return &sock->obj;
|
return &sock->obj;
|
||||||
|
@ -718,6 +719,7 @@ static struct sock *accept_socket( obj_handle_t handle )
|
||||||
release_object( sock );
|
release_object( sock );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
allow_fd_caching( acceptsock->fd );
|
||||||
}
|
}
|
||||||
clear_error();
|
clear_error();
|
||||||
sock->pmask &= ~FD_ACCEPT;
|
sock->pmask &= ~FD_ACCEPT;
|
||||||
|
|
|
@ -1475,7 +1475,7 @@ static void dump_get_handle_fd_request( const struct get_handle_fd_request *req
|
||||||
static void dump_get_handle_fd_reply( const struct get_handle_fd_reply *req )
|
static void dump_get_handle_fd_reply( const struct get_handle_fd_reply *req )
|
||||||
{
|
{
|
||||||
fprintf( stderr, " type=%d", req->type );
|
fprintf( stderr, " type=%d", req->type );
|
||||||
fprintf( stderr, ", removable=%d", req->removable );
|
fprintf( stderr, ", cacheable=%d", req->cacheable );
|
||||||
fprintf( stderr, ", access=%08x", req->access );
|
fprintf( stderr, ", access=%08x", req->access );
|
||||||
fprintf( stderr, ", options=%08x", req->options );
|
fprintf( stderr, ", options=%08x", req->options );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue