https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221331

Oleksandr Tymoshenko <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
          Component|Documentation               |Manual Pages
           Assignee|[email protected]             |[email protected]

WHR <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from WHR <[email protected]> ---
There was a case that unlink(2) may return EISDIR.

Function kern_unlinkat calls namei(9) to find the parent directory of the file;
it will return EISDIR if the requested path was '/'.

Since '/' isn't a real link (but '/.' and '/..'), it can't be unlinked anyways.

Test:

# cat unlink.c 
#include <unistd.h>
#include <stdio.h>

int main(int argc, char **argv) {
        if(argc != 2) {
                fprintf(stderr, "Usage: %s <path>\n", argv[0]);
                return -1;
        }
        if(unlink(argv[1]) < 0) {
                perror(argv[1]);
                return 1;
        }
        return 0;
}
# gcc -Wall -O1 unlink.c -o unlink
# ./unlink /etc/
/etc/: Operation not permitted
# ./unlink /.
/.: Operation not permitted
# ./unlink /
/: Is a directory

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to