diff options
Diffstat (limited to 'regress/sys/ffs/tests/open')
24 files changed, 619 insertions, 0 deletions
diff --git a/regress/sys/ffs/tests/open/00.t b/regress/sys/ffs/tests/open/00.t new file mode 100644 index 00000000000..1a60afbc139 --- /dev/null +++ b/regress/sys/ffs/tests/open/00.t @@ -0,0 +1,94 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/00.t,v 1.2 2007/01/25 20:50:02 pjd Exp $ + +desc="open opens (and eventually creates) a file" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +# POSIX: (If O_CREAT is specified and the file doesn't exist) [...] the access +# permission bits of the file mode shall be set to the value of the third +# argument taken as type mode_t modified as follows: a bitwise AND is performed +# on the file-mode bits and the corresponding bits in the complement of the +# process' file mode creation mask. Thus, all bits in the file mode whose +# corresponding bit in the file mode creation mask is set are cleared. +expect 0 open ${n0} O_CREAT,O_WRONLY 0755 +expect regular,0755 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 open ${n0} O_CREAT,O_WRONLY 0151 +expect regular,0151 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 077 open ${n0} O_CREAT,O_WRONLY 0151 +expect regular,0100 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 070 open ${n0} O_CREAT,O_WRONLY 0345 +expect regular,0305 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 0501 open ${n0} O_CREAT,O_WRONLY 0345 +expect regular,0244 lstat ${n0} type,mode +expect 0 unlink ${n0} + +# POSIX: (If O_CREAT is specified and the file doesn't exist) [...] the user ID +# of the file shall be set to the effective user ID of the process; the group ID +# of the file shall be set to the group ID of the file's parent directory or to +# the effective group ID of the process [...] +expect 0 chown . 65535 65535 +expect 0 -u 65535 -g 65535 open ${n0} O_CREAT,O_WRONLY 0644 +expect 65535,65535 lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 -u 65535 -g 65534 open ${n0} O_CREAT,O_WRONLY 0644 +expect "65535,6553[45]" lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 chmod . 0777 +expect 0 -u 65534 -g 65533 open ${n0} O_CREAT,O_WRONLY 0644 +expect "65534,6553[35]" lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# Update parent directory ctime/mtime if file didn't exist. +expect 0 chown . 0 0 +time=`${FSTEST} stat . ctime` +sleep 1 +expect 0 open ${n0} O_CREAT,O_WRONLY 0644 +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} + +# Don't update parent directory ctime/mtime if file existed. +expect 0 create ${n0} 0644 +dmtime=`${FSTEST} stat . mtime` +dctime=`${FSTEST} stat . ctime` +sleep 1 +expect 0 open ${n0} O_CREAT,O_RDONLY 0644 +mtime=`${FSTEST} stat . mtime` +test_check $dmtime -eq $mtime +ctime=`${FSTEST} stat . ctime` +test_check $dctime -eq $ctime +expect 0 unlink ${n0} + +echo test > ${n0} +expect 5 stat ${n0} size +mtime1=`${FSTEST} stat ${n0} mtime` +ctime1=`${FSTEST} stat ${n0} ctime` +sleep 1 +expect 0 open ${n0} O_WRONLY,O_TRUNC +mtime2=`${FSTEST} stat ${n0} mtime` +test_check $mtime1 -lt $mtime2 +ctime2=`${FSTEST} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 stat ${n0} size +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/regress/sys/ffs/tests/open/01.t b/regress/sys/ffs/tests/open/01.t new file mode 100644 index 00000000000..16d4c8577d1 --- /dev/null +++ b/regress/sys/ffs/tests/open/01.t @@ -0,0 +1,13 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/01.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns ENOTDIR if a component of the path prefix is not a directory" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR open ${n0}/${n1}/test O_CREAT 0644 +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/02.t b/regress/sys/ffs/tests/open/02.t new file mode 100644 index 00000000000..caaf0cfabae --- /dev/null +++ b/regress/sys/ffs/tests/open/02.t @@ -0,0 +1,9 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/02.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns ENAMETOOLONG if a component of a pathname exceeded 255 characters" + +expect 0 open ${name255} O_CREAT 0620 +expect 0620 stat ${name255} mode +expect 0 unlink ${name255} +expect ENAMETOOLONG open ${name256} O_CREAT 0620 diff --git a/regress/sys/ffs/tests/open/03.t b/regress/sys/ffs/tests/open/03.t new file mode 100644 index 00000000000..9b184fff702 --- /dev/null +++ b/regress/sys/ffs/tests/open/03.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/03.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open 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 open ${path1023} O_CREAT 0642 +expect 0642 stat ${path1023} mode +expect 0 unlink ${path1023} +expect ENAMETOOLONG open ${path1024} O_CREAT 0642 +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/open/04.t b/regress/sys/ffs/tests/open/04.t new file mode 100644 index 00000000000..c59bf4de48e --- /dev/null +++ b/regress/sys/ffs/tests/open/04.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/04.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns ENOENT if a component of the path name that must exist does not exist or O_CREAT is not set and the named file does not exist" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT open ${n0}/${n1}/test O_CREAT 0644 +expect ENOENT open ${n0}/${n1} O_RDONLY +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/05.t b/regress/sys/ffs/tests/open/05.t new file mode 100644 index 00000000000..a849b31480e --- /dev/null +++ b/regress/sys/ffs/tests/open/05.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/05.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open 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 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/06.t b/regress/sys/ffs/tests/open/06.t new file mode 100644 index 00000000000..8de3d1d3218 --- /dev/null +++ b/regress/sys/ffs/tests/open/06.t @@ -0,0 +1,84 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/06.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EACCES when the required permissions (for reading and/or writing) are denied for the given flags" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 chown ${n0} 65534 65534 +cdir=`pwd` +cd ${n0} + +expect 0 -u 65534 -g 65534 create ${n1} 0644 + +expect 0 -u 65534 -g 65534 chmod ${n1} 0600 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY +expect 0 -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0060 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY +expect 0 -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0006 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY +expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY +expect 0 -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 chmod ${n1} 0477 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0747 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0774 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 chmod ${n1} 0277 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0727 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0772 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY +expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 chmod ${n1} 0177 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0717 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0771 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 chmod ${n1} 0077 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0707 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0770 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 unlink ${n1} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/07.t b/regress/sys/ffs/tests/open/07.t new file mode 100644 index 00000000000..22e2f5733f7 --- /dev/null +++ b/regress/sys/ffs/tests/open/07.t @@ -0,0 +1,40 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/07.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EACCES when O_TRUNC is specified and write permission is denied" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 chown ${n0} 65534 65534 +cdir=`pwd` +cd ${n0} + +expect 0 -u 65534 -g 65534 create ${n1} 0644 + +expect 0 -u 65534 -g 65534 chmod ${n1} 0477 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0747 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0774 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC + +expect 0 -u 65534 -g 65534 chmod ${n1} 0177 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0717 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0771 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC + +expect 0 -u 65534 -g 65534 chmod ${n1} 0077 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0707 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0770 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC + +expect 0 -u 65534 -g 65534 unlink ${n1} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/08.t b/regress/sys/ffs/tests/open/08.t new file mode 100644 index 00000000000..200f8322a2e --- /dev/null +++ b/regress/sys/ffs/tests/open/08.t @@ -0,0 +1,14 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/08.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EACCES when O_CREAT is specified, the file does not exist, and the directory in which it is to be created does not permit writing" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_CREAT 0644 +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/09.t b/regress/sys/ffs/tests/open/09.t new file mode 100644 index 00000000000..71532485efc --- /dev/null +++ b/regress/sys/ffs/tests/open/09.t @@ -0,0 +1,46 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/09.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="O_CREAT is specified, the file does not exist, and the directory in which it is to be created has its immutable flag set" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} UF_IMMUTABLE +expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_APPEND +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} UF_APPEND +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} UF_NOUNLINK +expect 0 symlink test ${n0}/${n1} +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/10.t b/regress/sys/ffs/tests/open/10.t new file mode 100644 index 00000000000..0a207743e4c --- /dev/null +++ b/regress/sys/ffs/tests/open/10.t @@ -0,0 +1,38 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/10.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EPERM when the named file has its immutable flag set and the file is to be modified" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM open ${n0} O_WRONLY +expect EPERM open ${n0} O_RDWR +expect EPERM open ${n0} O_RDONLY,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} UF_IMMUTABLE +expect EPERM open ${n0} O_WRONLY +expect EPERM open ${n0} O_RDWR +expect EPERM open ${n0} O_RDONLY,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 open ${n0} O_WRONLY +expect 0 open ${n0} O_RDWR +expect 0 open ${n0} O_RDONLY,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} UF_NOUNLINK +expect 0 open ${n0} O_WRONLY +expect 0 open ${n0} O_RDWR +expect 0 open ${n0} O_RDONLY,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} diff --git a/regress/sys/ffs/tests/open/11.t b/regress/sys/ffs/tests/open/11.t new file mode 100644 index 00000000000..764cb02d937 --- /dev/null +++ b/regress/sys/ffs/tests/open/11.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/11.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EPERM when the named file has its append-only flag set, the file is to be modified, and O_TRUNC is specified or O_APPEND is not specified" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +expect 0 open ${n0} O_WRONLY,O_APPEND +expect 0 open ${n0} O_RDWR,O_APPEND +expect EPERM open ${n0} O_WRONLY +expect EPERM open ${n0} O_RDWR +expect EPERM open ${n0} O_RDONLY,O_TRUNC +expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC +expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC +expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} UF_APPEND +expect 0 open ${n0} O_WRONLY,O_APPEND +expect 0 open ${n0} O_RDWR,O_APPEND +expect EPERM open ${n0} O_WRONLY +expect EPERM open ${n0} O_RDWR +expect EPERM open ${n0} O_RDONLY,O_TRUNC +expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC +expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC +expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} diff --git a/regress/sys/ffs/tests/open/12.t b/regress/sys/ffs/tests/open/12.t new file mode 100644 index 00000000000..3e2884790d2 --- /dev/null +++ b/regress/sys/ffs/tests/open/12.t @@ -0,0 +1,14 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/12.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open 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 open ${n0}/test O_RDONLY +expect ELOOP open ${n1}/test O_RDONLY +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/regress/sys/ffs/tests/open/13.t b/regress/sys/ffs/tests/open/13.t new file mode 100644 index 00000000000..715f0819881 --- /dev/null +++ b/regress/sys/ffs/tests/open/13.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/13.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EISDIR when he named file is a directory, and the arguments specify it is to be modified" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 open ${n0} O_RDONLY +expect EISDIR open ${n0} O_WRONLY +expect EISDIR open ${n0} O_RDWR +expect EISDIR open ${n0} O_RDONLY,O_TRUNC +expect EISDIR open ${n0} O_WRONLY,O_TRUNC +expect EISDIR open ${n0} O_RDWR,O_TRUNC + +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/14.t b/regress/sys/ffs/tests/open/14.t new file mode 100644 index 00000000000..577d37f6634 --- /dev/null +++ b/regress/sys/ffs/tests/open/14.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/14.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EROFS if the named file resides on a read-only file system, and the file is to be modified" + +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 create ${n0}/${n1} 0644 +expect 0 open ${n0}/${n1} O_WRONLY +expect 0 open ${n0}/${n1} O_RDWR +expect 0 open ${n0}/${n1} O_RDONLY,O_TRUNC +mount -ur /dev/svnd1c +expect EROFS open ${n0}/${n1} O_WRONLY +expect EROFS open ${n0}/${n1} O_RDWR +expect EROFS open ${n0}/${n1} O_RDONLY,O_TRUNC +mount -uw /dev/svnd1c +expect 0 unlink ${n0}/${n1} +umount /dev/svnd1c +vnconfig -u svnd1 +rm tmpdisk +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/15.t b/regress/sys/ffs/tests/open/15.t new file mode 100644 index 00000000000..4eae05cb935 --- /dev/null +++ b/regress/sys/ffs/tests/open/15.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/15.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EROFS when O_CREAT is specified and the named file would reside 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 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 unlink ${n0}/${n1} +mount -ur /dev/svnd1c +expect EROFS open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +mount -uw /dev/svnd1c +umount /dev/svnd1c +vnconfig -u svnd1 +rm tmpdisk +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/16.t b/regress/sys/ffs/tests/open/16.t new file mode 100644 index 00000000000..d22381b48e4 --- /dev/null +++ b/regress/sys/ffs/tests/open/16.t @@ -0,0 +1,14 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/16.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EMLINK when O_NOFOLLOW was specified and the target is a symbolic link" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect EMLINK open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 +expect EMLINK open ${n1} O_RDONLY,O_NOFOLLOW +expect EMLINK open ${n1} O_WRONLY,O_NOFOLLOW +expect EMLINK open ${n1} O_RDWR,O_NOFOLLOW +expect 0 unlink ${n1} diff --git a/regress/sys/ffs/tests/open/17.t b/regress/sys/ffs/tests/open/17.t new file mode 100644 index 00000000000..49d569eaa72 --- /dev/null +++ b/regress/sys/ffs/tests/open/17.t @@ -0,0 +1,10 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/17.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns ENXIO when O_NONBLOCK is set, the named file is a fifo, O_WRONLY is set, and no process has the file open for reading" + +n0=`namegen` + +expect 0 mkfifo ${n0} 0644 +expect ENXIO open ${n0} O_WRONLY,O_NONBLOCK +expect 0 unlink ${n0} diff --git a/regress/sys/ffs/tests/open/18.t b/regress/sys/ffs/tests/open/18.t new file mode 100644 index 00000000000..d15190fc7eb --- /dev/null +++ b/regress/sys/ffs/tests/open/18.t @@ -0,0 +1,13 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/18.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EWOULDBLOCK when O_NONBLOCK and one of O_SHLOCK or O_EXLOCK is specified and the file is locked" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 open ${n0} O_RDONLY,O_SHLOCK : open ${n0} O_RDONLY,O_SHLOCK,O_NONBLOCK +expect "EWOULDBLOCK|EAGAIN" open ${n0} O_RDONLY,O_EXLOCK : open ${n0} O_RDONLY,O_EXLOCK,O_NONBLOCK +expect "EWOULDBLOCK|EAGAIN" open ${n0} O_RDONLY,O_SHLOCK : open ${n0} O_RDONLY,O_EXLOCK,O_NONBLOCK +expect "EWOULDBLOCK|EAGAIN" open ${n0} O_RDONLY,O_EXLOCK : open ${n0} O_RDONLY,O_SHLOCK,O_NONBLOCK +expect 0 unlink ${n0} diff --git a/regress/sys/ffs/tests/open/19.t b/regress/sys/ffs/tests/open/19.t new file mode 100644 index 00000000000..c25a4f4d78e --- /dev/null +++ b/regress/sys/ffs/tests/open/19.t @@ -0,0 +1,26 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/19.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns ENOSPC when O_CREAT is specified, the file does not exist, and there are no free inodes on the file system on which the file is being created" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +dd if=/dev/zero of=tmpdisk bs=1k count=256 2>/dev/null +vnconfig svnd1 tmpdisk +newfs /dev/rsvnd1c >/dev/null +mount /dev/svnd1c ${n0} +i=0 +while :; do + touch ${n0}/${i} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + break + fi + i=`expr $i + 1` +done +expect ENOSPC open ${n0}/${i} O_RDONLY,O_CREAT 0644 +umount /dev/svnd1c +vnconfig -u svnd1 +rm tmpdisk +expect 0 rmdir ${n0} diff --git a/regress/sys/ffs/tests/open/20.t b/regress/sys/ffs/tests/open/20.t new file mode 100644 index 00000000000..6313e9cb512 --- /dev/null +++ b/regress/sys/ffs/tests/open/20.t @@ -0,0 +1,13 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/20.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns ETXTBSY when the file is a pure procedure (shared text) file that is being executed and the open() system call requests write access" + +n0=`namegen` + +cp -pf `which sleep` ${n0} +./${n0} 3 & +expect ETXTBSY open ${n0} O_WRONLY +expect ETXTBSY open ${n0} O_RDWR +expect ETXTBSY open ${n0} O_RDONLY,O_TRUNC +expect 0 unlink ${n0} diff --git a/regress/sys/ffs/tests/open/21.t b/regress/sys/ffs/tests/open/21.t new file mode 100644 index 00000000000..c7f3b9db8b6 --- /dev/null +++ b/regress/sys/ffs/tests/open/21.t @@ -0,0 +1,7 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/21.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EFAULT if the path argument points outside the process's allocated address space" + +expect EFAULT open NULL O_RDONLY +expect EFAULT open DEADCODE O_RDONLY diff --git a/regress/sys/ffs/tests/open/22.t b/regress/sys/ffs/tests/open/22.t new file mode 100644 index 00000000000..80a3763c031 --- /dev/null +++ b/regress/sys/ffs/tests/open/22.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/22.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EEXIST when O_CREAT and O_EXCL were specified and the file exists" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EEXIST open ${n0} O_CREAT,O_EXCL 0644 +expect 0 unlink ${n0} + +expect 0 mkdir ${n0} 0755 +expect EEXIST open ${n0} O_CREAT,O_EXCL 0644 +expect 0 rmdir ${n0} + +expect 0 mkfifo ${n0} 0644 +expect EEXIST open ${n0} O_CREAT,O_EXCL 0644 +expect 0 unlink ${n0} + +expect 0 symlink test ${n0} +expect EEXIST open ${n0} O_CREAT,O_EXCL 0644 +expect 0 unlink ${n0} diff --git a/regress/sys/ffs/tests/open/23.t b/regress/sys/ffs/tests/open/23.t new file mode 100644 index 00000000000..7c5c3ab98a8 --- /dev/null +++ b/regress/sys/ffs/tests/open/23.t @@ -0,0 +1,11 @@ +#!/bin/sh +# $FreeBSD: src/tools/regression/fstest/tests/open/23.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ + +desc="open returns EINVAL when an attempt was made to open a descriptor with an illegal combination of O_RDONLY, O_WRONLY, and O_RDWR" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EINVAL open ${n0} O_WRONLY,O_RDWR +expect EINVAL open ${n0} O_RDONLY,O_WRONLY,O_RDWR +expect 0 unlink ${n0} |