System.Directory.removeDirectoryRecursive and symlinks

Brandon Allbery allbery.b at gmail.com
Tue Jun 10 20:24:41 UTC 2014


On Tue, Jun 10, 2014 at 3:19 PM, Gracjan Polak <gracjanpolak at gmail.com>
wrote:

> Easiest would be to removeLink, if that fails due to directory then empty
> directory and then removeDirectory, but unlink man page says:
>
> [EPERM] The named file is a directory and the effective user ID of the
> process is not the super-user.
>
> So unlink seems to sometimes be able to unlink directories. What happens to
>

unlink(2) can't unlink directories except as root, plus you have to follow
certain specific rules. rmdir(2) can. This is a historical thing.

(You must manually unlink(2) the '.' and '..' entries along with everything
else in the directory before you can unlink(2) the directory itself. except
on systems where this functionality was completely blocked in order to make
you use rmdir(2). This behavior is how directories worked in 7th research
edition and earlier, and AT&T System III; the syscalls were added primarily
for the benefit of NFS so that directory creation/removal would be atomic
and not involve root permissions vs. root squashing.)

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140610/20a441bf/attachment.html>


More information about the Libraries mailing list