[GRASS5] rmdir / NFS

Glynn Clements glynn at gclements.plus.com
Mon Feb 28 06:37:10 EST 2005


Radim Blazek wrote:

> What is the right way to delete a directory?

rmdir(). That will fail if the directory isn't empty.

> The problem appeares if a vector is deleted when it is in use via NFS by 
> another application. If a file is used when unlink is called, NFS 
> creates something like .nfs000500a800000038 in the directory and 
> consecutive rmdir() fails.

There isn't really a "right" way to delete a directory *and* its
contents, but typically you do the equivalent of "rm -rf". Note that
"rm -rf" will probably also fail in the situation which you describe.

In an extreme case, a process could be creating new files (etc) in a
directory faster than you can delete them.

Also, if someone can create a subdirectory which you don't own or have
write permission on, and you aren't root, you won't be able to delete
any files from that subdirectory, so you won't be able to delete the
subdirectory itself, and won't be able to delete its parent directory,
even if you do own that.

IOW, whichever method you use, you need to allow for the possibility
that the attempt to delete the directory will fail.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list