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

Oleksandr Tymoshenko <go...@freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |d...@freebsd.org
          Component|Documentation               |Manual Pages
           Assignee|d...@freebsd.org             |b...@freebsd.org

WHR <msl0000023...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msl0000023...@gmail.com

--- Comment #1 from WHR <msl0000023...@gmail.com> ---
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 on the CC list for the bug.
You are the assignee for the bug.
_______________________________________________
freebsd-doc@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-doc
To unsubscribe, send any mail to "freebsd-doc-unsubscr...@freebsd.org"

Reply via email to