--- sourceforge.net/trunk/rdesktop/rdpdr.c 2004/04/16 11:28:34 657 +++ sourceforge.net/trunk/rdesktop/rdpdr.c 2004/04/19 09:21:25 674 @@ -38,6 +38,7 @@ #include #include /* opendir, closedir, readdir */ #include +#include #include "rdesktop.h" #define IRP_MJ_CREATE 0x00 @@ -112,7 +113,7 @@ } } -BOOL +static BOOL rdpdr_handle_ok(int device, int handle) { switch (g_rdpdr_device[device].device_type) @@ -133,7 +134,7 @@ } /* Add a new io request to the table containing pending io requests so it won't block rdesktop */ -BOOL +static BOOL add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length, DEVICE_FNS * fns, uint32 total_timeout, uint32 interval_timeout, uint8 * buffer, uint32 offset) @@ -179,7 +180,7 @@ return True; } -void +static void rdpdr_send_connect(void) { uint8 magic[4] = "rDCC"; @@ -195,7 +196,7 @@ } -void +static void rdpdr_send_name(void) { uint8 magic[4] = "rDNC"; @@ -220,7 +221,7 @@ } /* Returns the size of the payload of the announce packet */ -int +static int announcedata_size() { int size, i; @@ -247,7 +248,7 @@ return size; } -void +static void rdpdr_send_available(void) { @@ -305,7 +306,7 @@ channel_send(s, rdpdr_channel); } -void +static void rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer, uint32 length) { @@ -658,6 +659,25 @@ result = buffer_len = out.p - out.data; break; + + case IRP_MJ_LOCK_CONTROL: + + if (g_rdpdr_device[device].device_type != DEVICE_TYPE_DISK) + { + status = STATUS_INVALID_HANDLE; + break; + } + + in_uint32_le(s, info_level); + + out.data = out.p = buffer; + out.size = sizeof(buffer); + /* FIXME: Perhaps consider actually *do* + something here :-) */ + status = STATUS_SUCCESS; + result = buffer_len = out.p - out.data; + break; + default: unimpl("IRP major=0x%x minor=0x%x\n", major, minor); break; @@ -672,7 +692,7 @@ buffer = NULL; } -void +static void rdpdr_send_clientcapabilty(void) { uint8 magic[4] = "rDPC"; @@ -790,6 +810,7 @@ { uint32 select_timeout = 0; // Timeout value to be used for select() (in millisecons). struct async_iorequest *iorq; + char c; iorq = g_iorequest; while (iorq != NULL) @@ -799,8 +820,16 @@ switch (iorq->major) { case IRP_MJ_READ: + /* Is this FD valid? FDs will + be invalid when + reconnecting. FIXME: Real + support for reconnects. */ + + if ((read(iorq->fd, &c, 0) != 0) && (errno == EBADF)) + break; FD_SET(iorq->fd, rfds); + *n = MAX(*n, iorq->fd); // Check if io request timeout is smaller than current (but not 0). if (iorq->timeout @@ -814,14 +843,20 @@ tv->tv_usec = (select_timeout % 1000) * 1000; *timeout = True; } + break; case IRP_MJ_WRITE: + /* FD still valid? See above. */ + if ((write(iorq->fd, &c, 0) != 0) && (errno == EBADF)) + break; + FD_SET(iorq->fd, wfds); + *n = MAX(*n, iorq->fd); break; } - *n = MAX(*n, iorq->fd); + } iorq = iorq->next;