Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Aug 2010 14:44:48 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211336 - head/tools/regression/fstest/tests/chmod
Message-ID:  <201008151444.o7FEimYA063143@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sun Aug 15 14:44:48 2010
New Revision: 211336
URL: http://svn.freebsd.org/changeset/base/211336

Log:
  More tests (especially for lchmod(2)), less code duplication.

Modified:
  head/tools/regression/fstest/tests/chmod/00.t
  head/tools/regression/fstest/tests/chmod/04.t
  head/tools/regression/fstest/tests/chmod/05.t
  head/tools/regression/fstest/tests/chmod/06.t
  head/tools/regression/fstest/tests/chmod/07.t
  head/tools/regression/fstest/tests/chmod/08.t
  head/tools/regression/fstest/tests/chmod/09.t
  head/tools/regression/fstest/tests/chmod/10.t
  head/tools/regression/fstest/tests/chmod/11.t

Modified: head/tools/regression/fstest/tests/chmod/00.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/00.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/00.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -7,9 +7,9 @@ dir=`dirname $0`
 . ${dir}/../misc.sh
 
 if supported lchmod; then
-	echo "1..77"
+	echo "1..203"
 else
-	echo "1..58"
+	echo "1..119"
 fi
 
 n0=`namegen`
@@ -20,116 +20,100 @@ expect 0 mkdir ${n2} 0755
 cdir=`pwd`
 cd ${n2}
 
-expect 0 create ${n0} 0644
-expect 0644 stat ${n0} mode
-expect 0 chmod ${n0} 0111
-expect 0111 stat ${n0} mode
-expect 0 unlink ${n0}
-
-expect 0 mkdir ${n0} 0755
-expect 0755 stat ${n0} mode
-expect 0 chmod ${n0} 0753
-expect 0753 stat ${n0} mode
-expect 0 rmdir ${n0}
-
-expect 0 mkfifo ${n0} 0644
-expect 0644 stat ${n0} mode
-expect 0 chmod ${n0} 0310
-expect 0310 stat ${n0} mode
-expect 0 unlink ${n0}
-
-expect 0 create ${n0} 0644
-expect 0 symlink ${n0} ${n1}
-expect 0644 stat ${n1} mode
-expect 0 chmod ${n1} 0321
-expect 0321 stat ${n1} mode
-expect 0321 lstat ${n0} mode
-expect 0 unlink ${n0}
-expect 0 unlink ${n1}
-
-if supported lchmod; then
-	expect 0 create ${n0} 0644
-	expect 0 symlink ${n0} ${n1}
-	expect 0644 stat ${n1} mode
-	expect 0 lchmod ${n1} 0321
-	expect 0321 lstat ${n1} mode
-	expect 0 lchmod ${n1} 0531
-	expect 0531 lstat ${n1} mode
-	expect 0644 stat ${n0} mode
-	expect 0644 stat ${n1} mode
-	expect 0 unlink ${n0}
-	expect 0 unlink ${n1}
-fi
+for type in regular dir fifo block char socket symlink; do
+	if [ "${type}" != "symlink" ]; then
+		create_file ${type} ${n0}
+		expect 0 chmod ${n0} 0111
+		expect 0111 stat ${n0} mode
+
+		expect 0 symlink ${n0} ${n1}
+		mode=`${fstest} lstat ${n1} mode`
+		expect 0 chmod ${n1} 0222
+		expect 0222 stat ${n1} mode
+		expect 0222 stat ${n0} mode
+		expect ${mode} lstat ${n1} mode
+		expect 0 unlink ${n1}
+
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n0}
+		else
+			expect 0 unlink ${n0}
+		fi
+	fi
+
+	if supported lchmod; then
+		create_file ${type} ${n0}
+		expect 0 lchmod ${n0} 0111
+		expect 0111 lstat ${n0} mode
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n0}
+		else
+			expect 0 unlink ${n0}
+		fi
+	fi
+done
 
 # successful chmod(2) updates ctime.
