Alexandre Julliard : server: Allow a device file to be mapped directly to a Unix device.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 21 07:24:23 CDT 2015


Module: wine
Branch: master
Commit: b414b93d5acc5629559f1e192de9034a833dda52
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b414b93d5acc5629559f1e192de9034a833dda52

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu May 21 17:18:08 2015 +0900

server: Allow a device file to be mapped directly to a Unix device.

---

 server/device.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/server/device.c b/server/device.c
index 6afa004..de11a9a 100644
--- a/server/device.c
+++ b/server/device.c
@@ -18,7 +18,11 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include "wine/port.h"
+
 #include <assert.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -120,6 +124,7 @@ struct device
 {
     struct object          obj;           /* object header */
     struct device_manager *manager;       /* manager for this device (or NULL if deleted) */
+    char                  *unix_path;     /* path to unix device if any */
     client_ptr_t           user_ptr;      /* opaque ptr for client side */
     struct list            entry;         /* entry in device manager list */
     struct list            files;         /* list of open files */
@@ -326,6 +331,7 @@ static void device_destroy( struct object *obj )
 
     assert( list_empty( &device->files ));
 
+    free( device->unix_path );
     if (device->manager) list_remove( &device->entry );
 }
 
@@ -340,7 +346,17 @@ static struct object *device_open_file( struct object *obj, unsigned int access,
         file->device = (struct device *)grab_object( device );
         list_init( &file->requests );
         list_add_tail( &device->files, &file->entry );
-        if (!(file->fd = alloc_pseudo_fd( &device_file_fd_ops, &file->obj, 0 )))
+        if (device->unix_path)
+        {
+            mode_t mode = 0666;
+            access = file->obj.ops->map_access( &file->obj, access );
+            file->fd = open_fd( NULL, device->unix_path, O_NONBLOCK | O_LARGEFILE,
+                                &mode, access, sharing, options );
+            if (file->fd) set_fd_user( file->fd, &device_file_fd_ops, &file->obj );
+        }
+        else file->fd = alloc_pseudo_fd( &device_file_fd_ops, &file->obj, 0 );
+
+        if (!file->fd)
         {
             release_object( file );
             file = NULL;
@@ -509,6 +525,7 @@ static struct device *create_device( struct directory *root, const struct unicod
         if (get_error() != STATUS_OBJECT_NAME_EXISTS)
         {
             /* initialize it if it didn't already exist */
+            device->unix_path = NULL;
             device->manager = manager;
             list_add_tail( &manager->devices, &device->entry );
             list_init( &device->files );




More information about the wine-cvs mailing list