summaryrefslogtreecommitdiff
path: root/scripts/perms.awk
blob: 4ace2a8425abed080c670384440eb16adf446a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
BEGIN {
	RS = ""
	sort = "sort -k 2"
}

function mode() {
	for (i = 2; i <= NF; ++i) {
		if ($i ~ /^mode=/)
			return substr($i, 6)
	}
	printf "file '%s' is missing mode attribute\n", $1 >"/proc/self/fd/2"
	exit(1)
}

/type=dir/ {
	printf "04%s %s\n", mode(), substr($1, 2) |sort
}

/type=reg/ {
	m = mode()
	if (m != "0644" && m != "0755")
		printf "10%s %s\n", m, substr($1, 2) |sort
}