* Unix Domain Sockets Implementation (PF_UNIX, PF_LOCAL)
* This code handles ioctl(2) commands to implement the socket API.
* Some helper functions are also present.
- *
- * The entry points into this file are...
- *
- * uds_do_ioctl: process an IOCTL request.
- * uds_clear_fds: calls vfs_put_filp for undelivered FDs.
*/
#include "uds.h"
sizeof(struct msg_control));
}
+static int
+do_fionread(devminor_t minor, endpoint_t endpt, cp_grant_id_t grant)
+{
+ int rc;
+
+ rc = uds_perform_read(minor, NONE, GRANT_INVALID, UDS_BUF, 1);
+
+ /* What should we do on error? Just set to zero for now. */
+ if (rc < 0)
+ rc = 0;
+
+ return sys_safecopyto(endpt, grant, 0, (vir_bytes) &rc, sizeof(rc));
+}
+
int
uds_do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
cp_grant_id_t grant)
break;
+ case FIONREAD:
+ /*
+ * Get the number of bytes immediately available for reading.
+ */
+ rc = do_fionread(minor, endpt, grant);
+
+ break;
+
default:
/*
* The IOCTL command is not valid for /dev/uds -- this happens
* Unix Domain Sockets Implementation (PF_UNIX, PF_LOCAL)
* This code handles requests generated by operations on /dev/uds
*
- * The entry points into this file are...
- *
- * uds_unsuspend: resume a previously suspended socket call
- * main: driver main loop
- *
- * The interface to unix domain sockets is similar to the interface to network
+ * The interface to UNIX domain sockets is similar to the interface to network
* sockets. There is a character device (/dev/uds) and this server is a
* 'driver' for that device.
*/
#include "uds.h"
-static ssize_t uds_perform_read(devminor_t, endpoint_t, cp_grant_id_t, size_t,
- int);
static ssize_t uds_perform_write(devminor_t, endpoint_t, cp_grant_id_t, size_t,
int);
return ready_ops;
}
-static ssize_t
+ssize_t
uds_perform_read(devminor_t minor, endpoint_t endpt, cp_grant_id_t grant,
size_t size, int pretend)
{
cp_grant_id_t grant);
/* uds.c */
+ssize_t uds_perform_read(devminor_t minor, endpoint_t endpt,
+ cp_grant_id_t grant, size_t size, int pretend);
void uds_unsuspend(devminor_t minor);
/* vfs_uds.c */