-expect 0 create ${n0} 0644
-ctime1=`${fstest} stat ${n0} ctime`
-sleep 1
-expect 0 chmod ${n0} 0111
-ctime2=`${fstest} stat ${n0} ctime`
-test_check $ctime1 -lt $ctime2
-expect 0 unlink ${n0}
-
-expect 0 mkdir ${n0} 0755
-ctime1=`${fstest} stat ${n0} ctime`
-sleep 1
-expect 0 chmod ${n0} 0753
-ctime2=`${fstest} stat ${n0} ctime`
-test_check $ctime1 -lt $ctime2
-expect 0 rmdir ${n0}
-
-expect 0 mkfifo ${n0} 0644
-ctime1=`${fstest} stat ${n0} ctime`
-sleep 1
-expect 0 chmod ${n0} 0310
-ctime2=`${fstest} stat ${n0} ctime`
-test_check $ctime1 -lt $ctime2
-expect 0 unlink ${n0}
-
-if supported lchmod; then
-	expect 0 symlink ${n1} ${n0}
-	ctime1=`${fstest} lstat ${n0} ctime`
-	sleep 1
-	expect 0 lchmod ${n0} 0321
-	ctime2=`${fstest} lstat ${n0} ctime`
-	test_check $ctime1 -lt $ctime2
-	expect 0 unlink ${n0}
-fi
+for type in regular dir fifo block char socket symlink; do
+	if [ "${type}" != "symlink" ]; then
+		create_file ${type} ${n0}
+		ctime1=`${fstest} stat ${n0} ctime`
+		sleep 1
+		expect 0 chmod ${n0} 0111
+		ctime2=`${fstest} stat ${n0} ctime`
+		test_check $ctime1 -lt $ctime2
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n0}
+		else
+			expect 0 unlink ${n0}
+		fi
+	fi
+
+	if supported lchmod; then
+		create_file ${type} ${n0}
+		ctime1=`${fstest} lstat ${n0} ctime`
+		sleep 1
+		expect 0 lchmod ${n0} 0111
+		ctime2=`${fstest} lstat ${n0} ctime`
+		test_check $ctime1 -lt $ctime2
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n0}
+		else
+			expect 0 unlink ${n0}
+		fi
+	fi
+done
 
 # unsuccessful chmod(2) does not update ctime.
-expect 0 create ${n0} 0644
-ctime1=`${fstest} stat ${n0} ctime`
-sleep 1
-expect EPERM -u 65534 chmod ${n0} 0111
-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 EPERM -u 65534 chmod ${n0} 0753
-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 EPERM -u 65534 chmod ${n0} 0310
-ctime2=`${fstest} stat ${n0} ctime`
-test_check $ctime1 -eq $ctime2
-expect 0 unlink ${n0}
-
-if supported lchmod; then
-	expect 0 symlink ${n1} ${n0}
-	ctime1=`${fstest} lstat ${n0} ctime`
-	sleep 1
-	expect EPERM -u 65534 lchmod ${n0} 0321
-	ctime2=`${fstest} lstat ${n0} ctime`
-	test_check $ctime1 -eq $ctime2
-	expect 0 unlink ${n0}
-fi
+for type in regular dir fifo block char socket symlink; do
+	if [ "${type}" != "symlink" ]; then
+		create_file ${type} ${n0}
+		ctime1=`${fstest} stat ${n0} ctime`
+		sleep 1
+		expect EPERM -u 65534 chmod ${n0} 0111
+		ctime2=`${fstest} stat ${n0} ctime`
+		test_check $ctime1 -eq $ctime2
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n0}
+		else
+			expect 0 unlink ${n0}
+		fi
+	fi
+
+	if supported lchmod; then
+		create_file ${type} ${n0}
+		ctime1=`${fstest} lstat ${n0} ctime`
+		sleep 1
+		expect EPERM -u 65534 lchmod ${n0} 0321
+		ctime2=`${fstest} lstat ${n0} ctime`
+		test_check $ctime1 -eq $ctime2
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n0}
+		else
+			expect 0 unlink ${n0}
+		fi
+	fi
+done
 
 # POSIX: If the calling process does not have appropriate privileges, and if
 # the group ID of the file does not match the effective group ID or one of the
