Toward a satisfactory showmanyc

Paolo Carlini pcarlini@unitus.it
Thu Mar 20 19:51:00 GMT 2003


Hi Nathan, hi everyone,

and sorry for late following up to your interesting messages.

 > #include <sys/ioctl.h>
 >
 > int i = 0;
 > ::ioctl(fd, FIONREAD, &i)
 >
 > on any file descriptor (pipe, socket, file, character device) to see
 > how much is available to read.
 >
 > Note that ioctl is not part of POSIX, and that it is often found at
 > <ioctl.h> instead. Also, for files bigger than 2G it reports silly
 > results.

and then:

> On many targets it doesn't work on regular files at all.  On some
> targets (apparently including FreeBSD and Solarix 9) FIONREAD is 
> defined in <sys/filio.h>.  See also 

Therefore, what about this updated strategy for showmanyc (easily
extensible to large file support, it seems to me):

1- fstat on files.
2- If fstat fails, ioctl for everything else.

Of course this implies autoconf machinery for <sys/ioctl.h>
vs <ioctl.h> and also for FIONREAD in <sys/filio.h>
(I had hoped for fewer different possibilites :(

If we agree by and large on this sketch, I can work on it during the
next few days.

Thanks,
Paolo.




More information about the Libstdc++ mailing list