On Tue, Jun 10, 2014 at 3:19 PM, Gracjan Polak <gracjanpolak@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@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net