@@ -144,17 +128,10 @@ expect 02755 stat ${n0} mode
 expect 0 -u 65535 -g 65535 chmod ${n0} 0755
 expect 0755 stat ${n0} mode
 
-# Unfortunately FreeBSD doesn't clear set-gid bit, but returns EPERM instead.
-case "${os}" in
-FreeBSD)
-	expect EPERM -u 65535 -g 65534 chmod ${n0} 02755
-	expect 0755 stat ${n0} mode
-	;;
-*)
-	expect 0 -u 65535 -g 65534 chmod ${n0} 02755
-	expect 0755 stat ${n0} mode
-	;;
-esac
+todo FreeBSD "S_ISGID should be removed and chmod(2) should success and FreeBSD returns EPERM."
+expect 0 -u 65535 -g 65534 chmod ${n0} 02755
+expect 0755 stat ${n0} mode
+
 expect 0 unlink ${n0}
 
 cd ${cdir}

Modified: head/tools/regression/fstest/tests/chmod/04.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/04.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/04.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -6,12 +6,24 @@ desc="chmod returns ENOENT if the named 
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..4"
+if supported lchmod; then
+	echo "1..9"
+else
+	echo "1..7"
+fi
 
 n0=`namegen`
 n1=`namegen`
+n2=`namegen`
 
 expect 0 mkdir ${n0} 0755
 expect ENOENT chmod ${n0}/${n1}/test 0644
 expect ENOENT chmod ${n0}/${n1} 0644
+if supported lchmod; then
+	expect ENOENT lchmod ${n0}/${n1}/test 0644
+	expect ENOENT lchmod ${n0}/${n1} 0644
+fi
+expect 0 symlink ${n2} ${n0}/${n1}
+expect ENOENT chmod ${n0}/${n1} 0644
+expect 0 unlink ${n0}/${n1}
 expect 0 rmdir ${n0}

Modified: head/tools/regression/fstest/tests/chmod/05.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/05.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/05.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -6,7 +6,11 @@ desc="chmod returns EACCES when search p
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..14"
+if supported lchmod; then
+	echo "1..19"
+else
+	echo "1..14"
+fi
 
 n0=`namegen`
 n1=`namegen`
@@ -25,6 +29,13 @@ expect EACCES -u 65534 -g 65534 chmod ${
 expect 0 chmod ${n1} 0755
 expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0420
 expect 0420 -u 65534 -g 65534 stat ${n1}/${n2} mode
+if supported lchmod; then
+	expect 0 chmod ${n1} 0644
+	expect EACCES -u 65534 -g 65534 lchmod ${n1}/${n2} 0410
+	expect 0 chmod ${n1} 0755
+	expect 0 -u 65534 -g 65534 lchmod ${n1}/${n2} 0710
+	expect 0710 -u 65534 -g 65534 stat ${n1}/${n2} mode
+fi
 expect 0 -u 65534 -g 65534 unlink ${n1}/${n2}
 expect 0 rmdir ${n1}
 cd ${cdir}

Modified: head/tools/regression/fstest/tests/chmod/06.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/06.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/06.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -6,7 +6,11 @@ desc="chmod returns ELOOP if too many sy
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..6"
+if supported lchmod; then
+	echo "1..8"
+else
+	echo "1..6"
+fi
 
 n0=`namegen`
 n1=`namegen`
@@ -15,5 +19,9 @@ expect 0 symlink ${n0} ${n1}
 expect 0 symlink ${n1} ${n0}
 expect ELOOP chmod ${n0}/test 0644
 expect ELOOP chmod ${n1}/test 0644
+if supported lchmod; then
+	expect ELOOP lchmod ${n0}/test 0644
+	expect ELOOP lchmod ${n1}/test 0644
+fi
 expect 0 unlink ${n0}
 expect 0 unlink ${n1}

Modified: head/tools/regression/fstest/tests/chmod/07.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/07.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/07.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -6,17 +6,23 @@ desc="chmod returns EPERM if the operati
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..14"
+if supported lchmod; then
+	echo "1..34"
+else
+	echo "1..25"
+fi
 
 n0=`namegen`
 n1=`namegen`
 n2=`namegen`
+n3=`namegen`
 
 expect 0 mkdir ${n0} 0755
 cdir=`pwd`
 cd ${n0}
 expect 0 mkdir ${n1} 0755
 expect 0 chown ${n1} 65534 65534
+
 expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
 expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642
 expect 0642 stat ${n1}/${n2} mode
@@ -26,6 +32,31 @@ expect 0 chown ${n1}/${n2} 0 0
 expect EPERM -u 65534 -g 65534 chmod ${n1}/${n2} 0641
 expect 0642 stat ${n1}/${n2} mode
 expect 0 unlink ${n1}/${n2}
+
+expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
+expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3}
+expect 0 -u 65534 -g 65534 chmod ${n1}/${n3} 0642
+expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid
+expect EPERM -u 65533 -g 65533 chmod ${n1}/${n3} 0641
+expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid
+expect 0 chown ${n1}/${n3} 0 0
+expect EPERM -u 65534 -g 65534 chmod ${n1}/${n3} 0641
+expect 0642,0,0 stat ${n1}/${n2} mode,uid,gid
+expect 0 unlink ${n1}/${n2}
+expect 0 unlink ${n1}/${n3}
+
+if supported lchmod; then
+	expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
+	expect 0 -u 65534 -g 65534 lchmod ${n1}/${n2} 0642
+	expect 0642 stat ${n1}/${n2} mode
+	expect EPERM -u 65533 -g 65533 lchmod ${n1}/${n2} 0641
+	expect 0642 stat ${n1}/${n2} mode
+	expect 0 chown ${n1}/${n2} 0 0
+	expect EPERM -u 65534 -g 65534 lchmod ${n1}/${n2} 0641
+	expect 0642 stat ${n1}/${n2} mode
+	expect 0 unlink ${n1}/${n2}
+fi
+
 expect 0 rmdir ${n1}
 cd ${cdir}
 expect 0 rmdir ${n0}

