MFC r272057,r272083,r272084,r272087,r274016:

r272057:

  Import pjdfstest from ^/vendor/pjdfstest/abf03c3a47745d4521b0e4aa141317553ca48f91

  - Remove tools/regression/pjdfstest
  - Add upgrade directions for contrib/pjdfstest
  - Add a note to UPDATING for the move (the reachover Makefiles are coming
    soon)

  Functional differences:
  - ftruncate testcases are added from upstream (github)

  Non-functional differences:
  - The copyright for the project has been updated to 2012
  - pjd's contact information has been updated

  Discussed with: -testing, jmmv, pjd
  Sponsored by: EMC / Isilon Storage Division

r272083:

  Expect ELOOP on Darwin/Linux with "O_NOFOLLOW was specified and the target is a
  symbolic link" case. Assume EMLINK on the rest of the OSes (FreeBSD, Solaris,
  etc)

  Sponsored by: EMC / Isilon Storage Division

r272084:

  Fix the executed testplan count

  Sponsored by: EMC / Isilon Storage Division

r272087:

  Increase the memory disk size in the following testcases to avoid mount
  failures, which would cause cascade failures in the rest of the test
  run:

  link/15.t, open/19.t, mkdir/11.t, mkfifo/11.t, symlink/11.t

  Fail quickly in all of the testcases if mdconfig, mount, umount, etc
  fails to avoid issues similar to this in the future

  Submitted by: Casey Peel <cpeel@isilon.com>
  Sponsored by: EMC / Isilon Storage Division

r274016:

  Integrate pjdfstest test suite execution into kyua

  pjdfstest execution is opt-in and must be done as root due to some of the
  assumptions made by the test suite and lack of error checking in the non-root
  case

  A description of how to execute pjdfstest with kyua is provided in
  share/pjdfstest/README

  Phabric: D824 (an earlier prototype patch)
  Relnotes: yes
  Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2014-12-05 11:44:18 +00:00
parent f905245087
commit 95b78c8f79
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/10/; revision=275504
255 changed files with 11320 additions and 5 deletions

View File

@ -16,6 +16,11 @@ from older versions of FreeBSD, try WITHOUT_CLANG to bootstrap to the tip of
stable/10, and then rebuild without this option. The bootstrap process from
older version of current is a bit fragile.
20141205:
pjdfstest has been integrated into kyua as an opt-in test suite.
Please see share/doc/pjdfstest/README for a more details on how to
execute it.
20141118:
10.1-RELEASE.

View File

@ -0,0 +1,25 @@
$FreeBSD$
This document contains a collection of notes specific to the import
of pjdfstest into head. These notes are built on the instructions in
the FreeBSD Subversion Primer that detail how to deal with vendor
branches and you are supposed to follow those:
http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html
The pjdfstest source code is hosted on GitHub:
https://github.com/pjd/pjdfstest
and is imported into the pjdfstest vendor branch (see base/vendor/pjdfstest/).
To merge the vendor branch into head do something like this:
cd .../base/head/contrib/pjdfstest
svn merge --accept=postpone \
svn+ssh://svn.freebsd.org/base/vendor/pjdfstest/dist .
and resolve any conflicts that may arise at this point.
Lastly, with the list of old and new files in this import, make sure
to update the reachover Makefiles accordingly.

27
contrib/pjdfstest/LICENSE Normal file
View File

@ -0,0 +1,27 @@
$FreeBSD: head/tools/regression/pjdfstest/LICENSE 211354 2010-08-15 21:29:03Z pjd $
License for all regression tests available with pjdfstest:
Copyright (c) 2006-2012 Pawel Jakub Dawidek <pawel@dawidek.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

View File

@ -0,0 +1,26 @@
# $FreeBSD$
PROG= pjdfstest
${PROG}: ${PROG}.c
@OSTYPE=`uname`; \
CFLAGS=-D__OS_$${OSTYPE}__; \
if [ $$OSTYPE = "FreeBSD" ]; then \
CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_FCHFLAGS -DHAS_CHFLAGSAT -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL -DHAS_BINDAT -DHAS_CONNECTAT -DHAS_LPATHCONF"; \
elif [ $$OSTYPE = "SunOS" ]; then \
CFLAGS="$$CFLAGS -DHAS_TRUNCATE64 -DHAS_STAT64"; \
CFLAGS="$$CFLAGS -lsocket"; \
elif [ $$OSTYPE = "Darwin" ]; then \
CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS"; \
elif [ $$OSTYPE == "Linux" ]; then \
CFLAGS="$$CFLAGS -D_GNU_SOURCE"; \
else \
echo "Unsupported operating system: ${OSTYPE}."; \
exit 1; \
fi; \
cmd="gcc -Wall $$CFLAGS ${PROG}.c -o ${PROG}"; \
echo $$cmd; \
$$cmd
clean:
rm -f ${PROG}

22
contrib/pjdfstest/README Normal file
View File

@ -0,0 +1,22 @@
$FreeBSD: head/tools/regression/pjdfstest/README 211354 2010-08-15 21:29:03Z pjd $
Few notes on how to use pjdfstest in short steps:
# cd pjdfstest
# vi tests/conf
Change 'fs' to file system type you want to test (UFS or ZFS).
# vi Makefile
You need to manually tweak few things by editing CFLAGS lines
at the top of the file.
# make
It will compile pjdfstest utility which is used by regression tests.
# cd /path/to/file/system/you/want/to/test/
# prove -r /path/to/pjdfstest/tests
That's all. Enjoy.
Currently supported operating systems: FreeBSD, Solaris.
Currently supported file system types: UFS, ZFS.
--
Pawel Jakub Dawidek <pawel@dawidek.net>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,178 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/00.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags changes flags"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:UFS)
allflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
userflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE"
systemflags="SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
echo "1..742"
;;
FreeBSD:ZFS)
allflags="UF_NODUMP,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
userflags="UF_NODUMP"
systemflags="SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
echo "1..482"
;;
*)
quick_exit
;;
esac
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
for type in regular dir fifo block char socket; do
create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 chflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
expect 0 chflags ${n0} ${userflags}
expect ${userflags} stat ${n0} flags
expect 0 chflags ${n0} ${systemflags}
expect ${systemflags} stat ${n0} flags
expect 0 chflags ${n0} none
expect none stat ${n0} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 lchflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
expect 0 lchflags ${n0} ${userflags}
expect ${userflags} stat ${n0} flags
expect 0 lchflags ${n0} ${systemflags}
expect ${systemflags} stat ${n0} flags
expect 0 lchflags ${n0} none
expect none stat ${n0} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
expect 0 create ${n0} 0644
expect 0 symlink ${n0} ${n1}
expect none stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} ${allflags}
expect ${allflags} stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} ${userflags}
expect ${userflags} stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} ${systemflags}
expect ${systemflags} stat ${n1} flags
expect none lstat ${n1} flags
expect 0 chflags ${n1} none
expect none stat ${n1} flags
expect none lstat ${n1} flags
expect 0 unlink ${n1}
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 symlink ${n0} ${n1}
expect none stat ${n1} flags
expect none lstat ${n1} flags
expect 0 lchflags ${n1} ${allflags}
expect ${allflags} lstat ${n1} flags
expect none stat ${n1} flags
expect 0 lchflags ${n1} ${userflags}
expect ${userflags} lstat ${n1} flags
expect none stat ${n1} flags
expect 0 lchflags ${n1} ${systemflags}
expect ${systemflags} lstat ${n1} flags
expect none stat ${n1} flags
expect 0 lchflags ${n1} none
expect none lstat ${n1} flags
expect none stat ${n1} flags
expect 0 unlink ${n1}
expect 0 unlink ${n0}
# successful chflags(2) updates ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 chflags ${n0} ${flag}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 lchflags ${n0} ${flag}
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -lt $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
# unsuccessful chflags(2) does not update ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EPERM -u 65534 chflags ${n0} ${flag}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect EPERM -u 65534 lchflags ${n0} ${flag}
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -eq $ctime2
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,22 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/01.t 211474 2010-08-18 22:06:43Z pjd $
desc="chflags returns ENOTDIR if a component of the path prefix is not a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..17"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
for type in regular fifo block char socket; do
create_file ${type} ${n0}/${n1}
expect ENOTDIR chflags ${n0}/${n1}/test SF_IMMUTABLE
expect 0 unlink ${n0}/${n1}
done
expect 0 rmdir ${n0}

View File

@ -0,0 +1,28 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..12"
nx=`namegen_max`
nxx="${nx}x"
expect 0 create ${nx} 0644
expect 0 chflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 chflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE
expect 0 create ${nx} 0644
expect 0 lchflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 lchflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE

View File

@ -0,0 +1,32 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..12"
nx=`dirgen_max`
nxx="${nx}x"
mkdir -p "${nx%/*}"
expect 0 create ${nx} 0644
expect 0 chflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 chflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE
expect 0 create ${nx} 0644
expect 0 lchflags ${nx} SF_IMMUTABLE
expect SF_IMMUTABLE stat ${nx} flags
expect 0 lchflags ${nx} none
expect 0 unlink ${nx}
expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE
rm -rf "${nx%%/*}"

View File

@ -0,0 +1,19 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/04.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ENOENT if the named file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..4"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT chflags ${n0}/${n1}/test SF_IMMUTABLE
expect ENOENT chflags ${n0}/${n1} SF_IMMUTABLE
expect 0 rmdir ${n0}

View File

@ -0,0 +1,35 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/05.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EACCES when search permission is denied for a component of the path prefix"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..16"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP
expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP
expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags
expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,21 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/06.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns ELOOP if too many symbolic links were encountered in translating the pathname"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..6"
n0=`namegen`
n1=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP chflags ${n0}/test SF_IMMUTABLE
expect ELOOP chflags ${n1}/test SF_IMMUTABLE
expect 0 unlink ${n0}
expect 0 unlink ${n1}

View File

@ -0,0 +1,50 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/07.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..93"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
expect none stat ${n1} flags
expect 0 chown ${n1} 65534 65534
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
expect none stat ${n1} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
expect none lstat ${n1} flags
expect 0 lchown ${n1} 65534 65534
expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
expect none lstat ${n1} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,58 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..249"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect 0 chown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 chflags ${n1} ${flag}
expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
done
expect 0 chflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect 0 lchown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 lchflags ${n1} ${flag}
expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
done
expect 0 lchflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,66 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/09.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and securelevel is greater than 0"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..327"
n0=`namegen`
n1=`namegen`
n2=`namegen`
old=`sysctl -n security.jail.chflags_allowed`
sysctl security.jail.chflags_allowed=1 >/dev/null
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect 0 chown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 chflags ${n1} ${flag}
jexpect 1 `pwd` EPERM chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
jexpect 1 `pwd` EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
jexpect 1 `pwd` EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
expect ${flag} stat ${n1} flags
done
expect 0 chflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect 0 lchown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect 0 lchflags ${n1} ${flag}
jexpect 1 `pwd` EPERM lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
jexpect 1 `pwd` EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
jexpect 1 `pwd` EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
expect ${flag} lstat ${n1} flags
done
expect 0 lchflags ${n1} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
sysctl security.jail.chflags_allowed=${old} >/dev/null
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,54 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/10.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..197"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect 0 chown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
expect none stat ${n1} flags
expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag}
expect none stat ${n1} flags
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect 0 lchown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag}
expect none lstat ${n1} flags
expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag}
expect none lstat ${n1} flags
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,58 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/11.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EPERM if a user tries to set or remove the SF_SNAPSHOT flag"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags_SF_SNAPSHOT
echo "1..145"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
expect none stat ${n1} flags
expect EPERM chflags ${n1} SF_SNAPSHOT
expect none stat ${n1} flags
expect 0 chown ${n1} 65534 65534
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
expect none stat ${n1} flags
expect EPERM chflags ${n1} SF_SNAPSHOT
expect none stat ${n1} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT
expect none lstat ${n1} flags
expect EPERM lchflags ${n1} SF_SNAPSHOT
expect none lstat ${n1} flags
expect 0 lchown ${n1} 65534 65534
expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT
expect none lstat ${n1} flags
expect EPERM lchflags ${n1} SF_SNAPSHOT
expect none lstat ${n1} flags
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,68 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/12.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EROFS if the named file resides on a read-only file system"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:UFS)
echo "1..14"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0}
expect 0 create ${n0}/${n1} 0644
expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
expect UF_IMMUTABLE stat ${n0}/${n1} flags
expect 0 chflags ${n0}/${n1} none
expect none stat ${n0}/${n1} flags
mount -ur /dev/md${n}
expect EROFS chflags ${n0}/${n1} UF_IMMUTABLE
expect none stat ${n0}/${n1} flags
mount -uw /dev/md${n}
expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
expect UF_IMMUTABLE stat ${n0}/${n1} flags
expect 0 chflags ${n0}/${n1} none
expect none stat ${n0}/${n1} flags
expect 0 unlink ${n0}/${n1}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}
;;
FreeBSD:ZFS)
echo "1..12"
n0=`namegen`
n1=`namegen`
n=`mdconfig -a -n -t malloc -s 128m` || exit
zpool create ${n0} /dev/md${n}
expect 0 create /${n0}/${n1} 0644
expect 0 chflags /${n0}/${n1} UF_NODUMP
expect UF_NODUMP stat /${n0}/${n1} flags
expect 0 chflags /${n0}/${n1} none
expect none stat /${n0}/${n1} flags
zfs set readonly=on ${n0}
expect EROFS chflags /${n0}/${n1} UF_NODUMP
expect none stat /${n0}/${n1} flags
zfs set readonly=off ${n0}
expect 0 chflags /${n0}/${n1} UF_NODUMP
expect UF_NODUMP stat /${n0}/${n1} flags
expect 0 chflags /${n0}/${n1} none
expect none stat /${n0}/${n1} flags
expect 0 unlink /${n0}/${n1}
zpool destroy ${n0}
mdconfig -d -u ${n} || exit
;;
*)
quick_exit
;;
esac

