xref: /freebsd/contrib/pjdfstest/tests/chmod/09.t (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
1#!/bin/sh
2# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/09.t 211352 2010-08-15 21:24:17Z pjd $
3
4desc="chmod returns EROFS if the named file resides on a read-only file system"
5
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
9[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
10
11echo "1..15"
12
13n0=`namegen`
14n1=`namegen`
15
16expect 0 mkdir ${n0} 0755
17n=`mdconfig -a -n -t malloc -s 1m` || exit
18newfs /dev/md${n} >/dev/null || exit
19mount /dev/md${n} ${n0} || exit
20expect 0 create ${n0}/${n1} 0644
21expect 0 chmod ${n0}/${n1} 0640
22expect 0640 stat ${n0}/${n1} mode
23expect 0 lchmod ${n0}/${n1} 0530
24expect 0530 stat ${n0}/${n1} mode
25mount -ur /dev/md${n}
26expect EROFS chmod ${n0}/${n1} 0600
27expect EROFS lchmod ${n0}/${n1} 0600
28expect 0530 stat ${n0}/${n1} mode
29mount -uw /dev/md${n}
30expect 0 chmod ${n0}/${n1} 0600
31expect 0600 stat ${n0}/${n1} mode
32expect 0 lchmod ${n0}/${n1} 0640
33expect 0640 stat ${n0}/${n1} mode
34expect 0 unlink ${n0}/${n1}
35umount /dev/md${n}
36mdconfig -d -u ${n} || exit
37expect 0 rmdir ${n0}
38