]>
Commit | Line | Data |
---|---|---|
2dba5ce7 FW |
1 | #!/bin/bash |
2 | # Consistency checks for the system call list | |
04277e02 | 3 | # Copyright (C) 2017-2019 Free Software Foundation, Inc. |
2dba5ce7 FW |
4 | # This file is part of the GNU C Library. |
5 | # | |
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Lesser General Public | |
8 | # License as published by the Free Software Foundation; either | |
9 | # version 2.1 of the License, or (at your option) any later version. | |
10 | # | |
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # Lesser General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU Lesser General Public | |
17 | # License along with the GNU C Library; if not, see | |
5a82c748 | 18 | # <https://www.gnu.org/licenses/>. |
2dba5ce7 FW |
19 | |
20 | export LC_ALL=C | |
21 | set -e | |
22 | set -o pipefail | |
23 | ||
24 | if test $# != 4; then | |
25 | echo "error: wrong number of arguments: $#" | |
26 | exit 1 | |
27 | fi | |
28 | ||
29 | macros="$1" | |
30 | list_nr="$2" | |
31 | list_sys="$3" | |
32 | GAWK="$4" | |
33 | ||
34 | linux_version="$("$GAWK" \ | |
35 | '/#define LINUX_VERSION_CODE / {print $3}' < "$macros")" | |
36 | glibc_linux_version="$("$GAWK" \ | |
37 | '/#define __GLIBC_LINUX_VERSION_CODE / {print $3}' < "$macros")" | |
38 | ||
39 | echo "info: LINUX_VERSION_CODE: $linux_version" | |
40 | echo "info: __GLIBC_LINUX_VERSION_CODE: $glibc_linux_version" | |
41 | # Ignore the subrelease in the comparison. | |
42 | if test $(expr "$glibc_linux_version" / 256) \ | |
43 | -lt $(expr "$linux_version" / 256); then | |
44 | echo "info: The kernel major/minor version is newer than the glibc version" | |
45 | kernel_newer=true | |
46 | else | |
47 | kernel_newer=false | |
48 | fi | |
49 | echo | |
50 | ||
51 | errors=0 | |
52 | ||
53 | # Use getpid as a system call which is expected to be always defined. | |
54 | # alpha uses getxpid instead, so it is permitted as an alternative. | |
55 | if ! grep -E -q '^getx?pid$' -- "$list_nr"; then | |
56 | echo "error: __NR_getpid not defined" | |
57 | errors=1 | |
58 | fi | |
59 | if ! grep -E -q '^getx?pid$' -- "$list_sys"; then | |
60 | echo "error: SYS_getpid not defined" | |
61 | errors=1 | |
62 | fi | |
63 | ||
64 | comm_1="$(mktemp)" | |
65 | comm_2="$(mktemp)" | |
66 | comm_result="$(mktemp)" | |
67 | cleanup () { | |
68 | rm -f -- "$comm_1" "$comm_2" "$comm_result" | |
69 | } | |
70 | trap cleanup 0 | |
71 | ||
72 | sort -o "$comm_1" -- "$list_nr" | |
73 | sort -o "$comm_2" -- "$list_sys" | |
74 | ||
75 | # Check for missing SYS_* macros. | |
76 | comm --check-order -2 -3 -- "$comm_1" "$comm_2" > "$comm_result" | |
77 | if test -s "$comm_result"; then | |
78 | echo "error: These system calls need to be added to syscall-names.list:" | |
79 | cat -- "$comm_result" | |
80 | # This is only an error if our version is older than the kernel | |
81 | # version because we cannot predict future kernel development. | |
82 | if $kernel_newer; then | |
83 | echo | |
84 | echo "warning: This error has been ignored because the glibc" | |
85 | echo "warning: system call list is older than the kernel version." | |
86 | else | |
87 | errors=1 | |
88 | fi | |
89 | fi | |
90 | ||
91 | # Check for additional SYS_* macros. | |
92 | comm --check-order -1 -3 -- "$comm_1" "$comm_2" > "$comm_result" | |
93 | if test -s "$comm_result"; then | |
94 | echo "error: The following system calls have unexpected SYS_* macros:" | |
95 | cat -- "$comm_result" | |
96 | errors=1 | |
97 | fi | |
98 | ||
99 | exit "$errors" |