Nicolas Williams wrote:
> On Fri, Dec 12, 2008 at 05:36:36PM -0600, Nicolas Williams wrote:
> > So, yes, open(2) of /dev/fd/N is as a dup(2) of N.
> 
> Also, every reference I can find says that open(2) of /dev/fd/N is
> supposed to be a dup(2) of file descriptor N, on Solaris, on Linux, on
> BSD, on Plan 9.
> 
> And, apparently also the convention is that open(2) of /proc/self/fd/N
> is NOT equivalent to dup(2) of fd N (it opens the same file, device,
> whatever, but does not keep the offset from fildes N).
> 
> % (read line <#((200)) ; print $line ; read line
> </proc/self/fd/9 ; print $line) <&9
> 1041
> 1001
> %
> 
> And that's supposed to be so for Linux and Solaris (haven't checked
> BSD).  An open(2) of /proc/self/fd/N is supposed to check file
> permissions too:
> 
> % pfexec chown root /tmp/foo
> % pfexec chmod 600 /tmp/foo
> % (read line <#((200)) ; print $line ; read line
> </proc/self/fd/9 ; print $line) <&9
> 1041
> ksh93: /proc/self/fd/9: cannot open [Permission denied]
> 1041
> %

Without looking at the matching code... does the standard (assuming
|openat()| passed the standards yet) about |cloned_fd =
openat(original_fd, ".", ...)| (the idea is to reference the current fd
as "." and hope it will open another fd to the same file) ?

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)

Reply via email to