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