* [Craig Allan Jeffree]
old = open(".");
chdir("foo);
delete stuff
fchdir(old);
delete more stuff
Isn't this potentially racey as well? I can see that fchdir(old); will
definately take you back to the parent of "foo" but how can you be sure
that the directories aren't moved around between step 1 and 2? You
could end up in a different "foo" to what you intended, I guess this is
a different issue - but it is still an issue isn't it?
I think the way rm already does that part is:
d=open("foo", 'r', O_DIRECTORY|O_NOFOLLOW);
fchdir(d);
If you don't do that, even in regular unix, a user can rename the dir
and exchange it with a symlink to / or whatever beneath your feet
between steps 1 and 2.
I've had other things to do in the easter, but I'll see if I can come up
with some translator stuff on top of this soon :)
Oystein