Re: seekable pipes

Frederik Eaton <[email protected]> Mon, 20 Jun 2005 22:02:52 -0700
Newsgroups gmane.linux.file-systems,gmane.linux.userfs
Message-ID <[email protected]>
> >The stat type for <() files is "character special"
> 
> When I do it, it's "FIFO" (st_mode contains S_IFIFO).
> 
> >such files are usually seekable.
> 
> Really?  Character device special files are usually not in my experience: 
> terminals, tapes, serial ports.
> 
> >In any case, emacs and vim are cool.
> 
> You can edit a device special file?  Emacs gives me "file cannot be read" 
> on various pipe and character device special files I tried.  strace shows 
> that it does an lstat(), then gives up.

I stand corrected. Sorry. Thanks for verifying. I was testing on
/proc/self/fd/XX after opening it with 'exec', obviously not the same.
So this is a real problem then.

I guess the issue is that the shell has to insert a fifo at the end of
the pipeline in a <() construct in order to get something that can be
read from when written to?

Maybe the solution would be to introduce a <>() construct which uses a
seekable pipe instead of a fifo at the end? And that would suggest a
new version of "|" as well.

Or your suggestion of using an ioctl to change the file type... If a
seekable pipe were created by "upgrading" a regular one then perhaps
this could automatically change the file type at the slave to "regular
file" (from "fifo"). This way the shell wouldn't have to know about
seekable pipes, which would be good. But I can't see how to get around
the race condition where the slave side of the pipe might do a 'stat'
call before the master side has had a chance to change the file type.
It could be possible to have 'stat' block until the master has written
something, but that might introduce deadlocks in existing programs.

Frederik

-- 
http://ofb.net/~frederik/
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html