Commit d705ab93 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

Check file permissions in the check_format script



Change-Id: I572b24b2f4f149333f2e4b04f6f4961de9c23373
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/427539


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent 48f70f48
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -8,6 +8,51 @@ set -e

rc=0

echo -n "Checking file permissions..."

while read -r perm _res0 _res1 path; do
	if [ ! -f "$path" ]; then
		continue
	fi

	fname=$(basename -- "$path")

	case ${fname##*.} in
		c|h|cpp|cc|cxx|hh|hpp|md|html|js|json|svg|Doxyfile|yml|LICENSE|README|conf|in|Makefile|mk|gitignore|go|txt)
			# These file types should never be executable
			if [ "$perm" -eq 100755 ]; then
				echo "ERROR: $path is marked executable but is a code file."
				rc=1
			fi
		;;
		*)
			shebang=$(head -n 1 $path | cut -c1-3)

			# git only tracks the execute bit, so will only ever return 755 or 644 as the permission.
			if [ "$perm" -eq 100755 ]; then
				# If the file has execute permission, it should start with a shebang.
				if [ "$shebang" != "#!/" ]; then
					echo "ERROR: $path is marked executable but does not start with a shebang."
					rc=1
				fi
			else
				# If the file doesnot have execute permissions, it should not start with a shebang.
				if [ "$shebang" = "#!/" ]; then
					echo "ERROR: $path is not marked executable but starts with a shebang."
					rc=1
				fi
			fi
		;;
	esac

done <<< $(git grep -I --name-only --untracked -e . | git ls-files -s)

if [ $rc -eq 0 ]; then
	echo " OK"
fi

exit 0

if hash astyle; then
	echo -n "Checking coding style..."
	if [ "$(astyle -V)" \< "Artistic Style Version 3" ]

scripts/rpc/bdev.py

100755 → 100644
+0 −0

File mode changed from 100755 to 100644.

test/bdev/bdevperf/bdevperf.c

100755 → 100644
+0 −0

File mode changed from 100755 to 100644.

test/json_config/common.sh

100755 → 100644
+0 −0

File mode changed from 100755 to 100644.

+0 −1
Original line number Diff line number Diff line
#!/usr/bin/env python3
import io
import time
import sys
Loading