mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 06:20:56 +00:00
server: Add a default access mapping function for files, and use it for devices too.
This commit is contained in:
parent
4a5ba4c732
commit
24001e8ddc
|
@ -157,7 +157,6 @@ struct dir
|
|||
};
|
||||
|
||||
static struct fd *dir_get_fd( struct object *obj );
|
||||
static unsigned int dir_map_access( struct object *obj, unsigned int access );
|
||||
static void dir_dump( struct object *obj, int verbose );
|
||||
static void dir_destroy( struct object *obj );
|
||||
|
||||
|
@ -171,7 +170,7 @@ static const struct object_ops dir_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
dir_get_fd, /* get_fd */
|
||||
dir_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
fd_close_handle, /* close_handle */
|
||||
|
@ -289,15 +288,6 @@ static struct fd *dir_get_fd( struct object *obj )
|
|||
return (struct fd *)grab_object( dir->fd );
|
||||
}
|
||||
|
||||
static unsigned int dir_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= FILE_GENERIC_READ;
|
||||
if (access & GENERIC_WRITE) access |= FILE_GENERIC_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= FILE_ALL_ACCESS;
|
||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
static struct change_record *get_first_change_record( struct dir *dir )
|
||||
{
|
||||
struct list *ptr = list_head( &dir->change_records );
|
||||
|
|
|
@ -130,7 +130,7 @@ static const struct object_ops device_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
device_get_fd, /* get_fd */
|
||||
no_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
device_open_file, /* open_file */
|
||||
no_close_handle, /* close_handle */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "handle.h"
|
||||
#include "request.h"
|
||||
#include "process.h"
|
||||
#include "object.h"
|
||||
#include "file.h"
|
||||
#include "unicode.h"
|
||||
|
||||
#define HASH_SIZE 7 /* default hash size */
|
||||
|
@ -48,7 +48,6 @@ struct directory
|
|||
};
|
||||
|
||||
static void directory_dump( struct object *obj, int verbose );
|
||||
static unsigned int directory_map_access( struct object *obj, unsigned int access );
|
||||
static struct object *directory_lookup_name( struct object *obj, struct unicode_str *name,
|
||||
unsigned int attr );
|
||||
static void directory_destroy( struct object *obj );
|
||||
|
@ -63,7 +62,7 @@ static const struct object_ops directory_ops =
|
|||
NULL, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
no_get_fd, /* get_fd */
|
||||
directory_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
directory_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
no_close_handle, /* close_handle */
|
||||
|
@ -123,15 +122,6 @@ static struct object *directory_lookup_name( struct object *obj, struct unicode_
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static unsigned int directory_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= FILE_GENERIC_READ;
|
||||
if (access & GENERIC_WRITE) access |= FILE_GENERIC_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= FILE_ALL_ACCESS;
|
||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
static void directory_destroy( struct object *obj )
|
||||
{
|
||||
struct directory *dir = (struct directory *)obj;
|
||||
|
|
10
server/fd.c
10
server/fd.c
|
@ -1710,6 +1710,16 @@ int default_fd_signaled( struct object *obj, struct thread *thread )
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* default map_access() routine for objects that behave like an fd */
|
||||
unsigned int default_fd_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= FILE_GENERIC_READ;
|
||||
if (access & GENERIC_WRITE) access |= FILE_GENERIC_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= FILE_ALL_ACCESS;
|
||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
int default_fd_get_poll_events( struct fd *fd )
|
||||
{
|
||||
int events = 0;
|
||||
|
|
|
@ -65,7 +65,6 @@ static unsigned int generic_file_map_access( unsigned int access );
|
|||
|
||||
static void file_dump( struct object *obj, int verbose );
|
||||
static struct fd *file_get_fd( struct object *obj );
|
||||
static unsigned int file_map_access( struct object *obj, unsigned int access );
|
||||
static void file_destroy( struct object *obj );
|
||||
|
||||
static int file_get_poll_events( struct fd *fd );
|
||||
|
@ -82,7 +81,7 @@ static const struct object_ops file_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
file_get_fd, /* get_fd */
|
||||
file_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
fd_close_handle, /* close_handle */
|
||||
|
@ -122,7 +121,7 @@ static struct file *create_file_for_fd( int fd, unsigned int access, unsigned in
|
|||
if ((file = alloc_object( &file_ops )))
|
||||
{
|
||||
file->mode = st.st_mode;
|
||||
file->access = file_map_access( &file->obj, access );
|
||||
file->access = default_fd_map_access( &file->obj, access );
|
||||
if (!(file->fd = create_anonymous_fd( &file_fd_ops, fd, &file->obj,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT )))
|
||||
{
|
||||
|
@ -268,11 +267,6 @@ static unsigned int generic_file_map_access( unsigned int access )
|
|||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
static unsigned int file_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
return generic_file_map_access( access );
|
||||
}
|
||||
|
||||
static void file_destroy( struct object *obj )
|
||||
{
|
||||
struct file *file = (struct file *)obj;
|
||||
|
|
|
@ -75,6 +75,7 @@ extern void unlock_fd( struct fd *fd, file_pos_t offset, file_pos_t count );
|
|||
extern void set_fd_signaled( struct fd *fd, int signaled );
|
||||
|
||||
extern int default_fd_signaled( struct object *obj, struct thread *thread );
|
||||
extern unsigned int default_fd_map_access( struct object *obj, unsigned int access );
|
||||
extern int default_fd_get_poll_events( struct fd *fd );
|
||||
extern void default_poll_event( struct fd *fd, int event );
|
||||
extern struct async *fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
|
||||
|
|
|
@ -130,9 +130,6 @@ static const struct object_ops named_pipe_ops =
|
|||
named_pipe_destroy /* destroy */
|
||||
};
|
||||
|
||||
/* functions common to server and client */
|
||||
static unsigned int pipe_map_access( struct object *obj, unsigned int access );
|
||||
|
||||
/* server end functions */
|
||||
static void pipe_server_dump( struct object *obj, int verbose );
|
||||
static struct fd *pipe_server_get_fd( struct object *obj );
|
||||
|
@ -152,7 +149,7 @@ static const struct object_ops pipe_server_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
pipe_server_get_fd, /* get_fd */
|
||||
pipe_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
fd_close_handle, /* close_handle */
|
||||
|
@ -188,7 +185,7 @@ static const struct object_ops pipe_client_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
pipe_client_get_fd, /* get_fd */
|
||||
pipe_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
fd_close_handle, /* close_handle */
|
||||
|
@ -357,15 +354,6 @@ static void do_disconnect( struct pipe_server *server )
|
|||
server->fd = NULL;
|
||||
}
|
||||
|
||||
static unsigned int pipe_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= FILE_GENERIC_READ;
|
||||
if (access & GENERIC_WRITE) access |= FILE_GENERIC_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= FILE_ALL_ACCESS;
|
||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
static void pipe_server_destroy( struct object *obj)
|
||||
{
|
||||
struct pipe_server *server = (struct pipe_server *)obj;
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
|
||||
static void serial_dump( struct object *obj, int verbose );
|
||||
static struct fd *serial_get_fd( struct object *obj );
|
||||
static unsigned int serial_map_access( struct object *obj, unsigned int access );
|
||||
static void serial_destroy(struct object *obj);
|
||||
|
||||
static enum server_fd_type serial_get_fd_type( struct fd *fd );
|
||||
|
@ -94,7 +93,7 @@ static const struct object_ops serial_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
serial_get_fd, /* get_fd */
|
||||
serial_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
fd_close_handle, /* close_handle */
|
||||
|
@ -145,15 +144,6 @@ static struct fd *serial_get_fd( struct object *obj )
|
|||
return (struct fd *)grab_object( serial->fd );
|
||||
}
|
||||
|
||||
static unsigned int serial_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= FILE_GENERIC_READ;
|
||||
if (access & GENERIC_WRITE) access |= FILE_GENERIC_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= FILE_ALL_ACCESS;
|
||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
static void serial_destroy( struct object *obj)
|
||||
{
|
||||
struct serial *serial = (struct serial *)obj;
|
||||
|
|
|
@ -90,7 +90,6 @@ struct sock
|
|||
static void sock_dump( struct object *obj, int verbose );
|
||||
static int sock_signaled( struct object *obj, struct thread *thread );
|
||||
static struct fd *sock_get_fd( struct object *obj );
|
||||
static unsigned int sock_map_access( struct object *obj, unsigned int access );
|
||||
static void sock_destroy( struct object *obj );
|
||||
|
||||
static int sock_get_poll_events( struct fd *fd );
|
||||
|
@ -113,7 +112,7 @@ static const struct object_ops sock_ops =
|
|||
no_satisfied, /* satisfied */
|
||||
no_signal, /* signal */
|
||||
sock_get_fd, /* get_fd */
|
||||
sock_map_access, /* map_access */
|
||||
default_fd_map_access, /* map_access */
|
||||
no_lookup_name, /* lookup_name */
|
||||
no_open_file, /* open_file */
|
||||
fd_close_handle, /* close_handle */
|
||||
|
@ -459,15 +458,6 @@ static int sock_signaled( struct object *obj, struct thread *thread )
|
|||
return check_fd_events( sock->fd, sock_get_poll_events( sock->fd ) ) != 0;
|
||||
}
|
||||
|
||||
static unsigned int sock_map_access( struct object *obj, unsigned int access )
|
||||
{
|
||||
if (access & GENERIC_READ) access |= FILE_GENERIC_READ;
|
||||
if (access & GENERIC_WRITE) access |= FILE_GENERIC_WRITE;
|
||||
if (access & GENERIC_EXECUTE) access |= FILE_GENERIC_EXECUTE;
|
||||
if (access & GENERIC_ALL) access |= FILE_ALL_ACCESS;
|
||||
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
||||
}
|
||||
|
||||
static int sock_get_poll_events( struct fd *fd )
|
||||
{
|
||||
struct sock *sock = get_fd_user( fd );
|
||||
|
|
Loading…
Reference in a new issue