UDS: add support for FIONREAD

Change-Id: I50030012b408242a86f8c55017429acdadff49d1
This commit is contained in:
David van Moolenbroek 2013-10-04 18:41:21 +02:00 committed by Lionel Sambuc
parent 10a344c3fd
commit f3d8aa65ac
3 changed files with 26 additions and 14 deletions

View file

@ -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

View file

@ -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)
{

View file

@ -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 */