- Use loops where possible to avoid code duplication.

- Don't pass uid and gid to create_file() if not needed.
- More tests.
This commit is contained in:
Pawel Jakub Dawidek 2010-08-11 17:34:58 +00:00
parent 8db93ae7d4
commit d999d7ae4f
14 changed files with 205 additions and 730 deletions

View File

@ -14,14 +14,14 @@ FreeBSD:UFS)
userflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE"
systemflags="SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
echo "1..780"
echo "1..742"
;;
FreeBSD:ZFS)
allflags="UF_NODUMP,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
userflags="UF_NODUMP"
systemflags="SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK"
echo "1..520"
echo "1..482"
;;
*)
quick_exit
@ -37,7 +37,7 @@ cdir=`pwd`
cd ${n2}
for type in regular dir fifo block char socket; do
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 chflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
@ -53,7 +53,7 @@ for type in regular dir fifo block char socket; do
expect 0 unlink ${n0}
fi
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
expect none stat ${n0} flags
expect 0 lchflags ${n0} ${allflags}
expect ${allflags} stat ${n0} flags
@ -111,7 +111,7 @@ expect 0 unlink ${n0}
# successful chflags(2) updates ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
@ -126,7 +126,7 @@ for type in regular dir fifo block char socket symlink; do
fi
fi
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
@ -144,7 +144,7 @@ done
# unsuccessful chflags(2) does not update ctime.
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
@ -159,7 +159,7 @@ for type in regular dir fifo block char socket symlink; do
fi
fi
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
for flag in `echo ${allflags},none | tr ',' ' '`; do
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1

View File

@ -8,7 +8,7 @@ dir=`dirname $0`
require chflags
echo "1..210"
echo "1..197"
n0=`namegen`
n1=`namegen`
@ -20,7 +20,7 @@ cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1} 0 0
create_file ${type} ${n1}
expect 0 chown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
@ -35,7 +35,7 @@ for type in regular dir fifo block char socket symlink; do
fi
fi
create_file ${type} ${n1} 0 0
create_file ${type} ${n1}
expect 0 lchown ${n1} 65534 65534
for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag}

View File

@ -8,7 +8,7 @@ dir=`dirname $0`
require chflags_SF_SNAPSHOT
echo "1..158"
echo "1..145"
n0=`namegen`
n1=`namegen`
@ -20,7 +20,7 @@ cd ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n1} 0 0
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
expect none stat ${n1} flags
expect EPERM chflags ${n1} SF_SNAPSHOT
@ -37,7 +37,7 @@ for type in regular dir fifo block char socket symlink; do
fi
fi
create_file ${type} ${n1} 0 0
create_file ${type} ${n1}
expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT
expect none lstat ${n1} flags
expect EPERM lchflags ${n1} SF_SNAPSHOT

View File

@ -6,7 +6,7 @@ desc="link creates hardlinks"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..217"
echo "1..202"
n0=`namegen`
n1=`namegen`
@ -18,7 +18,7 @@ cdir=`pwd`
cd ${n3}
for type in regular fifo block char socket; do
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
expect ${type},1 lstat ${n0} type,nlink
expect 0 link ${n0} ${n1}
@ -55,7 +55,7 @@ done
# successful link(2) updates ctime.
for type in regular fifo block char socket; do
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
ctime1=`${fstest} stat ${n0} ctime`
dctime1=`${fstest} stat . ctime`
dmtime1=`${fstest} stat . mtime`
@ -73,7 +73,7 @@ done
# unsuccessful link(2) does not update ctime.
for type in regular fifo block char socket; do
create_file ${type} ${n0} 0 0
create_file ${type} ${n0}
expect 0 -- chown ${n0} 65534 -1
ctime1=`${fstest} stat ${n0} ctime`
dctime1=`${fstest} stat . ctime`

View File

