From: David van Moolenbroek Date: Fri, 4 Oct 2013 16:41:21 +0000 (+0200) Subject: UDS: add support for FIONREAD X-Git-Tag: v3.3.0~537 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/verify-sign/tz-link.htm?a=commitdiff_plain;h=f3d8aa65ac2f7efe84842830535a64a69bb0c8e0;p=minix.git UDS: add support for FIONREAD Change-Id: I50030012b408242a86f8c55017429acdadff49d1 --- diff --git a/drivers/uds/ioc_uds.c b/drivers/uds/ioc_uds.c index af1f3d6b7..b31bcd877 100644 --- a/drivers/uds/ioc_uds.c +++ b/drivers/uds/ioc_uds.c @@ -2,11 +2,6 @@ * 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" @@ -919,6 +914,20 @@ do_recvmsg(devminor_t minor, endpoint_t endpt, cp_grant_id_t grant) 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) @@ -1046,6 +1055,14 @@ uds_do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt, 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 diff --git a/drivers/uds/uds.c b/drivers/uds/uds.c index f3a79d58d..8283c5bae 100644 --- a/drivers/uds/uds.c +++ b/drivers/uds/uds.c @@ -2,20 +2,13 @@ * 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); @@ -244,7 +237,7 @@ uds_select(devminor_t minor, unsigned int ops, endpoint_t endpt) 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) { diff --git a/drivers/uds/uds.h b/drivers/uds/uds.h index 202259970..24fa88f97 100644 --- a/drivers/uds/uds.h +++ b/drivers/uds/uds.h @@ -197,6 +197,8 @@ int uds_do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt, 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 */