]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/pjdfstest/tests/link/12.t
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / pjdfstest / tests / link / 12.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="link returns EPERM if the source file has its immutable or append-only flag set"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 require chflags
10
11 case "${os}:${fs}" in
12 FreeBSD:ZFS)
13         echo "1..27"
14         ;;
15 FreeBSD:UFS)
16         echo "1..48"
17         ;;
18 *)
19         quick_exit
20 esac
21
22 n0=`namegen`
23 n1=`namegen`
24
25 expect 0 create ${n0} 0644
26
27 expect 1 stat ${n0} nlink
28 expect 0 link ${n0} ${n1}
29 expect 2 stat ${n0} nlink
30 expect 0 unlink ${n1}
31 expect 1 stat ${n0} nlink
32
33 expect 0 chflags ${n0} SF_IMMUTABLE
34 todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM."
35 expect EPERM link ${n0} ${n1}
36 todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM."
37 expect 1 stat ${n0} nlink
38 expect 0 chflags ${n0} none
39 todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM."
40 expect 0 link ${n0} ${n1}
41 expect 2 stat ${n0} nlink
42 expect 0 unlink ${n1}
43 expect 1 stat ${n0} nlink
44
45 expect 0 chflags ${n0} SF_NOUNLINK
46 expect 0 link ${n0} ${n1}
47 expect 2 stat ${n0} nlink
48 expect 0 chflags ${n0} none
49 expect 0 unlink ${n1}
50 expect 1 stat ${n0} nlink
51
52 case "${os}:${fs}" in
53 FreeBSD:ZFS)
54         expect 0 chflags ${n0} SF_APPEND
55         expect 0 link ${n0} ${n1}
56         expect 2 stat ${n0} nlink
57         expect 0 chflags ${n0} none
58         expect 0 unlink ${n1}
59         expect 1 stat ${n0} nlink
60         ;;
61 FreeBSD:UFS)
62         expect 0 chflags ${n0} SF_APPEND
63         expect EPERM link ${n0} ${n1}
64         expect 0 chflags ${n0} none
65         expect 0 link ${n0} ${n1}
66         expect 2 stat ${n0} nlink
67         expect 0 unlink ${n1}
68         expect 1 stat ${n0} nlink
69
70         expect 0 chflags ${n0} UF_IMMUTABLE
71         expect EPERM link ${n0} ${n1}
72         expect 0 chflags ${n0} none
73         expect 0 link ${n0} ${n1}
74         expect 2 stat ${n0} nlink
75         expect 0 unlink ${n1}
76         expect 1 stat ${n0} nlink
77
78         expect 0 chflags ${n0} UF_NOUNLINK
79         expect 0 link ${n0} ${n1}
80         expect 2 stat ${n0} nlink
81         expect 0 chflags ${n0} none
82         expect 0 unlink ${n1}
83         expect 1 stat ${n0} nlink
84
85         expect 0 chflags ${n0} UF_APPEND
86         expect EPERM link ${n0} ${n1}
87         expect 0 chflags ${n0} none
88         expect 0 link ${n0} ${n1}
89         expect 2 stat ${n0} nlink
90         expect 0 unlink ${n1}
91         expect 1 stat ${n0} nlink
92         ;;
93 esac
94
95 expect 0 unlink ${n0}