@ -10,30 +10,12 @@ echo "1..21"
n0=`namegen`
expect 0 mkdir ${n0} 0755
expect EEXIST mkdir ${n0} 0755
expect 0 rmdir ${n0}
expect 0 create ${n0} 0644
expect EEXIST mkdir ${n0} 0755
expect 0 unlink ${n0}
expect 0 symlink test ${n0}
expect EEXIST mkdir ${n0} 0755
expect 0 unlink ${n0}
expect 0 mkfifo ${n0} 0644
expect EEXIST mkdir ${n0} 0755
expect 0 unlink ${n0}
expect 0 mknod ${n0} b 0644 1 2
expect EEXIST mkdir ${n0} 0755
expect 0 unlink ${n0}
expect 0 mknod ${n0} c 0644 1 2
expect EEXIST mkdir ${n0} 0755
expect 0 unlink ${n0}
expect 0 bind ${n0}
expect EEXIST mkdir ${n0} 0755
expect 0 unlink ${n0}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}
expect EEXIST mkdir ${n0} 0755
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done

View File

@ -10,30 +10,12 @@ echo "1..21"
n0=`namegen`
expect 0 create ${n0} 0644
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
expect 0 unlink ${n0}
expect 0 mkdir ${n0} 0755
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
expect 0 rmdir ${n0}
expect 0 mkfifo ${n0} 0644
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
expect 0 unlink ${n0}
expect 0 symlink test ${n0}
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
expect 0 unlink ${n0}
expect 0 mknod ${n0} b 0644 1 2
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
expect 0 unlink ${n0}
expect 0 mknod ${n0} c 0644 1 2
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
expect 0 unlink ${n0}
expect 0 bind ${n0}
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
expect 0 unlink ${n0}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}
expect EEXIST open ${n0} O_CREAT,O_EXCL 0644
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done

View File

