check_sys.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. # Script to test fpc to system syscall numbers
  3. # Location of syscall header in system
  4. syscall_header=/usr/include/sys/syscall.h
  5. verbose=0
  6. # Sustitution made to pass from fpc syscall number
  7. # to system define
  8. fpc_syscall_prefix=syscall_nr_
  9. syscall_prefix=SYS_
  10. # You should only need to change the variables above
  11. sed -n "s:^[ \t]*${fpc_syscall_prefix}\\([_a-zA-Z0-9]*\\)[ \t]*=[ \t]*\\([0-9]*\\).*:check_syscall_number ${syscall_prefix}\1 \2:p" sysnr.inc > check_sys_list.sh
  12. function check_syscall_number ()
  13. {
  14. sys=$1
  15. value=$2
  16. if [ $verbose -ne 0 ] ; then
  17. echo Testing $sys value $value
  18. fi
  19. found=`sed -n "/#define.*${sys}[^A-Za-z0-9_]/p" ${syscall_header}`
  20. val=`sed -n "s:#define.*${sys}[^A-Za-z0-9_][^A-Za-z0-9_]*\([0-9]*\).*:\1:p" ${syscall_header}`
  21. if [ $verbose -ne 0 ] ; then
  22. echo Test for $sys found \"${found}\" \"${value}\" \"${val}\"
  23. fi
  24. if [ "${val}" == "${value}" ] ; then
  25. if [ $verbose -ne 0 ] ; then
  26. echo ${sys} value ${val} is correct
  27. fi
  28. else
  29. if [ "${val}" == "" ] ; then
  30. found=`sed -n "/#define.*[^A-Za-z0-9_]${value}$/p" ${syscall_header}`
  31. if [ "${found}" == "" ] ; then
  32. found=`sed -n "s:\/\* ${value} is compa: ${value} is compa:p" ${syscall_header}`
  33. fi
  34. fi
  35. echo problem for ${sys} expected ${value}, line is \"${found}\", val found is \"${val}\"
  36. fi
  37. }
  38. source ./check_sys_list.sh