View File

@ -0,0 +1,14 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/13.t 211352 2010-08-15 21:24:17Z pjd $
desc="chflags returns EFAULT if the path argument points outside the process's allocated address space"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..2"
expect EFAULT chflags NULL UF_NODUMP
expect EFAULT chflags DEADCODE UF_NODUMP

View File

@ -0,0 +1,138 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/00.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod changes permission"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..203"
else
echo "1..119"
fi
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
expect 0 chmod ${n0} 0111
expect 0111 stat ${n0} mode
expect 0 symlink ${n0} ${n1}
mode=`${fstest} lstat ${n1} mode`
expect 0 chmod ${n1} 0222
expect 0222 stat ${n1} mode
expect 0222 stat ${n0} mode
expect ${mode} lstat ${n1} mode
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
if supported lchmod; then
create_file ${type} ${n0}
expect 0 lchmod ${n0} 0111
expect 0111 lstat ${n0} mode
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
done
# successful chmod(2) updates ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 chmod ${n0} 0111
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
if supported lchmod; then
create_file ${type} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 lchmod ${n0} 0111
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -lt $ctime2
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
done
# unsuccessful chmod(2) does not update ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EPERM -u 65534 chmod ${n0} 0111
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
if supported lchmod; then
create_file ${type} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect EPERM -u 65534 lchmod ${n0} 0321
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -eq $ctime2
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
done
# POSIX: If the calling process does not have appropriate privileges, and if
# the group ID of the file does not match the effective group ID or one of the
# supplementary group IDs and if the file is a regular file, bit S_ISGID
# (set-group-ID on execution) in the file's mode shall be cleared upon
# successful return from chmod().
expect 0 create ${n0} 0755
expect 0 chown ${n0} 65535 65535
expect 0 -u 65535 -g 65535 chmod ${n0} 02755
expect 02755 stat ${n0} mode
expect 0 -u 65535 -g 65535 chmod ${n0} 0755
expect 0755 stat ${n0} mode
todo FreeBSD "S_ISGID should be removed and chmod(2) should success and FreeBSD returns EPERM."
expect 0 -u 65535 -g 65534 chmod ${n0} 02755
expect 0755 stat ${n0} mode
expect 0 unlink ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/01.t 211474 2010-08-18 22:06:43Z pjd $
desc="chmod returns ENOTDIR if a component of the path prefix is not a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..17"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
for type in regular fifo block char socket; do
create_file ${type} ${n0}/${n1}
expect ENOTDIR chmod ${n0}/${n1}/test 0644
expect 0 unlink ${n0}/${n1}
done
expect 0 rmdir ${n0}

View File

@ -0,0 +1,24 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
nx=`namegen_max`
nxx="${nx}x"
expect 0 create ${nx} 0644
expect 0 chmod ${nx} 0620
expect 0620 stat ${nx} mode
expect 0 unlink ${nx}
expect ENAMETOOLONG chmod ${nxx} 0620
expect 0 create ${nx} 0644
expect 0 lchmod ${nx} 0620
expect 0620 stat ${nx} mode
expect 0 unlink ${nx}
expect ENAMETOOLONG lchmod ${nxx} 0620

View File

@ -0,0 +1,28 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
nx=`dirgen_max`
nxx="${nx}x"
mkdir -p "${nx%/*}"
expect 0 create ${nx} 0644
expect 0 chmod ${nx} 0642
expect 0642 stat ${nx} mode
expect 0 unlink ${nx}
expect ENAMETOOLONG chmod ${nxx} 0642
expect 0 create ${nx} 0644
expect 0 lchmod ${nx} 0642
expect 0642 stat ${nx} mode
expect 0 unlink ${nx}
expect ENAMETOOLONG lchmod ${nxx} 0642
rm -rf "${nx%%/*}"

View File

@ -0,0 +1,29 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/04.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns ENOENT if the named file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..9"
else
echo "1..7"
fi
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT chmod ${n0}/${n1}/test 0644
expect ENOENT chmod ${n0}/${n1} 0644
if supported lchmod; then
expect ENOENT lchmod ${n0}/${n1}/test 0644
expect ENOENT lchmod ${n0}/${n1} 0644
fi
expect 0 symlink ${n2} ${n0}/${n1}
expect ENOENT chmod ${n0}/${n1} 0644
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,42 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/05.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns EACCES when search permission is denied for a component of the path prefix"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..19"
else
echo "1..14"
fi
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642
expect 0642 -u 65534 -g 65534 stat ${n1}/${n2} mode
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 chmod ${n1}/${n2} 0620
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0420
expect 0420 -u 65534 -g 65534 stat ${n1}/${n2} mode
if supported lchmod; then
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 lchmod ${n1}/${n2} 0410
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 lchmod ${n1}/${n2} 0710
expect 0710 -u 65534 -g 65534 stat ${n1}/${n2} mode
fi
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,29 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/06.t 211474 2010-08-18 22:06:43Z pjd $
desc="chmod returns ELOOP if too many symbolic links were encountered in translating the pathname"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..10"
else
echo "1..8"
fi
n0=`namegen`
n1=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP chmod ${n0} 0644
expect ELOOP chmod ${n1} 0644
expect ELOOP chmod ${n0}/test 0644
expect ELOOP chmod ${n1}/test 0644
if supported lchmod; then
expect ELOOP lchmod ${n0}/test 0644
expect ELOOP lchmod ${n1}/test 0644
fi
expect 0 unlink ${n0}
expect 0 unlink ${n1}

View File

@ -0,0 +1,62 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/07.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..34"
else
echo "1..25"
fi
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642
expect 0642 stat ${n1}/${n2} mode
expect EPERM -u 65533 -g 65533 chmod ${n1}/${n2} 0641
expect 0642 stat ${n1}/${n2} mode
expect 0 chown ${n1}/${n2} 0 0
expect EPERM -u 65534 -g 65534 chmod ${n1}/${n2} 0641
expect 0642 stat ${n1}/${n2} mode
expect 0 unlink ${n1}/${n2}
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3}
expect 0 -u 65534 -g 65534 chmod ${n1}/${n3} 0642
expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid
expect EPERM -u 65533 -g 65533 chmod ${n1}/${n3} 0641
expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid
expect 0 chown ${n1}/${n3} 0 0
expect EPERM -u 65534 -g 65534 chmod ${n1}/${n3} 0641
expect 0642,0,0 stat ${n1}/${n2} mode,uid,gid
expect 0 unlink ${n1}/${n2}
expect 0 unlink ${n1}/${n3}
if supported lchmod; then
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65534 lchmod ${n1}/${n2} 0642
expect 0642 stat ${n1}/${n2} mode
expect EPERM -u 65533 -g 65533 lchmod ${n1}/${n2} 0641
expect 0642 stat ${n1}/${n2} mode
expect 0 chown ${n1}/${n2} 0 0
expect EPERM -u 65534 -g 65534 lchmod ${n1}/${n2} 0641
expect 0642 stat ${n1}/${n2} mode
expect 0 unlink ${n1}/${n2}
fi
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,98 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/08.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns EPERM if the named file has its immutable or append-only flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:ZFS)
echo "1..29"
;;
FreeBSD:UFS)
echo "1..54"
;;
*)
quick_exit
esac
n0=`namegen`
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_IMMUTABLE
expect EPERM chmod ${n0} 0600
supported lchmod && expect EPERM lchmod ${n0} 0600
expect 0644 stat ${n0} mode
expect 0 chflags ${n0} none
expect 0 chmod ${n0} 0600
expect 0600 stat ${n0} mode
supported lchmod && expect 0 lchmod ${n0} 0400
supported lchmod && expect 0400 stat ${n0} mode
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_NOUNLINK
expect 0 chmod ${n0} 0600
expect 0600 stat ${n0} mode
supported lchmod && expect 0 lchmod ${n0} 0400
supported lchmod && expect 0400 stat ${n0} mode
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
case "${os}:${fs}" in
FreeBSD:ZFS)
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_APPEND
expect 0 chmod ${n0} 0600
expect 0600 stat ${n0} mode
supported lchmod && expect 0 lchmod ${n0} 0500
supported lchmod && expect 0500 stat ${n0} mode
expect 0 chflags ${n0} none
expect 0 chmod ${n0} 0400
expect 0400 stat ${n0} mode
expect 0 unlink ${n0}
;;
FreeBSD:UFS)
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_APPEND
expect EPERM chmod ${n0} 0600
supported lchmod && expect EPERM lchmod ${n0} 0600
expect 0644 stat ${n0} mode
expect 0 chflags ${n0} none
expect 0 chmod ${n0} 0600
expect 0600 stat ${n0} mode
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM chmod ${n0} 0600
supported lchmod && expect EPERM lchmod ${n0} 0600
expect 0644 stat ${n0} mode
expect 0 chflags ${n0} none
expect 0 chmod ${n0} 0600
expect 0600 stat ${n0} mode
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_NOUNLINK
expect 0 chmod ${n0} 0600
expect 0600 stat ${n0} mode
supported lchmod && expect 0 lchmod ${n0} 0400
supported lchmod && expect 0400 stat ${n0} mode
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_APPEND
expect EPERM chmod ${n0} 0600
supported lchmod && expect EPERM lchmod ${n0} 0600
expect 0644 stat ${n0} mode
expect 0 chflags ${n0} none
expect 0 chmod ${n0} 0600
expect 0600 stat ${n0} mode
expect 0 unlink ${n0}
;;
esac

View File

@ -0,0 +1,37 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/09.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns EROFS if the named file resides on a read-only file system"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
echo "1..15"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 create ${n0}/${n1} 0644
expect 0 chmod ${n0}/${n1} 0640
expect 0640 stat ${n0}/${n1} mode
expect 0 lchmod ${n0}/${n1} 0530
expect 0530 stat ${n0}/${n1} mode
mount -ur /dev/md${n}
expect EROFS chmod ${n0}/${n1} 0600
expect EROFS lchmod ${n0}/${n1} 0600
expect 0530 stat ${n0}/${n1} mode
mount -uw /dev/md${n}
expect 0 chmod ${n0}/${n1} 0600
expect 0600 stat ${n0}/${n1} mode
expect 0 lchmod ${n0}/${n1} 0640
expect 0640 stat ${n0}/${n1} mode
expect 0 unlink ${n0}/${n1}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/10.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns EFAULT if the path argument points outside the process's allocated address space"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..4"
else
echo "1..2"
fi
expect EFAULT chmod NULL 0644
expect EFAULT chmod DEADCODE 0644
if supported lchmod; then
expect EFAULT lchmod NULL 0644
expect EFAULT lchmod DEADCODE 0644
fi

View File

