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