Make serial fd blocking mode depend on FILE_FLAG_OVERLAPPED.

diff --git a/server/protocol.def b/server/protocol.def
index e519beb..a7b7a2d 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -532,6 +532,7 @@
 #define FD_TYPE_DEFAULT    1
 #define FD_TYPE_CONSOLE    2
 #define FD_TYPE_OVERLAPPED 3
+#define FD_TYPE_TIMEOUT    4
 
 
 /* Set a file current position */
@@ -1299,6 +1300,7 @@
 @REQ(create_serial)
     unsigned int access;       /* wanted access rights */
     int          inherit;      /* inherit flag */
+    unsigned int attributes;   /* eg. FILE_FLAG_OVERLAPPED */
     unsigned int sharing;      /* sharing flags */
     VARARG(name,string);       /* file name */
 @REPLY
diff --git a/server/serial.c b/server/serial.c
index d6a1ea4..c16ccd7 100644
--- a/server/serial.c
+++ b/server/serial.c
@@ -44,6 +44,7 @@
 {
     struct object       obj;
     unsigned int        access;
+    unsigned int        attrib;
 
     /* timeout values */
     unsigned int        readinterval;
@@ -78,7 +79,7 @@
 
 /* SERIAL PORT functions */
 
-static struct serial *create_serial( const char *nameptr, size_t len, unsigned int access )
+static struct serial *create_serial( const char *nameptr, size_t len, unsigned int access, int attributes )
 {
     struct serial *serial;
     struct termios tios;
@@ -115,8 +116,14 @@
         return NULL;
     }
 
+    /* set the fd back to blocking if necessary */
+    if( ! (attributes & FILE_FLAG_OVERLAPPED) )
+       if(0>fcntl(fd, F_SETFL, 0))
+           perror("fcntl");
+
     if ((serial = alloc_object( &serial_ops, fd )))
     {
+        serial->attrib       = attributes;
         serial->access       = access;
         serial->readinterval = 0;
         serial->readmult     = 0;
@@ -160,6 +167,9 @@
 
 static int serial_get_info( struct object *obj, struct get_file_info_request *req )
 {
+    struct serial *serial = (struct serial *) obj;
+    assert( obj->ops == &serial_ops );
+
     if (req)
     {
         req->type        = FILE_TYPE_CHAR;
@@ -173,7 +183,11 @@
         req->index_low   = 0;
         req->serial      = 0;
     }
-    return FD_TYPE_DEFAULT;
+
+    if(serial->attrib & FILE_FLAG_OVERLAPPED)
+        return FD_TYPE_OVERLAPPED;
+
+    return FD_TYPE_TIMEOUT;
 }
 
 /* these function calculates the timeout for an async operation
@@ -202,7 +216,7 @@
     struct serial *serial;
 
     req->handle = 0;
-    if ((serial = create_serial( get_req_data(req), get_req_data_size(req), req->access )))
+    if ((serial = create_serial( get_req_data(req), get_req_data_size(req), req->access, req->attributes )))
     {
         req->handle = alloc_handle( current->process, serial, req->access, req->inherit );
         release_object( serial );
diff --git a/server/trace.c b/server/trace.c
index eeb323c..9ce6400 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1556,6 +1556,7 @@
 {
     fprintf( stderr, " access=%08x,", req->access );
     fprintf( stderr, " inherit=%d,", req->inherit );
+    fprintf( stderr, " attributes=%08x,", req->attributes );
     fprintf( stderr, " sharing=%08x,", req->sharing );
     fprintf( stderr, " name=" );
     cur_pos += dump_varargs_string( req );