@ -6,7 +6,7 @@ desc="rename changes file name"
dir=`dirname $0`
. ${dir}/../misc.sh
echo "1..145"
echo "1..150"
n0=`namegen`
n1=`namegen`
@ -17,21 +17,23 @@ expect 0 mkdir ${n3} 0755
cdir=`pwd`
cd ${n3}
expect 0 create ${n0} 0644
expect regular,0644,1 lstat ${n0} type,mode,nlink
inode=`${fstest} lstat ${n0} inode`
expect 0 rename ${n0} ${n1}
expect ENOENT lstat ${n0} type,mode,nlink
expect regular,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
expect 0 link ${n1} ${n0}
expect regular,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect regular,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
expect 0 rename ${n1} ${n2}
expect regular,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect ENOENT lstat ${n1} type,mode,nlink
expect regular,${inode},0644,2 lstat ${n2} type,inode,mode,nlink
expect 0 unlink ${n0}
expect 0 unlink ${n2}
for type in regular fifo block char socket; do
create_file ${type} ${n0} 0644
expect ${type},0644,1 lstat ${n0} type,mode,nlink
inode=`${fstest} lstat ${n0} inode`
expect 0 rename ${n0} ${n1}
expect ENOENT lstat ${n0} type,mode,nlink
expect ${type},${inode},0644,1 lstat ${n1} type,inode,mode,nlink
expect 0 link ${n1} ${n0}
expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect ${type},${inode},0644,2 lstat ${n1} type,inode,mode,nlink
expect 0 rename ${n1} ${n2}
expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect ENOENT lstat ${n1} type,mode,nlink
expect ${type},${inode},0644,2 lstat ${n2} type,inode,mode,nlink
expect 0 unlink ${n0}
expect 0 unlink ${n2}
done
expect 0 mkdir ${n0} 0755
expect dir,0755 lstat ${n0} type,mode
@ -41,70 +43,6 @@ expect ENOENT lstat ${n0} type,mode
expect dir,${inode},0755 lstat ${n1} type,inode,mode
expect 0 rmdir ${n1}
expect 0 mkfifo ${n0} 0644
expect fifo,0644,1 lstat ${n0} type,mode,nlink
inode=`${fstest} lstat ${n0} inode`
expect 0 rename ${n0} ${n1}
expect ENOENT lstat ${n0} type,mode,nlink
expect fifo,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
expect 0 link ${n1} ${n0}
expect fifo,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect fifo,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
expect 0 rename ${n1} ${n2}
expect fifo,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect ENOENT lstat ${n1} type,mode,nlink
expect fifo,${inode},0644,2 lstat ${n2} type,inode,mode,nlink
expect 0 unlink ${n0}
expect 0 unlink ${n2}
expect 0 mknod ${n0} b 0644 1 2
expect block,0644,1 lstat ${n0} type,mode,nlink
inode=`${fstest} lstat ${n0} inode`
expect 0 rename ${n0} ${n1}
expect ENOENT lstat ${n0} type,mode,nlink
expect block,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
expect 0 link ${n1} ${n0}
expect block,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect block,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
expect 0 rename ${n1} ${n2}
expect block,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect ENOENT lstat ${n1} type,mode,nlink
expect block,${inode},0644,2 lstat ${n2} type,inode,mode,nlink
expect 0 unlink ${n0}
expect 0 unlink ${n2}
expect 0 mknod ${n0} c 0644 1 2
expect char,0644,1 lstat ${n0} type,mode,nlink
inode=`${fstest} lstat ${n0} inode`
expect 0 rename ${n0} ${n1}
expect ENOENT lstat ${n0} type,mode,nlink
expect char,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
expect 0 link ${n1} ${n0}
expect char,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect char,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
expect 0 rename ${n1} ${n2}
expect char,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect ENOENT lstat ${n1} type,mode,nlink
expect char,${inode},0644,2 lstat ${n2} type,inode,mode,nlink
expect 0 unlink ${n0}
expect 0 unlink ${n2}
expect 0 -U 0133 bind ${n0}
expect socket,0644,1 lstat ${n0} type,mode,nlink
inode=`${fstest} lstat ${n0} inode`
expect 0 rename ${n0} ${n1}
expect ENOENT lstat ${n0} type,mode,nlink
expect socket,${inode},0644,1 lstat ${n1} type,inode,mode,nlink
expect 0 link ${n1} ${n0}
expect socket,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect socket,${inode},0644,2 lstat ${n1} type,inode,mode,nlink
expect 0 rename ${n1} ${n2}
expect socket,${inode},0644,2 lstat ${n0} type,inode,mode,nlink
expect ENOENT lstat ${n1} type,mode,nlink
expect socket,${inode},0644,2 lstat ${n2} type,inode,mode,nlink
expect 0 unlink ${n0}
expect 0 unlink ${n2}
expect 0 create ${n0} 0644
rinode=`${fstest} lstat ${n0} inode`
expect regular,0644 lstat ${n0} type,mode
@ -120,118 +58,34 @@ expect 0 unlink ${n0}
expect 0 unlink ${n2}
# successful rename(2) updates ctime.
expect 0 create ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n1}
expect 0 mkdir ${n0} 0755
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 rmdir ${n1}
expect 0 mkfifo ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n1}
expect 0 mknod ${n0} b 0644 1 2
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n1}
expect 0 mknod ${n0} c 0644 1 2
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n1}
expect 0 bind ${n0}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n1}
expect 0 symlink ${n2} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} lstat ${n1} ctime`
test_check $ctime1 -lt $ctime2
expect 0 unlink ${n1}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect 0 rename ${n0} ${n1}
ctime2=`${fstest} lstat ${n1} ctime`
test_check $ctime1 -lt $ctime2
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
# unsuccessful link(2) does not update ctime.
expect 0 create ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
expect 0 mkdir ${n0} 0755
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 rmdir ${n0}
expect 0 mkfifo ${n0} 0644
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
expect 0 mknod ${n0} b 0644 1 2
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
expect 0 mknod ${n0} c 0644 1 2
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
expect 0 bind ${n0}
ctime1=`${fstest} stat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} stat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
expect 0 symlink ${n2} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -eq $ctime2
expect 0 unlink ${n0}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}
ctime1=`${fstest} lstat ${n0} ctime`
sleep 1
expect EACCES -u 65534 rename ${n0} ${n1}
ctime2=`${fstest} lstat ${n0} ctime`
test_check $ctime1 -eq $ctime2
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
cd ${cdir}
expect 0 rmdir ${n3}

