2009/12/5 Bakul Shah <bakul+pl...@bitblocks.com>:
>       int newfd = fdfork(oldfd);

i'm not sure that there needs to be a new syscall to enable
this. a driver would be adequate.

here's one possibility:

the driver implements "buffered streams" - i.e. reads
are lazy, but previous reads can be re-read.

bind '#β4.8192' /mnt/bufstream to get a buffered, read-only stream of
fd 4, with an 8K buffer.

open /mnt/bufstream/data to get a new window
on the stream. if you read at an offset beyond
anything previously read, it triggers a read on the
underlying fd, which may block. if the offset isn't within the buffer size,
then the read returns -1; otherwise the read is satisfied
from the buffered data.

the underlying assumption is that the fd is stream-,
not message-oriented - as with tcp; message boundaries
are not preserved.


if you wanted it, an "fd join" driver could be simply
implemented in a similar way:

bind '#j4.5' /mnt/joined
open /mnt/joined/data to get a (read-only) fd that satisfies reads from fd 4
until eof, then fd 5.

both of these might make a fun exercise for a rainy day.

Reply via email to