@ -0,0 +1,118 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/11.t 211352 2010-08-15 21:24:17Z pjd $
desc="chmod returns EFTYPE if the effective user ID is not the super-user, the mode includes the sticky bit (S_ISVTX), and path does not refer to a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..173"
else
echo "1..109"
fi
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}
expect 0 chmod ${n1} 01621
expect 01621 stat ${n1} mode
expect 0 symlink ${n1} ${n2}
expect 0 chmod ${n2} 01700
expect 01700 stat ${n1} mode
expect 0 unlink ${n2}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
if supported lchmod; then
create_file ${type} ${n1}
expect 0 lchmod ${n1} 01621
expect 01621 lstat ${n1} mode
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
done
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 chmod ${n1} 01755
expect 01755 stat ${n1} mode
expect 0 symlink ${n1} ${n2}
expect 0 chmod ${n2} 01700
expect 01700 stat ${n1} mode
expect 0 unlink ${n2}
expect 0 rmdir ${n1}
for type in regular fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1} 0640 65534 65534
expect 0 symlink ${n1} ${n2}
case "${os}" in
FreeBSD)
expect EFTYPE -u 65534 -g 65534 chmod ${n1} 01644
expect 0640 stat ${n1} mode
expect EFTYPE -u 65534 -g 65534 chmod ${n2} 01644
expect 0640 stat ${n1} mode
;;
SunOS)
expect 0 -u 65534 -g 65534 chmod ${n1} 01644
expect 0644 stat ${n1} mode
expect 0 -u 65534 -g 65534 chmod ${n2} 01640
expect 0640 stat ${n1} mode
;;
Linux)
expect 0 -u 65534 -g 65534 chmod ${n1} 01644
expect 01644 stat ${n1} mode
expect 0 -u 65534 -g 65534 chmod ${n2} 01640
expect 01640 stat ${n1} mode
;;
esac
expect 0 unlink ${n2}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
if supported lchmod; then
create_file ${type} ${n1} 0640 65534 65534
case "${os}" in
FreeBSD)
expect EFTYPE -u 65534 -g 65534 lchmod ${n1} 01644
expect 0640 lstat ${n1} mode
;;
SunOS)
expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
expect 0644 lstat ${n1} mode
;;
Linux)
expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
expect 01644 lstat ${n1} mode
;;
esac
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
fi
done
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,38 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/12.t 219463 2011-03-10 20:59:02Z pjd $
desc="verify SUID/SGID bit behaviour"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..14"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
# Check whether writing to the file by non-owner clears the SUID.
expect 0 create ${n0} 04777
expect 0777 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x : fstat 0 mode
expect 0777 stat ${n0} mode
expect 0 unlink ${n0}
# Check whether writing to the file by non-owner clears the SGID.
expect 0 create ${n0} 02777
expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode
expect 0777 stat ${n0} mode
expect 0 unlink ${n0}
# Check whether writing to the file by non-owner clears the SUID+SGID.
expect 0 create ${n0} 06777
expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode
expect 0777 stat ${n0} mode
expect 0 unlink ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

View File

@ -0,0 +1,458 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/00.t 228975 2011-12-30 00:04:11Z uqs $
desc="chown changes ownership"
dir=`dirname $0`
. ${dir}/../misc.sh
if supported lchmod; then
echo "1..1349"
else
echo "1..1323"
fi
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
# super-user can always modify ownership
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
expect 0 chown ${n0} 123 456
expect 123,456 lstat ${n0} uid,gid
expect 0 chown ${n0} 0 0
expect 0,0 lstat ${n0} uid,gid
expect 0 symlink ${n0} ${n1}
uidgid=`${fstest} lstat ${n1} uid,gid`
expect 0 chown ${n1} 123 456
expect 123,456 stat ${n1} uid,gid
expect 123,456 stat ${n0} uid,gid
expect ${uidgid} lstat ${n1} uid,gid
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
expect 0 lchown ${n0} 123 456
expect 123,456 lstat ${n0} uid,gid
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
# non-super-user can modify file group if he is owner of a file and
# gid he is setting is in his groups list.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
expect 0 chown ${n0} 65534 65533
expect 65534,65533 lstat ${n0} uid,gid
expect 0 -u 65534 -g 65532,65531 -- chown ${n0} -1 65532
expect 65534,65532 lstat ${n0} uid,gid
expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531
expect 65534,65531 lstat ${n0} uid,gid
expect 0 symlink ${n0} ${n1}
uidgid=`${fstest} lstat ${n1} uid,gid`
expect 0 chown ${n1} 65534 65533
expect 65534,65533 stat ${n0} uid,gid
expect 65534,65533 stat ${n1} uid,gid
expect ${uidgid} lstat ${n1} uid,gid
expect 0 -u 65534 -g 65532,65531 -- chown ${n1} -1 65532
expect 65534,65532 stat ${n0} uid,gid
expect 65534,65532 stat ${n1} uid,gid
expect ${uidgid} lstat ${n1} uid,gid
expect 0 -u 65534 -g 65532,65531 chown ${n1} 65534 65531
expect 65534,65531 stat ${n0} uid,gid
expect 65534,65531 stat ${n1} uid,gid
expect ${uidgid} lstat ${n1} uid,gid
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
expect 0 lchown ${n0} 65534 65533
expect 65534,65533 lstat ${n0} uid,gid
expect 0 -u 65534 -g 65532,65531 -- lchown ${n0} -1 65532
expect 65534,65532 lstat ${n0} uid,gid
expect 0 -u 65534 -g 65532,65531 lchown ${n0} 65534 65531
expect 65534,65531 lstat ${n0} uid,gid
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
# chown(2) return 0 if user is not owner of a file, but chown(2) is called
# with both uid and gid equal to -1.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
expect 0 chown ${n0} 65534 65533
expect 0 -u 65532 -g 65531 -- chown ${n0} -1 -1
expect 65534,65533 stat ${n0} uid,gid
expect 0 symlink ${n0} ${n1}
uidgid=`${fstest} lstat ${n1} uid,gid`
expect 0 chown ${n1} 65534 65533
expect 65534,65533 stat ${n0} uid,gid
expect 65534,65533 stat ${n1} uid,gid
expect ${uidgid} lstat ${n1} uid,gid
expect 0 -u 65532 -g 65531 -- chown ${n0} -1 -1
expect 65534,65533 stat ${n0} uid,gid
expect 65534,65533 stat ${n1} uid,gid
expect ${uidgid} lstat ${n1} uid,gid
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
expect 0 lchown ${n0} 65534 65533
expect 0 -u 65532 -g 65531 -- lchown ${n0} -1 -1
expect 65534,65533 lstat ${n0} uid,gid
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
# when super-user calls chown(2), set-uid and set-gid bits may be removed.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
expect 0 chown ${n0} 65534 65533
expect 0 chmod ${n0} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 0 chown ${n0} 65532 65531
expect "(06555|0555),65532,65531" stat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555,65532,65531 stat ${n0} mode,uid,gid
expect 0 chown ${n0} 0 0
expect "(06555|0555),0,0" stat ${n0} mode,uid,gid
expect 0 symlink ${n0} ${n1}
expect 0 chown ${n1} 65534 65533
expect 0 chmod ${n1} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 06555,65534,65533 stat ${n1} mode,uid,gid
expect 0 chown ${n1} 65532 65531
expect "(06555|0555),65532,65531" stat ${n0} mode,uid,gid
expect "(06555|0555),65532,65531" stat ${n1} mode,uid,gid
expect 0 chmod ${n1} 06555
expect 06555,65532,65531 stat ${n0} mode,uid,gid
expect 06555,65532,65531 stat ${n1} mode,uid,gid
expect 0 chown ${n1} 0 0
expect "(06555|0555),0,0" stat ${n0} mode,uid,gid
expect "(06555|0555),0,0" stat ${n1} mode,uid,gid
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
if [ "${type}" != "symlink" ] || supported lchmod; then
create_file ${type} ${n0}
expect 0 lchown ${n0} 65534 65533
if supported lchmod; then
expect 0 lchmod ${n0} 06555
else
expect 0 chmod ${n0} 06555
fi
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 lchown ${n0} 65532 65531
expect "(06555|0555),65532,65531" lstat ${n0} mode,uid,gid
if supported lchmod; then
expect 0 lchmod ${n0} 06555
else
expect 0 chmod ${n0} 06555
fi
expect 06555,65532,65531 lstat ${n0} mode,uid,gid
expect 0 lchown ${n0} 0 0
expect "(06555|0555),0,0" lstat ${n0} mode,uid,gid
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
done
# when non-super-user calls chown(2) successfully, set-uid and set-gid bits may
# be removed, except when both uid and gid are equal to -1.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
expect 0 chown ${n0} 65534 65533
expect 0 chmod ${n0} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532
expect 0555,65534,65532 stat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555,65534,65532 stat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- chown ${n0} -1 65533
expect 0555,65534,65533 stat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- chown ${n0} -1 -1
expect "(06555|0555),65534,65533" stat ${n0} mode,uid,gid
expect 0 symlink ${n0} ${n1}
expect 0 chown ${n1} 65534 65533
expect 0 chmod ${n1} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 06555,65534,65533 stat ${n1} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 chown ${n1} 65534 65532
expect 0555,65534,65532 stat ${n0} mode,uid,gid
expect 0555,65534,65532 stat ${n1} mode,uid,gid
expect 0 chmod ${n1} 06555
expect 06555,65534,65532 stat ${n0} mode,uid,gid
expect 06555,65534,65532 stat ${n1} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- chown ${n1} -1 65533
expect 0555,65534,65533 stat ${n0} mode,uid,gid
expect 0555,65534,65533 stat ${n1} mode,uid,gid
expect 0 chmod ${n1} 06555
expect 06555,65534,65533 stat ${n0} mode,uid,gid
expect 06555,65534,65533 stat ${n1} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- chown ${n1} -1 -1
expect "(06555|0555),65534,65533" stat ${n0} mode,uid,gid
expect "(06555|0555),65534,65533" stat ${n1} mode,uid,gid
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
if [ "${type}" != "symlink" ] || supported lchmod; then
create_file ${type} ${n0}
expect 0 lchown ${n0} 65534 65533
if supported lchmod; then
expect 0 lchmod ${n0} 06555
else
expect 0 chmod ${n0} 06555
fi
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 lchown ${n0} 65534 65532
expect 0555,65534,65532 lstat ${n0} mode,uid,gid
if supported lchmod; then
expect 0 lchmod ${n0} 06555
else
expect 0 chmod ${n0} 06555
fi
expect 06555,65534,65532 lstat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- lchown ${n0} -1 65533
expect 0555,65534,65533 lstat ${n0} mode,uid,gid
if supported lchmod; then
expect 0 lchmod ${n0} 06555
else
expect 0 chmod ${n0} 06555
fi
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 -u 65534 -g 65533,65532 -- lchown ${n0} -1 -1
expect "(06555|0555),65534,65533" lstat ${n0} mode,uid,gid
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
done
# successful chown(2) call (except uid and gid equal to -1) updates ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 chown ${n0} 65534 65533
expect 65534,65533 stat ${n0} uid,gid
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 -u 65534 -g 65532 chown ${n0} 65534 65532
expect 65534,65532 stat ${n0} uid,gid
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
expect 0 symlink ${n0} ${n1}
ctime1=`${fstest} stat ${n1} ctime`
sleep 1
expect 0 chown ${n1} 65533 65532
expect 65533,65532 stat ${n1} uid,gid
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
ctime1=`${fstest} stat ${n1} ctime`
sleep 1
expect 0 -u 65533 -g 65531 chown ${n1} 65533 65531
expect 65533,65531 stat ${n1} uid,gid
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 lchown ${n0} 65534 65533
expect 65534,65533 lstat ${n0} uid,gid
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -lt $ctime2
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 -u 65534 -g 65532 lchown ${n0} 65534 65532
expect 65534,65532 lstat ${n0} uid,gid
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -lt $ctime2
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 -- chown ${n0} -1 -1
ctime2=`${fstest} stat ${n0} ctime`
todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated."
test_check $ctime1 -eq $ctime2
expect 0,0 stat ${n0} uid,gid
expect 0 symlink ${n0} ${n1}
ctime1=`${fstest} stat ${n1} ctime`
sleep 1
expect 0 -- chown ${n1} -1 -1
ctime2=`${fstest} stat ${n1} ctime`
todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated."
test_check $ctime1 -eq $ctime2
expect 0,0 stat ${n1} uid,gid
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 -- lchown ${n0} -1 -1
ctime2=`${fstest} lstat ${n0} ctime`
todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated."
test_check $ctime1 -eq $ctime2
expect 0,0 lstat ${n0} uid,gid
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
# unsuccessful chown(2) does not update ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EPERM -u 65534 -- chown ${n0} 65534 -1
expect EPERM -u 65534 -g 65534 -- chown ${n0} -1 65534
expect EPERM -u 65534 -g 65534 chown ${n0} 65534 65534
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0,0 stat ${n0} uid,gid
expect 0 symlink ${n0} ${n1}
ctime1=`${fstest} stat ${n1} ctime`
sleep 1
expect EPERM -u 65534 -- chown ${n1} 65534 -1
expect EPERM -u 65534 -g 65534 -- chown ${n1} -1 65534
expect EPERM -u 65534 -g 65534 chown ${n1} 65534 65534
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -eq $ctime2
expect 0,0 stat ${n1} uid,gid
expect 0 unlink ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
create_file ${type} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect EPERM -u 65534 -- lchown ${n0} 65534 -1
expect EPERM -u 65534 -g 65534 -- lchown ${n0} -1 65534
expect EPERM -u 65534 -g 65534 lchown ${n0} 65534 65534
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0,0 lstat ${n0} uid,gid
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,21 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/01.t 211474 2010-08-18 22:06:43Z pjd $
desc="chown returns ENOTDIR if a component of the path prefix is not a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..22"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
for type in regular fifo block char socket; do
create_file ${type} ${n0}/${n1}
expect ENOTDIR chown ${n0}/${n1}/test 65534 65534
expect ENOTDIR lchown ${n0}/${n1}/test 65534 65534
expect 0 unlink ${n0}/${n1}
done
expect 0 rmdir ${n0}

