server: Pass object attributes to create_named_object & find_object

Vitaliy Margolen wine-patch at kievinfo.com
Thu Oct 27 14:56:16 CDT 2005


Changing all involved open* and create* functions as well. This patch does not
change any other behavior.

The reason I'm passing whole attributes again, is that I'll need them when the
time comes for symlinks. I'll need to know what to open symlink itself or the
object it points to. Also we might think about merging Open and Create
functions. 

Next patch will actually use OBJ_CASE_INSENSITIVE in find_object.

Vitaliy Margolen

changelog:
  server
  - Pass object attributes to create_named_object & find_object
-------------- next part --------------
Index: server/console.c
===================================================================
RCS file: /home/wine/wine/server/console.c,v
retrieving revision 1.59
diff -u -p -r1.59 console.c
--- server/console.c	12 Jul 2005 20:27:09 -0000	1.59
+++ server/console.c	27 Oct 2005 19:37:16 -0000
@@ -227,7 +227,7 @@ static struct object *create_console_inp
     console_input->history_index = 0;
     console_input->history_mode  = 0;
     console_input->edition_mode  = 0;
-    console_input->event         = create_event( NULL, 0, 1, 0 );
+    console_input->event         = create_event( NULL, 0, 0, 1, 0 );
 
     if (!console_input->history || !console_input->evt)
     {
Index: server/event.c
===================================================================
RCS file: /home/wine/wine/server/event.c,v
retrieving revision 1.32
diff -u -p -r1.32 event.c
--- server/event.c	27 Oct 2005 18:30:37 -0000	1.32
+++ server/event.c	27 Oct 2005 19:37:16 -0000
@@ -59,12 +59,12 @@ static const struct object_ops event_ops
 };
 
 
