[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dirfd on mingw
From: |
Bruno Haible |
Subject: |
Re: dirfd on mingw |
Date: |
Fri, 29 Apr 2011 01:03:50 +0200 |
User-agent: |
KMail/1.9.9 |
Eric Blake wrote:
> perhaps the dummy fd for fchdir _should_ open a directory HANDLE, as
> windows guarantees that a directory with an open handle is less likely
> to be renamed out from under us
Yes, you can control this behaviour through the FILE_SHARE_DELETE bit of the
ShareMode parameter of CreateFile().
> the premise of storing the
> directory name in the fchdir shadow array is that the name is still
> likely to be valid the next time we need to get back to that directory
> (if other processes can rename the directory behind our back, we're
> liable to act on the wrong directory).
On newer versions of Windows, we could get away without this "you must not
rename the directory" constraint, by using the HANDLE -> file name
mapping implemented by GetFileInformationByHandleEx with FileNameInfo
parameter.
<http://msdn.microsoft.com/en-us/library/aa364953%28v=vs.85%29.aspx>
<http://msdn.microsoft.com/en-us/library/aa364388%28v=vs.85%29.aspx>
> > Ad 2): ...
> > Or you can make a mapping DIR * -> int , through a simple association
> > list.
> > (There won't be many DIR * objects open on average.)
>
> I was envisioning the reverse - maintain the shadow list of known fds
> associated with a DIR. The DIR*->int lookup for dirfd is then a matter
> of walking the shadow fd list of all known directory dummy fds
Either one should work, association list or array. The person who writes the
code will decide.
Bruno
--
In memoriam Heinz Droßel <http://en.wikipedia.org/wiki/Heinz_Drossel>