This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Toward a satisfactory showmanyc


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]