View File

@ -0,0 +1,24 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="chown returns ENAMETOOLONG if a component of a pathname exceeded ${NAME_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
nx=`namegen_max`
nxx="${nx}x"
expect 0 create ${nx} 0644
expect 0 chown ${nx} 65534 65534
expect 65534,65534 stat ${nx} uid,gid
expect 0 unlink ${nx}
expect ENAMETOOLONG chown ${nxx} 65534 65534
expect 0 create ${nx} 0644
expect 0 lchown ${nx} 65534 65534
expect 65534,65534 stat ${nx} uid,gid
expect 0 unlink ${nx}
expect ENAMETOOLONG lchown ${nxx} 65534 65534

View File

@ -0,0 +1,28 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="chown returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
nx=`dirgen_max`
nxx="${nx}x"
mkdir -p "${nx%/*}"
expect 0 create ${nx} 0644
expect 0 chown ${nx} 65534 65534
expect 65534,65534 stat ${nx} uid,gid
expect 0 unlink ${nx}
expect ENAMETOOLONG chown ${nxx} 65534 65534
expect 0 create ${nx} 0644
expect 0 lchown ${nx} 65534 65534
expect 65534,65534 stat ${nx} uid,gid
expect 0 unlink ${nx}
expect ENAMETOOLONG lchown ${nxx} 65534 65534
rm -rf "${nx%%/*}"

View File

@ -0,0 +1,23 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/04.t 211410 2010-08-17 06:08:09Z pjd $
desc="chown returns ENOENT if the named file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..9"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT chown ${n0}/${n1}/test 65534 65534
expect ENOENT chown ${n0}/${n1} 65534 65534
expect ENOENT lchown ${n0}/${n1}/test 65534 65534
expect ENOENT lchown ${n0}/${n1} 65534 65534
expect 0 symlink ${n2} ${n0}/${n1}
expect ENOENT chown ${n0}/${n1} 65534 65534
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,35 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/05.t 211410 2010-08-17 06:08:09Z pjd $
desc="chown returns EACCES when search permission is denied for a component of the path prefix"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..18"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65533
expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534
expect EACCES -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65534
expect 0 chmod ${n1} 0755
expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534
expect 65534,65534 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid
expect 0 -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65533
expect 65534,65533 -u 65534 -g 65533 stat ${n1}/${n2} uid,gid
expect 0 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,23 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/06.t 211410 2010-08-17 06:08:09Z pjd $
desc="chown returns ELOOP if too many symbolic links were encountered in translating the pathname"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
n0=`namegen`
n1=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP chown ${n0} 65534 65534
expect ELOOP chown ${n1} 65534 65534
expect ELOOP chown ${n0}/test 65534 65534
expect ELOOP chown ${n1}/test 65534 65534
expect ELOOP lchown ${n0}/test 65534 65534
expect ELOOP lchown ${n1}/test 65534 65534
expect 0 unlink ${n0}
expect 0 unlink ${n1}

View File

@ -0,0 +1,53 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/07.t 211410 2010-08-17 06:08:09Z pjd $
desc="chown returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user and the process is not an owner of the file"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..132"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1}/${n2} 65534 65534
expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533
expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534
expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533
expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n2} -1 65533
expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3}
expect EPERM -u 65534 -g 65534 chown ${n1}/${n3} 65533 65533
expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65534 65534
expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65533 65533
expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n3} -1 65533
expect 0 unlink ${n1}/${n3}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}/${n2}
else
expect 0 unlink ${n1}/${n2}
fi
fi
create_file ${type} ${n1}/${n2} 65534 65534
expect EPERM -u 65534 -g 65534 lchown ${n1}/${n2} 65533 65533
expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65534 65534
expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65533 65533
expect EPERM -u 65534 -g 65534 -- lchown ${n1}/${n2} -1 65533
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}/${n2}
else
expect 0 unlink ${n1}/${n2}
fi
done
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,84 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/08.t 211352 2010-08-15 21:24:17Z pjd $
desc="chown returns EPERM if the named file has its immutable or append-only flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:ZFS)
echo "1..20"
;;
FreeBSD:UFS)
echo "1..44"
;;
*)
quick_exit
esac
n0=`namegen`
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_IMMUTABLE
expect EPERM chown ${n0} 65534 65534
expect 0,0 stat ${n0} uid,gid
expect 0 chflags ${n0} none
expect 0 chown ${n0} 65534 65534
expect 65534,65534 stat ${n0} uid,gid
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_NOUNLINK
expect 0 chown ${n0} 65534 65534
expect 65534,65534 stat ${n0} uid,gid
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
case "${os}:${fs}" in
FreeBSD:ZFS)
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_APPEND
expect 0 chown ${n0} 65534 65534
expect 65534,65534 stat ${n0} uid,gid
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
;;
FreeBSD:UFS)
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_APPEND
expect EPERM chown ${n0} 65534 65534
expect 0,0 stat ${n0} uid,gid
expect 0 chflags ${n0} none
expect 0 chown ${n0} 65534 65534
expect 65534,65534 stat ${n0} uid,gid
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM chown ${n0} 65534 65534
expect 0,0 stat ${n0} uid,gid
expect 0 chflags ${n0} none
expect 0 chown ${n0} 65534 65534
expect 65534,65534 stat ${n0} uid,gid
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_NOUNLINK
expect 0 chown ${n0} 65534 65534
expect 65534,65534 stat ${n0} uid,gid
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_APPEND
expect EPERM chown ${n0} 65534 65534
expect 0,0 stat ${n0} uid,gid
expect 0 chflags ${n0} none
expect 0 chown ${n0} 65534 65534
expect 65534,65534 stat ${n0} uid,gid
expect 0 unlink ${n0}
;;
esac

View File

@ -0,0 +1,32 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/09.t 211352 2010-08-15 21:24:17Z pjd $
desc="chown returns EROFS if the named file resides on a read-only file system"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
echo "1..10"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 create ${n0}/${n1} 0644
expect 0 chown ${n0}/${n1} 65534 65534
expect 65534,65534 stat ${n0}/${n1} uid,gid
mount -ur /dev/md${n}
expect EROFS chown ${n0}/${n1} 65533 65533
expect 65534,65534 stat ${n0}/${n1} uid,gid
mount -uw /dev/md${n}
expect 0 chown ${n0}/${n1} 65533 65533
expect 65533,65533 stat ${n0}/${n1} uid,gid
expect 0 unlink ${n0}/${n1}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,14 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/10.t 211410 2010-08-17 06:08:09Z pjd $
desc="chown returns EFAULT if the path argument points outside the process's allocated address space"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..4"
expect EFAULT chown NULL 65534 65534
expect EFAULT chown DEADCODE 65534 65534
expect EFAULT lchown NULL 65534 65534
expect EFAULT lchown DEADCODE 65534 65534

View File

@ -0,0 +1,36 @@
# $FreeBSD: head/tools/regression/pjdfstest/tests/conf 211354 2010-08-15 21:29:03Z pjd $
# pjdfstest configuration file
# Supported operating systems: FreeBSD, Darwin, SunOS, Linux
os=`uname`
case "${os}" in
FreeBSD|Darwin)
GREP=grep
#fs=`df -T . | tail -1 | awk '{print $2}'`
pattern="`df . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`"
fs=`mount | ${GREP} -E "^${pattern}" | awk -F '[(,]' '{print toupper($2)}'`
;;
Solaris|SunOS)
GREP=ggrep
pattern=`df -Pk . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`
fs=`mount -v | ${GREP} -E "^${pattern}" | awk '{print $5}' | \
tr -s '[:lower:]' '[:upper:]'`
;;
Linux)
GREP=grep
fs=`df -PT . | tail -1 | awk '{print toupper($2)}'`
;;
*)
echo "Unsupported operating system ${os}." >/dev/stderr
exit 1
;;
esac
# If we cannot figure out file system type, define it here.
#fs="UFS"
if [ -z "${fs}" ]; then
echo "Cannot figure out file system type, define it by hand." >/dev/stderr
exit 1
fi

View File

@ -0,0 +1,58 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/ftruncate/00.t 219439 2011-03-09 23:11:30Z pjd $
desc="ftruncate descrease/increase file size"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..26"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n1} 0755
cdir=`pwd`
cd ${n1}
expect 0 create ${n0} 0644
expect 0 open ${n0} O_RDWR : ftruncate 0 1234567
expect 1234567 lstat ${n0} size
expect 0 open ${n0} O_WRONLY : ftruncate 0 567
expect 567 lstat ${n0} size
expect 0 unlink ${n0}
dd if=/dev/random of=${n0} bs=12345 count=1 >/dev/null 2>&1
expect 0 open ${n0} O_RDWR : ftruncate 0 23456
expect 23456 lstat ${n0} size
expect 0 open ${n0} O_WRONLY : ftruncate 0 1
expect 1 lstat ${n0} size
expect 0 unlink ${n0}
# successful ftruncate(2) updates ctime.
expect 0 create ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 open ${n0} O_RDWR : ftruncate 0 123
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n0}
# unsuccessful ftruncate(2) does not update ctime.
expect 0 create ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EINVAL -u 65534 open ${n0} O_RDONLY : ftruncate 0 123
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
# third argument should not affect permission.
expect 0 open ${n0} O_CREAT,O_RDWR 0 : ftruncate 0 0
expect 0 unlink ${n0}
expect 0 chmod . 0777
expect 0 -u 65534 open ${n0} O_CREAT,O_RDWR 0 : ftruncate 0 0
expect 0 unlink ${n0}
cd ${cdir}
expect 0 rmdir ${n1}

View File

@ -0,0 +1,18 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/01.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns ENOTDIR if a component of the path prefix is not a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..5"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n0}/${n1} 0644
expect ENOTDIR truncate ${n0}/${n1}/test 123
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,18 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..5"
nx=`namegen_max`
nxx="${nx}x"
expect 0 create ${nx} 0644
expect 0 truncate ${nx} 123
expect 123 stat ${nx} size
expect 0 unlink ${nx}
expect ENAMETOOLONG truncate ${nxx} 123

View File

@ -0,0 +1,22 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..5"
nx=`dirgen_max`
nxx="${nx}x"
mkdir -p "${nx%/*}"
expect 0 create ${nx} 0644
expect 0 truncate ${nx} 123
expect regular,123 stat ${nx} type,size
expect 0 unlink ${nx}
expect ENAMETOOLONG truncate ${nxx} 123
rm -rf "${nx%%/*}"

View File

@ -0,0 +1,17 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/04.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns ENOENT if the named file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..4"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT truncate ${n0}/${n1}/test 123
expect ENOENT truncate ${n0}/${n1} 123
expect 0 rmdir ${n0}

View File

@ -0,0 +1,32 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/05.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns EACCES when search permission is denied for a component of the path prefix"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..15"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 123
expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 truncate ${n1}/${n2} 1234
expect 0 chmod ${n1} 0755
expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size
expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 1234
expect 1234 -u 65534 -g 65534 stat ${n1}/${n2} size
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,24 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/06.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns EACCES if the named file is not writable by the user"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..8"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 create ${n1} 0644
expect EACCES -u 65534 -g 65534 truncate ${n1} 123
expect 0 chown ${n1} 65534 65534
expect 0 chmod ${n1} 0444
expect EACCES -u 65534 -g 65534 truncate ${n1} 123
expect 0 unlink ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,19 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/07.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns ELOOP if too many symbolic links were encountered in translating the pathname"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..6"
n0=`namegen`
n1=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP truncate ${n0}/test 123
expect ELOOP truncate ${n1}/test 123
expect 0 unlink ${n0}
expect 0 unlink ${n1}

View File

