Inconsistent/potentially incorrect behavior with relative lookups via chdir(2) on UFS/ZFS

Garrett Cooper yanegomi at gmail.com
Thu Nov 1 22:25:06 UTC 2012


Hi,
    Just doing some interop testing on UFS/ZFS to develop a baseline for
filesystem behavior, and I noticed some inconsistencies with the ENOENT
requirement in chdir(2) when dealing with relative ".." paths (dot-dot
lookups). In particular...
    1. I would have expected chdir('.') to have failed in UFS/ZFS with
ENOENT if '.' wasn't present, but it didn't.
    2. I would have expected chdir('..') to have failed in ZFS with ENOENT
if '..' wasn't present, but it didn't.
    Sidenote: python doesn't do any special handling with os.chdir, per
Modules/posixmodule.c (I checked).
    The full test I ran is included below.
Thoughts?
Thanks,
-Garrett

# uname -a
FreeBSD forza.west.isilon.com 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0
r240770: Thu Sep 20 19:28:45 PDT 2012
gcooper at forza.west.isilon.com:/usr/obj/usr/src/sys/FORZA
amd64

UFS:

# (set -x; rm -Rf *; for mc in '' 1; do export MUSICAL_CHAIRS=$mc; for d in
'' parent/child; do export BASEDIR=$d; python ~gcooper/pull_rug.py; env
CHROOT=1 python ~gcooper/pull_rug.py; done; done)
+ cd /tmp/foo/bar/baz/
+ rm -Rf child parent
+ for mc in ''\'''\''' 1
+ export MUSICAL_CHAIRS=
+ MUSICAL_CHAIRS=
+ for d in ''\'''\''' parent/child
+ export BASEDIR=
+ BASEDIR=
+ python /home/gcooper/pull_rug.py
did not fail with chdir(.)
cwd after is indeterminate
+ env CHROOT=1 python /home/gcooper/pull_rug.py
did not fail with chdir(.)
cwd after is indeterminate
+ for d in ''\'''\''' parent/child
+ export BASEDIR=parent/child
+ BASEDIR=parent/child
+ python /home/gcooper/pull_rug.py
did not fail with chdir(.)
cwd after is indeterminate
+ env CHROOT=1 python /home/gcooper/pull_rug.py
did not fail with chdir(.)
cwd after is indeterminate
+ for mc in ''\'''\''' 1
+ export MUSICAL_CHAIRS=1
+ MUSICAL_CHAIRS=1
+ for d in ''\'''\''' parent/child
+ export BASEDIR=
+ BASEDIR=
+ python /home/gcooper/pull_rug.py
[parent,before] inode is: 9985
[parent,after] inode is: 9988
[child] inode from fstat is: 9985
[child] inode from stat is: 9988
did not fail with chdir(.)
cwd after is indeterminate
+ env CHROOT=1 python /home/gcooper/pull_rug.py
[parent,before] inode is: 9989
[parent,after] inode is: 9985
[child] inode from fstat is: 4
did not fail with chdir(.)
cwd after is indeterminate
+ for d in ''\'''\''' parent/child
+ export BASEDIR=parent/child
+ BASEDIR=parent/child
+ python /home/gcooper/pull_rug.py
[parent,before] inode is: 5
[parent,after] inode is: 8
[child] inode from fstat is: 5
[child] inode from stat is: 8
did not fail with chdir(.)
cwd after is indeterminate
+ env CHROOT=1 python /home/gcooper/pull_rug.py
[parent,before] inode is: 10
[parent,after] inode is: 6
[child] inode from fstat is: 4
did not fail with chdir(.)
cwd after is indeterminate

ZFS:

# (set -x; rm -Rf *; for mc in '' 1; do export MUSICAL_CHAIRS=$mc; for d in
'' parent/child; do export BASEDIR=$d; python ~gcooper/pull_rug.py; env
CHROOT=1 python ~gcooper/pull_rug.py; done; done)
+ cd /root/foo/bar/baz/
+ rm -Rf child parent
+ for mc in ''\'''\''' 1
+ export MUSICAL_CHAIRS=
+ MUSICAL_CHAIRS=
+ for d in ''\'''\''' parent/child
+ export BASEDIR=
+ BASEDIR=
+ python /home/gcooper/pull_rug.py
did not fail with chdir(.)
did not fail with chdir(../..)
cwd after is /root/foo/bar
+ env CHROOT=1 python /home/gcooper/pull_rug.py
did not fail with chdir(.)
did not fail with chdir(../..)
cwd after is /
+ for d in ''\'''\''' parent/child
+ export BASEDIR=parent/child
+ BASEDIR=parent/child
+ python /home/gcooper/pull_rug.py
did not fail with chdir(.)
cwd after is indeterminate
+ env CHROOT=1 python /home/gcooper/pull_rug.py
did not fail with chdir(.)
cwd after is indeterminate
+ for mc in ''\'''\''' 1
+ export MUSICAL_CHAIRS=1
+ MUSICAL_CHAIRS=1
+ for d in ''\'''\''' parent/child
+ export BASEDIR=
+ BASEDIR=
+ python /home/gcooper/pull_rug.py
[parent,before] inode is: 3688787
[parent,after] inode is: 3688789
[child] inode from fstat is: 3688787
[child] inode from stat is: 3688789
did not fail with chdir(.)
did not fail with chdir(../..)
cwd after is /root/foo/bar
+ env CHROOT=1 python /home/gcooper/pull_rug.py
[parent,before] inode is: 3688790
[parent,after] inode is: 3688792
[child] inode from fstat is: 4
did not fail with chdir(.)
did not fail with chdir(../..)
cwd after is /
+ for d in ''\'''\''' parent/child
+ export BASEDIR=parent/child
+ BASEDIR=parent/child
+ python /home/gcooper/pull_rug.py
[parent,before] inode is: 3688794
[parent,after] inode is: 3688797
[child] inode from fstat is: 3688794
[child] inode from stat is: 3688797
did not fail with chdir(.)
cwd after is indeterminate
+ env CHROOT=1 python /home/gcooper/pull_rug.py
[parent,before] inode is: 3688799
[parent,after] inode is: 3688802
[child] inode from fstat is: 4
did not fail with chdir(.)
cwd after is indeterminate
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pull_rug.py
Type: application/octet-stream
Size: 2117 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20121101/8412d8b0/attachment.obj>


More information about the freebsd-fs mailing list