[klibc] [git patch] fstype + klibc enhancements

H. Peter Anvin hpa at zytor.com
Tue Aug 14 12:10:22 PDT 2007


maximilian attems wrote:
> 
> that directly leads to the next real trouble: ferror(3)
> due to empty _IO_file FILE; hack i don't see how it could be
> implemented!?!
> 
> feof should be possilbe with something along
> if (fgetc(stream) == EOF)
> 	return EOF;

No, that would be fatal if you're not at EOF.

> ferror(3) is used in busybox, lvm2, mdadm, toybox..

The only thing I can think of is #define ferror(x) 0

I don't know if ferror() is ever used for anything but displaying an
error message.

I honestly don't know of any way that this feof() and ferror() can be
implemented without actual file structures, which would be a massive
expansion in scope of klibc.

It doesn't automatically mean it's the wrong thing to do, just that if
we're going to go down that route, we should carefully measure the
impact.  It would, however, allow a proper fgets() as well as ungetc(),
the latter which is a requirement to support fscanf().

It probably means making stdio dependent on malloc(), but the malloc
implementation is quite lightweight, and it might be that this is the
right thing to do.

Overall, I want to see a working implementation, optimized for code
size, of buffered stdio and see how much the actual impact is before
either accepting or not accepting it.

	-hpa



More information about the klibc mailing list