@ -0,0 +1,78 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/08.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns EPERM if the named file has its immutable or append-only flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:ZFS)
echo "1..22"
;;
FreeBSD:UFS)
echo "1..44"
;;
*)
quick_exit
esac
n0=`namegen`
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_IMMUTABLE
expect EPERM truncate ${n0} 123
expect 0 stat ${n0} size
expect 0 chflags ${n0} none
expect 0 truncate ${n0} 123
expect 123 stat ${n0} size
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_NOUNLINK
expect 0 truncate ${n0} 123
expect 123 stat ${n0} size
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_APPEND
todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM."
expect EPERM truncate ${n0} 123
todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM."
expect 0 stat ${n0} size
expect 0 chflags ${n0} none
expect 0 truncate ${n0} 123
expect 123 stat ${n0} size
expect 0 unlink ${n0}
case "${os}:${fs}" in
FreeBSD:UFS)
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM truncate ${n0} 123
expect 0 stat ${n0} size
expect 0 chflags ${n0} none
expect 0 truncate ${n0} 123
expect 123 stat ${n0} size
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_NOUNLINK
expect 0 truncate ${n0} 123
expect 123 stat ${n0} size
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_APPEND
expect EPERM truncate ${n0} 123
expect 0 stat ${n0} size
expect 0 chflags ${n0} none
expect 0 truncate ${n0} 123
expect 123 stat ${n0} size
expect 0 unlink ${n0}
;;
esac

View File

@ -0,0 +1,15 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/09.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns EISDIR if the named file is a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..3"
n0=`namegen`
expect 0 mkdir ${n0} 0755
expect EISDIR truncate ${n0} 123
expect 0 rmdir ${n0}

View File

@ -0,0 +1,32 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/10.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns EROFS if the named file resides on a read-only file system"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
echo "1..10"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 create ${n0}/${n1} 0644
expect 0 truncate ${n0}/${n1} 123
expect 123 stat ${n0}/${n1} size
mount -ur /dev/md${n}
expect EROFS truncate ${n0}/${n1} 1234
expect 123 stat ${n0}/${n1} size
mount -uw /dev/md${n}
expect 0 truncate ${n0}/${n1} 1234
expect 1234 stat ${n0}/${n1} size
expect 0 unlink ${n0}/${n1}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,18 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/11.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns ETXTBSY the file is a pure procedure (shared text) file that is being executed"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}" = "FreeBSD" ] || quick_exit
echo "1..2"
n0=`namegen`
cp -pf `which sleep` ${n0}
./${n0} 3 &
expect ETXTBSY truncate ${n0} 123
expect 0 unlink ${n0}

View File

@ -0,0 +1,27 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/12.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns EFBIG or EINVAL if the length argument was greater than the maximum file size"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..3"
n0=`namegen`
expect 0 create ${n0} 0644
r=`${fstest} truncate ${n0} 999999999999999 2>/dev/null`
case "${r}" in
EFBIG|EINVAL)
expect 0 stat ${n0} size
;;
0)
expect 999999999999999 stat ${n0} size
;;
*)
echo "not ok ${ntest}"
ntest=`expr ${ntest} + 1`
;;
esac
expect 0 unlink ${n0}

View File

@ -0,0 +1,16 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/13.t 211352 2010-08-15 21:24:17Z pjd $
desc="ftruncate returns EINVAL if the length argument was less than 0"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..4"
n0=`namegen`
expect 0 create ${n0} 0644
expect EINVAL -- open ${n0} O_RDWR : ftruncate 0 -1
expect EINVAL -- open ${n0} O_WRONLY : ftruncate 0 -999999
expect 0 unlink ${n0}

View File

@ -0,0 +1,12 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/14.t 211352 2010-08-15 21:24:17Z pjd $
desc="truncate returns EFAULT if the path argument points outside the process's allocated address space"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..2"
expect EFAULT truncate NULL 123
expect EFAULT truncate DEADCODE 123

View File

@ -0,0 +1,112 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/00.t 211352 2010-08-15 21:24:17Z pjd $
desc="NFSv4 granular permissions checking - WRITE_DATA vs APPEND_DATA on directories"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
echo "1..49"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
expect 0 mkdir ${n2} 0755
expect 0 mkdir ${n3} 0777
cdir=`pwd`
cd ${n2}
# Tests 2..7 - check out whether root user can do stuff.
# Can create files?
expect 0 create ${n0} 0644
# Can create symlinks?
expect 0 link ${n0} ${n1}
expect 0 unlink ${n1}
expect 0 unlink ${n0}
# Can create directories?
expect 0 mkdir ${n0} 0755
expect 0 rmdir ${n0}
# Check whether user 65534 is permitted to create and remove
# files, but not subdirectories.
expect 0 prependacl . user:65534:write_data::allow,user:65534:append_data::deny
# Can create files?
expect 0 -u 65534 -g 65534 create ${n0} 0644
# Can create symlinks?
expect 0 -u 65534 -g 65534 link ${n0} ${n1}
expect 0 -u 65534 -g 65534 unlink ${n1}
expect 0 -u 65534 -g 65534 unlink ${n0}
# Can create directories?
expect EACCES -u 65534 -g 65534 mkdir ${n0} 0755
expect ENOENT -u 65534 -g 65534 rmdir ${n0}
expect 0 mkdir ${n0} 0755
expect 0 -u 65534 -g 65534 rmdir ${n0}
# Can move files from other directory?
expect 0 create ../${n3}/${n1} 0644
expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
# Can move files from other directory overwriting existing files?
expect 0 create ../${n3}/${n1} 0644
expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
expect 0 -u 65534 -g 65534 unlink ${n0}
# Can move directories from other directory?
expect 0 mkdir ../${n3}/${n1} 0777
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
# Can move directories from other directory overwriting existing directory?
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
expect 0 -u 65534 -g 65534 rmdir ../${n3}/${n1}
# Check whether user 65534 is permitted to create
# subdirectories, but not files - and to remove neither of them.
expect 0 prependacl . user:65534:write_data::deny,user:65534:append_data::allow
# Can create files?
expect EACCES -u 65534 -g 65534 create ${n0} 0644
# Can create symlinks?
expect 0 create ${n0} 0644
expect EACCES -u 65534 -g 65534 link ${n0} ${n1}
expect ENOENT -u 65534 -g 65534 unlink ${n1}
expect EACCES -u 65534 -g 65534 unlink ${n0}
expect 0 unlink ${n0}
# Can create directories?
expect 0 -u 65534 -g 65534 mkdir ${n0} 0755
expect EACCES -u 65534 -g 65534 rmdir ${n0}
expect 0 rmdir ${n0}
# Can move files from other directory?
expect 0 create ../${n3}/${n1} 0644
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
# Can move files from other directory overwriting existing files?
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
expect 0 -u 65534 -g 65534 unlink ../${n3}/${n1}
# Can move directories from other directory?
expect 0 mkdir ../${n3}/${n1} 0777
expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
# Can move directories from other directory overwriting existing directory?
expect 0 mkdir ../${n3}/${n1} 0777
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
expect 0 prependacl . user:65534:delete_child::allow
expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0}
expect 0 -u 65534 -g 65534 rmdir ${n0}
cd ${cdir}
expect 0 rmdir ${n2}
expect 0 rmdir ${n3}

View File

