Loading...
1#!/bin/sh
2# SPDX-License-Identifier: LGPL-2.1
3
4if [ $# -gt 0 ] ; then
5 uapi_header_dir=$1
6 beauty_header_dir=$2
7else
8 uapi_header_dir=tools/include/uapi/linux/
9 beauty_header_dir=tools/perf/trace/beauty/include/linux/
10fi
11
12printf "static const char *socket_ipproto[] = {\n"
13ipproto_regex='^[[:space:]]+IPPROTO_(\w+)[[:space:]]+=[[:space:]]+([[:digit:]]+),.*'
14
15grep -E $ipproto_regex ${uapi_header_dir}/in.h | \
16 sed -r "s/$ipproto_regex/\2 \1/g" | \
17 sort -n | xargs printf "\t[%s] = \"%s\",\n"
18printf "};\n\n"
19
20printf "static const char *socket_level[] = {\n"
21socket_level_regex='^#define[[:space:]]+SOL_(\w+)[[:space:]]+([[:digit:]]+)([[:space:]]+/.*)?'
22
23grep -E $socket_level_regex ${beauty_header_dir}/socket.h | \
24 sed -E "s%$socket_level_regex%\2 \1%g" | \
25 sort -n | xargs printf "\t[%s] = \"%s\",\n"
26printf "};\n\n"
27
28printf 'DEFINE_STRARRAY(socket_level, "SOL_");\n'
1#!/bin/sh
2# SPDX-License-Identifier: LGPL-2.1
3
4# This one uses a copy from the kernel sources headers that is in a
5# place used just for these tools/perf/beauty/ usage, we shouldn't not
6# put it in tools/include/linux otherwise they would be used in the
7# normal compiler building process and would drag needless stuff from the
8# kernel.
9
10# When what these scripts need is already in tools/include/ then use it,
11# otherwise grab and check the copy from the kernel sources just for these
12# string table building scripts.
13
14[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/perf/trace/beauty/include/linux/
15
16printf "static const char *socket_families[] = {\n"
17# #define AF_LOCAL 1 /* POSIX name for AF_UNIX */
18regex='^#define[[:space:]]+AF_(\w+)[[:space:]]+([[:digit:]]+).*'
19
20egrep $regex ${header_dir}/socket.h | \
21 sed -r "s/$regex/\2 \1/g" | \
22 xargs printf "\t[%s] = \"%s\",\n" | \
23 egrep -v "\"(UNIX|MAX)\""
24printf "};\n"