Modified: head/tools/regression/fstest/tests/chmod/08.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/08.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/08.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -10,10 +10,10 @@ require chflags
 
 case "${os}:${fs}" in
 FreeBSD:ZFS)
-	echo "1..22"
+	echo "1..29"
 	;;
 FreeBSD:UFS)
-	echo "1..44"
+	echo "1..54"
 	;;
 *)
 	quick_exit
@@ -24,16 +24,21 @@ n0=`namegen`
 expect 0 create ${n0} 0644
 expect 0 chflags ${n0} SF_IMMUTABLE
 expect EPERM chmod ${n0} 0600
+supported lchmod && expect EPERM lchmod ${n0} 0600
 expect 0644 stat ${n0} mode
 expect 0 chflags ${n0} none
 expect 0 chmod ${n0} 0600
 expect 0600 stat ${n0} mode
+supported lchmod && expect 0 lchmod ${n0} 0400
+supported lchmod && expect 0400 stat ${n0} mode
 expect 0 unlink ${n0}
 
 expect 0 create ${n0} 0644
 expect 0 chflags ${n0} SF_NOUNLINK
 expect 0 chmod ${n0} 0600
 expect 0600 stat ${n0} mode
+supported lchmod && expect 0 lchmod ${n0} 0400
+supported lchmod && expect 0400 stat ${n0} mode
 expect 0 chflags ${n0} none
 expect 0 unlink ${n0}
 
@@ -43,15 +48,18 @@ FreeBSD:ZFS)
 	expect 0 chflags ${n0} SF_APPEND
 	expect 0 chmod ${n0} 0600
 	expect 0600 stat ${n0} mode
+	supported lchmod && expect 0 lchmod ${n0} 0500
+	supported lchmod && expect 0500 stat ${n0} mode
 	expect 0 chflags ${n0} none
-	expect 0 chmod ${n0} 0600
-	expect 0600 stat ${n0} mode
+	expect 0 chmod ${n0} 0400
+	expect 0400 stat ${n0} mode
 	expect 0 unlink ${n0}
 	;;
 FreeBSD:UFS)
 	expect 0 create ${n0} 0644
 	expect 0 chflags ${n0} SF_APPEND
 	expect EPERM chmod ${n0} 0600
