server: Add a default access mapping function for files, and use it for devices too.
diff --git a/server/change.c b/server/change.c
index e996d49..c8966da 100644
--- a/server/change.c
+++ b/server/change.c
@@ -157,7 +157,6 @@
};
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 @@
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 @@
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 );
diff --git a/server/device.c b/server/device.c
index c52cd22..e4fa595 100644
--- a/server/device.c
+++ b/server/device.c
@@ -130,7 +130,7 @@
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 */
diff --git a/server/directory.c b/server/directory.c
index 55c3264..f170711 100644
--- a/server/directory.c
+++ b/server/directory.c
@@ -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 @@
};
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 @@
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 @@
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;
diff --git a/server/fd.c b/server/fd.c
index d671a1c..4779475 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1710,6 +1710,16 @@
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;
diff --git a/server/file.c b/server/file.c
index a8152da..d65ff44 100644
--- a/server/file.c
+++ b/server/file.c
@@ -65,7 +65,6 @@
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 @@
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 @@
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 @@
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;
diff --git a/server/file.h b/server/file.h
index d56aad0..823cc2c 100644
--- a/server/file.h
+++ b/server/file.h
@@ -75,6 +75,7 @@
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 );
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 39dd10a..e39f85a 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -130,9 +130,6 @@
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 @@
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 @@
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 @@
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;
diff --git a/server/serial.c b/server/serial.c
index 628db5a..5a1e3ca 100644
--- a/server/serial.c
+++ b/server/serial.c
@@ -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 @@
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 @@
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;
diff --git a/server/sock.c b/server/sock.c
index d7c1e68..0694c51 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -90,7 +90,6 @@
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 @@
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 @@
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 );