View File

@ -11,11 +11,11 @@ require chflags
case "${os}:${fs}" in
FreeBSD:ZFS)
flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND"
echo "1..105"
echo "1..195"
;;
FreeBSD:UFS)
flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND UF_IMMUTABLE UF_NOUNLINK UF_APPEND"
echo "1..189"
echo "1..351"
;;
*)
quick_exit
@ -24,86 +24,38 @@ esac
n0=`namegen`
n1=`namegen`
expect 0 create ${n0} 0644
for flag in ${flags}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
for type in regular dir fifo block char socket symlink; do
if [ "${type}" != "symlink" ]; then
create_file ${type} ${n0}
for flag in ${flags}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 chflags ${n0} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
fi
expect 0 mkdir ${n0} 0755
for flag in ${flags}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a directory protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a directory protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
create_file ${type} ${n0}
for flag in ${flags}; do
expect 0 lchflags ${n0} ${flag}
expect ${flag} lstat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 lchflags ${n0} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}
else
expect 0 unlink ${n0}
fi
done
expect 0 chflags ${n0} none
expect 0 rmdir ${n0}
expect 0 mkfifo ${n0} 0644
for flag in ${flags}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a fifo protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a fifo protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 mknod ${n0} b 0644 1 2
for flag in ${flags}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 mknod ${n0} c 0644 1 2
for flag in ${flags}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 bind ${n0}
for flag in ${flags}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a socket protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a socket protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}
expect 0 symlink ${n1} ${n0}
for flag in ${flags}; do
expect 0 lchflags ${n0} ${flag}
expect ${flag} lstat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a symlink protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0} ${n1}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a symlink protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n1} ${n0}
done
expect 0 lchflags ${n0} none
expect 0 unlink ${n0}

View File

@ -29,158 +29,38 @@ n2=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n0}/${n1} 0644
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}/${n1}
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}/${n1}
else
expect 0 unlink ${n0}/${n1}
fi
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 mkdir ${n0}/${n1} 0755
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}/${n1}
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}/${n1}
else
expect 0 unlink ${n0}/${n1}
fi
done
expect 0 chflags ${n0} none
expect 0 rmdir ${n0}/${n1}
expect 0 mkfifo ${n0}/${n1} 0644
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 mknod ${n0}/${n1} b 0644 1 2
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 mknod ${n0}/${n1} c 0644 1 2
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 bind ${n0}/${n1}
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 symlink ${n2} ${n0}/${n1}
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect EPERM rename ${n0}/${n1} ${n2}
[ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM."
expect ENOENT rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 create ${n0}/${n1} 0644
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 mkdir ${n0}/${n1} 0755
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 rmdir ${n0}/${n1}
expect 0 mkfifo ${n0}/${n1} 0644
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 mknod ${n0}/${n1} b 0644 1 2
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 mknod ${n0}/${n1} c 0644 1 2
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 bind ${n0}/${n1}
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 symlink ${n2} ${n0}/${n1}
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n0}/${n1} ${n2}
expect 0 rename ${n2} ${n0}/${n1}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n0}/${n1}
expect 0 rmdir ${n0}

View File

