help-hurd
[Top][All Lists]
Advanced

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

Re: recursive commands


From: Oystein Viggen
Subject: Re: recursive commands
Date: Tue, 02 Apr 2002 15:37:05 +0200
User-agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.1 (Capitol Reef, i386-debian-linux)

* [Craig Allan Jeffree] 

> This would just keep going back a step.  "foo" could be changed at any
> point between its discovery and the open syscall.  Obviously the user
> could look at the directory listing then run "rm -r foo", but in the
> time it takes for them to type the command someone else could change the
> directory tree - that is always going to be racey.  But internally to rm
> how can the discovery of a directory (from the directory recurse not the
> command line) be kept atomic with the entering of that directory?

O_NOFOLLOW should take care of directory symlinks, and opening "." should
take care of the tree being moved.  The worst think I can think of then
is creating new files or directories to make the unlinking of the
directories fail, but this is not really a problem, as it has no adverse
effect.

The discovery of the directory is not atomic with entering the
directory, but the trick is in the open(), which is an atomic
operation.  If the directory is removed or replaced by a symlink, open
will fail, and you can handle the error.  If not, open will succeed, and
you are guaranteed that the fchdir will also put you in the correct
directory no matter what somebody does to the directory between the open
and the fchdir.

Oystein
-- 
This message was generated by a horde of attack elephants armed with PRNGs.



reply via email to

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