* io/ftwtest-sh: Add test case for relative path with /. at the end.

2003-01-12  Jim Meyering  <jim@meyering.net>

	* io/ftw.c (ftw_startup): When trying to stat the starting directory,
	use the basename if we've already chdir'd into its parent directory.

2003-01-12  Ulrich Drepper  <drepper@redhat.com>

	to change directory after call to ftw_dir.
This commit is contained in:
Ulrich Drepper 2003-01-12 22:54:47 +00:00
parent a5ce5fcf38
commit b2608c2203
3 changed files with 39 additions and 4 deletions

View File

@ -1,7 +1,16 @@
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* io/ftwtest-sh: Add test case for relative path with /. at the end.
2003-01-12 Jim Meyering <jim@meyering.net>
* io/ftw.c (ftw_startup): When trying to stat the starting directory,
use the basename if we've already chdir'd into its parent directory.
2003-01-12 Ulrich Drepper <drepper@redhat.com>
* io/ftw.c (process_entry): Use relative path when using chdir()
to change direcoty after call to ftw_dir.
to change directory after call to ftw_dir.
* io/ftwtest-sh: Add test for relative path argument to nftw()
with FTW_CHDIR option.

View File

@ -358,7 +358,7 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
}
else
if (__chdir ("..") < 0)
result = 1;
result = -1;
}
}
}
@ -584,9 +584,13 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
/* Get stat info for start directory. */
if (result == 0)
{
const char *name = ((data.flags & FTW_CHDIR)
? data.dirbuf + data.ftw.base
: data.dirbuf);
if (((flags & FTW_PHYS)
? LXSTAT (_STAT_VER, data.dirbuf, &st)
: XSTAT (_STAT_VER, data.dirbuf, &st)) < 0)
? LXSTAT (_STAT_VER, name, &st)
: XSTAT (_STAT_VER, name, &st)) < 0)
{
if (!(flags & FTW_PHYS)
&& errno == ENOENT

View File

@ -160,6 +160,28 @@ base = "ftwtest.d/foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tm
EOF
rm $testout
curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
cd "$tmp"
LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/. |
sort > $testout
cd "$curwd"
cat <<EOF | diff -u $testout - || exit 1
base = "ftwtest.d/", file = ".", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 0
base = "ftwtest.d/./", file = "bar", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
base = "ftwtest.d/./", file = "baz", flag = FTW_F, cwd = $tmpreal/ftwtest.d, level = 1
base = "ftwtest.d/./", file = "foo", flag = FTW_D, cwd = $tmpreal/ftwtest.d, level = 1
base = "ftwtest.d/./bar/", file = "xo", flag = FTW_F, cwd = $tmpreal/ftwtest.d/bar, level = 2
base = "ftwtest.d/./foo/", file = "lvl1", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo, level = 2
base = "ftwtest.d/./foo/lvl1/", file = "file@1", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
base = "ftwtest.d/./foo/lvl1/", file = "link@1", flag = FTW_SLN, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
base = "ftwtest.d/./foo/lvl1/", file = "lvl2", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1, level = 3
base = "ftwtest.d/./foo/lvl1/lvl2/", file = "file@2", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
base = "ftwtest.d/./foo/lvl1/lvl2/", file = "lvl3", flag = FTW_D, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2, level = 4
base = "ftwtest.d/./foo/lvl1/lvl2/lvl3/", file = "file@3", flag = FTW_F, cwd = $tmpreal/ftwtest.d/foo/lvl1/lvl2/lvl3, level = 5
EOF
rm $testout
LD_LIBRARY_PATH=$objpfx $ldso $testprogram --early-exit $tmpdir |
sort > $testout