0

For using gadgetfs I have to mount the gadgetfs filesystem to the mount point /dev/gadget. But because /dev is controlled by udev a manually created directory gets lost on each reboot. Sure, I could create the directory in some init.d-Skript but a more clean solution would be to configure udev to automatically create this directory. I'm pretty sure this must be possible somehow because there are lots of other directories in there already.

So how can I configure udev to create a /dev/gadget directory automatically?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
kayahr
  • 20,913
  • 29
  • 99
  • 147

1 Answers1

0

Found the solution:

Create /etc/udev/rules/99-gadgetfs.rules with the following content:

ACTION=="add", DEVPATH=="/module/gadgetfs" SUBSYSTEM=="module" RUN+="/bin/mkdir /dev/gadget"
ACTION=="remove", DEVPATH=="/module/gadgetfs" SUBSYSTEM=="module" RUN+="/bin/rmdir /dev/gadget"

Restart udev or run this command:

udevadm trigger

Now when running modprobe gadgetfs udev automatically creates the /dev/gadget directory which can then be mounted. rmmod gadgetfs automatically removes the directory.

kayahr
  • 20,913
  • 29
  • 99
  • 147