xref: /freebsd/contrib/pjdfstest/tests/chflags/12.t (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/12.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="chflags returns EROFS if the named file resides on a read-only file system"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10require chflags
11
12case "${os}:${fs}" in
13FreeBSD:UFS)
14	echo "1..14"
15
16	n0=`namegen`
17	n1=`namegen`
18
19	expect 0 mkdir ${n0} 0755
20	n=`mdconfig -a -n -t malloc -s 1m` || exit
21	newfs /dev/md${n} >/dev/null || exit
22	mount /dev/md${n} ${n0}
23	expect 0 create ${n0}/${n1} 0644
24	expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
25	expect UF_IMMUTABLE stat ${n0}/${n1} flags
26	expect 0 chflags ${n0}/${n1} none
27	expect none stat ${n0}/${n1} flags
28	mount -ur /dev/md${n}
29	expect EROFS chflags ${n0}/${n1} UF_IMMUTABLE
30	expect none stat ${n0}/${n1} flags
31	mount -uw /dev/md${n}
32	expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
33	expect UF_IMMUTABLE stat ${n0}/${n1} flags
34	expect 0 chflags ${n0}/${n1} none
35	expect none stat ${n0}/${n1} flags
36	expect 0 unlink ${n0}/${n1}
37	umount /dev/md${n}
38	mdconfig -d -u ${n} || exit
39	expect 0 rmdir ${n0}
40	;;
41FreeBSD:ZFS)
42	echo "1..12"
43
44	n0=`namegen`
45	n1=`namegen`
46
47	n=`mdconfig -a -n -t malloc -s 128m` || exit
48	zpool create ${n0} /dev/md${n}
49	expect 0 create /${n0}/${n1} 0644
50	expect 0 chflags /${n0}/${n1} UF_NODUMP
51	expect UF_NODUMP stat /${n0}/${n1} flags
52	expect 0 chflags /${n0}/${n1} none
53	expect none stat /${n0}/${n1} flags
54	zfs set readonly=on ${n0}
55	expect EROFS chflags /${n0}/${n1} UF_NODUMP
56	expect none stat /${n0}/${n1} flags
57	zfs set readonly=off ${n0}
58	expect 0 chflags /${n0}/${n1} UF_NODUMP
59	expect UF_NODUMP stat /${n0}/${n1} flags
60	expect 0 chflags /${n0}/${n1} none
61	expect none stat /${n0}/${n1} flags
62	expect 0 unlink /${n0}/${n1}
63	zpool destroy ${n0}
64	mdconfig -d -u ${n} || exit
65	;;
66*)
67	quick_exit
68	;;
69esac
70