@ -0,0 +1,37 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/01.t 211352 2010-08-15 21:24:17Z pjd $
desc="NFSv4 granular permissions checking - ACL_READ_ATTRIBUTES and ACL_WRITE_ATTRIBUTES"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
echo "1..12"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
# Tests 1..12 - check out whether user 65534 is permitted to read attributes.
expect 0 create ${n0} 0644
expect 0 lstat ${n0} size
expect 0 -u 65534 -g 65534 stat ${n0} size
expect 0 prependacl ${n0} user:65534:read_attributes::deny
expect 0 lstat ${n0} size
expect EACCES -u 65534 -g 65534 stat ${n0} size
expect 0 prependacl ${n0} user:65534:read_attributes::allow
expect 0 -u 65534 -g 65534 stat ${n0} size
expect 0 lstat ${n0} size
expect 0 unlink ${n0}
# Tests 12..12 - check out whether user 65534 is permitted to write attributes.
# XXX: Check if ACL_WRITE_ATTRIBUTES allows for modifying access times.
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,144 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="NFSv4 granular permissions checking - ACL_READ_ACL and ACL_WRITE_ACL"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
echo "1..83"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
# Check whether user 65534 is permitted to read ACL.
expect 0 create ${n0} 0644
expect 0 readacl ${n0}
expect 0 -u 65534 -g 65534 readacl ${n0}
expect 0 prependacl ${n0} user:65534:read_acl::deny
expect 0 readacl ${n0}
expect EACCES -u 65534 -g 65534 readacl ${n0}
expect 0 prependacl ${n0} user:65534:read_acl::allow
expect 0 -u 65534 -g 65534 readacl ${n0}
expect 0 readacl ${n0}
expect 0 unlink ${n0}
# Check whether user 65534 is permitted to write ACL.
expect 0 create ${n0} 0644
expect EPERM -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow
expect 0 unlink ${n0}
# Check whether user 65534 is permitted to write mode.
expect 0 create ${n0} 0755
expect EPERM -u 65534 -g 65534 chmod ${n0} 0777
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect 0 -u 65534 -g 65534 chmod ${n0} 0777
expect 0 unlink ${n0}
# There is an interesting problem with interaction between ACL_WRITE_ACL
# and SUID/SGID bits. In case user does have ACL_WRITE_ACL, but is not
# a file owner, Solaris does the following:
# 1. Setting SUID fails with EPERM.
# 2. Setting SGID succeeds, but mode is not changed.
# 3. Modifying ACL does not clear SUID nor SGID bits.
# 4. Writing the file does clear both SUID and SGID bits.
#
# What we are doing is the following:
# 1. Setting SUID or SGID fails with EPERM.
# 2. Modifying ACL does not clear SUID nor SGID bits.
# 3. Writing the file does clear both SUID and SGID bits.
#
# Check whether user 65534 is denied to write mode with SUID bit.
expect 0 create ${n0} 0755
expect EPERM -u 65534 -g 65534 chmod ${n0} 04777
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect EPERM -u 65534 -g 65534 chmod ${n0} 04777
expect 0 unlink ${n0}
# Check whether user 65534 is denied to write mode with SGID bit.
expect 0 create ${n0} 0755
expect EPERM -u 65534 -g 65534 chmod ${n0} 02777
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect EPERM -u 65534 -g 65534 chmod ${n0} 02777
expect 0 unlink ${n0}
# Check whether user 65534 is allowed to write mode with sticky bit.
expect 0 mkdir ${n0} 0755
expect EPERM -u 65534 -g 65534 chmod ${n0} 01777
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect 0 -u 65534 -g 65534 chmod ${n0} 01777
expect 0 rmdir ${n0}
# Check whether modifying the ACL by not-owner preserves the SUID.
expect 0 create ${n0} 04755
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow
expect 04755 stat ${n0} mode
expect 0 unlink ${n0}
# Check whether modifying the ACL by not-owner preserves the SGID.
expect 0 create ${n0} 02755
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow
expect 02755 stat ${n0} mode
expect 0 unlink ${n0}
# Check whether modifying the ACL by not-owner preserves the sticky bit.
expect 0 mkdir ${n0} 0755
expect 0 chmod ${n0} 01755
expect 0 prependacl ${n0} user:65534:write_acl::allow
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow
expect 01755 stat ${n0} mode
expect 0 rmdir ${n0}
# Clearing the SUID and SGID bits when being written to by non-owner
# is checked in chmod/12.t.
# Check whether the file owner is always permitted to get and set
# ACL and file mode, even if ACL_{READ,WRITE}_ACL would deny it.
expect 0 chmod . 0777
expect 0 -u 65534 -g 65534 create ${n0} 0600
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny
expect 0 -u 65534 -g 65534 readacl ${n0}
expect 0600 -u 65534 -g 65534 stat ${n0} mode
expect 0 -u 65534 -g 65534 chmod ${n0} 0777
expect 0 unlink ${n0}
expect 0 -u 65534 -g 65534 mkdir ${n0} 0600
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny
expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny
expect 0 -u 65534 -g 65534 readacl ${n0}
expect 0600 -u 65534 -g 65534 stat ${n0} mode
expect 0 -u 65534 -g 65534 chmod ${n0} 0777
expect 0 rmdir ${n0}
# Check whether the root is allowed for these as well.
expect 0 -u 65534 -g 65534 create ${n0} 0600
expect 0 prependacl ${n0} everyone@:write_acl::deny
expect 0 prependacl ${n0} everyone@:read_acl::deny
expect 0 readacl ${n0}
expect 0600 stat ${n0} mode
expect 0 chmod ${n0} 0777
expect 0 unlink ${n0}
expect 0 -u 65534 -g 65534 mkdir ${n0} 0600
expect 0 prependacl ${n0} everyone@:write_acl::deny
expect 0 prependacl ${n0} everyone@:read_acl::deny
expect 0600 stat ${n0} mode
expect 0 readacl ${n0}
expect 0600 stat ${n0} mode
expect 0 chmod ${n0} 0777
expect 0 rmdir ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,134 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
echo "1..65"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
expect 0 mkdir ${n2} 0755
expect 0 mkdir ${n3} 0777
cdir=`pwd`
cd ${n2}
# Unlink allowed on writable directory.
expect 0 create ${n0} 0644
expect EACCES -u 65534 -g 65534 unlink ${n0}
expect 0 prependacl . user:65534:write_data::allow
expect 0 -u 65534 -g 65534 unlink ${n0}
# Moving file elsewhere allowed on writable directory.
expect 0 create ${n0} 0644
expect 0 prependacl . user:65534:write_data::deny
expect EACCES -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
expect 0 prependacl . user:65534:write_data::allow
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
# Moving file from elsewhere allowed on writable directory.
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 unlink ${n0}
# Moving file from elsewhere overwriting local file allowed
# on writable directory.
expect 0 create ${n0} 0644
expect 0 create ../${n3}/${n0} 0644
expect 0 prependacl . user:65534:write_data::deny
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 prependacl . user:65534:write_data::allow
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 unlink ${n0}
# Denied DELETE changes nothing wrt removing.
expect 0 create ${n0} 0644
expect 0 prependacl ${n0} user:65534:delete::deny
expect 0 -u 65534 -g 65534 unlink ${n0}
# Denied DELETE changes nothing wrt moving elsewhere or from elsewhere.
expect 0 create ${n0} 0644
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 unlink ${n0}
# DELETE_CHILD denies unlink on writable directory.
expect 0 create ${n0} 0644
expect 0 prependacl . user:65534:delete_child::deny
expect EPERM -u 65534 -g 65534 unlink ${n0}
expect 0 unlink ${n0}
# DELETE_CHILD denies moving file elsewhere.
expect 0 create ${n0} 0644
expect EPERM -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
expect 0 rename ${n0} ../${n3}/${n0}
# DELETE_CHILD does not deny moving file from elsewhere
# to a writable directory.
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# DELETE_CHILD denies moving file from elsewhere
# to a writable directory overwriting local file.
expect 0 create ../${n3}/${n0} 0644
expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# DELETE allowed on file allows for unlinking, no matter
# what permissions on containing directory are.
expect 0 prependacl ${n0} user:65534:delete::allow
expect 0 -u 65534 -g 65534 unlink ${n0}
# Same for moving the file elsewhere.
expect 0 create ${n0} 0644
expect 0 prependacl ${n0} user:65534:delete::allow
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
# Same for moving the file from elsewhere into a writable
# directory with DELETE_CHILD denied.
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 unlink ${n0}
# DELETE does not allow for overwriting a file in a unwritable
# directory with DELETE_CHILD denied.
expect 0 create ${n0} 0644
expect 0 create ../${n3}/${n0} 0644
expect 0 prependacl . user:65534:write_data::deny
expect 0 prependacl . user:65534:delete_child::deny
expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 prependacl ${n0} user:65534:delete::allow
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# But it allows for plain deletion.
expect 0 -u 65534 -g 65534 unlink ${n0}
# DELETE_CHILD allowed on unwritable directory.
expect 0 create ${n0} 0644
expect 0 prependacl . user:65534:delete_child::allow
expect 0 -u 65534 -g 65534 unlink ${n0}
# Moving things elsewhere is allowed.
expect 0 create ${n0} 0644
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
# Moving things back is not.
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# Even if we're overwriting.
expect 0 create ${n0} 0644
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# Even if we have DELETE on the existing file.
expect 0 prependacl ${n0} user:65534:delete::allow
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# Denied DELETE changes nothing wrt removing.
expect 0 prependacl ${n0} user:65534:delete::deny
expect 0 -u 65534 -g 65534 unlink ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,80 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/04.t 211352 2010-08-15 21:24:17Z pjd $
desc="NFSv4 granular permissions checking - ACL_WRITE_OWNER"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
echo "1..52"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
# ACL_WRITE_OWNER permits to set gid to our own only.
expect 0 create ${n0} 0644
expect 0,0 lstat ${n0} uid,gid
expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65532
expect 0,0 lstat ${n0} uid,gid
expect 0 prependacl ${n0} user:65534:write_owner::allow
expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65530
expect 0,0 lstat ${n0} uid,gid
expect 0 -u 65534 -g 65532,65531 chown ${n0} -1 65532
expect 0,65532 lstat ${n0} uid,gid
expect 0 unlink ${n0}
# ACL_WRITE_OWNER permits to set uid to our own only.
expect 0 create ${n0} 0644
expect 0,0 lstat ${n0} uid,gid
expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65534 65531
expect 0,0 lstat ${n0} uid,gid
expect 0 prependacl ${n0} user:65534:write_owner::allow
expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65530 65531
expect 0,0 lstat ${n0} uid,gid
expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531
expect 65534,65531 lstat ${n0} uid,gid
expect 0 unlink ${n0}
# When non-owner calls chown(2) successfully, set-uid and set-gid bits are
# removed, except when both uid and gid are equal to -1.
expect 0 create ${n0} 0644
expect 0 prependacl ${n0} user:65534:write_owner::allow
expect 0 chmod ${n0} 06555
expect 06555 lstat ${n0} mode
expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532
expect 0555,65534,65532 lstat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555 lstat ${n0} mode
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533
expect 0555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555 lstat ${n0} mode
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 unlink ${n0}
expect 0 mkdir ${n0} 0755
expect 0 prependacl ${n0} user:65534:write_owner::allow
expect 0 chmod ${n0} 06555
expect 06555 lstat ${n0} mode
expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532
expect 0555,65534,65532 lstat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555 lstat ${n0} mode
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533
expect 0555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 chmod ${n0} 06555
expect 06555 lstat ${n0} mode
expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1
expect 06555,65534,65533 lstat ${n0} mode,uid,gid
expect 0 rmdir ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,149 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/05.t 211352 2010-08-15 21:24:17Z pjd $
desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD with directories"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit
echo "1..68"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
expect 0 mkdir ${n2} 0755
expect 0 mkdir ${n3} 0777
cdir=`pwd`
cd ${n2}
# Unlink allowed on writable directory.
expect 0 mkdir ${n0} 0755
expect EACCES -u 65534 -g 65534 rmdir ${n0}
expect 0 prependacl . user:65534:write_data::allow
expect 0 -u 65534 -g 65534 rmdir ${n0}
# Moving directory elsewhere allowed on writable directory.
expect 0 mkdir ${n0} 0777
expect 0 prependacl . user:65534:write_data::deny
expect EACCES -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
expect 0 prependacl . user:65534:write_data::allow
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
# 12
# Moving directory from elsewhere allowed on writable directory.
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 prependacl . user:65534:append_data::allow
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 rmdir ${n0}
# Moving directory from elsewhere overwriting local directory allowed
# on writable directory.
expect 0 mkdir ${n0} 0755
expect 0 mkdir ../${n3}/${n0} 0777
expect 0 prependacl . user:65534:write_data::deny
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 prependacl . user:65534:write_data::allow
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 rmdir ${n0}
# 23
# Denied DELETE changes nothing wrt removing.
expect 0 mkdir ${n0} 0755
expect 0 prependacl ${n0} user:65534:delete::deny
expect 0 -u 65534 -g 65534 rmdir ${n0}
# Denied DELETE changes nothing wrt moving elsewhere or from elsewhere.
expect 0 mkdir ${n0} 0777
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 rmdir ${n0}
# DELETE_CHILD denies unlink on writable directory.
expect 0 mkdir ${n0} 0755
expect 0 prependacl . user:65534:delete_child::deny
expect EPERM -u 65534 -g 65534 rmdir ${n0}
expect 0 rmdir ${n0}
# 35
# DELETE_CHILD denies moving directory elsewhere.
expect 0 mkdir ${n0} 0777
expect EPERM -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
expect 0 rename ${n0} ../${n3}/${n0}
# DELETE_CHILD does not deny moving directory from elsewhere
# to a writable directory.
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# DELETE_CHILD denies moving directory from elsewhere
# to a writable directory overwriting local directory.
expect 0 mkdir ../${n3}/${n0} 0755
expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# DELETE allowed on directory allows for unlinking, no matter
# what permissions on containing directory are.
expect 0 prependacl ${n0} user:65534:delete::allow
expect 0 -u 65534 -g 65534 rmdir ${n0}
# Same for moving the directory elsewhere.
expect 0 mkdir ${n0} 0777
expect 0 prependacl ${n0} user:65534:delete::allow
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
# 46
# Same for moving the directory from elsewhere into a writable
# directory with DELETE_CHILD denied.
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 rmdir ${n0}
# DELETE does not allow for overwriting a directory in a unwritable
# directory with DELETE_CHILD denied.
expect 0 mkdir ${n0} 0755
expect 0 mkdir ../${n3}/${n0} 0777
expect 0 prependacl . user:65534:write_data::deny
expect 0 prependacl . user:65534:delete_child::deny
expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 prependacl ${n0} user:65534:delete::allow
# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# 54
# But it allows for plain deletion.
# XXX: expect 0 -u 65534 -g 65534 rmdir ${n0}
expect 0 rmdir ${n0}
# DELETE_CHILD allowed on unwritable directory.
expect 0 mkdir ${n0} 0755
expect 0 prependacl . user:65534:delete_child::allow
expect 0 -u 65534 -g 65534 rmdir ${n0}
# Moving things elsewhere is allowed.
expect 0 mkdir ${n0} 0777
expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0}
# 60
# Moving things back is not.
# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# Even if we're overwriting.
# XXX: expect 0 mkdir ${n0} 0755
expect 0 mkdir ../${n3}/${n0} 0777
# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 mkdir ../${n3}/${n0} 0777
# Even if we have DELETE on the existing directory.
expect 0 prependacl ${n0} user:65534:delete::allow
# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0}
# Denied DELETE changes nothing wrt removing.
expect 0 prependacl ${n0} user:65534:delete::deny
expect 0 -u 65534 -g 65534 rmdir ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

@ -0,0 +1,93 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/00.t 211352 2010-08-15 21:24:17Z pjd $
desc="link creates hardlinks"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..202"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
expect 0 mkdir ${n3} 0755
cdir=`pwd`
cd ${n3}
for type in regular fifo block char socket; do
create_file ${type} ${n0}
expect ${type},1 lstat ${n0} type,nlink
expect 0 link ${n0} ${n1}
expect ${type},2 lstat ${n0} type,nlink
expect ${type},2 lstat ${n1} type,nlink
expect 0 link ${n1} ${n2}
expect ${type},3 lstat ${n0} type,nlink
expect ${type},3 lstat ${n1} type,nlink
expect ${type},3 lstat ${n2} type,nlink
expect 0 chmod ${n1} 0201
expect 0 chown ${n1} 65534 65533
expect ${type},0201,3,65534,65533 lstat ${n0} type,mode,nlink,uid,gid
expect ${type},0201,3,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
expect ${type},0201,3,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
expect 0 unlink ${n0}
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
expect ${type},0201,2,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
expect ${type},0201,2,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
expect 0 unlink ${n2}
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
expect ${type},0201,1,65534,65533 lstat ${n1} type,mode,nlink,uid,gid
expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
expect 0 unlink ${n1}
expect ENOENT lstat ${n0} type,mode,nlink,uid,gid
expect ENOENT lstat ${n1} type,mode,nlink,uid,gid
expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
done
# successful link(2) updates ctime.
for type in regular fifo block char socket; do
create_file ${type} ${n0}
ctime1=`${fstest} stat ${n0} ctime`
dctime1=`${fstest} stat . ctime`
dmtime1=`${fstest} stat . mtime`
sleep 1
expect 0 link ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
dctime2=`${fstest} stat . ctime`
test_check $dctime1 -lt $dctime2
dmtime2=`${fstest} stat . mtime`
test_check $dctime1 -lt $dmtime2
expect 0 unlink ${n0}
expect 0 unlink ${n1}
done
# unsuccessful link(2) does not update ctime.
for type in regular fifo block char socket; do
create_file ${type} ${n0}
expect 0 -- chown ${n0} 65534 -1
ctime1=`${fstest} stat ${n0} ctime`
dctime1=`${fstest} stat . ctime`
dmtime1=`${fstest} stat . mtime`
sleep 1
expect EACCES -u 65534 link ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
dctime2=`${fstest} stat . ctime`
test_check $dctime1 -eq $dctime2
dmtime2=`${fstest} stat . mtime`
test_check $dctime1 -eq $dmtime2
expect 0 unlink ${n0}
done
cd ${cdir}
expect 0 rmdir ${n3}

View File

