]> git.ipfire.org Git - thirdparty/linux.git/blame - scripts/headers_install.sh
pidfs: remove config option
[thirdparty/linux.git] / scripts / headers_install.sh
CommitLineData
e0e2fa4b 1#!/bin/sh
b2441318 2# SPDX-License-Identifier: GPL-2.0
e0e2fa4b 3
555187a8 4if [ $# -ne 2 ]
e0e2fa4b 5then
555187a8 6 echo "Usage: headers_install.sh INFILE OUTFILE"
e0e2fa4b
RL
7 echo
8 echo "Prepares kernel header files for use by user space, by removing"
9 echo "all compiler.h definitions and #includes, removing any"
10 echo "#ifdef __KERNEL__ sections, and putting __underscores__ around"
11 echo "asm/inline/volatile keywords."
12 echo
555187a8 13 echo "INFILE: header file to operate on"
0f50d21a 14 echo "OUTFILE: output file which the processed header is written to"
e0e2fa4b
RL
15
16 exit 1
17fi
18
19# Grab arguments
555187a8
MY
20INFILE=$1
21OUTFILE=$2
22TMPFILE=$OUTFILE.tmp
e0e2fa4b 23
555187a8 24trap 'rm -f $OUTFILE $TMPFILE' EXIT
e0e2fa4b 25
62244554
MY
26# SPDX-License-Identifier with GPL variants must have "WITH Linux-syscall-note"
27if [ -n "$(sed -n -e "/SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/!p}" $INFILE)" ]; then
28 echo "error: $INFILE: missing \"WITH Linux-syscall-note\" for SPDX-License-Identifier" >&2
29 exit 1
30fi
31
555187a8
MY
32sed -E -e '
33 s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
34 s/__attribute_const__([[:space:]]|$)/\1/g
35 s@^#include <linux/compiler(|_types).h>@@
36 s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
37 s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
38 s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
39' $INFILE > $TMPFILE || exit 1
e0e2fa4b 40
555187a8
MY
41scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
42[ $? -gt 1 ] && exit 1
43
c7c0eecf
MY
44# Remove /* ... */ style comments, and find CONFIG_ references in code
45configs=$(sed -e '
46:comment
47 s:/\*[^*][^*]*:/*:
48 s:/\*\*\**\([^/]\):/*\1:
49 t comment
50 s:/\*\*/: :
51 t comment
52 /\/\*/! b check
53 N
54 b comment
55:print
56 P
57 D
58:check
59 s:^\(CONFIG_[[:alnum:]_]*\):\1\n:
60 t print
61 s:^[[:alnum:]_][[:alnum:]_]*::
62 s:^[^[:alnum:]_][^[:alnum:]_]*::
63 t check
64 d
65' $OUTFILE)
66
59675772 67# The entries in the following list do not result in an error.
c7c0eecf
MY
68# Please do not add a new entry. This list is only for existing ones.
69# The list will be reduced gradually, and deleted eventually. (hopefully)
70#
71# The format is <file-name>:<CONFIG-option> in each line.
72config_leak_ignores="
c7c0eecf
MY
73arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_16K
74arch/arc/include/uapi/asm/page.h:CONFIG_ARC_PAGE_SIZE_4K
75arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
76arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
c7c0eecf
MY
77arch/m68k/include/uapi/asm/ptrace.h:CONFIG_COLDFIRE
78arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
79arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
c7c0eecf
MY
80arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
81arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
c7c0eecf
MY
82"
83
84for c in $configs
85do
59675772 86 leak_error=1
c7c0eecf
MY
87
88 for ignore in $config_leak_ignores
89 do
90 if echo "$INFILE:$c" | grep -q "$ignore$"; then
59675772 91 leak_error=
c7c0eecf
MY
92 break
93 fi
94 done
95
59675772
SG
96 if [ "$leak_error" = 1 ]; then
97 echo "error: $INFILE: leak $c to user-space" >&2
98 exit 1
c7c0eecf
MY
99 fi
100done
101
555187a8 102rm -f $TMPFILE
e0e2fa4b 103trap - EXIT