Imported Upstream version 1.5.1

This commit is contained in:
Mario Fetka
2020-09-22 02:25:22 +02:00
commit 434d6067d9
2103 changed files with 928962 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/00.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink removes regular files, symbolic links, fifos and sockets"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..55"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
expect 0 create ${n0} 0644
expect regular lstat ${n0} type
expect 0 unlink ${n0}
expect ENOENT lstat ${n0} type
expect 0 symlink ${n1} ${n0}
expect symlink lstat ${n0} type
expect 0 unlink ${n0}
expect ENOENT lstat ${n0} type
expect_noop 0 mkfifo ${n0} 0644
expect_noop fifo lstat ${n0} type
expect_noop 0 unlink ${n0}
expect_noop ENOENT lstat ${n0} type
# TODO: sockets removal
# successful unlink(2) updates ctime.
expect 0 create ${n0} 0644
expect 0 link ${n0} ${n1}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 unlink ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n0}
expect_noop 0 mkfifo ${n0} 0644
expect_noop 0 link ${n0} ${n1}
ctime1=`${fstest} stat ${n0} ctime`
#sleep 1
expect_noop 0 unlink ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check_noop $ctime1 -lt $ctime2
expect_noop 0 unlink ${n0}
# unsuccessful unlink(2) does not update ctime.
expect 0 create ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EACCES -u 65534 unlink ${n0}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
expect_noop 0 mkfifo ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
#sleep 1
expect_noop EACCES -u 65534 unlink ${n0}
ctime2=`${fstest} stat ${n0} ctime`
test_check_noop $ctime1 -eq $ctime2
expect_noop 0 unlink ${n0}
expect 0 mkdir ${n0} 0755
expect 0 create ${n0}/${n1} 0644
time=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 unlink ${n0}/${n1}
mtime=`${fstest} stat ${n0} mtime`
test_check $time -lt $mtime
ctime=`${fstest} stat ${n0} ctime`
test_check $time -lt $ctime
expect 0 rmdir ${n0}
expect_noop 0 mkdir ${n0} 0755
expect_noop 0 mkfifo ${n0}/${n1} 0644
time=`${fstest} stat ${n0} ctime`
#sleep 1
expect_noop 0 unlink ${n0}/${n1}
mtime=`${fstest} stat ${n0} mtime`
test_check_noop $time -lt $mtime
ctime=`${fstest} stat ${n0} ctime`
test_check_noop $time -lt $ctime
expect_noop 0 rmdir ${n0}
expect 0 mkdir ${n0} 0755
expect 0 symlink test ${n0}/${n1}
time=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 unlink ${n0}/${n1}
mtime=`${fstest} stat ${n0} mtime`
test_check $time -lt $mtime
ctime=`${fstest} stat ${n0} ctime`
test_check $time -lt $ctime
expect 0 rmdir ${n0}
expect 0 create ${n0} 0644
expect 0 link ${n0} ${n1}
time=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 unlink ${n1}
ctime=`${fstest} stat ${n0} ctime`
test_check $time -lt $ctime
expect 0 unlink ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

@@ -0,0 +1,18 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/01.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink 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 unlink ${n0}/${n1}/test
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@@ -0,0 +1,14 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/02.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..4"
expect 0 create ${name255} 0644
expect 0 unlink ${name255}
expect ENOENT unlink ${name255}
expect ENAMETOOLONG unlink ${name256}

View File

@@ -0,0 +1,24 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/03.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..12"
expect 0 mkdir ${name255} 0755
expect 0 mkdir ${name255}/${name255} 0755
expect 0 mkdir ${name255}/${name255}/${name255} 0755
expect 0 mkdir ${path1021} 0755
expect 0 create ${path1023} 0644
expect 0 unlink ${path1023}
expect ENOENT unlink ${path1023}
create_too_long
expect ENAMETOOLONG unlink ${too_long}
unlink_too_long
expect 0 rmdir ${path1021}
expect 0 rmdir ${name255}/${name255}/${name255}
expect 0 rmdir ${name255}/${name255}
expect 0 rmdir ${name255}

View File

@@ -0,0 +1,17 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/04.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns ENOENT if the named file does not exist"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..4"
n0=`namegen`
n1=`namegen`
expect 0 create ${n0} 0644
expect 0 unlink ${n0}
expect ENOENT unlink ${n0}
expect ENOENT unlink ${n1}

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/05.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns EACCES when search permission is denied for a component of the path prefix"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
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 chmod ${n1} 0644
expect EACCES -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/06.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns EACCES when write permission is denied on the directory containing the link to be removed"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..10"
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 chmod ${n1} 0555
expect EACCES -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 chmod ${n1} 0755
expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
expect 0 rmdir ${n1}
cd ${cdir}
expect 0 rmdir ${n0}

View File

@@ -0,0 +1,19 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/07.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink 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 unlink ${n0}/test
expect ELOOP unlink ${n1}/test
expect 0 unlink ${n0}
expect 0 unlink ${n1}

View File

@@ -0,0 +1,28 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/08.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns EPERM if the named file is a directory"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..3"
n0=`namegen`
expect 0 mkdir ${n0} 0755
case "${os}:${fs}" in
SunOS:UFS)
expect 0 unlink ${n0}
expect ENOENT rmdir ${n0}
;;
Linux:*)
# Non-POSIX value returned by Linux since 2.1.132
expect EISDIR unlink ${n0}
expect 0 rmdir ${n0}
;;
*)
expect EPERM unlink ${n0}
expect 0 rmdir ${n0}
;;
esac

View File

