Whamcloud - gitweb
LU-16272 libcfs: cfs_hash_for_each_empty optimization
[fs/lustre-release.git] / rpm / find-provides.ksyms
1 #! /bin/bash
2
3 IFS=$'\n'
4
5 MODULE_SYMVERS=$RPM_BUILD_ROOT/Module.symvers
6
7 for module in $(grep -E '/lib/modules/.+\.ko(\.gz|\.bz2|\.xz)?$'); do
8     tmpfile=""
9     if [ "x${module%.ko}" = "x${module}" ]; then
10         tmpfile=$(mktemp -t ${0##*/}.XXXXXX.ko)
11         proc_bin=
12         case "${module##*.}" in
13         xz)
14                 proc_bin=xz
15                 ;;
16         bz2)
17                 proc_bin=bzip2
18                 ;;
19         gz)
20                 proc_bin=gzip
21                 ;;
22         esac
23
24         [ -n "$proc_bin" ] || continue
25
26         "$proc_bin" -d -c - < "$module" > "$tmpfile" || continue
27         module="$tmpfile"
28     fi
29
30     if [[ -f $MODULE_SYMVERS ]] ; then
31         # all symbols prefixed with __rcr_ where the symbol is:
32         #  A   - symbol is an absolute value
33         #  D,d - symbol is in the initialized data section
34         #  R,r - symbol is in the read-only data section
35         #  T,t - symbol is in the text (code) section
36         for sym in $(nm $module | sed -r -ne 's:^0*([0-9a-f]+) [ADdRr] __crc_(.+):\2:p'); do
37             grep -w $sym $MODULE_SYMVERS | awk '{printf("ksym(%s) = %08s\n", $2, $1)}'
38         done \
39         | LC_ALL=C sort -u
40     else
41         >&2 echo "Module.symvers required for provides."
42     fi
43     [ -z "$tmpfile" ] || rm -f -- "$tmpfile"
44 done