Implemented ioctl(FIONREAD) on tty devices. Untested.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35960 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8ce4644fbd
commit
baaa0348a9
@ -17,6 +17,7 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -1739,6 +1740,26 @@ tty_ioctl(tty_cookie* cookie, uint32 op, void* buffer, size_t length)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
case FIONREAD:
|
||||
{
|
||||
int toRead = 0;
|
||||
|
||||
// release the mutex and grab a read lock
|
||||
locker.Unlock();
|
||||
ReaderLocker readLocker(cookie);
|
||||
|
||||
status_t status = readLocker.AcquireReader(0, 1);
|
||||
if (status >= B_OK)
|
||||
toRead = readLocker.AvailableBytes();
|
||||
else if(status != B_WOULD_BLOCK)
|
||||
return status;
|
||||
|
||||
if (user_memcpy(buffer, &toRead, sizeof(int)) != B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
case TCWAITEVENT: // BeOS (uint*)
|
||||
// wait for event (timeout if !NULL)
|
||||
case TCVTIME: // BeOS (bigtime_t*) set highrez VTIME
|
||||
|
Loading…
x
Reference in New Issue
Block a user