@ -0,0 +1,24 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/01.t 211474 2010-08-18 22:06:43Z pjd $
desc="link returns ENOTDIR if a component of either path prefix is not a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..32"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
for type in regular fifo block char socket; do
create_file ${type} ${n0}/${n1}
expect ENOTDIR link ${n0}/${n1}/test ${n0}/${n2}
create_file ${type} ${n0}/${n2}
expect ENOTDIR link ${n0}/${n2} ${n0}/${n1}/test
expect 0 unlink ${n0}/${n1}
expect 0 unlink ${n0}/${n2}
done
expect 0 rmdir ${n0}

View File

@ -0,0 +1,25 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns ENAMETOOLONG if a component of either pathname exceeded {NAME_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
n0=`namegen`
nx=`namegen_max`
nxx="${nx}x"
expect 0 create ${nx} 0644
expect 0 link ${nx} ${n0}
expect 0 unlink ${nx}
expect 0 link ${n0} ${nx}
expect 0 unlink ${n0}
expect 0 unlink ${nx}
expect 0 create ${n0} 0644
expect ENAMETOOLONG link ${n0} ${nxx}
expect 0 unlink ${n0}
expect ENAMETOOLONG link ${nxx} ${n0}

View File

@ -0,0 +1,31 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns ENAMETOOLONG if an entire length of either path name exceeded {PATH_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..13"
n0=`namegen`
nx=`dirgen_max`
nxx="${nx}x"
mkdir -p "${nx%/*}"
expect 0 create ${nx} 0644
expect 0 link ${nx} ${n0}
expect 2 stat ${n0} nlink
expect 2 stat ${nx} nlink
expect 0 unlink ${nx}
expect 0 link ${n0} ${nx}
expect 2 stat ${n0} nlink
expect 2 stat ${nx} nlink
expect 0 unlink ${nx}
expect ENAMETOOLONG link ${n0} ${nxx}
expect 1 stat ${n0} nlink
expect 0 unlink ${n0}
expect ENAMETOOLONG link ${nxx} ${n0}
rm -rf "${nx%%/*}"

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/04.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns ENOENT if a component of either path prefix does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..6"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT link ${n0}/${n1}/test ${n2}
expect 0 create ${n2} 0644
expect ENOENT link ${n2} ${n0}/${n1}/test
expect 0 unlink ${n2}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,36 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/05.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EMLINK if the link count of the file named by name1 would exceed 32767"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
echo "1..5"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs -i 1 /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 create ${n0}/${n1} 0644
i=1
while :; do
link ${n0}/${n1} ${n0}/${i} >/dev/null 2>&1
if [ $? -ne 0 ]; then
break
fi
i=`expr $i + 1`
done
test_check $i -eq 32767
expect EMLINK link ${n0}/${n1} ${n0}/${n2}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,43 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/06.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EACCES when a component of either path prefix denies search permission"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..18"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
n4=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 mkdir ${n2} 0755
expect 0 chown ${n2} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644
expect 0 -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
expect 0 -u 65534 -g 65534 unlink ${n2}/${n4}
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n1}/${n4}
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
expect 0 chmod ${n1} 0755
expect 0 chmod ${n2} 0644
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
expect 0 unlink ${n1}/${n3}
expect 0 rmdir ${n1}
expect 0 rmdir ${n2}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,41 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/07.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EACCES when the requested link requires writing in a directory with a mode that denies write permission"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..17"
n0=`namegen`
n1=`namegen`
n2=`namegen`
n3=`namegen`
n4=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 mkdir ${n2} 0755
expect 0 chown ${n2} 65534 65534
expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644
expect 0 -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
expect 0 -u 65534 -g 65534 unlink ${n2}/${n4}
expect 0 chmod ${n2} 0555
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
expect 0 chmod ${n1} 0555
expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n1}/${n4}
expect 0 chmod ${n1} 0755
expect 0 unlink ${n1}/${n3}
expect 0 rmdir ${n1}
expect 0 rmdir ${n2}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,24 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/08.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns ELOOP if too many symbolic links were encountered in translating one of the pathnames"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP link ${n0}/test ${n2}
expect ELOOP link ${n1}/test ${n2}
expect 0 create ${n2} 0644
expect ELOOP link ${n2} ${n0}/test
expect ELOOP link ${n2} ${n1}/test
expect 0 unlink ${n0}
expect 0 unlink ${n1}
expect 0 unlink ${n2}

View File

@ -0,0 +1,18 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/09.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns ENOENT if the source file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..5"
n0=`namegen`
n1=`namegen`
expect 0 create ${n0} 0644
expect 0 link ${n0} ${n1}
expect 0 unlink ${n0}
expect 0 unlink ${n1}
expect ENOENT link ${n0} ${n1}

View File

@ -0,0 +1,26 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/10.t 211474 2010-08-18 22:06:43Z pjd $
desc="link returns EEXIST if the destination file does exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..23"
n0=`namegen`
n1=`namegen`
expect 0 create ${n0} 0644
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n1}
expect EEXIST link ${n0} ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
expect 0 unlink ${n0}

View File

@ -0,0 +1,41 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/11.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EPERM if the source file is a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
n0=`namegen`
n1=`namegen`
n2=`namegen`
case "${os}:${fs}" in
SunOS:UFS)
echo "1..10"
expect 0 mkdir ${n0} 0755
expect 0 link ${n0} ${n1}
expect 0 unlink ${n1}
expect 0 rmdir ${n0}
;;
*)
echo "1..9"
expect 0 mkdir ${n0} 0755
expect EPERM link ${n0} ${n1}
expect 0 rmdir ${n0}
;;
esac
expect 0 mkdir ${n0} 0755
expect 0 chown ${n0} 65534 65534
cdir=`pwd`
cd ${n0}
expect 0 -u 65534 -g 65534 mkdir ${n1} 0755
expect EPERM -u 65534 -g 65534 link ${n1} ${n2}
expect 0 -u 65534 -g 65534 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,95 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/12.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EPERM if the source file has its immutable or append-only flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:ZFS)
echo "1..27"
;;
FreeBSD:UFS)
echo "1..48"
;;
*)
quick_exit
esac
n0=`namegen`
n1=`namegen`
expect 0 create ${n0} 0644
expect 1 stat ${n0} nlink
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
expect 0 chflags ${n0} SF_IMMUTABLE
todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM."
expect EPERM link ${n0} ${n1}
todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM."
expect 1 stat ${n0} nlink
expect 0 chflags ${n0} none
todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM."
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
expect 0 chflags ${n0} SF_NOUNLINK
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
case "${os}:${fs}" in
FreeBSD:ZFS)
expect 0 chflags ${n0} SF_APPEND
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
;;
FreeBSD:UFS)
expect 0 chflags ${n0} SF_APPEND
expect EPERM link ${n0} ${n1}
expect 0 chflags ${n0} none
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM link ${n0} ${n1}
expect 0 chflags ${n0} none
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
expect 0 chflags ${n0} UF_NOUNLINK
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
expect 0 chflags ${n0} UF_APPEND
expect EPERM link ${n0} ${n1}
expect 0 chflags ${n0} none
expect 0 link ${n0} ${n1}
expect 2 stat ${n0} nlink
expect 0 unlink ${n1}
expect 1 stat ${n0} nlink
;;
esac
expect 0 unlink ${n0}

View File

@ -0,0 +1,86 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/13.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EPERM if the parent directory of the destination file has its immutable flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:ZFS)
echo "1..29"
;;
FreeBSD:UFS)
echo "1..49"
;;
*)
quick_exit
esac
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n0}/${n1} 0644
expect 1 stat ${n0}/${n1} nlink
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 2 stat ${n0}/${n1} nlink
expect 0 unlink ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} SF_IMMUTABLE
expect EPERM link ${n0}/${n1} ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} none
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 2 stat ${n0}/${n1} nlink
expect 0 unlink ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} SF_NOUNLINK
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 2 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} SF_APPEND
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 2 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
case "${os}:${fs}" in
FreeBSD:UFS)
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM link ${n0}/${n1} ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} none
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 2 stat ${n0}/${n1} nlink
expect 0 unlink ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} UF_NOUNLINK
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 2 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} UF_APPEND
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 2 stat ${n0}/${n1} nlink
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n2}
expect 1 stat ${n0}/${n1} nlink
;;
esac
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,29 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/14.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EXDEV if the source and the destination files are on different file systems"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}" = "FreeBSD" ] || quick_exit
echo "1..8"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 create ${n0}/${n1} 0644
expect EXDEV link ${n0}/${n1} ${n2}
expect 0 unlink ${n0}/${n1}
expect 0 create ${n1} 0644
expect EXDEV link ${n1} ${n0}/${n2}
expect 0 unlink ${n1}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,33 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/15.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns ENOSPC if the directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
echo "1..4"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 512k` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 create ${n0}/${n1} 0644
i=0
while :; do
link ${n0}/${n1} ${n0}/${i} >/dev/null 2>&1
if [ $? -ne 0 ]; then
break
fi
i=`expr $i + 1`
done
expect ENOSPC link ${n0}/${n1} ${n0}/${n2}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,34 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/16.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EROFS if the requested link requires writing in a directory on a read-only file system"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}" = "FreeBSD" ] || quick_exit
echo "1..9"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 create ${n0}/${n1} 0644
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 0 unlink ${n0}/${n2}
mount -ur /dev/md${n}
expect EROFS link ${n0}/${n1} ${n0}/${n2}
mount -uw /dev/md${n}
expect 0 link ${n0}/${n1} ${n0}/${n2}
expect 0 unlink ${n0}/${n2}
expect 0 unlink ${n0}/${n1}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/17.t 211352 2010-08-15 21:24:17Z pjd $
desc="link returns EFAULT if one of the pathnames specified is outside the process's allocated address space"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..8"
n0=`namegen`
expect 0 create ${n0} 0644
expect EFAULT link ${n0} NULL
expect EFAULT link ${n0} DEADCODE
expect 0 unlink ${n0}
expect EFAULT link NULL ${n0}
expect EFAULT link DEADCODE ${n0}
expect EFAULT link NULL DEADCODE
expect EFAULT link DEADCODE NULL

221
contrib/pjdfstest/tests/misc.sh Executable file
View File

@ -0,0 +1,221 @@
# $FreeBSD$
ntest=1
case "${dir}" in
/*)
maindir="${dir}/../.."
;;
*)
maindir="`pwd`/${dir}/../.."
;;
esac
fstest="${maindir}/pjdfstest"
. ${maindir}/tests/conf
expect()
{
e="${1}"
shift
r=`${fstest} $* 2>/dev/null | tail -1`
echo "${r}" | ${GREP} -Eq '^'${e}'$'
if [ $? -eq 0 ]; then
if [ -z "${todomsg}" ]; then
echo "ok ${ntest}"
else
echo "ok ${ntest} # TODO ${todomsg}"
fi
else
if [ -z "${todomsg}" ]; then
echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}"
else
echo "not ok ${ntest} # TODO ${todomsg}"
fi
fi
todomsg=""
ntest=$((ntest+1))
}
jexpect()
{
s="${1}"
d="${2}"
e="${3}"
shift 3
r=`jail -s ${s} / pjdfstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} $* 2>/dev/null" | tail -1`
echo "${r}" | ${GREP} -Eq '^'${e}'$'
if [ $? -eq 0 ]; then
if [ -z "${todomsg}" ]; then
echo "ok ${ntest}"
else
echo "ok ${ntest} # TODO ${todomsg}"
fi
else
if [ -z "${todomsg}" ]; then
echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}"
else
echo "not ok ${ntest} # TODO ${todomsg}"
fi
fi
todomsg=""
ntest=$((ntest+1))
}
test_check()
{
if [ $* ]; then
if [ -z "${todomsg}" ]; then
echo "ok ${ntest}"
else
echo "ok ${ntest} # TODO ${todomsg}"
fi
else
if [ -z "${todomsg}" ]; then
echo "not ok ${ntest}"
else
echo "not ok ${ntest} # TODO ${todomsg}"
fi
fi
todomsg=""
ntest=$((ntest+1))
}
todo()
{
if [ "${os}" = "${1}" -o "${os}:${fs}" = "${1}" ]; then
todomsg="${2}"
fi
}
namegen()
{
echo "pjdfstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`"
}
namegen_len()
{
len="${1}"
name=""
while :; do
namepart="`dd if=/dev/urandom bs=64 count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`"
name="${name}${namepart}"
curlen=`printf "%s" "${name}" | wc -c`
[ ${curlen} -lt ${len} ] || break
done
name=`echo "${name}" | cut -b -${len}`
printf "%s" "${name}"
}
# POSIX:
# {NAME_MAX}
# Maximum number of bytes in a filename (not including terminating null).
namegen_max()
{
name_max=`${fstest} pathconf . _PC_NAME_MAX`
namegen_len ${name_max}
}
# POSIX:
# {PATH_MAX}
# Maximum number of bytes in a pathname, including the terminating null character.
dirgen_max()
{
name_max=`${fstest} pathconf . _PC_NAME_MAX`
complen=$((name_max/2))
path_max=`${fstest} pathconf . _PC_PATH_MAX`
# "...including the terminating null character."
path_max=$((path_max-1))
name=""
while :; do
name="${name}`namegen_len ${complen}`/"
curlen=`printf "%s" "${name}" | wc -c`
[ ${curlen} -lt ${path_max} ] || break
done
name=`echo "${name}" | cut -b -${path_max}`
name=`echo "${name}" | sed -E 's@/$@x@'`
printf "%s" "${name}"
}
quick_exit()
{
echo "1..1"
echo "ok 1"
exit 0
}
supported()
{
case "${1}" in
lchmod)
if [ "${os}" != "FreeBSD" ]; then
return 1
fi
;;
chflags)
if [ "${os}" != "FreeBSD" ]; then
return 1
fi
;;
chflags_SF_SNAPSHOT)
if [ "${os}" != "FreeBSD" -o "${fs}" != "UFS" ]; then
return 1
fi
;;
esac
return 0
}
require()
{
if supported ${1}; then
return
fi
quick_exit
}
# usage:
# create_file <type> <name>
# create_file <type> <name> <mode>
# create_file <type> <name> <uid> <gid>
# create_file <type> <name> <mode> <uid> <gid>
create_file() {
type="${1}"
name="${2}"
case "${type}" in
none)
return
;;
regular)
expect 0 create ${name} 0644
;;
dir)
expect 0 mkdir ${name} 0755
;;
fifo)
expect 0 mkfifo ${name} 0644
;;
block)
expect 0 mknod ${name} b 0644 1 2
;;
char)
expect 0 mknod ${name} c 0644 1 2
;;
socket)
expect 0 bind ${name}
;;
symlink)
expect 0 symlink test ${name}
;;
esac
if [ -n "${3}" -a -n "${4}" -a -n "${5}" ]; then
expect 0 lchmod ${name} ${3}
expect 0 lchown ${name} ${4} ${5}
elif [ -n "${3}" -a -n "${4}" ]; then
expect 0 lchown ${name} ${3} ${4}
elif [ -n "${3}" ]; then
expect 0 lchmod ${name} ${3}
fi
}

