server: Store the opening options in the file descriptor instead of in the individual objects.
Allows moving the FD_FLAG_OVERLAPPED support to the generic
get_handle_fd request handling.
diff --git a/server/file.c b/server/file.c
index e038af3..e6f1c71 100644
--- a/server/file.c
+++ b/server/file.c
@@ -58,7 +58,6 @@
struct object obj; /* object header */
struct fd *fd; /* file descriptor for this file */
unsigned int access; /* file access (FILE_READ_DATA etc.) */
- unsigned int options; /* file options (FILE_DELETE_ON_CLOSE, FILE_SYNCHRONOUS...) */
};
static unsigned int generic_file_map_access( unsigned int access );
@@ -102,7 +101,7 @@
static inline int is_overlapped( const struct file *file )
{
- return !(file->options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT));
+ return !(get_fd_options( file->fd ) & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT));
}
/* create a file from a file descriptor */
@@ -113,9 +112,9 @@
if ((file = alloc_object( &file_ops )))
{
- file->access = file_map_access( &file->obj, access );
- file->options = FILE_SYNCHRONOUS_IO_NONALERT;
- if (!(file->fd = create_anonymous_fd( &file_fd_ops, fd, &file->obj )))
+ file->access = file_map_access( &file->obj, access );
+ if (!(file->fd = create_anonymous_fd( &file_fd_ops, fd, &file->obj,
+ FILE_SYNCHRONOUS_IO_NONALERT )))
{
release_object( file );
return NULL;
@@ -124,13 +123,12 @@
return file;
}
-static struct object *create_file_obj( struct fd *fd, unsigned int access, unsigned int options )
+static struct object *create_file_obj( struct fd *fd, unsigned int access )
{
struct file *file = alloc_object( &file_ops );
if (!file) return NULL;
file->access = access;
- file->options = options;
file->fd = fd;
grab_object( fd );
set_fd_user( fd, &file_fd_ops, &file->obj );
@@ -177,9 +175,9 @@
if (S_ISDIR(mode))
obj = create_dir_obj( fd );
else if (S_ISCHR(mode) && is_serial_fd( fd ))
- obj = create_serial( fd, options );
+ obj = create_serial( fd );
else
- obj = create_file_obj( fd, access, options );
+ obj = create_file_obj( fd, access );
release_object( fd );
@@ -215,7 +213,7 @@
{
struct file *file = (struct file *)obj;
assert( obj->ops == &file_ops );
- fprintf( stderr, "File fd=%p options=%08x\n", file->fd, file->options );
+ fprintf( stderr, "File fd=%p\n", file->fd );
}
static int file_get_poll_events( struct fd *fd )
@@ -236,10 +234,7 @@
static enum server_fd_type file_get_info( struct fd *fd, int *flags )
{
- struct file *file = get_fd_user( fd );
-
*flags = 0;
- if (is_overlapped( file )) *flags |= FD_FLAG_OVERLAPPED;
return FD_TYPE_FILE;
}