[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ftw must *not* strip trailing slashes
From: |
Jim Meyering |
Subject: |
Re: ftw must *not* strip trailing slashes |
Date: |
Mon, 03 Feb 2003 00:15:44 +0100 |
Hi Uli,
Regarding this,
http://sources.redhat.com/ml/bug-glibc/2003-01/msg00074.html
you asked for more details.
POSIX's section 4.11 on Pathname Resolution says in part that
A pathname that contains at least one non-slash character and that ends
with one or more trailing slashes shall be resolved as if a single dot
character ('.') were appended to the pathname.
Here's the test program I described in the message listed above.
=============================
$ cat ftw-test.c
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ftw.h>
static int
cb (const char *file, const struct stat64 *sb, int file_type, struct FTW *info)
{
printf ("%s\n", file);
return 0;
}
int
main (int argc, char **argv)
{
int flags = FTW_PHYS | FTW_MOUNT | FTW_CHDIR;
int err;
if (argc < 2)
exit (2);
err = nftw64 (argv[1], cb, 30, flags);
exit (err);
}
=============================
When linking with the version of nftw64 from GNU libc, I get this output:
$ ./a.out slink/
slink
When linking with the patched version (the patch in the above message),
I get this:
$ ./a.out slink/
slink/
slink/x
I think the latter is more in line with the standard.
The reasoning is identical to that requiring `stat ("symlink-to-dir/", &sb)'
to dereference the symlink.
Jim
I wrote:
> Currently, ftw and nftw strip trailing slashes.
> Isn't that contrary to POSIX? In the section on pathname resolution,
> it says that a symlink to a directory that is specified with a trailing
> slash must be treated as if `.' were appended.
>
> Accordingly, these commands
>
> mkdir -p d/x
> ln -s d slink
> a.out slink/
>
> should produce output like this:
>
> slink/
> slink/x
...
pgp_EPN42VITp.pgp
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: ftw must *not* strip trailing slashes,
Jim Meyering <=