@@ -161,6 +161,31 @@ function mangle_lib_syscall() {
161161 sed $sed_filter | sed ' /,-[0-9]\+$/d'
162162}
163163
164+ #
165+ # Dump syscalls matching specified tags from the given syscall.tbl file
166+ #
167+ # Arguments:
168+ # 1 path to the syscall.tbl file to dump
169+ # (rest) tags to match (except "common" which is always included)
170+ #
171+ # Dump the matched syscall table entries to stdout.
172+ #
173+ function dump_from_syscall_tbl() {
174+ local file=" $1 "
175+ shift
176+
177+ local tag
178+ local tag_regexp=' ^(common'
179+ for tag in " $@ " ; do
180+ tag_regexp=" ${tag_regexp} |${tag} "
181+ done
182+ tag_regexp=" ${tag_regexp} ) "
183+
184+ cat " $file " | grep -v ' ^#\|^$' | awk ' { print $2,$3,$1 }' | \
185+ grep -E " $tag_regexp " | awk ' { print $2","$3 }' | sort | \
186+ grep -Ev ' ^(reserved|unused)[0-9]+,'
187+ }
188+
164189#
165190# Dump the x86 system syscall table
166191#
@@ -170,9 +195,7 @@ function mangle_lib_syscall() {
170195# Dump the architecture's syscall table to stdout.
171196#
172197function dump_sys_x86() {
173- cat $1 /arch/x86/entry/syscalls/syscall_32.tbl | \
174- grep -v " ^#" | awk ' { print $3","$1 }' | \
175- sort
198+ dump_from_syscall_tbl " $1 /arch/x86/entry/syscalls/syscall_32.tbl" i386
176199}
177200
178201#
@@ -193,9 +216,7 @@ function dump_lib_x86() {
193216# Dump the architecture's syscall table to stdout.
194217#
195218function dump_sys_x86_64() {
196- cat $1 /arch/x86/entry/syscalls/syscall_64.tbl | \
197- grep -v " ^#" | sed ' /^$/d' | awk ' { print $2,$3,$1 }' | \
198- sed ' /^x32/d' | awk ' { print $2","$3 }' | sort
219+ dump_from_syscall_tbl " $1 /arch/x86/entry/syscalls/syscall_64.tbl" 64
199220}
200221
201222#
@@ -216,9 +237,7 @@ function dump_lib_x86_64() {
216237# Dump the architecture's syscall table to stdout.
217238#
218239function dump_sys_x32() {
219- cat $1 /arch/x86/entry/syscalls/syscall_64.tbl | \
220- grep -v " ^#" | sed ' /^$/d' | awk ' { print $2,$3,$1 }' | \
221- sed ' /^64/d' | awk ' { print $2","$3 }' | sort
240+ dump_from_syscall_tbl " $1 /arch/x86/entry/syscalls/syscall_64.tbl" x32
222241}
223242
224243#
@@ -239,14 +258,12 @@ function dump_lib_x32() {
239258# Dump the architecture's syscall table to stdout.
240259#
241260function dump_sys_arm() {
242- cat $1 /arch/arm/tools/syscall.tbl | grep -v " ^#" | \
243- sed -n " /[0-9]\+[ \t]\+\(common\|eabi\)/p" | \
244- awk ' { print $3","$1 }' | sort | (cat -; \
245- (cat $1 /arch/arm/include/uapi/asm/unistd.h | \
246- grep " ^#define __ARM_NR_" | \
247- grep -v " ^#define __ARM_NR_BASE" | \
248- sed ' s/#define __ARM_NR_\([a-z0-9_]*\)[ \t]\+(__ARM_NR_BASE+\(.*\))/\1 983040 + \2/' | \
249- awk ' { print $1","$2+$4 }' )) | sort
261+ dump_from_syscall_tbl " $1 /arch/arm/tools/syscall.tbl" eabi | (cat -; \
262+ (cat $1 /arch/arm/include/uapi/asm/unistd.h | \
263+ grep " ^#define __ARM_NR_" | \
264+ grep -v " ^#define __ARM_NR_BASE" | \
265+ sed ' s/#define __ARM_NR_\([a-z0-9_]*\)[ \t]\+(__ARM_NR_BASE+\(.*\))/\1 983040 + \2/' | \
266+ awk ' { print $1","$2+$4 }' )) | sort
250267}
251268
252269#
@@ -314,11 +331,7 @@ function dump_lib_aarch64() {
314331# Dump the architecture's syscall table to stdout.
315332#
316333function dump_sys_mips() {
317- cat $1 /arch/mips/kernel/syscalls/syscall_o32.tbl | \
318- grep -v " ^#" | \
319- sed -e ' /[ \t]\+reserved[0-9]\+[ \t]\+/d;' | \
320- sed -e ' /[ \t]\+unused[0-9]\+[ \t]\+/d;' | \
321- awk ' { print $3","$1 }' | sort
334+ dump_from_syscall_tbl " $1 /arch/mips/kernel/syscalls/syscall_o32.tbl" o32
322335}
323336
324337#
@@ -339,11 +352,7 @@ function dump_lib_mips() {
339352# Dump the architecture's syscall table to stdout.
340353#
341354function dump_sys_mips64() {
342- cat $1 /arch/mips/kernel/syscalls/syscall_n64.tbl | \
343- grep -v " ^#" | \
344- sed -e ' /[ \t]\+reserved[0-9]\+[ \t]\+/d;' | \
345- sed -e ' /[ \t]\+unused[0-9]\+[ \t]\+/d;' | \
346- awk ' { print $3","$1 }' | sort
355+ dump_from_syscall_tbl " $1 /arch/mips/kernel/syscalls/syscall_n64.tbl" n64
347356}
348357
349358#
@@ -364,11 +373,7 @@ function dump_lib_mips64() {
364373# Dump the architecture's syscall table to stdout.
365374#
366375function dump_sys_mips64n32() {
367- cat $1 /arch/mips/kernel/syscalls/syscall_n32.tbl | \
368- grep -v " ^#" | \
369- sed -e ' /[ \t]\+reserved[0-9]\+[ \t]\+/d;' | \
370- sed -e ' /[ \t]\+unused[0-9]\+[ \t]\+/d;' | \
371- awk ' { print $3","$1 }' | sort
376+ dump_from_syscall_tbl " $1 /arch/mips/kernel/syscalls/syscall_n32.tbl" n32
372377}
373378
374379#
@@ -389,11 +394,7 @@ function dump_lib_mips64n32() {
389394# Dump the architecture's syscall table to stdout.
390395#
391396function dump_sys_parisc() {
392- cat $1 /arch/parisc/kernel/syscalls/syscall.tbl | \
393- grep -v " ^#" | \
394- sed -n " /[0-9]\+[ \t]\+\(common\|32\)/p" | \
395- awk ' { print $3","$1 }' | \
396- sort
397+ dump_from_syscall_tbl " $1 /arch/parisc/kernel/syscalls/syscall.tbl" 32
397398}
398399
399400#
@@ -414,11 +415,7 @@ function dump_lib_parisc() {
414415# Dump the architecture's syscall table to stdout.
415416#
416417function dump_sys_parisc64() {
417- cat $1 /arch/parisc/kernel/syscalls/syscall.tbl | \
418- grep -v " ^#" | \
419- sed -n " /[0-9]\+[ \t]\+\(common\|64\)/p" | \
420- awk ' { print $3","$1 }' | \
421- sort
418+ dump_from_syscall_tbl " $1 /arch/parisc/kernel/syscalls/syscall.tbl" 64
422419}
423420
424421#
@@ -439,9 +436,8 @@ function dump_lib_parisc64() {
439436# Dump the architecture's syscall table to stdout.
440437#
441438function dump_sys_ppc() {
442- cat $1 /arch/powerpc/kernel/syscalls/syscall.tbl | grep -v " ^#" | \
443- sed -ne " /[0-9]\+[ \t]\+\(common\|nospu\|32\)/p" | \
444- awk ' { print $3","$1 }' | sort
439+ dump_from_syscall_tbl " $1 /arch/powerpc/kernel/syscalls/syscall.tbl" \
440+ nospu 32
445441}
446442
447443#
@@ -462,9 +458,8 @@ function dump_lib_ppc() {
462458# Dump the architecture's syscall table to stdout.
463459#
464460function dump_sys_ppc64() {
465- cat $1 /arch/powerpc/kernel/syscalls/syscall.tbl | grep -v " ^#" | \
466- sed -ne " /[0-9]\+[ \t]\+\(common\|nospu\|64\)/p" | \
467- awk ' { print $3","$1 }' | sort
461+ dump_from_syscall_tbl " $1 /arch/powerpc/kernel/syscalls/syscall.tbl" \
462+ nospu 64
468463}
469464
470465#
@@ -528,10 +523,7 @@ function dump_lib_riscv64() {
528523# Dump the architecture's syscall table to stdout.
529524#
530525function dump_sys_s390() {
531- cat $1 /arch/s390/kernel/syscalls/syscall.tbl | grep -v " ^#" | \
532- sed -ne " /[0-9]\+[ \t]\+\(common\|32\)/p" | \
533- awk ' { print $3","$1 }' | \
534- sort
526+ dump_from_syscall_tbl " $1 /arch/s390/kernel/syscalls/syscall.tbl" 32
535527}
536528
537529#
@@ -552,10 +544,7 @@ function dump_lib_s390() {
552544# Dump the architecture's syscall table to stdout.
553545#
554546function dump_sys_s390x() {
555- cat $1 /arch/s390/kernel/syscalls/syscall.tbl | grep -v " ^#" | \
556- sed -ne " /[0-9]\+[ \t]\+\(common\|64\)/p" | \
557- awk ' { print $3","$1 }' | \
558- sort
547+ dump_from_syscall_tbl " $1 /arch/s390/kernel/syscalls/syscall.tbl" 64
559548}
560549
561550#
0 commit comments