vhost_virtio_ioctl.sh 739 B

123456789101112131415161718
  1. #!/bin/sh
  2. [ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
  3. printf "static const char *vhost_virtio_ioctl_cmds[] = {\n"
  4. regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*'
  5. egrep $regex ${header_dir}/vhost.h | \
  6. sed -r "s/$regex/\2 \1/g" | \
  7. sort | xargs printf "\t[%s] = \"%s\",\n"
  8. printf "};\n"
  9. printf "static const char *vhost_virtio_ioctl_read_cmds[] = {\n"
  10. regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?R\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*'
  11. egrep $regex ${header_dir}/vhost.h | \
  12. sed -r "s/$regex/\2 \1/g" | \
  13. sort | xargs printf "\t[%s] = \"%s\",\n"
  14. printf "};\n"