@ -12,12 +12,12 @@ case "${os}:${fs}" in
FreeBSD:ZFS)
flags1="SF_IMMUTABLE"
flags2="SF_NOUNLINK SF_APPEND"
echo "1..110"
echo "1..128"
;;
FreeBSD:UFS)
flags1="SF_IMMUTABLE UF_IMMUTABLE"
flags2="SF_NOUNLINK SF_APPEND UF_NOUNLINK UF_APPEND"
echo "1..188"
echo "1..219"
;;
*)
quick_exit
@ -29,118 +29,35 @@ n2=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n1} 0644
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect EPERM rename ${n1} ${n0}/${n2}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 0 mkdir ${n1} 0755
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect EPERM rename ${n1} ${n0}/${n2}
done
expect 0 chflags ${n0} none
expect 0 rmdir ${n1}
expect 0 mkfifo ${n1} 0644
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect EPERM rename ${n1} ${n0}/${n2}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 0 mknod ${n1} c 0644 1 2
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect EPERM rename ${n1} ${n0}/${n2}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 0 bind ${n1}
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect EPERM rename ${n1} ${n0}/${n2}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 0 symlink ${n2} ${n1}
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect EPERM rename ${n1} ${n0}/${n2}
done
expect 0 chflags ${n0} none
expect 0 unlink ${n1}
expect 0 create ${n1} 0644
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n1} ${n0}/${n2}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n1}
for flag in ${flags1}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect EPERM rename ${n1} ${n0}/${n2}
done
expect 0 chflags ${n0} none
expect 0 rename ${n0}/${n2} ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
expect 0 unlink ${n1}
expect 0 mkdir ${n1} 0755
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n1} ${n0}/${n2}
expect 0 chflags ${n0} none
expect 0 rename ${n0}/${n2} ${n1}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n1}
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n1} ${n0}/${n2}
expect 0 chflags ${n0} none
expect 0 rename ${n0}/${n2} ${n1}
done
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}
else
expect 0 unlink ${n1}
fi
done
expect 0 rmdir ${n1}
expect 0 mkfifo ${n1} 0644
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n1} ${n0}/${n2}
expect 0 chflags ${n0} none
expect 0 rename ${n0}/${n2} ${n1}
done
expect 0 unlink ${n1}
expect 0 mknod ${n1} c 0644 1 2
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n1} ${n0}/${n2}
expect 0 chflags ${n0} none
expect 0 rename ${n0}/${n2} ${n1}
done
expect 0 unlink ${n1}
expect 0 bind ${n1}
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n1} ${n0}/${n2}
expect 0 chflags ${n0} none
expect 0 rename ${n0}/${n2} ${n1}
done
expect 0 unlink ${n1}
expect 0 symlink ${n2} ${n1}
for flag in ${flags2}; do
expect 0 chflags ${n0} ${flag}
expect ${flag} stat ${n0} flags
expect 0 rename ${n1} ${n0}/${n2}
expect 0 chflags ${n0} none
expect 0 rename ${n0}/${n2} ${n1}
done
expect 0 unlink ${n1}
expect 0 rmdir ${n0}

View File

@ -13,40 +13,12 @@ n1=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n1} 0644
expect ENOTDIR rename ${n0} ${n1}
expect dir lstat ${n0} type
expect regular lstat ${n1} type
expect 0 unlink ${n1}
expect 0 mkfifo ${n1} 0644
expect ENOTDIR rename ${n0} ${n1}
expect dir lstat ${n0} type
expect fifo lstat ${n1} type
expect 0 unlink ${n1}
expect 0 mknod ${n1} b 0644 1 2
expect ENOTDIR rename ${n0} ${n1}
expect dir lstat ${n0} type
expect block lstat ${n1} type
expect 0 unlink ${n1}
expect 0 mknod ${n1} c 0644 1 2
expect ENOTDIR rename ${n0} ${n1}
expect dir lstat ${n0} type
expect char lstat ${n1} type
expect 0 unlink ${n1}
expect 0 bind ${n1}
expect ENOTDIR rename ${n0} ${n1}
expect dir lstat ${n0} type
expect socket lstat ${n1} type
expect 0 unlink ${n1}
expect 0 symlink test ${n1}
expect ENOTDIR rename ${n0} ${n1}
expect dir lstat ${n0} type
expect symlink lstat ${n1} type
expect 0 unlink ${n1}
for type in regular fifo block char socket symlink; do
create_file ${type} ${n1}
expect ENOTDIR rename ${n0} ${n1}
expect dir lstat ${n0} type
expect ${type} lstat ${n1} type
expect 0 unlink ${n1}
done
expect 0 rmdir ${n0}

View File

