1166065Spjd#!/bin/sh
2166065Spjd# $FreeBSD$
3166065Spjd
4166065Spjddesc="chflags returns EROFS if the named file resides on a read-only file system"
5166065Spjd
6166065Spjddir=`dirname $0`
7166065Spjd. ${dir}/../misc.sh
8166065Spjd
9166065Spjdrequire chflags
10166065Spjd
11166065Spjdcase "${os}:${fs}" in
12166065SpjdFreeBSD:UFS)
13166065Spjd	echo "1..14"
14166065Spjd
15166065Spjd	n0=`namegen`
16166065Spjd	n1=`namegen`
17166065Spjd
18166065Spjd	expect 0 mkdir ${n0} 0755
19166065Spjd	n=`mdconfig -a -n -t malloc -s 1m`
20166065Spjd	newfs /dev/md${n} >/dev/null
21166065Spjd	mount /dev/md${n} ${n0}
22166065Spjd	expect 0 create ${n0}/${n1} 0644
23166065Spjd	expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
24166065Spjd	expect UF_IMMUTABLE stat ${n0}/${n1} flags
25166065Spjd	expect 0 chflags ${n0}/${n1} none
26166065Spjd	expect none stat ${n0}/${n1} flags
27166065Spjd	mount -ur /dev/md${n}
28166065Spjd	expect EROFS chflags ${n0}/${n1} UF_IMMUTABLE
29166065Spjd	expect none stat ${n0}/${n1} flags
30166065Spjd	mount -uw /dev/md${n}
31166065Spjd	expect 0 chflags ${n0}/${n1} UF_IMMUTABLE
32166065Spjd	expect UF_IMMUTABLE stat ${n0}/${n1} flags
33166065Spjd	expect 0 chflags ${n0}/${n1} none
34166065Spjd	expect none stat ${n0}/${n1} flags
35166065Spjd	expect 0 unlink ${n0}/${n1}
36166065Spjd	umount /dev/md${n}
37166065Spjd	mdconfig -d -u ${n}
38166065Spjd	expect 0 rmdir ${n0}
39166065Spjd	;;
40185173SpjdFreeBSD:ZFS)
41185173Spjd	echo "1..12"
42185173Spjd
43185173Spjd	n0=`namegen`
44185173Spjd	n1=`namegen`
45185173Spjd
46185173Spjd	n=`mdconfig -a -n -t malloc -s 128m`
47185173Spjd	zpool create ${n0} /dev/md${n}
48185173Spjd	expect 0 create /${n0}/${n1} 0644
49185173Spjd	expect 0 chflags /${n0}/${n1} UF_NODUMP
50185173Spjd	expect UF_NODUMP stat /${n0}/${n1} flags
51185173Spjd	expect 0 chflags /${n0}/${n1} none
52185173Spjd	expect none stat /${n0}/${n1} flags
53185173Spjd	zfs set readonly=on ${n0}
54185173Spjd	expect EROFS chflags /${n0}/${n1} UF_NODUMP
55185173Spjd	expect none stat /${n0}/${n1} flags
56185173Spjd	zfs set readonly=off ${n0}
57185173Spjd	expect 0 chflags /${n0}/${n1} UF_NODUMP
58185173Spjd	expect UF_NODUMP stat /${n0}/${n1} flags
59185173Spjd	expect 0 chflags /${n0}/${n1} none
60185173Spjd	expect none stat /${n0}/${n1} flags
61185173Spjd	expect 0 unlink /${n0}/${n1}
62185173Spjd	zpool destroy ${n0}
63185173Spjd	mdconfig -d -u ${n}
64185173Spjd	;;
65166065Spjd*)
66166065Spjd	quick_exit
67166065Spjd	;;
68166065Spjdesac
69