brintos

brintos / linux-shallow public Read only

0
0
Text · 1.2 KiB · 4436fcd Raw
32 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: LGPL-2.13 4if [ $# -ne 2 ] ; then5	[ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/`6	asm_header_dir=tools/include/uapi/asm-generic7	arch_header_dir=tools/arch/${hostarch}/include/uapi/asm8else9	asm_header_dir=$110	arch_header_dir=$211fi12 13common_mman=${asm_header_dir}/mman-common.h14arch_mman=${arch_header_dir}/mman.h15 16prefix="PROT"17 18printf "static const char *mmap_prot[] = {\n"19regex=`printf '^[[:space:]]*#[[:space:]]*define[[:space:]]+%s_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' ${prefix}`20( ! test -f ${arch_mman} \21|| grep -E -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&22(grep -E $regex ${common_mman} | \23	grep -E -vw PROT_NONE | \24	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \25	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef ${prefix}_%s\n#define ${prefix}_%s %s\n#endif\n")26test -f ${arch_mman} && grep -E -q $regex ${arch_mman} &&27(grep -E $regex ${arch_mman} | \28	grep -E -vw PROT_NONE | \29	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \30	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef ${prefix}_%s\n#define ${prefix}_%s %s\n#endif\n")31printf "};\n"32