Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Nov 2019 09:17:22 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 221331] [PATCH] update for unlink(2) manpage
Message-ID:  <bug-221331-227-BShtmNe3Io@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-221331-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-221331-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D221331

Oleksandr Tymoshenko <gonzo@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doc@FreeBSD.org
          Component|Documentation               |Manual Pages
           Assignee|doc@FreeBSD.org             |bugs@FreeBSD.org

WHR <msl0000023508@gmail.com> changed:

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

--- Comment #1 from WHR <msl0000023508@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 f=
ile;
it will return EISDIR if the requested path was '/'.

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

Test:

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

int main(int argc, char **argv) {
        if(argc !=3D 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

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-221331-227-BShtmNe3Io>