xref: /freebsd/contrib/pjdfstest/tests/open/06.t (revision 531c2d7af3cd2e64eec94aa1b19c4b2f16fce515)
140a8ac8fSEnji Cooper#!/bin/sh
2*3416500aSEnji Cooper# vim: filetype=sh noexpandtab ts=8 sw=8
340a8ac8fSEnji Cooper# $FreeBSD: head/tools/regression/pjdfstest/tests/open/06.t 211352 2010-08-15 21:24:17Z pjd $
440a8ac8fSEnji Cooper
540a8ac8fSEnji Cooperdesc="open returns EACCES when the required permissions (for reading and/or writing) are denied for the given flags"
640a8ac8fSEnji Cooper
740a8ac8fSEnji Cooperdir=`dirname $0`
840a8ac8fSEnji Cooper. ${dir}/../misc.sh
940a8ac8fSEnji Cooper
1040a8ac8fSEnji Cooperecho "1..144"
1140a8ac8fSEnji Cooper
1240a8ac8fSEnji Coopern0=`namegen`
1340a8ac8fSEnji Coopern1=`namegen`
1440a8ac8fSEnji Cooper
1540a8ac8fSEnji Cooperexpect 0 mkdir ${n0} 0755
1640a8ac8fSEnji Cooperexpect 0 chown ${n0} 65534 65534
1740a8ac8fSEnji Coopercdir=`pwd`
1840a8ac8fSEnji Coopercd ${n0}
1940a8ac8fSEnji Cooper
2040a8ac8fSEnji Cooper# Regular file.
2140a8ac8fSEnji Cooper
2240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 create ${n1} 0644
2340a8ac8fSEnji Cooper
2440a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0600
2540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,
2640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_WRONLY,
2740a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDWR,
2840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0060
2940a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,
3040a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_WRONLY,
3140a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDWR,
3240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0006
3340a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,
3440a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_WRONLY,
3540a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDWR,
3640a8ac8fSEnji Cooper
3740a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0477
3840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,
3940a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY,
4040a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
4140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0747
4240a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,
4340a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY,
4440a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
4540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0774
4640a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,
4740a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY,
4840a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
4940a8ac8fSEnji Cooper
5040a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0277
5140a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,
5240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_WRONLY,
5340a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
5440a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0727
5540a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,
5640a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_WRONLY,
5740a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
5840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0772
5940a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,
6040a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_WRONLY,
6140a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
6240a8ac8fSEnji Cooper
6340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0177
6440a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,
6540a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY,
6640a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
6740a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0717
6840a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,
6940a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY,
7040a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
7140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0771
7240a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,
7340a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY,
7440a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
7540a8ac8fSEnji Cooper
7640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0077
7740a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,
7840a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY,
7940a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDWR,
8040a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0707
8140a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,
8240a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY,
8340a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDWR,
8440a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0770
8540a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,
8640a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY,
8740a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDWR,
8840a8ac8fSEnji Cooper
8940a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 unlink ${n1}
9040a8ac8fSEnji Cooper
9140a8ac8fSEnji Cooper# FIFO.
9240a8ac8fSEnji Cooper
9340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 mkfifo ${n1} 0644
9440a8ac8fSEnji Cooper
9540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0600
9640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
9740a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDWR,O_NONBLOCK
9840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0060
9940a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
10040a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDWR,O_NONBLOCK
10140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0006
10240a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK
10340a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDWR,O_NONBLOCK
10440a8ac8fSEnji Cooper
10540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0477
10640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
10740a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY
10840a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
10940a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0747
11040a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK
11140a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY
11240a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDWR
11340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0774
11440a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK
11540a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY
11640a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDWR
11740a8ac8fSEnji Cooper
11840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0177
11940a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
12040a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY
12140a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
12240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0717
12340a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
12440a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY
12540a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDWR
12640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0771
12740a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
12840a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY
12940a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDWR
13040a8ac8fSEnji Cooper
13140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0077
13240a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
13340a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY
13440a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDWR
13540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0707
13640a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
13740a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY
13840a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDWR
13940a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0770
14040a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
14140a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY
14240a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDWR
14340a8ac8fSEnji Cooper
14440a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 unlink ${n1}
14540a8ac8fSEnji Cooper
14640a8ac8fSEnji Cooper# Directory.
14740a8ac8fSEnji Cooper
14840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 mkdir ${n1} 0755
14940a8ac8fSEnji Cooper
15040a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0600
15140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDONLY
15240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0060
15340a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDONLY
15440a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0006
15540a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDONLY
15640a8ac8fSEnji Cooper
15740a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0477
15840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 open ${n1} O_RDONLY
15940a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0747
16040a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65534 open ${n1} O_RDONLY
16140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0774
16240a8ac8fSEnji Cooperexpect 0 -u 65533 -g 65533 open ${n1} O_RDONLY
16340a8ac8fSEnji Cooper
16440a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0277
16540a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
16640a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0727
16740a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
16840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0772
16940a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
17040a8ac8fSEnji Cooper
17140a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0177
17240a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
17340a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0717
17440a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
17540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0771
17640a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
17740a8ac8fSEnji Cooper
17840a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0077
17940a8ac8fSEnji Cooperexpect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY
18040a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0707
18140a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY
18240a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 chmod ${n1} 0770
18340a8ac8fSEnji Cooperexpect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY
18440a8ac8fSEnji Cooper
18540a8ac8fSEnji Cooperexpect 0 -u 65534 -g 65534 rmdir ${n1}
18640a8ac8fSEnji Cooper
18740a8ac8fSEnji Coopercd ${cdir}
18840a8ac8fSEnji Cooperexpect 0 rmdir ${n0}
189