summaryrefslogtreecommitdiff
path: root/regress/sys/ffs/tests/rmdir
diff options
context:
space:
mode:
Diffstat (limited to 'regress/sys/ffs/tests/rmdir')
-rw-r--r--regress/sys/ffs/tests/rmdir/00.t23
-rw-r--r--regress/sys/ffs/tests/rmdir/01.t25
-rw-r--r--regress/sys/ffs/tests/rmdir/02.t9
-rw-r--r--regress/sys/ffs/tests/rmdir/03.t17
-rw-r--r--regress/sys/ffs/tests/rmdir/04.t12
-rw-r--r--regress/sys/ffs/tests/rmdir/05.t14
-rw-r--r--regress/sys/ffs/tests/rmdir/06.t31
-rw-r--r--regress/sys/ffs/tests/rmdir/07.t22
-rw-r--r--regress/sys/ffs/tests/rmdir/08.t22
-rw-r--r--regress/sys/ffs/tests/rmdir/09.t42
-rw-r--r--regress/sys/ffs/tests/rmdir/10.t45
-rw-r--r--regress/sys/ffs/tests/rmdir/11.t35
-rw-r--r--regress/sys/ffs/tests/rmdir/12.t14
-rw-r--r--regress/sys/ffs/tests/rmdir/13.t17
-rw-r--r--regress/sys/ffs/tests/rmdir/14.t22
-rw-r--r--regress/sys/ffs/tests/rmdir/15.t7
16 files changed, 357 insertions, 0 deletions
diff --git a/regress/sys/ffs/tests/rmdir/00.t b/regress/sys/ffs/tests/rmdir/00.t
new file mode 100644
index 00000000000..6086173f175
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/00.t
@@ -0,0 +1,23 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/00.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir removes directories"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect dir lstat ${n0} type
+expect 0 rmdir ${n0}
+expect ENOENT lstat ${n0} type
+
+expect 0 mkdir ${n0} 0755
+expect 0 mkdir ${n0}/${n1} 0755
+time=`${FSTEST} stat ${n0} ctime`
+sleep 1
+expect 0 rmdir ${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}
diff --git a/regress/sys/ffs/tests/rmdir/01.t b/regress/sys/ffs/tests/rmdir/01.t
new file mode 100644
index 00000000000..cd98094a39b
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/01.t
@@ -0,0 +1,25 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/01.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns ENOTDIR if a component of the path is not a directory"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect 0 create ${n0}/${n1} 0644
+expect ENOTDIR rmdir ${n0}/${n1}/test
+expect 0 unlink ${n0}/${n1}
+expect 0 rmdir ${n0}
+
+expect 0 create ${n0} 0644
+expect ENOTDIR rmdir ${n0}
+expect 0 unlink ${n0}
+
+expect 0 symlink ${n1} ${n0}
+expect ENOTDIR rmdir ${n0}
+expect 0 unlink ${n0}
+
+expect 0 mkfifo ${n0} 0644
+expect ENOTDIR rmdir ${n0}
+expect 0 unlink ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/02.t b/regress/sys/ffs/tests/rmdir/02.t
new file mode 100644
index 00000000000..cc184e5da3b
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/02.t
@@ -0,0 +1,9 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/02.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns ENAMETOOLONG if a component of a pathname exceeded 255 characters"
+
+expect 0 mkdir ${name255} 0755
+expect 0 rmdir ${name255}
+expect ENOENT rmdir ${name255}
+expect ENAMETOOLONG rmdir ${name256}
diff --git a/regress/sys/ffs/tests/rmdir/03.t b/regress/sys/ffs/tests/rmdir/03.t
new file mode 100644
index 00000000000..c311fbf5b12
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/03.t
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/03.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns ENAMETOOLONG if an entire path name exceeded 1023 characters"
+
+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 mkdir ${path1023} 0755
+expect 0 rmdir ${path1023}
+expect ENOENT rmdir ${path1023}
+expect ENAMETOOLONG rmdir ${path1024}
+expect 0 rmdir ${path1021}
+expect 0 rmdir ${name255}/${name255}/${name255}
+expect 0 rmdir ${name255}/${name255}
+expect 0 rmdir ${name255}
diff --git a/regress/sys/ffs/tests/rmdir/04.t b/regress/sys/ffs/tests/rmdir/04.t
new file mode 100644
index 00000000000..0f5baa2ba05
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/04.t
@@ -0,0 +1,12 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/04.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns ENOENT if the named directory does not exist"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect 0 rmdir ${n0}
+expect ENOENT rmdir ${n0}
+expect ENOENT rmdir ${n1}
diff --git a/regress/sys/ffs/tests/rmdir/05.t b/regress/sys/ffs/tests/rmdir/05.t
new file mode 100644
index 00000000000..120e3cc48f3
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/05.t
@@ -0,0 +1,14 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/05.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns ELOOP if too many symbolic links were encountered in translating the pathname"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 symlink ${n0} ${n1}
+expect 0 symlink ${n1} ${n0}
+expect ELOOP rmdir ${n0}/test
+expect ELOOP rmdir ${n1}/test
+expect 0 unlink ${n0}
+expect 0 unlink ${n1}
diff --git a/regress/sys/ffs/tests/rmdir/06.t b/regress/sys/ffs/tests/rmdir/06.t
new file mode 100644
index 00000000000..ce3313f3e7c
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/06.t
@@ -0,0 +1,31 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/06.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EEXIST or ENOTEMPTY the named directory contains files other than '.' and '..' in it"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect 0 mkdir ${n0}/${n1} 0755
+expect "EEXIST|ENOTEMPTY" rmdir ${n0}
+expect 0 rmdir ${n0}/${n1}
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 create ${n0}/${n1} 0644
+expect "EEXIST|ENOTEMPTY" rmdir ${n0}
+expect 0 unlink ${n0}/${n1}
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 symlink test ${n0}/${n1}
+expect "EEXIST|ENOTEMPTY" rmdir ${n0}
+expect 0 unlink ${n0}/${n1}
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 mkfifo ${n0}/${n1} 0644
+expect "EEXIST|ENOTEMPTY" rmdir ${n0}
+expect 0 unlink ${n0}/${n1}
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/07.t b/regress/sys/ffs/tests/rmdir/07.t
new file mode 100644
index 00000000000..8e99d13eebd
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/07.t
@@ -0,0 +1,22 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/07.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EACCES when search permission is denied for a component of the path prefix"
+
+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 chmod ${n1} 0644
+expect EACCES -u 65534 -g 65534 rmdir ${n1}/${n2}
+expect 0 chmod ${n1} 0755
+expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
+expect 0 rmdir ${n1}
+cd ${cdir}
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/08.t b/regress/sys/ffs/tests/rmdir/08.t
new file mode 100644
index 00000000000..c60c44b16fa
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/08.t
@@ -0,0 +1,22 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/08.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EACCES when write permission is denied on the directory containing the link to be removed"
+
+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 chmod ${n1} 0555
+expect EACCES -u 65534 -g 65534 rmdir ${n1}/${n2}
+expect 0 chmod ${n1} 0755
+expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2}
+expect 0 rmdir ${n1}
+cd ${cdir}
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/09.t b/regress/sys/ffs/tests/rmdir/09.t
new file mode 100644
index 00000000000..93e00085cb8
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/09.t
@@ -0,0 +1,42 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/09.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EPERM if the named file has its immutable, undeletable or append-only flag set"
+
+n0=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect 0 chflags ${n0} SF_IMMUTABLE
+expect EPERM rmdir ${n0}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 chflags ${n0} UF_IMMUTABLE
+expect EPERM rmdir ${n0}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 chflags ${n0} SF_NOUNLINK
+expect EPERM rmdir ${n0}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 chflags ${n0} UF_NOUNLINK
+expect EPERM rmdir ${n0}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 chflags ${n0} SF_APPEND
+expect EPERM rmdir ${n0}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}
+
+expect 0 mkdir ${n0} 0755
+expect 0 chflags ${n0} UF_APPEND
+expect EPERM rmdir ${n0}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/10.t b/regress/sys/ffs/tests/rmdir/10.t
new file mode 100644
index 00000000000..7e51a85c37e
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/10.t
@@ -0,0 +1,45 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/10.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EPERM if the parent directory of the named file has its immutable or append-only flag set"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+
+expect 0 mkdir ${n0}/${n1} 0755
+expect 0 chflags ${n0} SF_IMMUTABLE
+expect EPERM rmdir ${n0}/${n1}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}/${n1}
+
+expect 0 mkdir ${n0}/${n1} 0755
+expect 0 chflags ${n0} UF_IMMUTABLE
+expect EPERM rmdir ${n0}/${n1}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}/${n1}
+
+expect 0 mkdir ${n0}/${n1} 0755
+expect 0 chflags ${n0} SF_APPEND
+expect EPERM rmdir ${n0}/${n1}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}/${n1}
+
+expect 0 mkdir ${n0}/${n1} 0755
+expect 0 chflags ${n0} UF_APPEND
+expect EPERM rmdir ${n0}/${n1}
+expect 0 chflags ${n0} none
+expect 0 rmdir ${n0}/${n1}
+
+expect 0 mkdir ${n0}/${n1} 0755
+expect 0 chflags ${n0} SF_NOUNLINK
+expect 0 rmdir ${n0}/${n1}
+expect 0 chflags ${n0} none
+
+expect 0 mkdir ${n0}/${n1} 0755
+expect 0 chflags ${n0} UF_NOUNLINK
+expect 0 rmdir ${n0}/${n1}
+expect 0 chflags ${n0} none
+
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/11.t b/regress/sys/ffs/tests/rmdir/11.t
new file mode 100644
index 00000000000..7869a79c17e
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/11.t
@@ -0,0 +1,35 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/11.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EACCES or EPERM if the directory containing the directory to be removed is marked sticky, and neither the containing directory nor the directory to be removed are owned by the effective user ID"
+
+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 directory to be removed.
+expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755
+expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
+# User owns the directory to be removed, but doesn't own the sticky directory.
+expect 0 -u 65533 -g 65533 mkdir ${n0}/${n1} 0755
+expect 0 -u 65533 -g 65533 rmdir ${n0}/${n1}
+# User owns the sticky directory, but doesn't own the directory to be removed.
+expect 0 -u 65533 -g 65533 mkdir ${n0}/${n1} 0755
+expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1}
+# User doesn't own the sticky directory nor the directory to be removed.
+expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755
+expect "EACCES|EPERM" -u 65533 -g 65533 rmdir ${n0}/${n1}
+expect 0 rmdir ${n0}/${n1}
+
+expect 0 rmdir ${n0}
+
+cd ${cdir}
+expect 0 rmdir ${n2}
diff --git a/regress/sys/ffs/tests/rmdir/12.t b/regress/sys/ffs/tests/rmdir/12.t
new file mode 100644
index 00000000000..a3fb0a87e09
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/12.t
@@ -0,0 +1,14 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/12.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EINVAL if the last component of the path is '.' or '..'"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect 0 mkdir ${n0}/${n1} 0755
+expect EINVAL rmdir ${n0}/${n1}/.
+expect EINVAL rmdir ${n0}/${n1}/..
+expect 0 rmdir ${n0}/${n1}
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/13.t b/regress/sys/ffs/tests/rmdir/13.t
new file mode 100644
index 00000000000..64c475dae28
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/13.t
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/13.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EBUSY if the directory to be removed is the mount point for a mounted file system"
+
+n0=`namegen`
+
+expect 0 mkdir ${n0} 0755
+dd if=/dev/zero of=tmpdisk bs=1k count=1024 2>/dev/null
+vnconfig svnd1 tmpdisk
+newfs /dev/rsvnd1c >/dev/null
+mount /dev/svnd1c ${n0}
+expect EBUSY rmdir ${n0}
+umount /dev/svnd1c
+vnconfig -u svnd1
+rm tmpdisk
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/14.t b/regress/sys/ffs/tests/rmdir/14.t
new file mode 100644
index 00000000000..d9d6703965b
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/14.t
@@ -0,0 +1,22 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/14.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EROFS if the named file resides on a read-only file system"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+dd if=/dev/zero of=tmpdisk bs=1k count=1024 2>/dev/null
+vnconfig svnd1 tmpdisk
+newfs /dev/rsvnd1c >/dev/null
+mount /dev/svnd1c ${n0}
+expect 0 mkdir ${n0}/${n1} 0755
+mount -ur /dev/svnd1c
+expect EROFS rmdir ${n0}/${n1}
+mount -uw /dev/svnd1c
+expect 0 rmdir ${n0}/${n1}
+umount /dev/svnd1c
+vnconfig -u svnd1
+rm tmpdisk
+expect 0 rmdir ${n0}
diff --git a/regress/sys/ffs/tests/rmdir/15.t b/regress/sys/ffs/tests/rmdir/15.t
new file mode 100644
index 00000000000..1b719e977a4
--- /dev/null
+++ b/regress/sys/ffs/tests/rmdir/15.t
@@ -0,0 +1,7 @@
+#!/bin/sh
+# $FreeBSD: src/tools/regression/fstest/tests/rmdir/15.t,v 1.1 2007/01/17 01:42:11 pjd Exp $
+
+desc="rmdir returns EFAULT if the path argument points outside the process's allocated address space"
+
+expect EFAULT rmdir NULL
+expect EFAULT rmdir DEADCODE