Date:        Tue, 1 Feb 2022 18:27:24 +0000
    From:        "Martin Husemann" <mar...@netbsd.org>
    Message-ID:  <20220201182724.90f82f...@cvs.netbsd.org>

  | Test mkdir(2) with one or more trailing slashes - this currently fails
  | for v7fs.

As it should I think, trailing slashes are not simply deleted in v7fs.

If you do

        mkdir /path/to/dir/

in a v7 fs, then you're guaranteed (unless some other error happens earlier)
either ENOENT if /path/to/dir doesn't already exist, ENOTDIR if it it does
but isn't a directory, or EEXIST if it exists and is a directory.   The thing
to be created always follows the final slash, everything prior to that is
path to look up, and must all exist and be directories (with appropriate
permissions, etc).In this case the "thing" is "" which is (kind of) an
alias for "." (without ever actually looking up ".").   It can never not
exist if the preceding path all exists.

If this was ever changed, it would not truly be a v7fs any more.

kre

ps: I never understood the fascination with always writing directory names
with a trailing / - it seems to come largely from filename completion
where the '/' is added if the name found is a directory, so you can just
go on typing anything that is to follow in the path (but could easily be
removed again if no more components are added - just isn't) but it makes
no sense for this to have happened with mkdir, filename completion can
only find files that exist, not ones to be created, so it couldn't be that
which adds the '/' after the directory name - some human must be doing
that, but why?  It seems to be to be just meaningless extra unneeded typing.


Reply via email to