summaryrefslogtreecommitdiffstats
path: root/contrib/pjdfstest/tests/open
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pjdfstest/tests/open')
-rw-r--r--contrib/pjdfstest/tests/open/00.t99
-rw-r--r--contrib/pjdfstest/tests/open/01.t21
-rw-r--r--contrib/pjdfstest/tests/open/02.t17
-rw-r--r--contrib/pjdfstest/tests/open/03.t21
-rw-r--r--contrib/pjdfstest/tests/open/04.t17
-rw-r--r--contrib/pjdfstest/tests/open/05.t29
-rw-r--r--contrib/pjdfstest/tests/open/06.t187
-rw-r--r--contrib/pjdfstest/tests/open/07.t45
-rw-r--r--contrib/pjdfstest/tests/open/08.t19
-rw-r--r--contrib/pjdfstest/tests/open/09.t66
-rw-r--r--contrib/pjdfstest/tests/open/10.t58
-rw-r--r--contrib/pjdfstest/tests/open/11.t56
-rw-r--r--contrib/pjdfstest/tests/open/12.t19
-rw-r--r--contrib/pjdfstest/tests/open/13.t24
-rw-r--r--contrib/pjdfstest/tests/open/14.t32
-rw-r--r--contrib/pjdfstest/tests/open/15.t27
-rw-r--r--contrib/pjdfstest/tests/open/16.t27
-rw-r--r--contrib/pjdfstest/tests/open/17.t15
-rw-r--r--contrib/pjdfstest/tests/open/18.t20
-rw-r--r--contrib/pjdfstest/tests/open/19.t31
-rw-r--r--contrib/pjdfstest/tests/open/20.t20
-rw-r--r--contrib/pjdfstest/tests/open/21.t12
-rw-r--r--contrib/pjdfstest/tests/open/22.t21
-rw-r--r--contrib/pjdfstest/tests/open/23.t17
-rw-r--r--contrib/pjdfstest/tests/open/24.t17
25 files changed, 917 insertions, 0 deletions
diff --git a/contrib/pjdfstest/tests/open/00.t b/contrib/pjdfstest/tests/open/00.t
new file mode 100644
index 0000000..cf11a92
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/00.t
@@ -0,0 +1,99 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/00.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open opens (and eventually creates) a file"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..47"
+
+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/contrib/pjdfstest/tests/open/01.t b/contrib/pjdfstest/tests/open/01.t
new file mode 100644
index 0000000..df17590
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/01.t
@@ -0,0 +1,21 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/01.t 211474 2010-08-18 22:06:43Z pjd $
+
+desc="open 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 open ${n0}/${n1}/test O_RDONLY
+ expect ENOTDIR open ${n0}/${n1}/test O_CREAT 0644
+ expect 0 unlink ${n0}/${n1}
+done
+expect 0 rmdir ${n0}
diff --git a/contrib/pjdfstest/tests/open/02.t b/contrib/pjdfstest/tests/open/02.t
new file mode 100644
index 0000000..adb3bb0
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/02.t
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/02.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..4"
+
+nx=`namegen_max`
+nxx="${nx}x"
+
+expect 0 open ${nx} O_CREAT 0620
+expect regular,0620 stat ${nx} type,mode
+expect 0 unlink ${nx}
+expect ENAMETOOLONG open ${nxx} O_CREAT 0620
diff --git a/contrib/pjdfstest/tests/open/03.t b/contrib/pjdfstest/tests/open/03.t
new file mode 100644
index 0000000..89e67bb
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/03.t
@@ -0,0 +1,21 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/03.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns ENAMETOOLONG if an entire path name exceeded ${PATH_MAX} characters"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..4"
+
+nx=`dirgen_max`
+nxx="${nx}x"
+
+mkdir -p "${nx%/*}"
+
+expect 0 open ${nx} O_CREAT 0642
+expect regular,0642 stat ${nx} type,mode
+expect 0 unlink ${nx}
+expect ENAMETOOLONG open ${nxx} O_CREAT 0642
+
+rm -rf "${nx%%/*}"
diff --git a/contrib/pjdfstest/tests/open/04.t b/contrib/pjdfstest/tests/open/04.t
new file mode 100644
index 0000000..84b0441
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/04.t
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/04.t 211352 2010-08-15 21:24:17Z pjd $
+
+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"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..4"
+
+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/contrib/pjdfstest/tests/open/05.t b/contrib/pjdfstest/tests/open/05.t
new file mode 100644
index 0000000..1b69c61
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/05.t
@@ -0,0 +1,29 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/05.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open 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 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/contrib/pjdfstest/tests/open/06.t b/contrib/pjdfstest/tests/open/06.t
new file mode 100644
index 0000000..b33e640
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/06.t
@@ -0,0 +1,187 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/06.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EACCES when the required permissions (for reading and/or writing) are denied for the given flags"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..144"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 mkdir ${n0} 0755
+expect 0 chown ${n0} 65534 65534
+cdir=`pwd`
+cd ${n0}
+
+# Regular file.
+
+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}
+
+# FIFO.
+
+expect 0 -u 65534 -g 65534 mkfifo ${n1} 0644
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0600
+expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
+expect 0 -u 65534 -g 65534 open ${n1} O_RDWR,O_NONBLOCK
+expect 0 -u 65534 -g 65534 chmod ${n1} 0060
+expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
+expect 0 -u 65533 -g 65534 open ${n1} O_RDWR,O_NONBLOCK
+expect 0 -u 65534 -g 65534 chmod ${n1} 0006
+expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK
+expect 0 -u 65533 -g 65533 open ${n1} O_RDWR,O_NONBLOCK
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0477
+expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
+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,O_NONBLOCK
+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,O_NONBLOCK
+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} 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}
+
+# Directory.
+
+expect 0 -u 65534 -g 65534 mkdir ${n1} 0755
+
+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 chmod ${n1} 0060
+expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0006
+expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0477
+expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0747
+expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0774
+expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY
+
+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 chmod ${n1} 0727
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0772
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0177
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0717
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0771
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
+
+expect 0 -u 65534 -g 65534 chmod ${n1} 0077
+expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0707
+expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
+expect 0 -u 65534 -g 65534 chmod ${n1} 0770
+expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
+
+expect 0 -u 65534 -g 65534 rmdir ${n1}
+
+cd ${cdir}
+expect 0 rmdir ${n0}
diff --git a/contrib/pjdfstest/tests/open/07.t b/contrib/pjdfstest/tests/open/07.t
new file mode 100644
index 0000000..edc4be1
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/07.t
@@ -0,0 +1,45 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/07.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EACCES when O_TRUNC is specified and write permission is denied"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..23"
+
+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/contrib/pjdfstest/tests/open/08.t b/contrib/pjdfstest/tests/open/08.t
new file mode 100644
index 0000000..f47ff87
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/08.t
@@ -0,0 +1,19 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/08.t 211352 2010-08-15 21:24:17Z pjd $
+
+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"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..3"
+
+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/contrib/pjdfstest/tests/open/09.t b/contrib/pjdfstest/tests/open/09.t
new file mode 100644
index 0000000..b76c70d
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/09.t
@@ -0,0 +1,66 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/09.t 211352 2010-08-15 21:24:17Z pjd $
+
+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"
+
+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 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} 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} SF_APPEND
+expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
+expect 0 chflags ${n0} none
+expect 0 unlink ${n0}/${n1}
+
+case "${os}:${fs}" in
+FreeBSD:UFS)
+ 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} UF_NOUNLINK
+ expect 0 symlink test ${n0}/${n1}
+ 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}
+ ;;
+esac
+
+expect 0 rmdir ${n0}
diff --git a/contrib/pjdfstest/tests/open/10.t b/contrib/pjdfstest/tests/open/10.t
new file mode 100644
index 0000000..bd6fdd2
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/10.t
@@ -0,0 +1,58 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/10.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EPERM when the named file has its immutable flag set and the file is to be modified"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+require chflags
+
+case "${os}:${fs}" in
+FreeBSD:ZFS)
+ echo "1..14"
+ ;;
+FreeBSD:UFS)
+ echo "1..28"
+ ;;
+*)
+ quick_exit
+esac
+
+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} 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}
+
+case "${os}:${fs}" in
+FreeBSD:UFS)
+ 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} 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}
+ ;;
+esac
diff --git a/contrib/pjdfstest/tests/open/11.t b/contrib/pjdfstest/tests/open/11.t
new file mode 100644
index 0000000..e4a3a2d
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/11.t
@@ -0,0 +1,56 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/11.t 211352 2010-08-15 21:24:17Z pjd $
+
+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"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+require chflags
+
+case "${os}:${fs}" in
+FreeBSD:ZFS)
+ echo "1..12"
+ ;;
+FreeBSD:UFS)
+ echo "1..24"
+ ;;
+*)
+ quick_exit
+esac
+
+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
+todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM."
+expect EPERM open ${n0} O_RDONLY,O_TRUNC
+todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM."
+expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC
+todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM."
+expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC
+todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM."
+expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC
+expect 0 chflags ${n0} none
+expect 0 unlink ${n0}
+
+case "${os}:${fs}" in
+FreeBSD:UFS)
+ 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}
+ ;;
+esac
diff --git a/contrib/pjdfstest/tests/open/12.t b/contrib/pjdfstest/tests/open/12.t
new file mode 100644
index 0000000..d38309d
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/12.t
@@ -0,0 +1,19 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/12.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open 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 open ${n0}/test O_RDONLY
+expect ELOOP open ${n1}/test O_RDONLY
+expect 0 unlink ${n0}
+expect 0 unlink ${n1}
diff --git a/contrib/pjdfstest/tests/open/13.t b/contrib/pjdfstest/tests/open/13.t
new file mode 100644
index 0000000..64bb0b8
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/13.t
@@ -0,0 +1,24 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/13.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EISDIR when trying to open a directory for writing"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+require chflags
+
+echo "1..8"
+
+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/contrib/pjdfstest/tests/open/14.t b/contrib/pjdfstest/tests/open/14.t
new file mode 100644
index 0000000..8d90065
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/14.t
@@ -0,0 +1,32 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/14.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EROFS if the named file resides on a read-only file system, and the file is to be modified"
+
+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 open ${n0}/${n1} O_WRONLY
+expect 0 open ${n0}/${n1} O_RDWR
+expect 0 open ${n0}/${n1} O_RDONLY,O_TRUNC
+mount -ur /dev/md${n}
+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/md${n}
+expect 0 unlink ${n0}/${n1}
+umount /dev/md${n}
+mdconfig -d -u ${n} || exit
+expect 0 rmdir ${n0}
diff --git a/contrib/pjdfstest/tests/open/15.t b/contrib/pjdfstest/tests/open/15.t
new file mode 100644
index 0000000..a8230d8
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/15.t
@@ -0,0 +1,27 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/15.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EROFS when O_CREAT is specified and the named file would reside on a read-only file system"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
+
+echo "1..5"
+
+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 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
+expect 0 unlink ${n0}/${n1}
+mount -ur /dev/md${n}
+expect EROFS open ${n0}/${n1} O_RDONLY,O_CREAT 0644
+mount -uw /dev/md${n}
+umount /dev/md${n}
+mdconfig -d -u ${n} || exit
+expect 0 rmdir ${n0}
diff --git a/contrib/pjdfstest/tests/open/16.t b/contrib/pjdfstest/tests/open/16.t
new file mode 100644
index 0000000..7f796d6
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/16.t
@@ -0,0 +1,27 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/16.t 219621 2011-03-13 19:35:13Z pjd $
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+case "${os}" in
+Darwin|Linux)
+ error=ELOOP
+ ;;
+*)
+ error=EMLINK
+ ;;
+esac
+desc="open returns $error when O_NOFOLLOW was specified and the target is a symbolic link"
+
+echo "1..6"
+
+n0=`namegen`
+n1=`namegen`
+
+expect 0 symlink ${n0} ${n1}
+expect $error open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644
+expect $error open ${n1} O_RDONLY,O_NOFOLLOW
+expect $error open ${n1} O_WRONLY,O_NOFOLLOW
+expect $error open ${n1} O_RDWR,O_NOFOLLOW
+expect 0 unlink ${n1}
diff --git a/contrib/pjdfstest/tests/open/17.t b/contrib/pjdfstest/tests/open/17.t
new file mode 100644
index 0000000..e5888fc
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/17.t
@@ -0,0 +1,15 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/17.t 211352 2010-08-15 21:24:17Z pjd $
+
+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"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..3"
+
+n0=`namegen`
+
+expect 0 mkfifo ${n0} 0644
+expect ENXIO open ${n0} O_WRONLY,O_NONBLOCK
+expect 0 unlink ${n0}
diff --git a/contrib/pjdfstest/tests/open/18.t b/contrib/pjdfstest/tests/open/18.t
new file mode 100644
index 0000000..6d0713b
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/18.t
@@ -0,0 +1,20 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/18.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EWOULDBLOCK when O_NONBLOCK and one of O_SHLOCK or O_EXLOCK is specified and the file is locked"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+[ "${os}" = "FreeBSD" ] || quick_exit
+
+echo "1..6"
+
+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/contrib/pjdfstest/tests/open/19.t b/contrib/pjdfstest/tests/open/19.t
new file mode 100644
index 0000000..c9d98eb
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/19.t
@@ -0,0 +1,31 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/19.t 211352 2010-08-15 21:24:17Z pjd $
+
+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"
+
+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
+ 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/md${n}
+mdconfig -d -u ${n} || exit
+expect 0 rmdir ${n0}
diff --git a/contrib/pjdfstest/tests/open/20.t b/contrib/pjdfstest/tests/open/20.t
new file mode 100644
index 0000000..de80b61
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/20.t
@@ -0,0 +1,20 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/20.t 211352 2010-08-15 21:24:17Z pjd $
+
+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"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
+
+echo "1..4"
+
+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/contrib/pjdfstest/tests/open/21.t b/contrib/pjdfstest/tests/open/21.t
new file mode 100644
index 0000000..4a2422c
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/21.t
@@ -0,0 +1,12 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/21.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open 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 open NULL O_RDONLY
+expect EFAULT open DEADCODE O_RDONLY
diff --git a/contrib/pjdfstest/tests/open/22.t b/contrib/pjdfstest/tests/open/22.t
new file mode 100644
index 0000000..55d4b9b
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/22.t
@@ -0,0 +1,21 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/22.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EEXIST when O_CREAT and O_EXCL were specified and the 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 open ${n0} O_CREAT,O_EXCL 0644
+ if [ "${type}" = "dir" ]; then
+ expect 0 rmdir ${n0}
+ else
+ expect 0 unlink ${n0}
+ fi
+done
diff --git a/contrib/pjdfstest/tests/open/23.t b/contrib/pjdfstest/tests/open/23.t
new file mode 100644
index 0000000..4728c18
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/23.t
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/23.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open may return EINVAL when an attempt was made to open a descriptor with an illegal combination of O_RDONLY, O_WRONLY, and O_RDWR"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..5"
+
+n0=`namegen`
+
+expect 0 create ${n0} 0644
+expect "0|EINVAL" open ${n0} O_RDONLY,O_RDWR
+expect "0|EINVAL" open ${n0} O_WRONLY,O_RDWR
+expect "0|EINVAL" open ${n0} O_RDONLY,O_WRONLY,O_RDWR
+expect 0 unlink ${n0}
diff --git a/contrib/pjdfstest/tests/open/24.t b/contrib/pjdfstest/tests/open/24.t
new file mode 100644
index 0000000..ca709f2
--- /dev/null
+++ b/contrib/pjdfstest/tests/open/24.t
@@ -0,0 +1,17 @@
+#!/bin/sh
+# $FreeBSD: head/tools/regression/pjdfstest/tests/open/24.t 211352 2010-08-15 21:24:17Z pjd $
+
+desc="open returns EOPNOTSUPP when trying to open UNIX domain socket"
+
+dir=`dirname $0`
+. ${dir}/../misc.sh
+
+echo "1..5"
+
+n0=`namegen`
+
+expect 0 bind ${n0}
+expect "EOPNOTSUPP" open ${n0} O_RDONLY
+expect "EOPNOTSUPP" open ${n0} O_WRONLY
+expect "EOPNOTSUPP" open ${n0} O_RDWR
+expect 0 unlink ${n0}
OpenPOWER on IntegriCloud