tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

fun (not so much) with funopen



Hello,

As some of you might have noted, recently we changed the API/ABI of funopen(3)
from:

        FILE    *funopen(const void *cookie,
            int (*readf)(void *cookie, char *buf, int len),   
            int (*writef)(void *cookie, const char *buf, int len),
            fpos_t (*seekf)(void *cookie, fpos_t offs, int whence),

to:

        FILE    *funopen(const void *cookie,
            int (*readf)(void *cookie, char *buf, int len),   
            int (*writef)(void *cookie, const char *buf, int len),
            off_t (*seekf)(void *cookie, off_t offs, int whence),
            int (*closef)(void *cookie));
            int (*closef)(void *cookie));

This change broke both binary and source compatibility with the previous
version, but was necessary since fpos_t is an opaque type used only by
fgetpos(3) and fsetpos(3), and programs using funopen(3) resorted in
ugly games with its guts to make funopen(3) to work properly. It would
be nice if other BSD's followed suit if/when their fpos_t is not off_t.

Since this change is still fresh, I suggest that we go one step further and
change the signature to be more in accordance with the standard read(2) and
write(2) system calls:

        FILE    *funopen(const void *cookie,
            ssize_t (*readf)(void *cookie, void *buf, size_t len),   
            ssize_t (*writef)(void *cookie, const void *buf, size_t len),
            off_t (*seekf)(void *cookie, off_t offs, int whence),
            int (*closef)(void *cookie));
            int (*closef)(void *cookie));

The reason to do this, is so that we can make the internal stdio read and
write functions match better with the system calls they actually use.
I am planning use the standard rename process to maintain binary compatibility
with the previous version of the function...

What do you think?

The alternative would be to supply a funopen2() system call with the proposed
signature.

christos


Home | Main Index | Thread Index | Old Index