From: md@Linux.IT (Marco d'Itri)
To: linux-hotplug@vger.kernel.org
Subject: an SUBSYSTEM-based approach to rules
Date: Sat, 09 Apr 2005 17:32:08 +0000 [thread overview]
Message-ID: <20050409173208.GA14897@wonderland.linux.it> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 362 bytes --]
These are the new rules files used by the debian udev package.
The interesting parts are the usage of SYSFS{type}, SYSFS{removable} and
SUBSYSTEM attributes to assign the default permissions for the devices.
This allows removing a lot of rules, e.g. now permissions for all block
devices except cdroms are assigned with just two rules.
--
ciao,
Marco
[-- Attachment #1.2: permissions.rules --]
[-- Type: text/plain, Size: 2122 bytes --]
# default permissions for block devices
SUBSYSTEM="block", GROUP="disk"
SUBSYSTEM="block", SYSFS{removable}="1", GROUP="floppy"
# IDE devices
BUS="ide", KERNEL="hd[a-z]", SYSFS{removable}="1", \
PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom*", GROUP="cdrom"
BUS="ide", KERNEL="ht[0-9]*", GROUP="tape"
BUS="ide", KERNEL="nht[0-9]*", GROUP="tape"
# SCSI devices
BUS="scsi", SYSFS{type}="1", GROUP="tape"
BUS="scsi", SYSFS{type}="5", GROUP="cdrom"
BUS="scsi", SYSFS{type}="6", GROUP="scanner"
# USB devices
BUS="usb", KERNEL="legousbtower*", MODE="0666"
# serial devices
SUBSYSTEM="tty", GROUP="dialout"
SUBSYSTEM="capi", GROUP="dialout"
# vc devices (all members of the tty subsystem)
KERNEL="ptmx", MODE="0666", GROUP="root"
KERNEL="console", MODE="0600", GROUP="root"
KERNEL="tty", MODE="0666", GROUP="root"
KERNEL="tty[0-9]*", GROUP="root"
# video devices
SUBSYSTEM="video4linux", GROUP="video"
SUBSYSTEM="dvb", GROUP="video"
SUBSYSTEM="graphics", GROUP="video"
SUBSYSTEM="nvidia", GROUP="video"
SUBSYSTEM="drm", GROUP="video"
# misc devices
KERNEL="random", MODE="0666"
KERNEL="urandom", MODE="0444"
KERNEL="mem", MODE="0640", GROUP="kmem"
KERNEL="kmem", MODE="0640", GROUP="kmem"
KERNEL="port", MODE="0640", GROUP="kmem"
KERNEL="full", MODE="0666"
KERNEL="null", MODE="0666"
KERNEL="zero", MODE="0666"
KERNEL="inotify", MODE="0666"
KERNEL="sgi_fetchop", MODE="0666"
KERNEL="sonypi", MODE="0666"
KERNEL="agpgart", GROUP="video"
KERNEL="nvram", GROUP="nvram"
KERNEL="rtc", MODE="0660", GROUP="audio"
KERNEL="cdemu[0-9]*", GROUP="cdrom"
KERNEL="pktcdvd[0-9]*", GROUP="cdrom"
KERNEL="pktcdvd", MODE="0644"
# printers and parallel devices
SUBSYSTEM="printer", GROUP="lp"
SUBSYSTEM="ppdev", GROUP="lp"
KERNEL="pt[0-9]*", GROUP="tape"
KERNEL="pht[0-9]*", GROUP="tape"
# sound devices
SUBSYSTEM="sound", GROUP="audio"
# input devices
KERNEL="event[0-9]*", PROGRAM="/etc/udev/scripts/inputdev.sh %k", \
RESULT="inputdev", MODE="0664", GROUP="video"
KERNEL="js[0-9]*", MODE="0664"
# AOE character devices
SUBSYSTEM="aoe", MODE="0220", GROUP="disk"
SUBSYSTEM="aoe", KERNEL="err", MODE="0440"
[-- Attachment #1.3: devfs.rules --]
[-- Type: text/plain, Size: 4621 bytes --]
# There are a number of modifiers that are allowed to be used in some
# of the different fields. They provide the following subsitutions:
#
# %n the "kernel number" of the device.
# For example, 'sda3' has a "kernel number" of '3'
# %e the smallest number for that name which does not matches an existing node
# %k the kernel name for the device.
# %M the kernel major number for the device
# %m the kernel minor number for the device
# %b the bus id for the device
# %c the string returned by the PROGRAM
# %s{filename} the content of a sysfs attribute.
# %% the '%' char itself.
#
# workaround for devices which do not report media changes
BUS="ide", KERNEL="hd[a-z]", SYSFS{removable}="1", \
PROGRAM="/etc/udev/scripts/ide-model.sh %k", RESULT="IOMEGA ZIP *", \
OPTIONS="all_partitions", NAME="%k"
# IDE devices
BUS="ide", KERNEL="hd[a-z]*", \
PROGRAM="/etc/udev/scripts/ide-devfs.sh %k %b %n", \
NAME="%c{1}", SYMLINK="%k %c{2}"
# SCSI devices
BUS="scsi", PROGRAM="/etc/udev/scripts/scsi-devfs.sh %k %b %n", \
NAME="%c{1}", SYMLINK="%k %c{2}"
# RAID controllers
KERNEL="cciss!*", PROGRAM="/etc/udev/scripts/raid-devfs.sh %k", \
NAME="%c{1}", SYMLINK="%k"
KERNEL="ida!*", PROGRAM="/etc/udev/scripts/raid-devfs.sh %k", \
NAME="%c{1}", SYMLINK="%k"
KERNEL="rd!*", PROGRAM="/etc/udev/scripts/raid-devfs.sh %k", \
NAME="%c{1}", SYMLINK="%k"
# other block devices
KERNEL="md[0-9]*", NAME="md/%n",
KERNEL="loop[0-9]*", NAME="loop/%n"
KERNEL="ram[0-9]*", NAME="rd/%n"
# USB devices
BUS="usb", KERNEL="auer[0-9]*", NAME="usb/%k"
BUS="usb", KERNEL="cpad[0-9]*", NAME="usb/%k"
BUS="usb", KERNEL="dabusb*", NAME="usb/%k"
BUS="usb", KERNEL="hiddev*", NAME="usb/%k"
BUS="usb", KERNEL="legousbtower*", NAME="usb/%k"
BUS="usb", KERNEL="lp[0-9]*", NAME="usb/%k"
BUS="usb", KERNEL="ttyUSB*", SYSFS{product}="Palm Handheld*", SYMLINK="pilot"
# serial devices
KERNEL="ttyS[0-9]*", NAME="tts/%n"
KERNEL="ttyUSB[0-9]*", NAME="tts/USB%n"
KERNEL="rfcomm[0-9]*", NAME="bluetooth/rfcomm/%n",
KERNEL="capi", NAME="capi20", SYMLINK="isdn/capi20"
KERNEL="capi[0-9]*", NAME="capi/%n"
# vc devices
KERNEL="tty[0-9]*", NAME="vc/%n"
KERNEL="vcs", NAME="vcc/0"
KERNEL="vcs[0-9]*", NAME="vcc/%n"
KERNEL="vcsa", NAME="vcc/a0"
KERNEL="vcsa[0-9]*", NAME="vcc/a%n"
# video devices
KERNEL="video[0-9]*", NAME="v4l/%k"
KERNEL="radio[0-9]*", NAME="v4l/%k"
KERNEL="vbi[0-9]*", NAME="v4l/%k"
KERNEL="vtx[0-9]*", NAME="v4l/%k"
KERNEL="dvb*", PROGRAM="/etc/udev/scripts/dvb.sh %k", NAME="%c"
KERNEL="fb[0-9]*", NAME="fb/%n"
KERNEL="card[0-9]*", NAME="dri/%k"
# misc devices
KERNEL="apm_bios", NAME="misc/%k",
KERNEL="agpgart", NAME="misc/%k"
KERNEL="nvram", NAME="misc/%k"
KERNEL="psaux", NAME="misc/%k"
KERNEL="rtc", NAME="misc/%k"
KERNEL="hw_random", NAME="hwrng"
# printers and parallel devices
KERNEL="lp[0-9]*", NAME="printers/%n"
KERNEL="parport[0-9]*", NAME="parports/%n"
KERNEL="i2c-[0-9]*", NAME="i2c/%n"
KERNEL="fd[0-9]*", NAME="floppy/%n"
KERNEL="cdemu[0-9]*", NAME="cdemu/%n"
KERNEL="pktcdvd[0-9]*", NAME="pktcdvd/%n"
KERNEL="pktcdvd", NAME="pktcdvd/control"
KERNEL="cpu[0-9]*", NAME="cpu/%n/cpuid"
KERNEL="msr[0-9]*", NAME="cpu/%n/msr"
KERNEL="microcode", NAME="cpu/microcode"
KERNEL="umad*", NAME="infiniband/%k"
KERNEL="issm*", NAME="infiniband/%k"
KERNEL="tap[0-9]*", NAME="net/%k"
KERNEL="tun", NAME="net/%k"
# sound devices
KERNEL="controlC[0-9]*", NAME="snd/%k"
KERNEL="hwC[D0-9]*", NAME="snd/%k"
KERNEL="pcmC[D0-9cp]*", NAME="snd/%k"
KERNEL="midiC[D0-9]*", NAME="snd/%k"
KERNEL="timer", NAME="snd/%k"
KERNEL="seq", NAME="snd/%k"
KERNEL="audio*", NAME="sound/%k"
KERNEL="dsp*", NAME="sound/%k"
KERNEL="adsp*", NAME="sound/%k"
KERNEL="midi*", NAME="sound/%k"
KERNEL="mixer*", NAME="sound/%k"
KERNEL="sequencer*", NAME="sound/%k"
KERNEL="amidi*", NAME="sound/%k"
KERNEL="dmmidi*", NAME="sound/%k"
KERNEL="admmidi*", NAME="sound/%k"
# input devices
KERNEL="mice", NAME="input/%k"
KERNEL="mouse[0-9]*", NAME="input/%k"
KERNEL="event[0-9]*", NAME="input/%k"
KERNEL="js[0-9]*", NAME="input/%k"
KERNEL="ts[0-9]*", NAME="input/%k"
KERNEL="uinput", NAME="input/%k"
# Zaptel
KERNEL="zapctl", NAME="zap/ctl"
KERNEL="zaptimer", NAME="zap/timer"
KERNEL="zapchannel", NAME="zap/channel"
KERNEL="zappseudo", NAME="zap/pseudo"
KERNEL="zap[0-9]*", NAME="zap/%n"
# AOE character devices
SUBSYSTEM="aoe", KERNEL="discover", NAME="etherd/%k"
SUBSYSTEM="aoe", KERNEL="err", NAME="etherd/%k"
SUBSYSTEM="aoe", KERNEL="interfaces", NAME="etherd/%k"
# device mapper creates its own device nodes, so ignore these
KERNEL="dm-[0-9]*", OPTIONS="ignore_device"
KERNEL="device-mapper", NAME="mapper/control"
[-- Attachment #1.4: udev.rules --]
[-- Type: text/plain, Size: 2884 bytes --]
# There are a number of modifiers that are allowed to be used in some
# of the different fields. They provide the following subsitutions:
#
# %n the "kernel number" of the device.
# For example, 'sda3' has a "kernel number" of '3'
# %e the smallest number for that name which does not matches an existing node
# %k the kernel name for the device.
# %M the kernel major number for the device
# %m the kernel minor number for the device
# %b the bus id for the device
# %c the string returned by the PROGRAM
# %s{filename} the content of a sysfs attribute.
# %% the '%' char itself.
#
# workaround for devices which do not report media changes
BUS="ide", KERNEL="hd[a-z]", SYSFS{removable}="1", \
PROGRAM="/etc/udev/scripts/ide-model.sh %k", RESULT="IOMEGA ZIP *", \
OPTIONS="all_partitions", NAME="%k"
# SCSI devices
BUS="scsi", KERNEL="sr[0-9]*", NAME="scd%n", SYMLINK="sr%n"
# USB devices
BUS="usb", KERNEL="hiddev*", NAME="usb/%k"
BUS="usb", KERNEL="auer[0-9]*", NAME="usb/%k"
BUS="usb", KERNEL="legousbtower*", NAME="usb/%k"
BUS="usb", KERNEL="dabusb*", NAME="usb/%k"
BUS="usb", KERNEL="cpad[0-9]*", NAME="usb/%k"
BUS="usb", KERNEL="lp[0-9]*", NAME="usb/%k"
BUS="usb", KERNEL="ttyUSB*", SYSFS{product}="Palm Handheld*", SYMLINK="pilot"
# serial devices
KERNEL="capi", NAME="capi20", SYMLINK="isdn/capi20"
KERNEL="capi[0-9]*", NAME="capi/%n"
# video devices
KERNEL="dvb*", PROGRAM="/etc/udev/scripts/dvb.sh %k", NAME="%c"
KERNEL="card[0-9]*", NAME="dri/%k"
# misc devices
KERNEL="hw_random", NAME="hwrng"
KERNEL="cdemu[0-9]*", NAME="cdemu/%n"
KERNEL="pktcdvd[0-9]*", NAME="pktcdvd/%n"
KERNEL="pktcdvd", NAME="pktcdvd/control"
KERNEL="cpu[0-9]*", NAME="cpu/%n/cpuid"
KERNEL="msr[0-9]*", NAME="cpu/%n/msr"
KERNEL="microcode", NAME="cpu/microcode"
KERNEL="umad*", NAME="infiniband/%k"
KERNEL="issm*", NAME="infiniband/%k"
KERNEL="tap[0-9]*", NAME="net/%k"
KERNEL="tun", NAME="net/%k"
# ALSA devices
KERNEL="controlC[0-9]*", NAME="snd/%k"
KERNEL="hwC[D0-9]*", NAME="snd/%k"
KERNEL="pcmC[D0-9cp]*", NAME="snd/%k"
KERNEL="midiC[D0-9]*", NAME="snd/%k"
KERNEL="timer", NAME="snd/%k"
KERNEL="seq", NAME="snd/%k"
# input devices
KERNEL="mice", NAME="input/%k"
KERNEL="mouse[0-9]*", NAME="input/%k"
KERNEL="event[0-9]*", NAME="input/%k"
KERNEL="js[0-9]*", NAME="input/%k"
KERNEL="ts[0-9]*", NAME="input/%k"
KERNEL="uinput", NAME="input/%k"
# Zaptel
KERNEL="zapctl", NAME="zap/ctl"
KERNEL="zaptimer", NAME="zap/timer"
KERNEL="zapchannel", NAME="zap/channel"
KERNEL="zappseudo", NAME="zap/pseudo"
KERNEL="zap[0-9]*", NAME="zap/%n"
# AOE character devices
SUBSYSTEM="aoe", KERNEL="discover", NAME="etherd/%k"
SUBSYSTEM="aoe", KERNEL="err", NAME="etherd/%k"
SUBSYSTEM="aoe", KERNEL="interfaces", NAME="etherd/%k"
# device mapper creates its own device nodes, so ignore these
KERNEL="dm-[0-9]*", OPTIONS="ignore_device"
KERNEL="device-mapper", NAME="mapper/control"
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2005-04-09 17:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-09 17:32 Marco d'Itri [this message]
2005-04-10 2:01 ` an SUBSYSTEM-based approach to rules Alexander E. Patrakov
2005-04-10 11:34 ` Kay Sievers
2005-04-10 11:36 ` Marco d'Itri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050409173208.GA14897@wonderland.linux.it \
--to=md@linux.it \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).