ioctl
Allan Christian Long
acl3k at pine.cs.Virginia.EDU
Fri May 24 05:10:33 AEST 1991
In article <105737 at sgi.sgi.com> rpw3 at sgi.com (Rob Warnock) writes:
>In article <1991May22.161432.25064 at murdoch.acc.Virginia.EDU>
>acl3k at jade.cs.Virginia.EDU (Allan Christian Long) writes:
>+---------------
>| The problem is that the prototype for ioctl is
>| int ioctl (int fildes, int request, ...);
>| That says what the first and second parameters should be, but I need to
>| find out about the rest, which are dependent upon what request is. The
>| entry for FIONREAD in ioctl.h is
>| #define FIONREAD _IOR(f, 127, int) /* get # bytes to read */
>| I tried changing charToRead to an int, but that didn't help. I need
>| documentation for FIONREAD, more than what it says in the header file.
>+---------------
>
>The third arg for FIONREAD is the *address* of an integer, that is:
>
> int num_bytes_avail_to_read;
>
> err = ioctl(file_descriptor, FIONREAD, &num_bytes_avail_to_read);
I tried a call exactly like this, but I always got error 22 (invalid
argument).
[stuff about how # of bytes can change right after the ioctl call and
how you can use read() since it returns the number of bytes actually read]
If I were writing a program from scratch, this would probably be fine.
I may not have mentioned, tho, that what I'm doing is porting a tracker
library from SunOS to IRIX (a library that I didn't write). I COULD use
read, but it would require some rewiring of the library that would be
somewhat difficult. What I'd really like to have is a way to tell how
many bytes there are to be read without actually reading them.
Thanks to everyone who has responded. I'm still open to suggestions.
If I don't get any soon, I'll probably go ahead and rewrite part of the
library to use read() and/or select().
- Chris
A. Chris Long, Jr. acl3k at virginia.edu
If only we could overcome our tools...
More information about the Comp.sys.sgi
mailing list