00-virtio-ports.hotplug 401 B

12345678910111213141516171819
  1. #!/bin/sh
  2. # Copyright (C) 2016 OpenWrt.org
  3. # Copyright (C) 2016 Yousong Zhou <yszhou4tech@gmail.com>
  4. [ "$SUBSYSTEM" = "virtio-ports" ] || exit 0
  5. syspath="/sys/$DEVPATH"
  6. name="$(cat "$syspath/name" 2>/dev/null)"
  7. [ -n "$name" ] || exit 0
  8. case "$ACTION" in
  9. "add")
  10. mkdir -p /dev/virtio-ports
  11. ln -s "/dev/$DEVNAME" "/dev/virtio-ports/$name"
  12. ;;
  13. "del")
  14. rm -f "/dev/virtio-ports/$name"
  15. ;;
  16. esac