fs_at_flags.sh 1.1 KB

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. # SPDX-License-Identifier: LGPL-2.1
  3. if [ $# -ne 1 ] ; then
  4. beauty_uapi_linux_dir=tools/perf/trace/beauty/include/uapi/linux/
  5. else
  6. beauty_uapi_linux_dir=$1
  7. fi
  8. linux_fcntl=${beauty_uapi_linux_dir}/fcntl.h
  9. printf "static const char *fs_at_flags[] = {\n"
  10. regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+AT_([^_]+[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
  11. # AT_EACCESS is only meaningful to faccessat, so we will special case it there...
  12. # AT_STATX_SYNC_TYPE is not a bit, its a mask of AT_STATX_SYNC_AS_STAT, AT_STATX_FORCE_SYNC and AT_STATX_DONT_SYNC
  13. # AT_HANDLE_FID, AT_HANDLE_MNT_ID_UNIQUE and AT_HANDLE_CONNECTABLE are reusing values and are valid only for name_to_handle_at()
  14. # AT_RENAME_NOREPLACE reuses 0x1 and is valid only for renameat2()
  15. grep -E $regex ${linux_fcntl} | \
  16. grep -v AT_EACCESS | \
  17. grep -v AT_STATX_SYNC_TYPE | \
  18. grep -v AT_HANDLE_FID | \
  19. grep -v AT_HANDLE_MNT_ID_UNIQUE | \
  20. grep -v AT_HANDLE_CONNECTABLE | \
  21. grep -v AT_RENAME_NOREPLACE | \
  22. sed -r "s/$regex/\2 \1/g" | \
  23. xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n"
  24. printf "};\n"