xref: /freebsd/contrib/pjdfstest/tests/link/16.t (revision 0e97acdf58fe27b09c4824a474b0344daf997c5f)
1#!/bin/sh
2# $FreeBSD: head/tools/regression/pjdfstest/tests/link/16.t 211352 2010-08-15 21:24:17Z pjd $
3
4desc="link returns EROFS if the requested link requires writing in a directory on a read-only file system"
5
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
9[ "${os}" = "FreeBSD" ] || quick_exit
10
11echo "1..9"
12
13n0=`namegen`
14n1=`namegen`
15n2=`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
22
23expect 0 link ${n0}/${n1} ${n0}/${n2}
24expect 0 unlink ${n0}/${n2}
25mount -ur /dev/md${n}
26expect EROFS link ${n0}/${n1} ${n0}/${n2}
27mount -uw /dev/md${n}
28expect 0 link ${n0}/${n1} ${n0}/${n2}
29expect 0 unlink ${n0}/${n2}
30
31expect 0 unlink ${n0}/${n1}
32umount /dev/md${n}
33mdconfig -d -u ${n} || exit
34expect 0 rmdir ${n0}
35