View File

@ -0,0 +1,73 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/00.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir creates directories"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..36"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n1} 0755
cdir=`pwd`
cd ${n1}
# POSIX: The file permission bits of the new directory shall be initialized from
# mode. These file permission bits of the mode argument shall be modified by the
# process' file creation mask.
expect 0 mkdir ${n0} 0755
expect dir,0755 lstat ${n0} type,mode
expect 0 rmdir ${n0}
expect 0 mkdir ${n0} 0151
expect dir,0151 lstat ${n0} type,mode
expect 0 rmdir ${n0}
expect 0 -U 077 mkdir ${n0} 0151
expect dir,0100 lstat ${n0} type,mode
expect 0 rmdir ${n0}
expect 0 -U 070 mkdir ${n0} 0345
expect dir,0305 lstat ${n0} type,mode
expect 0 rmdir ${n0}
expect 0 -U 0501 mkdir ${n0} 0345
expect dir,0244 lstat ${n0} type,mode
expect 0 rmdir ${n0}
# POSIX: The directory's user ID shall be set to the process' effective user ID.
# The directory's group ID shall be set to the group ID of the parent directory
# or to the effective group ID of the process.
expect 0 chown . 65535 65535
expect 0 -u 65535 -g 65535 mkdir ${n0} 0755
expect 65535,65535 lstat ${n0} uid,gid
expect 0 rmdir ${n0}
expect 0 -u 65535 -g 65534 mkdir ${n0} 0755
expect "65535,6553[45]" lstat ${n0} uid,gid
expect 0 rmdir ${n0}
expect 0 chmod . 0777
expect 0 -u 65534 -g 65533 mkdir ${n0} 0755
expect "65534,6553[35]" lstat ${n0} uid,gid
expect 0 rmdir ${n0}
# POSIX: Upon successful completion, mkdir() shall mark for update the st_atime,
# st_ctime, and st_mtime fields of the directory. Also, the st_ctime and
# st_mtime fields of the directory that contains the new entry shall be marked
# for update.
expect 0 chown . 0 0
time=`${fstest} stat . ctime`
sleep 1
expect 0 mkdir ${n0} 0755
atime=`${fstest} stat ${n0} atime`
test_check $time -lt $atime
mtime=`${fstest} stat ${n0} mtime`
test_check $time -lt $mtime
ctime=`${fstest} stat ${n0} ctime`
test_check $time -lt $ctime
mtime=`${fstest} stat . mtime`
test_check $time -lt $mtime
ctime=`${fstest} stat . ctime`
test_check $time -lt $ctime
expect 0 rmdir ${n0}
cd ${cdir}
expect 0 rmdir ${n1}

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/01.t 211474 2010-08-18 22:06:43Z pjd $
desc="mkdir returns ENOTDIR if a component of the path prefix is not a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..17"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
for type in regular fifo block char socket; do
create_file ${type} ${n0}/${n1}
expect ENOTDIR mkdir ${n0}/${n1}/test 0755
expect 0 unlink ${n0}/${n1}
done
expect 0 rmdir ${n0}

View File

@ -0,0 +1,16 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/02.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..3"
nx=`namegen_max`
nxx="${nx}x"
expect 0 mkdir ${nx} 0755
expect 0 rmdir ${nx}
expect ENAMETOOLONG mkdir ${nxx} 0755

View File

@ -0,0 +1,20 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/03.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..3"
nx=`dirgen_max`
nxx="${nx}x"
mkdir -p "${nx%/*}"
expect 0 mkdir ${nx} 0755
expect 0 rmdir ${nx}
expect ENAMETOOLONG mkdir ${nxx} 0755
rm -rf "${nx%%/*}"

View File

@ -0,0 +1,16 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/04.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns ENOENT if a component of the path prefix does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..3"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
expect ENOENT mkdir ${n0}/${n1}/test 0755
expect 0 rmdir ${n0}

View File

@ -0,0 +1,29 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/05.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns EACCES when search permission is denied for a component of the path prefix"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..12"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
expect 0 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,29 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/06.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns EACCES when write permission is denied on the parent directory of the directory to be created"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..12"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
cdir=`pwd`
cd ${n0}
expect 0 mkdir ${n1} 0755
expect 0 chown ${n1} 65534 65534
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
expect 0 chmod ${n1} 0555
expect EACCES -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755
expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@ -0,0 +1,19 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/07.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns ELOOP if too many symbolic links were encountered in translating the pathname"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..6"
n0=`namegen`
n1=`namegen`
expect 0 symlink ${n0} ${n1}
expect 0 symlink ${n1} ${n0}
expect ELOOP mkdir ${n0}/test 0755
expect ELOOP mkdir ${n1}/test 0755
expect 0 unlink ${n0}
expect 0 unlink ${n1}

View File

@ -0,0 +1,66 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/08.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns EPERM if the parent directory of the directory to be created has its immutable flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
case "${os}:${fs}" in
FreeBSD:ZFS)
echo "1..17"
;;
FreeBSD:UFS)
echo "1..30"
;;
*)
quick_exit
esac
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 mkdir ${n0}/${n1} 0755
expect 0 rmdir ${n0}/${n1}
expect 0 chflags ${n0} SF_IMMUTABLE
expect EPERM mkdir ${n0}/${n1} 0755
expect 0 chflags ${n0} none
expect 0 mkdir ${n0}/${n1} 0755
expect 0 rmdir ${n0}/${n1}
expect 0 chflags ${n0} SF_NOUNLINK
expect 0 mkdir ${n0}/${n1} 0755
expect 0 rmdir ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 chflags ${n0} SF_APPEND
expect 0 mkdir ${n0}/${n1} 0755
expect 0 chflags ${n0} none
expect 0 rmdir ${n0}/${n1}
case "${os}:${fs}" in
FreeBSD:UFS)
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM mkdir ${n0}/${n1} 0755
expect 0 chflags ${n0} none
expect 0 mkdir ${n0}/${n1} 0755
expect 0 rmdir ${n0}/${n1}
expect 0 chflags ${n0} UF_NOUNLINK
expect 0 mkdir ${n0}/${n1} 0755
expect 0 rmdir ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 chflags ${n0} UF_APPEND
expect 0 mkdir ${n0}/${n1} 0755
expect 0 chflags ${n0} none
expect 0 rmdir ${n0}/${n1}
;;
esac
expect 0 rmdir ${n0}

View File

@ -0,0 +1,29 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/09.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns EROFS if the named file resides on a read-only file system"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
echo "1..7"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
expect 0 mkdir ${n0}/${n1} 0755
expect 0 rmdir ${n0}/${n1}
mount -ur /dev/md${n}
expect EROFS mkdir ${n0}/${n1} 0755
mount -uw /dev/md${n}
expect 0 mkdir ${n0}/${n1} 0755
expect 0 rmdir ${n0}/${n1}
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,21 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/10.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns EEXIST if the named file exists"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..21"
n0=`namegen`
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}
expect EEXIST mkdir ${n0} 0755
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done

View File

@ -0,0 +1,31 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/11.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns ENOSPC if there are no free inodes on the file system on which the directory is being created"
dir=`dirname $0`
. ${dir}/../misc.sh
[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
echo "1..3"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 512k` || exit
newfs /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
i=0
while :; do
mkdir ${n0}/${i} >/dev/null 2>&1
if [ $? -ne 0 ]; then
break
fi
i=`expr $i + 1`
done
expect ENOSPC mkdir ${n0}/${n1} 0755
umount /dev/md${n}
mdconfig -d -u ${n} || exit
expect 0 rmdir ${n0}

View File

@ -0,0 +1,12 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/12.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkdir returns EFAULT if the path argument points outside the process's allocated address space"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..2"
expect EFAULT mkdir NULL 0755
expect EFAULT mkdir DEADCODE 0755

View File

@ -0,0 +1,73 @@
#!/bin/sh
# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/00.t 211352 2010-08-15 21:24:17Z pjd $
desc="mkfifo creates fifo files"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..36"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n1} 0755
cdir=`pwd`
cd ${n1}
# POSIX: The file permission bits of the new FIFO shall be initialized from
# mode. The file permission bits of the mode argument shall be modified by the
# process' file creation mask.
expect 0 mkfifo ${n0} 0755
expect fifo,0755 lstat ${n0} type,mode
expect 0 unlink ${n0}
expect 0 mkfifo ${n0} 0151
expect fifo,0151 lstat ${n0} type,mode
expect 0 unlink ${n0}
expect 0 -U 077 mkfifo ${n0} 0151
expect fifo,0100 lstat ${n0} type,mode
expect 0 unlink ${n0}
expect 0 -U 070 mkfifo ${n0} 0345
expect fifo,0305 lstat ${n0} type,mode
expect 0 unlink ${n0}
expect 0 -U 0501 mkfifo ${n0} 0345
expect fifo,0244 lstat ${n0} type,mode
expect 0 unlink ${n0}
# POSIX: The FIFO's user ID shall be set to the process' effective user ID.
# The FIFO's group ID shall be set to the group ID of the parent directory or to
# the effective group ID of the process.
expect 0 chown . 65535 65535
expect 0 -u 65535 -g 65535 mkfifo ${n0} 0755
expect 65535,65535 lstat ${n0} uid,gid
expect 0 unlink ${n0}
expect 0 -u 65535 -g 65534 mkfifo ${n0} 0755
expect "65535,6553[45]" lstat ${n0} uid,gid
expect 0 unlink ${n0}
expect 0 chmod . 0777
expect 0 -u 65534 -g 65533 mkfifo ${n0} 0755
expect "65534,6553[35]" lstat ${n0} uid,gid
expect 0 unlink ${n0}
# POSIX: Upon successful completion, mkfifo() shall mark for update the
# st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and
# st_mtime fields of the directory that contains the new entry shall be marked
# for update.
expect 0 chown . 0 0
time=`${fstest} stat . ctime`
sleep 1
expect 0 mkfifo ${n0} 0755
atime=`${fstest} stat ${n0} atime`
test_check $time -lt $atime
mtime=`${fstest} stat ${n0} mtime`
test_check $time -lt $mtime
ctime=`${fstest} stat ${n0} ctime`
test_check $time -lt $ctime
mtime=`${fstest} stat . mtime`
test_check $time -lt $mtime
ctime=`${fstest} stat . ctime`
test_check $time -lt $ctime
expect 0 unlink ${n0}
cd ${cdir}
expect 0 rmdir ${n1}

Some files were not shown because too many files have changed in this diff Show More