08.t revision 166065
1166065Spjd#!/bin/sh
2166065Spjd# $FreeBSD: head/tools/regression/fstest/tests/rename/08.t 166065 2007-01-17 01:42:12Z pjd $
3166065Spjd
4166065Spjddesc="rename returns EPERM if the parent directory of the file pointed at by the 'to' argument has its immutable flag set"
5166065Spjd
6166065Spjddir=`dirname $0`
7166065Spjd. ${dir}/../misc.sh
8166065Spjd
9166065Spjdrequire chflags
10166065Spjd
11166065Spjdecho "1..126"
12166065Spjd
13166065Spjdn0=`namegen`
14166065Spjdn1=`namegen`
15166065Spjdn2=`namegen`
16166065Spjd
17166065Spjdexpect 0 mkdir ${n0} 0755
18166065Spjd
19166065Spjdexpect 0 create ${n1} 0644
20166065Spjdfor flag in SF_IMMUTABLE UF_IMMUTABLE; do
21166065Spjd	expect 0 chflags ${n0} ${flag}
22166065Spjd	expect ${flag} stat ${n0} flags
23166065Spjd	expect EPERM rename ${n1} ${n0}/${n2}
24166065Spjddone
25166065Spjdexpect 0 chflags ${n0} none
26166065Spjdexpect 0 unlink ${n1}
27166065Spjd
28166065Spjdexpect 0 mkdir ${n1} 0755
29166065Spjdfor flag in SF_IMMUTABLE UF_IMMUTABLE; do
30166065Spjd	expect 0 chflags ${n0} ${flag}
31166065Spjd	expect ${flag} stat ${n0} flags
32166065Spjd	expect EPERM rename ${n1} ${n0}/${n2}
33166065Spjddone
34166065Spjdexpect 0 chflags ${n0} none
35166065Spjdexpect 0 rmdir ${n1}
36166065Spjd
37166065Spjdexpect 0 mkfifo ${n1} 0644
38166065Spjdfor flag in SF_IMMUTABLE UF_IMMUTABLE; do
39166065Spjd	expect 0 chflags ${n0} ${flag}
40166065Spjd	expect ${flag} stat ${n0} flags
41166065Spjd	expect EPERM rename ${n1} ${n0}/${n2}
42166065Spjddone
43166065Spjdexpect 0 chflags ${n0} none
44166065Spjdexpect 0 unlink ${n1}
45166065Spjd
46166065Spjdexpect 0 symlink ${n2} ${n1}
47166065Spjdfor flag in SF_IMMUTABLE UF_IMMUTABLE; do
48166065Spjd	expect 0 chflags ${n0} ${flag}
49166065Spjd	expect ${flag} stat ${n0} flags
50166065Spjd	expect EPERM rename ${n1} ${n0}/${n2}
51166065Spjddone
52166065Spjdexpect 0 chflags ${n0} none
53166065Spjdexpect 0 unlink ${n1}
54166065Spjd
55166065Spjdexpect 0 create ${n1} 0644
56166065Spjdfor flag in SF_APPEND UF_APPEND SF_NOUNLINK UF_NOUNLINK; do
57166065Spjd	expect 0 chflags ${n0} ${flag}
58166065Spjd	expect ${flag} stat ${n0} flags
59166065Spjd	expect 0 rename ${n1} ${n0}/${n2}
60166065Spjd	expect 0 chflags ${n0} none
61166065Spjd	expect 0 rename ${n0}/${n2} ${n1}
62166065Spjddone
63166065Spjdexpect 0 unlink ${n1}
64166065Spjd
65166065Spjdexpect 0 mkdir ${n1} 0755
66166065Spjdfor flag in SF_APPEND UF_APPEND SF_NOUNLINK UF_NOUNLINK; do
67166065Spjd	expect 0 chflags ${n0} ${flag}
68166065Spjd	expect ${flag} stat ${n0} flags
69166065Spjd	expect 0 rename ${n1} ${n0}/${n2}
70166065Spjd	expect 0 chflags ${n0} none
71166065Spjd	expect 0 rename ${n0}/${n2} ${n1}
72166065Spjddone
73166065Spjdexpect 0 rmdir ${n1}
74166065Spjd
75166065Spjdexpect 0 mkfifo ${n1} 0644
76166065Spjdfor flag in SF_APPEND UF_APPEND SF_NOUNLINK UF_NOUNLINK; do
77166065Spjd	expect 0 chflags ${n0} ${flag}
78166065Spjd	expect ${flag} stat ${n0} flags
79166065Spjd	expect 0 rename ${n1} ${n0}/${n2}
80166065Spjd	expect 0 chflags ${n0} none
81166065Spjd	expect 0 rename ${n0}/${n2} ${n1}
82166065Spjddone
83166065Spjdexpect 0 unlink ${n1}
84166065Spjd
85166065Spjdexpect 0 symlink ${n2} ${n1}
86166065Spjdfor flag in SF_APPEND UF_APPEND SF_NOUNLINK UF_NOUNLINK; do
87166065Spjd	expect 0 chflags ${n0} ${flag}
88166065Spjd	expect ${flag} stat ${n0} flags
89166065Spjd	expect 0 rename ${n1} ${n0}/${n2}
90166065Spjd	expect 0 chflags ${n0} none
91166065Spjd	expect 0 rename ${n0}/${n2} ${n1}
92166065Spjddone
93166065Spjdexpect 0 unlink ${n1}
94166065Spjd
95166065Spjdexpect 0 rmdir ${n0}
96