@ -13,40 +13,12 @@ n1=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 create ${n1} 0644
expect EISDIR rename ${n1} ${n0}
expect dir lstat ${n0} type
expect regular lstat ${n1} type
expect 0 unlink ${n1}
expect 0 mkfifo ${n1} 0644
expect EISDIR rename ${n1} ${n0}
expect dir lstat ${n0} type
expect fifo lstat ${n1} type
expect 0 unlink ${n1}
expect 0 mknod ${n1} b 0644 1 2
expect EISDIR rename ${n1} ${n0}
expect dir lstat ${n0} type
expect block lstat ${n1} type
expect 0 unlink ${n1}
expect 0 mknod ${n1} c 0644 1 2
expect EISDIR rename ${n1} ${n0}
expect dir lstat ${n0} type
expect char lstat ${n1} type
expect 0 unlink ${n1}
expect 0 bind ${n1}
expect EISDIR rename ${n1} ${n0}
expect dir lstat ${n0} type
expect socket lstat ${n1} type
expect 0 unlink ${n1}
expect 0 symlink test ${n1}
expect EISDIR rename ${n1} ${n0}
expect dir lstat ${n0} type
expect symlink lstat ${n1} type
expect 0 unlink ${n1}
for type in regular fifo block char socket symlink; do
create_file ${type} ${n1}
expect EISDIR rename ${n1} ${n0}
expect dir lstat ${n0} type
expect ${type} lstat ${n1} type
expect 0 unlink ${n1}
done
expect 0 rmdir ${n0}

View File

@ -19,33 +19,15 @@ n=`mdconfig -a -n -t malloc -s 1m`
newfs /dev/md${n} >/dev/null
mount /dev/md${n} ${n0}
expect 0 create ${n0}/${n1} 0644
expect EXDEV rename ${n0}/${n1} ${n2}
expect 0 unlink ${n0}/${n1}
expect 0 mkdir ${n0}/${n1} 0755
expect EXDEV rename ${n0}/${n1} ${n2}
expect 0 rmdir ${n0}/${n1}
expect 0 mkfifo ${n0}/${n1} 0644
expect EXDEV rename ${n0}/${n1} ${n2}
expect 0 unlink ${n0}/${n1}
expect 0 mknod ${n0}/${n1} b 0644 1 2
expect EXDEV rename ${n0}/${n1} ${n2}
expect 0 unlink ${n0}/${n1}
expect 0 mknod ${n0}/${n1} c 0644 1 2
expect EXDEV rename ${n0}/${n1} ${n2}
expect 0 unlink ${n0}/${n1}
expect 0 bind ${n0}/${n1}
expect EXDEV rename ${n0}/${n1} ${n2}
expect 0 unlink ${n0}/${n1}
expect 0 symlink test ${n0}/${n1}
expect EXDEV rename ${n0}/${n1} ${n2}
expect 0 unlink ${n0}/${n1}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n0}/${n1}
expect EXDEV rename ${n0}/${n1} ${n2}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n0}/${n1}
else
expect 0 unlink ${n0}/${n1}
fi
done
umount /dev/md${n}
mdconfig -d -u ${n}

View File

@ -15,33 +15,15 @@ n2=`namegen`
expect 0 mkdir ${n0} 0755
expect 0 mkdir ${n1} 0755
expect 0 create ${n1}/${n2} 0644
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
expect 0 unlink ${n1}/${n2}
expect 0 mkdir ${n1}/${n2} 0755
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
expect 0 rmdir ${n1}/${n2}
expect 0 mkfifo ${n1}/${n2} 0644
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
expect 0 unlink ${n1}/${n2}
expect 0 mknod ${n1}/${n2} b 0644 1 2
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
expect 0 unlink ${n1}/${n2}
expect 0 mknod ${n1}/${n2} c 0644 1 2
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
expect 0 unlink ${n1}/${n2}
expect 0 bind ${n1}/${n2}
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
expect 0 unlink ${n1}/${n2}
expect 0 symlink test ${n1}/${n2}
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
expect 0 unlink ${n1}/${n2}
for type in regular dir fifo block char socket symlink; do
create_file ${type} ${n1}/${n2}
expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1}
if [ "${type}" = "dir" ]; then
expect 0 rmdir ${n1}/${n2}
else
expect 0 unlink ${n1}/${n2}
fi
done
expect 0 rmdir ${n1}
expect 0 rmdir ${n0}