@@ -0,0 +1,49 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/09.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns EPERM if the named file has its immutable, undeletable or append-only flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..30"
n0=`namegen`
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_IMMUTABLE
expect EPERM unlink ${n0}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM unlink ${n0}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_NOUNLINK
expect EPERM unlink ${n0}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_NOUNLINK
expect EPERM unlink ${n0}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} SF_APPEND
expect EPERM unlink ${n0}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 create ${n0} 0644
expect 0 chflags ${n0} UF_APPEND
expect EPERM unlink ${n0}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}

View File

@@ -0,0 +1,52 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/10.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns EPERM if the parent directory of the named file has its immutable or append-only flag set"
dir=`dirname $0`
. ${dir}/../misc.sh
require chflags
echo "1..30"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n0}/${n1} 0644
expect 0 chflags ${n0} SF_IMMUTABLE
expect EPERM unlink ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 create ${n0}/${n1} 0644
expect 0 chflags ${n0} UF_IMMUTABLE
expect EPERM unlink ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 create ${n0}/${n1} 0644
expect 0 chflags ${n0} SF_APPEND
expect EPERM unlink ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 create ${n0}/${n1} 0644
expect 0 chflags ${n0} UF_APPEND
expect EPERM unlink ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 create ${n0}/${n1} 0644
expect 0 chflags ${n0} SF_NOUNLINK
expect 0 unlink ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 create ${n0}/${n1} 0644
expect 0 chflags ${n0} UF_NOUNLINK
expect 0 unlink ${n0}/${n1}
expect 0 chflags ${n0} none
expect 0 rmdir ${n0}

View File

@@ -0,0 +1,68 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/11.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns EACCES or EPERM if the directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..33"
n0=`namegen`
n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n2} 0755
cdir=`pwd`
cd ${n2}
expect 0 mkdir ${n0} 0755
expect 0 chown ${n0} 65534 65534
expect 0 chmod ${n0} 01777
# User owns both: the sticky directory and the file to be removed.
expect 0 -u 65534 -g 65534 create ${n0}/${n1} 0644
expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
# User owns the file to be removed, but doesn't own the sticky directory.
expect 0 -u 65533 -g 65533 create ${n0}/${n1} 0644
expect 0 -u 65533 -g 65533 unlink ${n0}/${n1}
# User owns the sticky directory, but doesn't own the file to be removed.
expect 0 -u 65533 -g 65533 create ${n0}/${n1} 0644
expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
# User doesn't own the sticky directory nor the file to be removed.
expect 0 -u 65534 -g 65534 create ${n0}/${n1} 0644
expect "EACCES|EPERM" -u 65533 -g 65533 unlink ${n0}/${n1}
expect 0 unlink ${n0}/${n1}
# User owns both: the sticky directory and the fifo to be removed.
expect_noop 0 -u 65534 -g 65534 mkfifo ${n0}/${n1} 0644
expect_noop 0 -u 65534 -g 65534 unlink ${n0}/${n1}
# User owns the fifo to be removed, but doesn't own the sticky directory.
expect_noop 0 -u 65533 -g 65533 mkfifo ${n0}/${n1} 0644
expect_noop 0 -u 65533 -g 65533 unlink ${n0}/${n1}
# User owns the sticky directory, but doesn't own the fifo to be removed.
expect_noop 0 -u 65533 -g 65533 mkfifo ${n0}/${n1} 0644
expect_noop 0 -u 65534 -g 65534 unlink ${n0}/${n1}
# User doesn't own the sticky directory nor the fifo to be removed.
expect_noop 0 -u 65534 -g 65534 mkfifo ${n0}/${n1} 0644
expect_noop "EACCES|EPERM" -u 65533 -g 65533 unlink ${n0}/${n1}
expect_noop 0 unlink ${n0}/${n1}
# User owns both: the sticky directory and the symlink to be removed.
expect 0 -u 65534 -g 65534 symlink test ${n0}/${n1}
expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
# User owns the symlink to be removed, but doesn't own the sticky directory.
expect 0 -u 65533 -g 65533 symlink test ${n0}/${n1}
expect 0 -u 65533 -g 65533 unlink ${n0}/${n1}
# User owns the sticky directory, but doesn't own the symlink to be removed.
expect 0 -u 65533 -g 65533 symlink test ${n0}/${n1}
expect 0 -u 65534 -g 65534 unlink ${n0}/${n1}
# User doesn't own the sticky directory nor the symlink to be removed.
expect 0 -u 65534 -g 65534 symlink test ${n0}/${n1}
expect "EACCES|EPERM" -u 65533 -g 65533 unlink ${n0}/${n1}
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}
cd ${cdir}
expect 0 rmdir ${n2}

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/12.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink returns EROFS if the named file resides on a read-only file system"
dir=`dirname $0`
. ${dir}/../misc.sh
case "${os}:${fs}" in
FreeBSD:UFS)
echo "1..5"
n0=`namegen`
n1=`namegen`
expect 0 mkdir ${n0} 0755
n=`mdconfig -a -n -t malloc -s 1m`
newfs /dev/md${n} >/dev/null
mount /dev/md${n} ${n0}
expect 0 create ${n0}/${n1} 0644
mount -ur /dev/md${n}
expect EROFS unlink ${n0}/${n1}
mount -uw /dev/md${n}
expect 0 unlink ${n0}/${n1}
umount /dev/md${n}
mdconfig -d -u ${n}
expect 0 rmdir ${n0}
;;
*)
quick_exit
;;
esac

View File

@@ -0,0 +1,12 @@
#!/bin/sh
# $FreeBSD: src/tools/regression/fstest/tests/unlink/13.t,v 1.1 2007/01/17 01:42:12 pjd Exp $
desc="unlink 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 unlink NULL
expect EFAULT unlink DEADCODE