+	supported lchmod && expect EPERM lchmod ${n0} 0600
 	expect 0644 stat ${n0} mode
 	expect 0 chflags ${n0} none
 	expect 0 chmod ${n0} 0600
@@ -61,6 +69,7 @@ FreeBSD:UFS)
 	expect 0 create ${n0} 0644
 	expect 0 chflags ${n0} UF_IMMUTABLE
 	expect EPERM chmod ${n0} 0600
+	supported lchmod && expect EPERM lchmod ${n0} 0600
 	expect 0644 stat ${n0} mode
 	expect 0 chflags ${n0} none
 	expect 0 chmod ${n0} 0600
@@ -71,12 +80,15 @@ FreeBSD:UFS)
 	expect 0 chflags ${n0} UF_NOUNLINK
 	expect 0 chmod ${n0} 0600
 	expect 0600 stat ${n0} mode
+	supported lchmod && expect 0 lchmod ${n0} 0400
+	supported lchmod && expect 0400 stat ${n0} mode
 	expect 0 chflags ${n0} none
 	expect 0 unlink ${n0}
 
 	expect 0 create ${n0} 0644
 	expect 0 chflags ${n0} UF_APPEND
 	expect EPERM chmod ${n0} 0600
+	supported lchmod && expect EPERM lchmod ${n0} 0600
 	expect 0644 stat ${n0} mode
 	expect 0 chflags ${n0} none
 	expect 0 chmod ${n0} 0600

Modified: head/tools/regression/fstest/tests/chmod/09.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/09.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/09.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -8,7 +8,7 @@ dir=`dirname $0`
 
 [ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
 
-echo "1..10"
+echo "1..15"
 
 n0=`namegen`
 n1=`namegen`
@@ -20,12 +20,17 @@ mount /dev/md${n} ${n0}
 expect 0 create ${n0}/${n1} 0644
 expect 0 chmod ${n0}/${n1} 0640
 expect 0640 stat ${n0}/${n1} mode
+expect 0 lchmod ${n0}/${n1} 0530
+expect 0530 stat ${n0}/${n1} mode
 mount -ur /dev/md${n}
 expect EROFS chmod ${n0}/${n1} 0600
-expect 0640 stat ${n0}/${n1} mode
+expect EROFS lchmod ${n0}/${n1} 0600
+expect 0530 stat ${n0}/${n1} mode
 mount -uw /dev/md${n}
 expect 0 chmod ${n0}/${n1} 0600
 expect 0600 stat ${n0}/${n1} mode
+expect 0 lchmod ${n0}/${n1} 0640
+expect 0640 stat ${n0}/${n1} mode
 expect 0 unlink ${n0}/${n1}
 umount /dev/md${n}
 mdconfig -d -u ${n}

Modified: head/tools/regression/fstest/tests/chmod/10.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/10.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/10.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -6,7 +6,15 @@ desc="chmod returns EFAULT if the path a
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..2"
+if supported lchmod; then
+	echo "1..4"
+else
+	echo "1..2"
+fi
 
 expect EFAULT chmod NULL 0644
 expect EFAULT chmod DEADCODE 0644
+if supported lchmod; then
+	expect EFAULT lchmod NULL 0644
+	expect EFAULT lchmod DEADCODE 0644
+fi

Modified: head/tools/regression/fstest/tests/chmod/11.t
==============================================================================
--- head/tools/regression/fstest/tests/chmod/11.t	Sun Aug 15 14:38:01 2010	(r211335)
+++ head/tools/regression/fstest/tests/chmod/11.t	Sun Aug 15 14:44:48 2010	(r211336)
@@ -6,48 +6,113 @@ desc="chmod returns EFTYPE if the effect
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..20"
+if supported lchmod; then
+	echo "1..173"
+else
+	echo "1..109"
+fi
 
 n0=`namegen`
 n1=`namegen`
+n2=`namegen`
 
 expect 0 mkdir ${n0} 0755
 cdir=`pwd`
 cd ${n0}
 
-expect 0 mkdir ${n1} 0755
-expect 0 chmod ${n1} 01755
-expect 01755 stat ${n1} mode
-expect 0 rmdir ${n1}
-
-expect 0 create ${n1} 0644
-expect 0 chmod ${n1} 01644
-expect 01644 stat ${n1} mode
-expect 0 unlink ${n1}
+for type in regular dir fifo block char socket symlink; do
+	if [ "${type}" != "symlink" ]; then
+		create_file ${type} ${n1}
+		expect 0 chmod ${n1} 01621
+		expect 01621 stat ${n1} mode
+		expect 0 symlink ${n1} ${n2}
+		expect 0 chmod ${n2} 01700
+		expect 01700 stat ${n1} mode
+		expect 0 unlink ${n2}
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n1}
+		else
+			expect 0 unlink ${n1}
+		fi
+	fi
+
+	if supported lchmod; then
+		create_file ${type} ${n1}
+		expect 0 lchmod ${n1} 01621
+		expect 01621 lstat ${n1} mode
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n1}
+		else
+			expect 0 unlink ${n1}
+		fi
+	fi
+done
 
 expect 0 mkdir ${n1} 0755
 expect 0 chown ${n1} 65534 65534
 expect 0 -u 65534 -g 65534 chmod ${n1} 01755
 expect 01755 stat ${n1} mode
