Pass security attributes for DOSFS creation.

diff --git a/files/dos_fs.c b/files/dos_fs.c
index 39b270f..8af8ff1 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -705,7 +705,7 @@
 /**************************************************************************
  *         DOSFS_CreateCommPort
  */
-static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access, DWORD attributes)
+static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa)
 {
     HANDLE ret;
     char devname[40];
@@ -723,7 +723,7 @@
     SERVER_START_VAR_REQ( create_serial, len )
     {
         req->access  = access;
-        req->inherit = 0;  /*FIXME*/
+        req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
         req->attributes = attributes;
         req->sharing = FILE_SHARE_READ|FILE_SHARE_WRITE;
         memcpy( server_data_ptr(req), devname, len );
@@ -746,7 +746,7 @@
  * Open a DOS device. This might not map 1:1 into the UNIX device concept.
  * Returns 0 on failure.
  */
-HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes )
+HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa )
 {
     int i;
     const char *p;
@@ -765,7 +765,7 @@
 	    	/* got it */
 		if (!strcmp(DOSFS_Devices[i].name,"NUL"))
                     return FILE_CreateFile( "/dev/null", access,
-                                            FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
+                                            FILE_SHARE_READ|FILE_SHARE_WRITE, sa,
                                             OPEN_EXISTING, 0, 0, TRUE );
 		if (!strcmp(DOSFS_Devices[i].name,"CON")) {
 			HANDLE to_dup;
@@ -781,17 +781,19 @@
 				return 0;
 			}
 			if (!DuplicateHandle( GetCurrentProcess(), to_dup, GetCurrentProcess(),
-					      &handle, 0, FALSE, DUPLICATE_SAME_ACCESS ))
+					      &handle, 0, 
+					      sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle, 
+					      DUPLICATE_SAME_ACCESS ))
 			    handle = 0;
 			return handle;
 		}
 		if (!strcmp(DOSFS_Devices[i].name,"SCSIMGR$") ||
                     !strcmp(DOSFS_Devices[i].name,"HPSCAN"))
                 {
-                    return FILE_CreateDevice( i, access, NULL );
+                    return FILE_CreateDevice( i, access, sa );
 		}
 
-                if( (handle=DOSFS_CreateCommPort(DOSFS_Devices[i].name,access,attributes)) )
+                if( (handle=DOSFS_CreateCommPort(DOSFS_Devices[i].name,access,attributes,sa)) )
                     return handle;
                 FIXME("device open %s not supported (yet)\n",DOSFS_Devices[i].name);
     		return 0;
diff --git a/files/file.c b/files/file.c
index 8f5d3e4..49becca 100644
--- a/files/file.c
+++ b/files/file.c
@@ -488,7 +488,7 @@
     {
         TRACE("opening device '%s'\n", filename );
 
-        if (!(ret = DOSFS_OpenDevice( filename, access, attributes )))
+        if (!(ret = DOSFS_OpenDevice( filename, access, attributes, sa )))
         {
             /* Do not silence this please. It is a critical error. -MM */
             ERR("Couldn't open device '%s'!\n",filename);