Debian Codegraph @

scripts/nsdeps

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # SPDX-License-Identifier: GPL-2.0
3 # Linux kernel symbol namespace import generator
4 #
5 # This script requires a minimum spatch version.
6 SPATCH_REQ_VERSION="1.0.4"
7
8 DIR="$(dirnamescip-shell system . . dirname. $(readlinkscip-shell system . . readlink. -f $0))/.."
9 SPATCH="`whichscip-shell system . . which. ${SPATCH:=spatch}`"
10 if [scip-shell system . . `[`. ! -x "$SPATCH" ]; then
11 echoscip-shell system . . echo. 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
12 exit 1
13 fi
14
15 SPATCH_VERSION=$($SPATCH --version | headscip-shell system . . head. -1 | awkscip-shell system . . awk. '{print $3}')
16
17 if ! { echoscip-shell system . . echo. "$SPATCH_REQ_VERSION"; echoscip-shell system . . echo. "$SPATCH_VERSION"; } | sortscip-shell system . . sort. -CV ; then
18 echoscip-shell system . . echo. "spatch needs to be version $SPATCH_REQ_VERSION or higher"
19 exit 1
20 fi
21
22 generate_deps_for_nsscip-shell shell linux 7.0.12-2 generate_deps_for_ns().() {
23 $SPATCH --very-quiet --in-place --sp-file \
24 $srctree/scripts/coccinelle/misc/add_namespace.cocci -D nsdeps -D ns=\"$1\" $2
25 }
26
27 generate_depsscip-shell shell linux 7.0.12-2 generate_deps().() {
28 local mod=${1%.ko:}
29 shift
30 local namespaces="$*"
31 local mod_source_files=$(sedscip-shell system . . sed. "s|^\(.*\)\.o$|${srcroot}/\1.c|" $mod.mod)
32
33 for ns in $namespaces; do
34 echoscip-shell system . . echo. "Adding namespace $ns to module $mod.ko."
35 generate_deps_for_nsscip-shell shell linux 7.0.12-2 generate_deps_for_ns(). $ns "$mod_source_files"
36 # sort the imports
37 for source_file in $mod_source_files; do
38 sedscip-shell system . . sed. '/MODULE_IMPORT_NS/Qscip-shell filesystem . . `/MODULE_IMPORT_NS/Q`.' $source_file > ${source_file}.tmp
39 offset=$(wcscip-shell system . . wc. -l ${source_file}.tmp | awkscip-shell system . . awk. '{print $1;}')
40 catscip-shell system . . cat. $source_file | grepscip-shell system . . grep. MODULE_IMPORT_NS | LC_ALL=C sortscip-shell system . . sort. -u >> ${source_file}.tmp
41 tailscip-shell system . . tail. -n +$((offset +1)) ${source_file} | grepscip-shell system . . grep. -v MODULE_IMPORT_NS >> ${source_file}.tmp
42 if ! diffscip-shell system . . diff. -q ${source_file} ${source_file}.tmp; then
43 mvscip-shell system . . mv. ${source_file}.tmp ${source_file}
44 else
45 rmscip-shell system . . rm. ${source_file}.tmp
46 fi
47 done
48 done
49 }
50
51 while read line
52 do
53 generate_depsscip-shell shell linux 7.0.12-2 generate_deps(). $line
54 done < modules.nsdeps