Bug 212385 - path_resolution(7): "a pathname with a trailing '/' is equivalent to the pathname obtained by appending '.' to it" - this is wrong
Summary: path_resolution(7): "a pathname with a trailing '/' is equivalent to the path...
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-22 11:27 UTC by Askar Safin
Modified: 2021-08-08 23:26 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Askar Safin 2021-03-22 11:27:04 UTC
path_resolution(7) says:

Trailing slashes
       If a pathname ends in a '/', that forces resolution of the
       preceding component as in Step 2: it has to exist and resolve to
       a directory.  Otherwise, a trailing '/' is ignored.  (Or,
       equivalently, a pathname with a trailing '/' is equivalent to the
       pathname obtained by appending '.' to it.)

It seems the whole paragraph is wrong, at least for "mkdir" function. The following code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
int
main ()
{
printf("%d\n", mkdir("no-ex/", 0777));
printf("%d\n", mkdir("no-ex-2/.", 0777));
}

prints "0\n-1\n" (assuming both no-ex and no-ex-2 do not exist). Linux 4.19.0, glibc 2.24
Comment 1 Michael Kerrisk 2021-08-08 23:05:57 UTC
Hello Askar. Thanks for the report. Yes, the text is a bit off.

The text in POSIX.1-2018 Section 4.13 ("Pathname Resolution")
is helpful in pointing to a better wording.

How about the following as a replacement text:

       If a pathname ends in a '/', that forces resolution of the
       preceding component as in Step 2: the component preceding the
       slash either exists and resolves to a directory of it names a
       directory that is to be created immediately after the
       pathname is resolved.  Otherwise, a trailing '/' is ignored.

I'm closing this bug report for now. Please reopen if you think something still needs fixing.

Note You need to log in before you can comment on or make changes to this bug.