On 14 September 2012 06:01, Roland Mainz <roland.ma...@nrubsig.org> wrote:
> Hi!
>
> ----
>
> Attached (as "astksh_chroot_cd_devfd_cd_f_20120911_001.diff.txt") is a
> patch which fixes two issues with "cd":
> 1. $ cd /dev/fd/$fd # doesn't work in chroot'ed environments when
> /dev/fd is not mounted (thanks to CERN staff for reporting this).
> 2. POSIX does not mandate _any_ paths. Since doing a "cd" relative to
> a directory fd has become very popular the request was made to add an
> alternative to using /dev/fd which is more or less acceptable for the
> POSIX people. Based on that and a few discussions I added the option
> -f to cd that a directory descriptor can be passed and the path given
> is relative to that file descriptor.
>
> Notes:
> - The code introduces a new function called |pathdevfd2relpathfd()| in
> libast which can extract the fd number from a /dev/fd/$fd path (even
> nested)
> - If files or directories are opened relative to /dev/fd/$fd/$path
> |sfopen()|/|sfopenat()| will now bypass the /dev/fd filesystem
> completely (which gives a nice performance boost). The only exception
> is that this can *NOT* be done for a plain /dev/fd/$fd, e.g.
> /dev/fd/15. The problem is that there is AFAIK no way to open a file
> from a file descriptor without using the /dev/fd filesystem or using
> |dup()| ... but |dup()| rules itself out because the resulting
> "cloned" fd still shares attributes like the current seek position
> with the original fd...

Patch looks good to me. Testing is in progress, from an initial glance
it seems to work in chroot.

Lionel
_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to