+expect 0 symlink ${n1} ${n2}
+expect 0 chmod ${n2} 01700
+expect 01700 stat ${n1} mode
+expect 0 unlink ${n2}
 expect 0 rmdir ${n1}
 
-expect 0 create ${n1} 0644
-expect 0 chown ${n1} 65534 65534
-case "${os}" in
-FreeBSD)
-	expect EFTYPE -u 65534 -g 65534 chmod ${n1} 01644
-	expect 0644 stat ${n1} mode
-	;;
-SunOS)
-	expect 0 -u 65534 -g 65534 chmod ${n1} 01644
-	expect 0644 stat ${n1} mode
-	;;
-Linux)
-	expect 0 -u 65534 -g 65534 chmod ${n1} 01644
-	expect 01644 stat ${n1} mode
-	;;
-esac
-expect 0 unlink ${n1}
+for type in regular fifo block char socket symlink; do
+	if [ "${type}" != "symlink" ]; then
+		create_file ${type} ${n1} 0640 65534 65534
+		expect 0 symlink ${n1} ${n2}
+		case "${os}" in
+		FreeBSD)
+			expect EFTYPE -u 65534 -g 65534 chmod ${n1} 01644
+			expect 0640 stat ${n1} mode
+			expect EFTYPE -u 65534 -g 65534 chmod ${n2} 01644
+			expect 0640 stat ${n1} mode
+			;;
+		SunOS)
+			expect 0 -u 65534 -g 65534 chmod ${n1} 01644
+			expect 0644 stat ${n1} mode
+			expect 0 -u 65534 -g 65534 chmod ${n2} 01640
+			expect 0640 stat ${n1} mode
+			;;
+		Linux)
+			expect 0 -u 65534 -g 65534 chmod ${n1} 01644
+			expect 01644 stat ${n1} mode
+			expect 0 -u 65534 -g 65534 chmod ${n2} 01640
+			expect 01640 stat ${n1} mode
+			;;
+		esac
+		expect 0 unlink ${n2}
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n1}
+		else
+			expect 0 unlink ${n1}
+		fi
+	fi
+
+	if supported lchmod; then
+		create_file ${type} ${n1} 0640 65534 65534
+		case "${os}" in
+		FreeBSD)
+			expect EFTYPE -u 65534 -g 65534 lchmod ${n1} 01644
+			expect 0640 lstat ${n1} mode
+			;;
+		SunOS)
+			expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
+			expect 0644 lstat ${n1} mode
+			;;
+		Linux)
+			expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
+			expect 01644 lstat ${n1} mode
+			;;
+		esac
+		if [ "${type}" = "dir" ]; then
+			expect 0 rmdir ${n1}
+		else
+			expect 0 unlink ${n1}
+		fi
+	fi
+done
 
 cd ${cdir}
 expect 0 rmdir ${n0}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008151444.o7FEimYA063143>