bug-gnulib
[Top][All Lists]
Advanced

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

Re: coreutils-6.0 on platforms without fchdir


From: Paul Eggert
Subject: Re: coreutils-6.0 on platforms without fchdir
Date: Fri, 01 Sep 2006 14:47:43 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Thanks for working on it, but I think we'd prefer a solution that
doesn't require the maintainer having to think about obsolete
platforms that lack fchdir.

How about the following idea instead?  On platforms lacking fchdir,
put a wrapper around 'open' so that we can keep track of which file
descriptors correspond to directories.  The 'open' wrapper puts the
name of the opened directory into a hash table.  (The name must be
absolute, so 'open' may need to do the equivalent of pwd.  This could
be further optimized by wrapping 'chdir' and 'close', though I'm not
sure it's worth the trouble.  We  might also get away with using
O_DIRECTORY to decide whether to put an entry in the hash table.)

Once this wrapper is in place, we can implement 'fchdir' as a
function that looks up the file descriptor in the table, and invokes
chdir on the resulting file name.  (The code also must check that the
file descriptor is still open, if 'close' is not wrapped.)

The emulation wouldn't be perfect, but it would be good enough, and it
could be isolated into one small region of code (presumably a new
Gnulib module 'fchdir'), such that we wouldn't need to worry about
this problem in the rest of coreutils.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]