]> git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/utils/check-os.sh
import ceph 16.2.7
[ceph.git] / ceph / src / pmdk / utils / check-os.sh
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2017-2019, Intel Corporation
4
5 #
6 # Used to check if there are no banned functions in .o file
7 #
8 # usage: ./check-os.sh [os.h path] [.o file] [.c file]
9
10 EXCLUDE="os_posix|os_thread_posix"
11 if [[ $2 =~ $EXCLUDE ]]; then
12 echo "skip $2"
13 exit 0
14 fi
15
16 symbols=$(nm --demangle --undefined-only --format=posix $2 | sed 's/ U *//g')
17 functions=$(cat $1 | tr '\n' '|')
18 functions=${functions%?} # remove trailing | character
19 out=$(
20 for sym in $symbols
21 do
22 grep -wE $functions <<<"$sym"
23 done | sed 's/$/\(\)/g')
24
25 [[ ! -z $out ]] &&
26 echo -e "`pwd`/$3:1: non wrapped function(s):\n$out\nplease use os wrappers" &&
27 rm -f $2 && # remove .o file as it don't match requirements
28 exit 1
29
30 exit 0