-struct event *create_event( const WCHAR *name, size_t len,
+struct event *create_event( const WCHAR *name, size_t len, unsigned int attr,
                             int manual_reset, int initial_state )
 {
     struct event *event;
 
-    if ((event = create_named_object( sync_namespace, &event_ops, name, len )))
+    if ((event = create_named_object( sync_namespace, &event_ops, name, len, attr )))
     {
         if (get_error() != STATUS_OBJECT_NAME_COLLISION)
         {
@@ -147,7 +147,7 @@ DECL_HANDLER(create_event)
     struct event *event;
 
     reply->handle = 0;
-    if ((event = create_event( get_req_data(), get_req_data_size(),
+    if ((event = create_event( get_req_data(), get_req_data_size(), req->attributes,
                                req->manual_reset, req->initial_state )))
     {
         reply->handle = alloc_handle( current->process, event, req->access,
Index: server/handle.c
===================================================================
RCS file: /home/wine/wine/server/handle.c,v
retrieving revision 1.40
diff -u -p -r1.40 handle.c
--- server/handle.c	27 Oct 2005 18:30:37 -0000	1.40
+++ server/handle.c	27 Oct 2005 19:37:16 -0000
@@ -525,7 +525,7 @@ obj_handle_t open_object( const struct n
                           const struct object_ops *ops, unsigned int access, unsigned int attr )
 {
     obj_handle_t handle = 0;
-    struct object *obj = find_object( namespace, name, len );
+    struct object *obj = find_object( namespace, name, len, attr );
     if (obj)
     {
         if (ops && obj->ops != ops)
Index: server/mailslot.c
===================================================================
RCS file: /home/wine/wine/server/mailslot.c,v
retrieving revision 1.10
diff -u -p -r1.10 mailslot.c
--- server/mailslot.c	27 Oct 2005 18:30:37 -0000	1.10
+++ server/mailslot.c	27 Oct 2005 19:37:16 -0000
@@ -213,8 +213,8 @@ static void mailslot_queue_async( struct
     fd_queue_async_timeout( fd, apc, user, iosb, type, count, timeout );
 }
 
-static struct mailslot *create_mailslot( const WCHAR *name, size_t len, int max_msgsize,
-                                         int read_timeout )
+static struct mailslot *create_mailslot( const WCHAR *name, size_t len, unsigned int attr,
+                                         int max_msgsize, int read_timeout )
 {
     struct mailslot *mailslot;
     int fds[2];
@@ -226,7 +226,7 @@ static struct mailslot *create_mailslot(
         return NULL;
     }
 
-    mailslot = create_named_object( sync_namespace, &mailslot_ops, name, len );
+    mailslot = create_named_object( sync_namespace, &mailslot_ops, name, len, attr );
     if (!mailslot)
         return NULL;
 
@@ -259,11 +259,11 @@ static struct mailslot *create_mailslot(
     return NULL;
 }
 
-static struct mailslot *open_mailslot( const WCHAR *name, size_t len )
+static struct mailslot *open_mailslot( const WCHAR *name, size_t len, unsigned int attr )
 {
     struct object *obj;
 
-    obj = find_object( sync_namespace, name, len );
+    obj = find_object( sync_namespace, name, len, attr );
     if (obj)
     {
         if (obj->ops == &mailslot_ops)
@@ -352,7 +352,7 @@ DECL_HANDLER(create_mailslot)
     struct mailslot *mailslot;
 
     reply->handle = 0;
-    mailslot = create_mailslot( get_req_data(), get_req_data_size(),
+    mailslot = create_mailslot( get_req_data(), get_req_data_size(), req->attributes,
                                 req->max_msgsize, req->read_timeout );
     if (mailslot)
     {
@@ -376,7 +376,7 @@ DECL_HANDLER(open_mailslot)
         return;
     }
 
-    mailslot = open_mailslot( get_req_data(), get_req_data_size() );
+    mailslot = open_mailslot( get_req_data(), get_req_data_size(), req->attributes );
     if (mailslot)
     {
         struct mail_writer *writer;
Index: server/mapping.c
===================================================================
RCS file: /home/wine/wine/server/mapping.c,v
retrieving revision 1.57
diff -u -p -r1.57 mapping.c
--- server/mapping.c	27 Oct 2005 18:30:37 -0000	1.57
+++ server/mapping.c	27 Oct 2005 19:37:16 -0000
@@ -270,15 +270,15 @@ inline static int get_file_size( struct 
     return 1;
 }
 
-static struct object *create_mapping( file_pos_t size, int protect, obj_handle_t handle,
-                                      const WCHAR *name, size_t len )
+static struct object *create_mapping( const WCHAR *name, size_t len, unsigned int attr,
+                                      file_pos_t size, int protect, obj_handle_t handle )
 {
     struct mapping *mapping;
     int access = 0;
 
     if (!page_mask) init_page_size();
 
-    if (!(mapping = create_named_object( sync_namespace, &mapping_ops, name, len )))
+    if (!(mapping = create_named_object( sync_namespace, &mapping_ops, name, len, attr )))
         return NULL;
     if (get_error() == STATUS_OBJECT_NAME_COLLISION)
         return &mapping->obj;  /* Nothing else to do */
@@ -377,8 +377,8 @@ DECL_HANDLER(create_mapping)
     file_pos_t size = ((file_pos_t)req->size_high << 32) | req->size_low;
 
     reply->handle = 0;
-    if ((obj = create_mapping( size, req->protect, req->file_handle,
-                               get_req_data(), get_req_data_size() )))
+    if ((obj = create_mapping( get_req_data(), get_req_data_size(), req->attributes,
+                               size, req->protect, req->file_handle )))
     {
         reply->handle = alloc_handle( current->process, obj, req->access,
                                       req->attributes & OBJ_INHERIT );
Index: server/mutex.c
===================================================================
RCS file: /home/wine/wine/server/mutex.c,v
retrieving revision 1.30
diff -u -p -r1.30 mutex.c
--- server/mutex.c	27 Oct 2005 18:30:37 -0000	1.30
+++ server/mutex.c	27 Oct 2005 19:37:16 -0000
@@ -62,11 +62,12 @@ static const struct object_ops mutex_ops
 };
 
 
-static struct mutex *create_mutex( const WCHAR *name, size_t len, int owned )
+static struct mutex *create_mutex( const WCHAR *name, size_t len, unsigned int attr,
+                                   int owned )
 {
     struct mutex *mutex;
 
-    if ((mutex = create_named_object( sync_namespace, &mutex_ops, name, len )))
+    if ((mutex = create_named_object( sync_namespace, &mutex_ops, name, len, attr )))
     {
         if (get_error() != STATUS_OBJECT_NAME_COLLISION)
         {
@@ -172,7 +173,8 @@ DECL_HANDLER(create_mutex)
     struct mutex *mutex;
 
     reply->handle = 0;
-    if ((mutex = create_mutex( get_req_data(), get_req_data_size(), req->owned )))
+    if ((mutex = create_mutex( get_req_data(), get_req_data_size(), req->attributes,
+                               req->owned )))
     {
         reply->handle = alloc_handle( current->process, mutex, req->access,
                                       req->attributes & OBJ_INHERIT );
Index: server/named_pipe.c
===================================================================
RCS file: /home/wine/wine/server/named_pipe.c,v
retrieving revision 1.49
diff -u -p -r1.49 named_pipe.c
--- server/named_pipe.c	27 Oct 2005 18:30:37 -0000	1.49
+++ server/named_pipe.c	27 Oct 2005 19:37:16 -0000
@@ -397,7 +397,7 @@ static int pipe_server_flush( struct fd 
 
         /* this kind of sux - 
            there's no unix way to be alerted when a pipe becomes empty */
-        server->event = create_event( NULL, 0, 0, 0 );
+        server->event = create_event( NULL, 0, 0, 0, 0 );
         if (!server->event)
             return 0;
         gettimeofday( &tv, NULL );
@@ -440,11 +440,11 @@ static int pipe_client_get_info( struct 
     return flags;
 }
 
-static struct named_pipe *create_named_pipe( const WCHAR *name, size_t len )
+static struct named_pipe *create_named_pipe( const WCHAR *name, size_t len, unsigned int attr )
 {
     struct named_pipe *pipe;
 
-    pipe = create_named_object( sync_namespace, &named_pipe_ops, name, len );
+    pipe = create_named_object( sync_namespace, &named_pipe_ops, name, len, attr );
     if (pipe)
     {
         if (get_error() != STATUS_OBJECT_NAME_COLLISION)
@@ -458,11 +458,11 @@ static struct named_pipe *create_named_p
     return pipe;
 }
 
-static struct named_pipe *open_named_pipe( const WCHAR *name, size_t len )
+static struct named_pipe *open_named_pipe( const WCHAR *name, size_t len, unsigned int attr )
 {
     struct object *obj;
 
-    if ((obj = find_object( sync_namespace, name, len )))
+    if ((obj = find_object( sync_namespace, name, len, attr )))
     {
         if (obj->ops == &named_pipe_ops) return (struct named_pipe *)obj;
         release_object( obj );
@@ -548,7 +548,7 @@ DECL_HANDLER(create_named_pipe)
     struct pipe_server *server;
 
     reply->handle = 0;
-    pipe = create_named_pipe( get_req_data(), get_req_data_size() );
+    pipe = create_named_pipe( get_req_data(), get_req_data_size(), req->attributes );
     if (!pipe)
         return;
 
@@ -598,7 +598,7 @@ DECL_HANDLER(open_named_pipe)
     struct named_pipe *pipe;
     int fds[2];
 
-    pipe = open_named_pipe( get_req_data(), get_req_data_size() );
+    pipe = open_named_pipe( get_req_data(), get_req_data_size(), req->attributes );
     if (!pipe)
     {
         set_error( STATUS_NO_SUCH_FILE );
@@ -697,7 +697,7 @@ DECL_HANDLER(wait_named_pipe)
     struct named_pipe *pipe;
     struct pipe_server *server;
 
-    if (!(pipe = open_named_pipe( get_req_data(), get_req_data_size() )))
+    if (!(pipe = open_named_pipe( get_req_data(), get_req_data_size(), OBJ_CASE_INSENSITIVE )))
     {
         set_error( STATUS_PIPE_NOT_AVAILABLE );
         return;
Index: server/object.c
===================================================================
RCS file: /home/wine/wine/server/object.c,v
retrieving revision 1.34
diff -u -p -r1.34 object.c
--- server/object.c	28 Sep 2005 12:04:51 -0000	1.34
+++ server/object.c	27 Oct 2005 19:37:16 -0000
@@ -157,14 +157,14 @@ void *alloc_object( const struct object_
 }
 
 void *create_named_object( struct namespace *namespace, const struct object_ops *ops,
-                           const WCHAR *name, size_t len )
+                           const WCHAR *name, size_t len, unsigned int attributes )
 {
     struct object *obj;
     struct object_name *name_ptr;
 
     if (!name || !len) return alloc_object( ops );
 
-    if ((obj = find_object( namespace, name, len )))
+    if ((obj = find_object( namespace, name, len, attributes )))
     {
         if (obj->ops != ops)
         {
@@ -225,7 +225,8 @@ void release_object( void *ptr )
 }
 
 /* find an object by its name; the refcount is incremented */
-struct object *find_object( const struct namespace *namespace, const WCHAR *name, size_t len )
+struct object *find_object( const struct namespace *namespace, const WCHAR *name, size_t len,
+                            unsigned int attributes )
 {
     const struct list *list, *p;
 
Index: server/object.h
===================================================================
RCS file: /home/wine/wine/server/object.h,v
retrieving revision 1.66
diff -u -p -r1.66 object.h
--- server/object.h	19 Aug 2005 14:01:43 -0000	1.66
+++ server/object.h	27 Oct 2005 19:37:16 -0000
@@ -94,13 +94,14 @@ extern void *alloc_object( const struct 
 extern const WCHAR *get_object_name( struct object *obj, size_t *len );
 extern void dump_object_name( struct object *obj );
 extern void *create_named_object( struct namespace *namespace, const struct object_ops *ops,
-                                  const WCHAR *name, size_t len );
+                                  const WCHAR *name, size_t len, unsigned int attributes );
 extern struct namespace *create_namespace( unsigned int hash_size, int case_sensitive );
 /* grab/release_object can take any pointer, but you better make sure */
 /* that the thing pointed to starts with a struct object... */
 extern struct object *grab_object( void *obj );
 extern void release_object( void *obj );
-extern struct object *find_object( const struct namespace *namespace, const WCHAR *name, size_t len );
+extern struct object *find_object( const struct namespace *namespace, const WCHAR *name, size_t len,
+                                   unsigned int attributes );
 extern int no_add_queue( struct object *obj, struct wait_queue_entry *entry );
 extern int no_satisfied( struct object *obj, struct thread *thread );
 extern int no_signal( struct object *obj, unsigned int access );
@@ -115,7 +116,7 @@ extern void dump_objects(void);
 
 struct event;
 
-extern struct event *create_event( const WCHAR *name, size_t len,
+extern struct event *create_event( const WCHAR *name, size_t len, unsigned int attr,
                                    int manual_reset, int initial_state );
 extern struct event *get_event_obj( struct process *process, obj_handle_t handle, unsigned int access );
 extern void pulse_event( struct event *event );
Index: server/process.c
===================================================================
RCS file: /home/wine/wine/server/process.c,v
retrieving revision 1.142
diff -u -p -r1.142 process.c
--- server/process.c	12 Oct 2005 21:10:52 -0000	1.142
+++ server/process.c	27 Oct 2005 19:37:16 -0000
@@ -993,7 +993,7 @@ DECL_HANDLER(init_process_done)
     generate_startup_debug_events( process, req->entry );
     set_process_startup_state( process, STARTUP_DONE );
 
-    if (req->gui) process->idle_event = create_event( NULL, 0, 1, 0 );
+    if (req->gui) process->idle_event = create_event( NULL, 0, 0, 1, 0 );
     if (current->suspend + process->suspend > 0) stop_thread( current );
     if (process->debugger) set_process_debug_flag( process, 1 );
 }
Index: server/semaphore.c
===================================================================
RCS file: /home/wine/wine/server/semaphore.c,v
retrieving revision 1.30
diff -u -p -r1.30 semaphore.c
--- server/semaphore.c	27 Oct 2005 18:30:37 -0000	1.30
+++ server/semaphore.c	27 Oct 2005 19:37:16 -0000
@@ -59,7 +59,7 @@ static const struct object_ops semaphore
 };
 
 
-static struct semaphore *create_semaphore( const WCHAR *name, size_t len,
+static struct semaphore *create_semaphore( const WCHAR *name, size_t len, unsigned int attr,
                                            unsigned int initial, unsigned int max )
 {
     struct semaphore *sem;
@@ -69,7 +69,7 @@ static struct semaphore *create_semaphor
         set_error( STATUS_INVALID_PARAMETER );
         return NULL;
     }
-    if ((sem = create_named_object( sync_namespace, &semaphore_ops, name, len )))
+    if ((sem = create_named_object( sync_namespace, &semaphore_ops, name, len, attr )))
     {
         if (get_error() != STATUS_OBJECT_NAME_COLLISION)
         {
@@ -147,7 +147,7 @@ DECL_HANDLER(create_semaphore)
     struct semaphore *sem;
 
     reply->handle = 0;
-    if ((sem = create_semaphore( get_req_data(), get_req_data_size(),
+    if ((sem = create_semaphore( get_req_data(), get_req_data_size(), req->attributes,
                                  req->initial, req->max )))
     {
         reply->handle = alloc_handle( current->process, sem, req->access,
Index: server/timer.c
===================================================================
RCS file: /home/wine/wine/server/timer.c,v
retrieving revision 1.29
diff -u -p -r1.29 timer.c
--- server/timer.c	27 Oct 2005 18:30:37 -0000	1.29
+++ server/timer.c	27 Oct 2005 19:37:16 -0000
@@ -68,11 +68,12 @@ static const struct object_ops timer_ops
 
 
 /* create a timer object */
-static struct timer *create_timer( const WCHAR *name, size_t len, int manual )
+static struct timer *create_timer( const WCHAR *name, size_t len, unsigned int attr,
+                                   int manual )
 {
     struct timer *timer;
 
-    if ((timer = create_named_object( sync_namespace, &timer_ops, name, len )))
+    if ((timer = create_named_object( sync_namespace, &timer_ops, name, len, attr )))
     {
         if (get_error() != STATUS_OBJECT_NAME_COLLISION)
         {
@@ -205,7 +206,7 @@ DECL_HANDLER(create_timer)
     struct timer *timer;
 
     reply->handle = 0;
-    if ((timer = create_timer( get_req_data(), get_req_data_size(), req->manual )))
+    if ((timer = create_timer( get_req_data(), get_req_data_size(), req->attributes, req->manual )))
     {
         reply->handle = alloc_handle( current->process, timer, req->access,
                                       req->attributes & OBJ_INHERIT );
Index: server/winstation.c
===================================================================
RCS file: /home/wine/wine/server/winstation.c,v
retrieving revision 1.11
diff -u -p -r1.11 winstation.c
--- server/winstation.c	27 Oct 2005 18:30:37 -0000	1.11
+++ server/winstation.c	27 Oct 2005 19:37:16 -0000
@@ -93,7 +93,8 @@ static struct winstation *create_winstat
         return NULL;
     }
 
-    if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name, len )))
+    if ((winstation = create_named_object( winstation_namespace, &winstation_ops, name, len,
+                                           OBJ_CASE_INSENSITIVE )))
     {
         if (get_error() != STATUS_OBJECT_NAME_COLLISION)
         {
@@ -182,7 +183,8 @@ static struct desktop *create_desktop( c
 
     if (!(full_name = build_desktop_name( name, len, winstation, &full_len ))) return NULL;
 
-    if ((desktop = create_named_object( winstation_namespace, &desktop_ops, full_name, full_len )))
+    if ((desktop = create_named_object( winstation_namespace, &desktop_ops, full_name, full_len,
+                                        OBJ_CASE_INSENSITIVE )))
     {
         if (get_error() != STATUS_OBJECT_NAME_COLLISION)
         {
@@ -323,7 +325,8 @@ DECL_HANDLER(open_winstation)
 {
     if (winstation_namespace)
         reply->handle = open_object( winstation_namespace, get_req_data(), get_req_data_size(),
-                                     &winstation_ops, req->access, (req->inherit) ? OBJ_INHERIT:0 );
+                                     &winstation_ops, req->access,
+                                     OBJ_CASE_INSENSITIVE | ((req->inherit) ? OBJ_INHERIT:0) );
     else
         set_error( STATUS_OBJECT_NAME_NOT_FOUND );
 }
@@ -398,7 +401,7 @@ DECL_HANDLER(open_desktop)
         {
             reply->handle = open_object( winstation_namespace, full_name, full_len,
                                          &desktop_ops, req->access,
-                                         (req->inherit) ? OBJ_INHERIT:0 );
+                                         OBJ_CASE_INSENSITIVE | ((req->inherit) ? OBJ_INHERIT:0) );
             free( full_name );
         }
         release_object( winstation );


More information about the wine-patches mailing list