├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── TODO ├── autogen.sh ├── configure.ac ├── m4 └── .gitignore ├── rules ├── 42-usb-hid-pm.rules ├── 50-udev-default.rules ├── 60-persistent-alsa.rules ├── 60-persistent-input.rules ├── 60-persistent-serial.rules ├── 60-persistent-storage-tape.rules ├── 60-persistent-storage.rules ├── 75-net-description.rules ├── 75-tty-description.rules ├── 78-sound-card.rules ├── 80-drivers.rules └── 95-udev-late.rules ├── src ├── .gitignore ├── COPYING ├── accelerometer │ ├── 61-accelerometer.rules │ └── accelerometer.c ├── ata_id │ └── ata_id.c ├── cdrom_id │ ├── 60-cdrom_id.rules │ └── cdrom_id.c ├── collect │ └── collect.c ├── docs │ ├── .gitignore │ ├── Makefile.am │ ├── libudev-docs.xml │ ├── libudev-sections.txt │ ├── libudev.types │ └── version.xml.in ├── floppy │ ├── 60-floppy.rules │ └── create_floppy_devices.c ├── gudev │ ├── .gitignore │ ├── COPYING │ ├── docs │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── gudev-docs.xml │ │ ├── gudev-sections.txt │ │ ├── gudev.types │ │ └── version.xml.in │ ├── gjs-example.js │ ├── gudev-1.0.pc.in │ ├── gudev.h │ ├── gudevclient.c │ ├── gudevclient.h │ ├── gudevdevice.c │ ├── gudevdevice.h │ ├── gudevenumerator.c │ ├── gudevenumerator.h │ ├── gudevenums.h │ ├── gudevenumtypes.c.template │ ├── gudevenumtypes.h.template │ ├── gudevmarshal.list │ ├── gudevprivate.h │ ├── gudevtypes.h │ ├── seed-example-enum.js │ └── seed-example.js ├── keymap │ ├── .gitignore │ ├── 95-keyboard-force-release.rules │ ├── 95-keymap.rules │ ├── README.keymap.txt │ ├── check-keymaps.sh │ ├── findkeyboards │ ├── force-release-maps │ │ ├── common-volume-keys │ │ ├── dell-touchpad │ │ ├── dell-xps │ │ ├── hp-other │ │ ├── samsung-90x3a │ │ └── samsung-other │ ├── keyboard-force-release.sh.in │ ├── keymap.c │ └── keymaps │ │ ├── acer │ │ ├── acer-aspire_5720 │ │ ├── acer-aspire_5920g │ │ ├── acer-aspire_6920 │ │ ├── acer-aspire_8930 │ │ ├── acer-travelmate_c300 │ │ ├── asus │ │ ├── compaq-e_evo │ │ ├── dell │ │ ├── dell-latitude-xt2 │ │ ├── everex-xt5000 │ │ ├── fujitsu-amilo_li_2732 │ │ ├── fujitsu-amilo_pa_2548 │ │ ├── fujitsu-amilo_pro_edition_v3505 │ │ ├── fujitsu-amilo_pro_v3205 │ │ ├── fujitsu-amilo_si_1520 │ │ ├── fujitsu-esprimo_mobile_v5 │ │ ├── fujitsu-esprimo_mobile_v6 │ │ ├── genius-slimstar-320 │ │ ├── hewlett-packard │ │ ├── hewlett-packard-2510p_2530p │ │ ├── hewlett-packard-compaq_elitebook │ │ ├── hewlett-packard-pavilion │ │ ├── hewlett-packard-presario-2100 │ │ ├── hewlett-packard-tablet │ │ ├── hewlett-packard-tx2 │ │ ├── ibm-thinkpad-usb-keyboard-trackpoint │ │ ├── inventec-symphony_6.0_7.0 │ │ ├── lenovo-3000 │ │ ├── lenovo-ideapad │ │ ├── lenovo-thinkpad-usb-keyboard-trackpoint │ │ ├── lenovo-thinkpad_x200_tablet │ │ ├── lenovo-thinkpad_x6_tablet │ │ ├── lg-x110 │ │ ├── logitech-wave │ │ ├── logitech-wave-cordless │ │ ├── logitech-wave-pro-cordless │ │ ├── maxdata-pro_7000 │ │ ├── medion-fid2060 │ │ ├── medionnb-a555 │ │ ├── micro-star │ │ ├── module-asus-w3j │ │ ├── module-ibm │ │ ├── module-lenovo │ │ ├── module-sony │ │ ├── module-sony-old │ │ ├── module-sony-vgn │ │ ├── olpc-xo │ │ ├── onkyo │ │ ├── oqo-model2 │ │ ├── samsung-90x3a │ │ ├── samsung-other │ │ ├── samsung-sq1us │ │ ├── samsung-sx20s │ │ ├── toshiba-satellite_a100 │ │ ├── toshiba-satellite_a110 │ │ ├── toshiba-satellite_m30x │ │ └── zepto-znote ├── libudev-device-private.c ├── libudev-device.c ├── libudev-enumerate.c ├── libudev-list.c ├── libudev-monitor.c ├── libudev-private.h ├── libudev-queue-private.c ├── libudev-queue.c ├── libudev-selinux-private.c ├── libudev-util-private.c ├── libudev-util.c ├── libudev.c ├── libudev.h ├── libudev.pc.in ├── mtd_probe │ ├── 75-probe_mtd.rules │ ├── mtd_probe.c │ ├── mtd_probe.h │ └── probe_smartmedia.c ├── rule_generator │ ├── 75-cd-aliases-generator.rules │ ├── 75-persistent-net-generator.rules │ ├── rule_generator.functions │ ├── write_cd_rules │ └── write_net_rules ├── scsi_id │ ├── .gitignore │ ├── README │ ├── scsi.h │ ├── scsi_id.c │ ├── scsi_id.h │ └── scsi_serial.c ├── sd-daemon.c ├── sd-daemon.h ├── test-libudev.c ├── test-udev.c ├── udev-builtin-blkid.c ├── udev-builtin-firmware.c ├── udev-builtin-hwdb.c ├── udev-builtin-input_id.c ├── udev-builtin-kmod.c ├── udev-builtin-path_id.c ├── udev-builtin-usb_id.c ├── udev-builtin.c ├── udev-control.socket ├── udev-ctrl.c ├── udev-event.c ├── udev-kernel.socket ├── udev-node.c ├── udev-rules.c ├── udev-settle.service.in ├── udev-trigger.service.in ├── udev-watch.c ├── udev.conf ├── udev.h ├── udev.pc.in ├── udev.service.in ├── udev.xml ├── udevadm-control.c ├── udevadm-info.c ├── udevadm-monitor.c ├── udevadm-settle.c ├── udevadm-test-builtin.c ├── udevadm-test.c ├── udevadm-trigger.c ├── udevadm.c ├── udevadm.xml ├── udevd.c ├── udevd.xml └── v4l_id │ ├── 60-persistent-v4l.rules │ └── v4l_id.c └── test ├── rule-syntax-check.py ├── rules-test.sh ├── sys.tar.xz └── udev-test.pl /INSTALL: -------------------------------------------------------------------------------- 1 | The options used usually look like: 2 | %configure \ 3 | --prefix=/usr \ 4 | --sysconfdir=/etc \ 5 | --bindir=/usr/bin \ 6 | --libdir=/usr/lib64 \ 7 | --libexecdir=/usr/lib \ 8 | --with-systemdsystemunitdir=/usr/lib/systemd/system \ 9 | --with-selinux 10 | 11 | The options used in a RPM spec file look like: 12 | %configure \ 13 | --prefix=%{_prefix} \ 14 | --sysconfdir=%{_sysconfdir} \ 15 | --bindir=%{_bindir} \ 16 | --libdir=%{_libdir} \ 17 | --libexecdir=%{_prefix}/lib \ 18 | --with-systemdsystemunitdir=%{_prefix}/lib/systemd/system \ 19 | --with-selinux 20 | 21 | The options to install udev in the rootfs instead of /usr, 22 | and udevadm in /sbin: 23 | --prefix=%{_prefix} \ 24 | --with-rootprefix= \ 25 | --sysconfdir=%{_sysconfdir} \ 26 | --bindir=/sbin \ 27 | --libdir=%{_libdir} \ 28 | --with-rootlibdir=/lib64 \ 29 | --libexecdir=/lib \ 30 | --with-systemdsystemunitdir=/lib/systemd/system \ 31 | --with-selinux 32 | 33 | Some tools expect udevadm in 'sbin'. A symlink to udevadm in 'bin' 34 | needs to be manually created if needed. 35 | 36 | The defined location for scripts and binaries which are called 37 | from rules is (/usr)/lib/udev/ on all systems and architectures. Any 38 | other location will break other packages, who rightfully expect 39 | the (/usr)/lib/udev/ directory, to install their rule helper and udev 40 | rule files. 41 | 42 | Default udev rules and persistent device naming rules may be required 43 | by other software that depends on the data udev collects from the 44 | devices. 45 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | NO FUCKING SYSTEMD!!! 3 | 4 | 5 | udev - Linux userspace device management 6 | 7 | Integrating udev in the system has complex dependencies and may differ from 8 | distribution to distribution. A system may not be able to boot up or work 9 | reliably without a properly installed udev version. The upstream udev project 10 | does not recommend replacing a distro's udev installation with the upstream 11 | version. 12 | 13 | The upstream udev project's set of default rules may require a most recent 14 | kernel release to work properly. 15 | 16 | Tools and rules shipped by udev are not public API and may change at any time. 17 | Never call any private tool in /usr/lib/udev from any external application; it 18 | might just go away in the next release. Access to udev information is only offered 19 | by udevadm and libudev. Tools and rules in /usr/lib/udev and the entire contents 20 | of the /run/udev directory are private to udev and do change whenever needed. 21 | 22 | Requirements: 23 | - Version 2.6.34 of the Linux kernel with sysfs, procfs, signalfd, inotify, 24 | unix domain sockets, networking and hotplug enabled 25 | 26 | - Some architectures might need a later kernel, that supports accept4(), 27 | or need to backport the accept4() syscall wiring in the kernel. 28 | 29 | - These options are required: 30 | CONFIG_DEVTMPFS=y 31 | CONFIG_HOTPLUG=y 32 | CONFIG_INOTIFY_USER=y 33 | CONFIG_NET=y 34 | CONFIG_PROC_FS=y 35 | CONFIG_SIGNALFD=y 36 | CONFIG_SYSFS=y 37 | CONFIG_SYSFS_DEPRECATED*=n 38 | CONFIG_UEVENT_HELPER_PATH="" 39 | 40 | - These options might be needed: 41 | CONFIG_BLK_DEV_BSG=y (SCSI devices) 42 | CONFIG_TMPFS_POSIX_ACL=y (user ACLs for device nodes) 43 | 44 | - The /dev directory needs the 'devtmpfs' filesystem mounted. 45 | Udev only manages the permissions and ownership of the 46 | kernel-provided device nodes, and possibly creates additional symlinks. 47 | 48 | - Udev requires /run to be writable, which is usually done by mounting a 49 | 'tmpfs' filesystem. 50 | 51 | - This version of udev does not work properly with the CONFIG_SYSFS_DEPRECATED* 52 | option enabled. 53 | 54 | - The deprecated hotplug helper /sbin/hotplug should be disabled in the 55 | kernel configuration, it is not needed today, and may render the system 56 | unusable because the kernel may create too many processes in parallel 57 | so that the system runs out-of-memory. 58 | 59 | - The proc filesystem must be mounted on /proc, and the sysfs filesystem must 60 | be mounted at /sys. No other locations are supported by a standard 61 | udev installation. 62 | 63 | - The default rule sset requires the following group names resolvable at udev startup: 64 | disk, cdrom, floppy, tape, audio, video, lp, tty, dialout, and kmem. 65 | Especially in LDAP setups, it is required that getgrnam() be able to resolve 66 | these group names with only the rootfs mounted and while no network is 67 | available. 68 | 69 | - Some udev extras have external dependencies like: 70 | libglib2, usbutils, pciutils, and gperf. 71 | All these extras can be disabled with configure options. 72 | 73 | Setup: 74 | - The udev daemon should be started to handle device events sent by the kernel. 75 | During bootup, the events for already existing devices can be replayed, so 76 | that they are configured by udev. The systemd service files contain the 77 | needed commands to start the udev daemon and the coldplug sequence. 78 | 79 | - Restarting the daemon never applies any rules to existing devices. 80 | 81 | - New/changed rule files are picked up automatically; there is usually no 82 | daemon restart or signal needed. 83 | 84 | Operation: 85 | - Based on events the kernel sends out on device creation/removal, udev 86 | creates/removes device nodes and symlinks in the /dev directory. 87 | 88 | - All kernel events are matched against a set of specified rules, which 89 | possibly hook into the event processing and load required kernel 90 | modules to set up devices. For all devices, the kernel exports a major/minor 91 | number; if needed, udev creates a device node with the default kernel 92 | device name. If specified, udev applies permissions/ownership to the device 93 | node, creates additional symlinks pointing to the node, and executes 94 | programs to handle the device. 95 | 96 | - The events udev handles, and the information udev merges into its device 97 | database, can be accessed with libudev: 98 | http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/ 99 | http://www.kernel.org/pub/linux/utils/kernel/hotplug/gudev/ 100 | 101 | For more details about udev and udev rules, see the udev man pages: 102 | http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev/ 103 | 104 | Please direct any comment/question to the linux-hotplug mailing list at: 105 | linux-hotplug@vger.kernel.org 106 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - find a way to tell udev to not cancel firmware 2 | requests in initramfs 3 | 4 | - scsi_id -> sg3_utils? 5 | 6 | - make gtk-doc optional like kmod 7 | 8 | - move /usr/lib/udev/devices/ to tmpfiles 9 | 10 | - trigger --subsystem-match=usb/usb_device 11 | 12 | - kill rules_generator 13 | 14 | - have a $attrs{} ? 15 | 16 | - remove RUN+="socket:" 17 | 18 | - libudev.so.1 19 | - symbol versioning 20 | - return object with *_unref() 21 | - udev_monitor_from_socket() 22 | - udev_queue_get_failed_list_entry() 23 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then 4 | cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \ 5 | chmod +x .git/hooks/pre-commit && \ 6 | echo "Activated pre-commit hook." 7 | fi 8 | 9 | gtkdocize 10 | autoreconf --install --symlink 11 | 12 | libdir() { 13 | echo $(cd $1/$(gcc -print-multi-os-directory); pwd) 14 | } 15 | 16 | args="$args \ 17 | --prefix=/usr \ 18 | --sysconfdir=/etc \ 19 | --libdir=$(libdir /usr/lib) \ 20 | --with-selinux \ 21 | --enable-gtk-doc" 22 | 23 | if [ -L /bin ]; then 24 | args="$args \ 25 | --libexecdir=/usr/lib \ 26 | --with-systemdsystemunitdir=/usr/lib/systemd/system \ 27 | " 28 | else 29 | args="$args \ 30 | --with-rootprefix= \ 31 | ---with-rootlibdir=$(libdir /lib) \ 32 | --bindir=/sbin \ 33 | --libexecdir=/lib \ 34 | --with-systemdsystemunitdir=/lib/systemd/system \ 35 | " 36 | fi 37 | 38 | echo 39 | echo "----------------------------------------------------------------" 40 | echo "Initialized build system. For a common configuration please run:" 41 | echo "----------------------------------------------------------------" 42 | echo 43 | echo "./configure CFLAGS='-g -O1' $args" 44 | echo 45 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | libtool.m4 2 | lt*m4 3 | gtk-doc.m4 4 | 5 | -------------------------------------------------------------------------------- /rules/42-usb-hid-pm.rules: -------------------------------------------------------------------------------- 1 | # 2 | # Enable autosuspend for qemu emulated usb hid devices. 3 | # 4 | # Note that there are buggy qemu versions which advertise remote 5 | # wakeup support but don't actually implement it correctly. This 6 | # is the reason why we need a match for the serial number here. 7 | # The serial number "42" is used to tag the implementations where 8 | # remote wakeup is working. 9 | # 10 | 11 | ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="QEMU USB Mouse", ATTR{serial}=="42", TEST=="power/control", ATTR{power/control}="auto" 12 | ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="QEMU USB Tablet", ATTR{serial}=="42", TEST=="power/control", ATTR{power/control}="auto" 13 | ACTION=="add", SUBSYSTEM=="usb", ATTR{product}=="QEMU USB Keyboard", ATTR{serial}=="42", TEST=="power/control", ATTR{power/control}="auto" 14 | 15 | # 16 | # Enable autosuspend for KVM and iLO usb hid devices. These are 17 | # effectively self-powered (despite what some claim in their USB 18 | # profiles) and so it's safe to do so. 19 | # 20 | 21 | # AMI 046b:ff10 22 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="046b", ATTR{idProduct}=="ff10", TEST=="power/control", ATTR{power/control}="auto" 23 | 24 | # 25 | # Catch-all for Avocent HID devices. Keyed off interface in order to only 26 | # trigger on HID class devices. 27 | # 28 | ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0624", ATTR{bInterfaceClass}=="03", TEST=="../power/control", ATTR{../power/control}="auto" 29 | 30 | # Dell DRAC 4 31 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="413c", ATTR{idProduct}=="2500", TEST=="power/control", ATTR{power/control}="auto" 32 | 33 | # Dell DRAC 5 34 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="413c", ATTR{idProduct}=="0000", TEST=="power/control", ATTR{power/control}="auto" 35 | 36 | # Hewlett Packard iLO 37 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="03f0", ATTR{idProduct}=="7029", TEST=="power/control", ATTR{power/control}="auto" 38 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="03f0", ATTR{idProduct}=="1027", TEST=="power/control", ATTR{power/control}="auto" 39 | 40 | # IBM remote access 41 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="04b3", ATTR{idProduct}=="4001", TEST=="power/control", ATTR{power/control}="auto" 42 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="04b3", ATTR{idProduct}=="4002", TEST=="power/control", ATTR{power/control}="auto" 43 | ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="04b3", ATTR{idProduct}=="4012", TEST=="power/control", ATTR{power/control}="auto" 44 | 45 | # Raritan Computer, Inc KVM. 46 | ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="14dd", ATTR{idProduct}="0002", TEST=="power/control", ATTR{power/control}="auto" 47 | 48 | # USB HID devices that are internal to the machine should also be safe to autosuspend 49 | ACTION=="add", SUBSYSTEM=="usb", ATTR{bInterfaceClass}=="03", ATTRS{removable}=="fixed", TEST=="../power/control", ATTR{../power/control}="auto" 50 | -------------------------------------------------------------------------------- /rules/50-udev-default.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | KERNEL=="pty[pqrstuvwxyzabcdef][0123456789abcdef]", GROUP="tty", MODE="0660" 4 | KERNEL=="tty[pqrstuvwxyzabcdef][0123456789abcdef]", GROUP="tty", MODE="0660" 5 | KERNEL=="ptmx", GROUP="tty", MODE="0666" 6 | KERNEL=="tty", GROUP="tty", MODE="0666" 7 | KERNEL=="tty[0-9]*", GROUP="tty", MODE="0620" 8 | KERNEL=="vcs|vcs[0-9]*|vcsa|vcsa[0-9]*", GROUP="tty" 9 | 10 | # serial 11 | KERNEL=="tty[A-Z]*[0-9]|pppox[0-9]*|ircomm[0-9]*|noz[0-9]*|rfcomm[0-9]*", GROUP="dialout" 12 | KERNEL=="mwave", GROUP="dialout" 13 | KERNEL=="hvc*|hvsi*", GROUP="dialout" 14 | 15 | # virtio serial / console ports 16 | KERNEL=="vport*", ATTR{name}=="?*", SYMLINK+="virtio-ports/$attr{name}" 17 | 18 | # mem 19 | KERNEL=="null|zero|full|random|urandom", MODE="0666" 20 | KERNEL=="mem|kmem|port|nvram", GROUP="kmem", MODE="0640" 21 | 22 | # input 23 | SUBSYSTEM=="input", ENV{ID_INPUT}=="", IMPORT{builtin}="input_id" 24 | KERNEL=="mouse*|mice|event*", MODE="0640" 25 | KERNEL=="ts[0-9]*|uinput", MODE="0640" 26 | KERNEL=="js[0-9]*", MODE="0644" 27 | 28 | # video4linux 29 | SUBSYSTEM=="video4linux", GROUP="video" 30 | KERNEL=="vttuner*", GROUP="video" 31 | KERNEL=="vtx*|vbi*", GROUP="video" 32 | KERNEL=="winradio*", GROUP="video" 33 | 34 | # graphics 35 | KERNEL=="agpgart", GROUP="video" 36 | KERNEL=="pmu", GROUP="video" 37 | KERNEL=="nvidia*|nvidiactl*", GROUP="video" 38 | SUBSYSTEM=="graphics", GROUP="video" 39 | SUBSYSTEM=="drm", GROUP="video" 40 | 41 | # sound 42 | SUBSYSTEM=="sound", GROUP="audio", \ 43 | OPTIONS+="static_node=snd/seq", OPTIONS+="static_node=snd/timer" 44 | 45 | # DVB (video) 46 | SUBSYSTEM=="dvb", GROUP="video" 47 | 48 | # FireWire (firewire-core driver: IIDC devices, AV/C devices) 49 | SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x00010*", GROUP="video" 50 | SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", GROUP="video" 51 | SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", GROUP="video" 52 | SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", GROUP="video" 53 | 54 | # 'libusb' device nodes 55 | SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664" 56 | SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id" 57 | 58 | # printer 59 | KERNEL=="parport[0-9]*", GROUP="lp" 60 | SUBSYSTEM=="printer", KERNEL=="lp*", GROUP="lp" 61 | SUBSYSTEM=="ppdev", GROUP="lp" 62 | KERNEL=="lp[0-9]*", GROUP="lp" 63 | KERNEL=="irlpt[0-9]*", GROUP="lp" 64 | SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*", GROUP="lp" 65 | 66 | # block 67 | SUBSYSTEM=="block", GROUP="disk" 68 | 69 | # floppy 70 | SUBSYSTEM=="block", KERNEL=="fd[0-9]", GROUP="floppy" 71 | 72 | # cdrom 73 | SUBSYSTEM=="block", KERNEL=="sr[0-9]*", GROUP="cdrom" 74 | SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="4|5", GROUP="cdrom" 75 | KERNEL=="pktcdvd[0-9]*", GROUP="cdrom" 76 | KERNEL=="pktcdvd", GROUP="cdrom" 77 | 78 | # tape 79 | KERNEL=="ht[0-9]*|nht[0-9]*", GROUP="tape" 80 | KERNEL=="pt[0-9]*|npt[0-9]*|pht[0-9]*", GROUP="tape" 81 | SUBSYSTEM=="scsi_generic|scsi_tape", SUBSYSTEMS=="scsi", ATTRS{type}=="1|8", GROUP="tape" 82 | 83 | # block-related 84 | KERNEL=="sch[0-9]*", GROUP="disk" 85 | SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="0", GROUP="disk" 86 | KERNEL=="pg[0-9]*", GROUP="disk" 87 | KERNEL=="qft[0-9]*|nqft[0-9]*|zqft[0-9]*|nzqft[0-9]*|rawqft[0-9]*|nrawqft[0-9]*", GROUP="disk" 88 | KERNEL=="rawctl", GROUP="disk" 89 | SUBSYSTEM=="raw", KERNEL=="raw[0-9]*", GROUP="disk" 90 | SUBSYSTEM=="aoe", GROUP="disk", MODE="0220" 91 | SUBSYSTEM=="aoe", KERNEL=="err", MODE="0440" 92 | 93 | # network 94 | KERNEL=="tun", MODE="0666", OPTIONS+="static_node=net/tun" 95 | KERNEL=="rfkill", MODE="0644" 96 | 97 | # CPU 98 | KERNEL=="cpu[0-9]*", MODE="0444" 99 | 100 | KERNEL=="fuse", ACTION=="add", MODE="0666", OPTIONS+="static_node=fuse" 101 | 102 | SUBSYSTEM=="rtc", ATTR{hctosys}=="1", SYMLINK+="rtc" 103 | KERNEL=="mmtimer", MODE="0644" 104 | KERNEL=="rflash[0-9]*", MODE="0400" 105 | KERNEL=="rrom[0-9]*", MODE="0400" 106 | 107 | SUBSYSTEM=="firmware", ACTION=="add", IMPORT{builtin}="firmware" 108 | -------------------------------------------------------------------------------- /rules/60-persistent-alsa.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="persistent_alsa_end" 4 | SUBSYSTEM!="sound", GOTO="persistent_alsa_end" 5 | KERNEL!="controlC[0-9]*", GOTO="persistent_alsa_end" 6 | 7 | SUBSYSTEMS=="usb", ENV{ID_MODEL}=="", IMPORT{builtin}="usb_id" 8 | ENV{ID_SERIAL}=="?*", ENV{ID_USB_INTERFACE_NUM}=="?*", SYMLINK+="snd/by-id/$env{ID_BUS}-$env{ID_SERIAL}-$env{ID_USB_INTERFACE_NUM}" 9 | ENV{ID_SERIAL}=="?*", ENV{ID_USB_INTERFACE_NUM}=="", SYMLINK+="snd/by-id/$env{ID_BUS}-$env{ID_SERIAL}" 10 | 11 | IMPORT{builtin}="path_id" 12 | ENV{ID_PATH}=="?*", SYMLINK+="snd/by-path/$env{ID_PATH}" 13 | 14 | LABEL="persistent_alsa_end" 15 | -------------------------------------------------------------------------------- /rules/60-persistent-input.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="persistent_input_end" 4 | SUBSYSTEM!="input", GOTO="persistent_input_end" 5 | SUBSYSTEMS=="bluetooth", GOTO="persistent_input_end" 6 | 7 | SUBSYSTEMS=="usb", ENV{ID_BUS}=="", IMPORT{builtin}="usb_id" 8 | 9 | # determine class name for persistent symlinks 10 | ENV{ID_INPUT_KEYBOARD}=="?*", ENV{.INPUT_CLASS}="kbd" 11 | ENV{ID_INPUT_MOUSE}=="?*", ENV{.INPUT_CLASS}="mouse" 12 | ENV{ID_INPUT_TOUCHPAD}=="?*", ENV{.INPUT_CLASS}="mouse" 13 | ENV{ID_INPUT_TABLET}=="?*", ENV{.INPUT_CLASS}="mouse" 14 | ENV{ID_INPUT_JOYSTICK}=="?*", ENV{.INPUT_CLASS}="joystick" 15 | DRIVERS=="pcspkr", ENV{.INPUT_CLASS}="spkr" 16 | ATTRS{name}=="*dvb*|*DVB*|* IR *", ENV{.INPUT_CLASS}="ir" 17 | 18 | # fill empty serial number 19 | ENV{.INPUT_CLASS}=="?*", ENV{ID_SERIAL}=="", ENV{ID_SERIAL}="noserial" 20 | 21 | # by-id links 22 | KERNEL=="mouse*|js*", ENV{ID_BUS}=="?*", ENV{.INPUT_CLASS}=="?*", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-$env{.INPUT_CLASS}" 23 | KERNEL=="mouse*|js*", ENV{ID_BUS}=="?*", ENV{.INPUT_CLASS}=="?*", ATTRS{bInterfaceNumber}=="?*", ATTRS{bInterfaceNumber}!="00", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$attr{bInterfaceNumber}-$env{.INPUT_CLASS}" 24 | KERNEL=="event*", ENV{ID_BUS}=="?*", ENV{.INPUT_CLASS}=="?*", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-event-$env{.INPUT_CLASS}" 25 | KERNEL=="event*", ENV{ID_BUS}=="?*", ENV{.INPUT_CLASS}=="?*", ATTRS{bInterfaceNumber}=="?*", ATTRS{bInterfaceNumber}!="00", SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$attr{bInterfaceNumber}-event-$env{.INPUT_CLASS}" 26 | # allow empty class for USB devices, by appending the interface number 27 | SUBSYSTEMS=="usb", ENV{ID_BUS}=="?*", KERNEL=="event*", ENV{.INPUT_CLASS}=="", ATTRS{bInterfaceNumber}=="?*", \ 28 | SYMLINK+="input/by-id/$env{ID_BUS}-$env{ID_SERIAL}-event-if$attr{bInterfaceNumber}" 29 | 30 | # by-path 31 | SUBSYSTEMS=="pci|usb|platform|acpi", IMPORT{builtin}="path_id" 32 | ENV{ID_PATH}=="?*", KERNEL=="mouse*|js*", ENV{.INPUT_CLASS}=="?*", SYMLINK+="input/by-path/$env{ID_PATH}-$env{.INPUT_CLASS}" 33 | ENV{ID_PATH}=="?*", KERNEL=="event*", ENV{.INPUT_CLASS}=="?*", SYMLINK+="input/by-path/$env{ID_PATH}-event-$env{.INPUT_CLASS}" 34 | # allow empty class for platform and usb devices; platform supports only a single interface that way 35 | SUBSYSTEMS=="usb|platform", ENV{ID_PATH}=="?*", KERNEL=="event*", ENV{.INPUT_CLASS}=="", \ 36 | SYMLINK+="input/by-path/$env{ID_PATH}-event" 37 | 38 | LABEL="persistent_input_end" 39 | -------------------------------------------------------------------------------- /rules/60-persistent-serial.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="persistent_serial_end" 4 | SUBSYSTEM!="tty", GOTO="persistent_serial_end" 5 | KERNEL!="ttyUSB[0-9]*|ttyACM[0-9]*", GOTO="persistent_serial_end" 6 | 7 | SUBSYSTEMS=="usb-serial", ENV{.ID_PORT}="$attr{port_number}" 8 | 9 | IMPORT{builtin}="path_id" 10 | ENV{ID_PATH}=="?*", ENV{.ID_PORT}=="", SYMLINK+="serial/by-path/$env{ID_PATH}" 11 | ENV{ID_PATH}=="?*", ENV{.ID_PORT}=="?*", SYMLINK+="serial/by-path/$env{ID_PATH}-port$env{.ID_PORT}" 12 | 13 | IMPORT{builtin}="usb_id" 14 | ENV{ID_SERIAL}=="", GOTO="persistent_serial_end" 15 | SUBSYSTEMS=="usb", ENV{ID_USB_INTERFACE_NUM}="$attr{bInterfaceNumber}" 16 | ENV{ID_USB_INTERFACE_NUM}=="", GOTO="persistent_serial_end" 17 | ENV{.ID_PORT}=="", SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_USB_INTERFACE_NUM}" 18 | ENV{.ID_PORT}=="?*", SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_USB_INTERFACE_NUM}-port$env{.ID_PORT}" 19 | 20 | LABEL="persistent_serial_end" 21 | -------------------------------------------------------------------------------- /rules/60-persistent-storage-tape.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | # persistent storage links: /dev/tape/{by-id,by-path} 4 | 5 | ACTION=="remove", GOTO="persistent_storage_tape_end" 6 | 7 | # type 8 devices are "Medium Changers" 8 | SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8", IMPORT{program}="scsi_id --sg-version=3 --export --whitelisted -d $devnode", \ 9 | SYMLINK+="tape/by-id/scsi-$env{ID_SERIAL}" 10 | 11 | SUBSYSTEM!="scsi_tape", GOTO="persistent_storage_tape_end" 12 | 13 | KERNEL=="st*[0-9]|nst*[0-9]", ATTRS{ieee1394_id}=="?*", ENV{ID_SERIAL}="$attr{ieee1394_id}", ENV{ID_BUS}="ieee1394" 14 | KERNEL=="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id" 15 | KERNEL=="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", KERNELS=="[0-9]*:*[0-9]", ENV{.BSG_DEV}="$root/bsg/$id" 16 | KERNEL=="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --whitelisted --export --device=$env{.BSG_DEV}", ENV{ID_BUS}="scsi" 17 | KERNEL=="st*[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}" 18 | KERNEL=="nst*[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}-nst" 19 | 20 | # by-path (parent device path) 21 | KERNEL=="st*[0-9]|nst*[0-9]", IMPORT{builtin}="path_id" 22 | KERNEL=="st*[0-9]", ENV{ID_PATH}=="?*", SYMLINK+="tape/by-path/$env{ID_PATH}" 23 | KERNEL=="nst*[0-9]", ENV{ID_PATH}=="?*", SYMLINK+="tape/by-path/$env{ID_PATH}-nst" 24 | 25 | LABEL="persistent_storage_tape_end" 26 | -------------------------------------------------------------------------------- /rules/60-persistent-storage.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | # persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path} 4 | # scheme based on "Linux persistent device names", 2004, Hannes Reinecke 5 | 6 | # forward scsi device event to corresponding block device 7 | ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change" 8 | 9 | ACTION=="remove", GOTO="persistent_storage_end" 10 | 11 | # enable in-kernel media-presence polling 12 | ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_poll_msecs}=="0", ATTR{parameters/events_dfl_poll_msecs}="2000" 13 | 14 | SUBSYSTEM!="block", GOTO="persistent_storage_end" 15 | 16 | # skip rules for inappropriate block devices 17 | KERNEL=="fd*|mtd*|nbd*|gnbd*|btibm*|dm-*|md*", GOTO="persistent_storage_end" 18 | 19 | # ignore partitions that span the entire disk 20 | TEST=="whole_disk", GOTO="persistent_storage_end" 21 | 22 | # for partitions import parent information 23 | ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*" 24 | 25 | # virtio-blk 26 | KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}" 27 | KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n" 28 | 29 | # ATA devices with their own "ata" kernel subsystem 30 | KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="ata", IMPORT{program}="ata_id --export $devnode" 31 | # ATA devices using the "scsi" subsystem 32 | KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode" 33 | # ATA/ATAPI devices (SPC-3 or later) using the "scsi" subsystem 34 | KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode" 35 | 36 | # Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures) 37 | KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode" 38 | # Otherwise fall back to using usb_id for USB devices 39 | KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id" 40 | 41 | # scsi devices 42 | KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi" 43 | KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="cciss" 44 | KERNEL=="sd*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}" 45 | KERNEL=="sd*|cciss*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n" 46 | 47 | # firewire 48 | KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}" 49 | KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n" 50 | 51 | KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}" 52 | KERNEL=="mmcblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n" 53 | KERNEL=="mspblk[0-9]", SUBSYSTEMS=="memstick", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}" 54 | KERNEL=="mspblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}-part%n" 55 | 56 | # by-path (parent device path) 57 | ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id" 58 | ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}" 59 | ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n" 60 | 61 | # skip unpartitioned removable media devices from drivers which do not send "change" events 62 | ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end" 63 | 64 | # probe filesystem metadata of optical drives which have a media inserted 65 | KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \ 66 | IMPORT{builtin}="blkid --offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}" 67 | # single-session CDs do not have ID_CDROM_MEDIA_SESSION_LAST_OFFSET 68 | KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="", \ 69 | IMPORT{builtin}="blkid --noraid" 70 | 71 | # probe filesystem metadata of disks 72 | KERNEL!="sr*", IMPORT{builtin}="blkid" 73 | 74 | # watch metadata changes by tools closing the device after writing 75 | KERNEL!="sr*", OPTIONS+="watch" 76 | 77 | # by-label/by-uuid links (filesystem metadata) 78 | ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" 79 | ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" 80 | 81 | # by-id (World Wide Name) 82 | ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}" 83 | ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n" 84 | 85 | # by-partlabel/by-partuuid links (partition metadata) 86 | ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}" 87 | ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}" 88 | 89 | LABEL="persistent_storage_end" 90 | -------------------------------------------------------------------------------- /rules/75-net-description.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="net_end" 4 | SUBSYSTEM!="net", GOTO="net_end" 5 | 6 | SUBSYSTEMS=="usb", ENV{ID_MODEL}=="", IMPORT{builtin}="usb_id" 7 | SUBSYSTEMS=="usb", IMPORT{builtin}="usb-db" 8 | SUBSYSTEMS=="usb", ATTRS{idVendor}!="", ATTRS{idProduct}!="", ENV{ID_VENDOR_ID}="$attr{idVendor}", ENV{ID_MODEL_ID}="$attr{idProduct}" 9 | SUBSYSTEMS=="usb", GOTO="net_end" 10 | 11 | SUBSYSTEMS=="pci", IMPORT{builtin}="pci-db" 12 | SUBSYSTEMS=="pci", ENV{ID_BUS}="pci", ENV{ID_VENDOR_ID}="$attr{vendor}", ENV{ID_MODEL_ID}="$attr{device}" 13 | 14 | LABEL="net_end" 15 | -------------------------------------------------------------------------------- /rules/75-tty-description.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="tty_end" 4 | SUBSYSTEM!="tty", GOTO="tty_end" 5 | 6 | SUBSYSTEMS=="usb", ENV{ID_MODEL}=="", IMPORT{builtin}="usb_id" 7 | SUBSYSTEMS=="usb", IMPORT{builtin}="usb-db" 8 | SUBSYSTEMS=="usb", ATTRS{idVendor}!="", ATTRS{idProduct}!="", ENV{ID_VENDOR_ID}="$attr{idVendor}", ENV{ID_MODEL_ID}="$attr{idProduct}" 9 | SUBSYSTEMS=="usb", GOTO="tty_end" 10 | 11 | SUBSYSTEMS=="pci", IMPORT{builtin}="pci-db" 12 | SUBSYSTEMS=="pci", ENV{ID_BUS}="pci", ENV{ID_VENDOR_ID}="$attr{vendor}", ENV{ID_MODEL_ID}="$attr{device}" 13 | 14 | LABEL="tty_end" 15 | -------------------------------------------------------------------------------- /rules/78-sound-card.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | SUBSYSTEM!="sound", GOTO="sound_end" 4 | 5 | ACTION=="add|change", KERNEL=="controlC*", ATTR{../uevent}="change" 6 | ACTION!="change", GOTO="sound_end" 7 | 8 | # Ok, we probably need a little explanation here for what the two lines above 9 | # are good for. 10 | # 11 | # The story goes like this: when ALSA registers a new sound card it emits a 12 | # series of 'add' events to userspace, for the main card device and for all the 13 | # child device nodes that belong to it. udev relays those to applications, 14 | # however only maintains the order between father and child, but not between 15 | # the siblings. The control device node creation can be used as synchronization 16 | # point. All other devices that belong to a card are created in the kernel 17 | # before it. However unfortunately due to the fact that siblings are forwarded 18 | # out of order by udev this fact is lost to applications. 19 | # 20 | # OTOH before an application can open a device it needs to make sure that all 21 | # its device nodes are completely created and set up. 22 | # 23 | # As a workaround for this issue we have added the udev rule above which will 24 | # generate a 'change' event on the main card device from the 'add' event of the 25 | # card's control device. Due to the ordering semantics of udev this event will 26 | # only be relayed after all child devices have finished processing properly. 27 | # When an application needs to listen for appearing devices it can hence look 28 | # for 'change' events only, and ignore the actual 'add' events. 29 | # 30 | # When the application is initialized at the same time as a device is plugged 31 | # in it may need to figure out if the 'change' event has already been triggered 32 | # or not for a card. To find that out we store the flag environment variable 33 | # SOUND_INITIALIZED on the device which simply tells us if the card 'change' 34 | # event has already been processed. 35 | 36 | KERNEL!="card*", GOTO="sound_end" 37 | 38 | ENV{SOUND_INITIALIZED}="1" 39 | 40 | SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id" 41 | SUBSYSTEMS=="usb", IMPORT{builtin}="usb-db" 42 | SUBSYSTEMS=="usb", GOTO="skip_pci" 43 | 44 | SUBSYSTEMS=="firewire", ATTRS{vendor_name}=="?*", ATTRS{model_name}=="?*", \ 45 | ENV{ID_BUS}="firewire", ENV{ID_VENDOR}="$attr{vendor_name}", ENV{ID_MODEL}="$attr{model_name}" 46 | SUBSYSTEMS=="firewire", ATTRS{guid}=="?*", ENV{ID_ID}="firewire-$attr{guid}" 47 | SUBSYSTEMS=="firewire", GOTO="skip_pci" 48 | 49 | 50 | SUBSYSTEMS=="pci", IMPORT{builtin}="pci-db" 51 | SUBSYSTEMS=="pci", ENV{ID_BUS}="pci", ENV{ID_VENDOR_ID}="$attr{vendor}", ENV{ID_MODEL_ID}="$attr{device}" 52 | 53 | LABEL="skip_pci" 54 | 55 | ENV{ID_SERIAL}=="?*", ENV{ID_USB_INTERFACE_NUM}=="?*", ENV{ID_ID}="$env{ID_BUS}-$env{ID_SERIAL}-$env{ID_USB_INTERFACE_NUM}-$attr{id}" 56 | ENV{ID_SERIAL}=="?*", ENV{ID_USB_INTERFACE_NUM}=="", ENV{ID_ID}="$env{ID_BUS}-$env{ID_SERIAL}-$attr{id}" 57 | 58 | IMPORT{builtin}="path_id" 59 | 60 | # The values used here for $SOUND_FORM_FACTOR and $SOUND_CLASS should be kept 61 | # in sync with those defined for PulseAudio's src/pulse/proplist.h 62 | # PA_PROP_DEVICE_FORM_FACTOR, PA_PROP_DEVICE_CLASS properties. 63 | 64 | # If the first PCM device of this card has the pcm class 'modem', then the card is a modem 65 | ATTR{pcmC%nD0p/pcm_class}=="modem", ENV{SOUND_CLASS}="modem", GOTO="sound_end" 66 | 67 | # Identify cards on the internal PCI bus as internal 68 | SUBSYSTEMS=="pci", DEVPATH=="*/0000:00:??.?/sound/*", ENV{SOUND_FORM_FACTOR}="internal", GOTO="sound_end" 69 | 70 | # Devices that also support Image/Video interfaces are most likely webcams 71 | SUBSYSTEMS=="usb", ENV{ID_USB_INTERFACES}=="*:0e????:*", ENV{SOUND_FORM_FACTOR}="webcam", GOTO="sound_end" 72 | 73 | # Matching on the model strings is a bit ugly, I admit 74 | ENV{ID_MODEL}=="*[Ss]peaker*", ENV{SOUND_FORM_FACTOR}="speaker", GOTO="sound_end" 75 | ENV{ID_MODEL_FROM_DATABASE}=="*[Ss]peaker*", ENV{SOUND_FORM_FACTOR}="speaker", GOTO="sound_end" 76 | 77 | ENV{ID_MODEL}=="*[Hh]eadphone*", ENV{SOUND_FORM_FACTOR}="headphone", GOTO="sound_end" 78 | ENV{ID_MODEL_FROM_DATABASE}=="*[Hh]eadphone*", ENV{SOUND_FORM_FACTOR}="headphone", GOTO="sound_end" 79 | 80 | ENV{ID_MODEL}=="*[Hh]eadset*", ENV{SOUND_FORM_FACTOR}="headset", GOTO="sound_end" 81 | ENV{ID_MODEL_FROM_DATABASE}=="*[Hh]eadset*", ENV{SOUND_FORM_FACTOR}="headset", GOTO="sound_end" 82 | 83 | ENV{ID_MODEL}=="*[Hh]andset*", ENV{SOUND_FORM_FACTOR}="handset", GOTO="sound_end" 84 | ENV{ID_MODEL_FROM_DATABASE}=="*[Hh]andset*", ENV{SOUND_FORM_FACTOR}="handset", GOTO="sound_end" 85 | 86 | ENV{ID_MODEL}=="*[Mm]icrophone*", ENV{SOUND_FORM_FACTOR}="microphone", GOTO="sound_end" 87 | ENV{ID_MODEL_FROM_DATABASE}=="*[Mm]icrophone*", ENV{SOUND_FORM_FACTOR}="microphone", GOTO="sound_end" 88 | 89 | LABEL="sound_end" 90 | -------------------------------------------------------------------------------- /rules/80-drivers.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="drivers_end" 4 | 5 | DRIVER!="?*", ENV{MODALIAS}=="?*", IMPORT{builtin}="kmod load $env{MODALIAS}" 6 | SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="SD", IMPORT{builtin}="kmod load tifm_sd" 7 | SUBSYSTEM=="tifm", ENV{TIFM_CARD_TYPE}=="MS", IMPORT{builtin}="kmod load tifm_ms" 8 | SUBSYSTEM=="memstick", IMPORT{builtin}="kmod load ms_block mspro_block" 9 | SUBSYSTEM=="i2o", IMPORT{builtin}="kmod load i2o_block" 10 | SUBSYSTEM=="module", KERNEL=="parport_pc", IMPORT{builtin}="kmod load ppdev" 11 | 12 | LABEL="drivers_end" 13 | -------------------------------------------------------------------------------- /rules/95-udev-late.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | # run a command on remove events 4 | ACTION=="remove", ENV{REMOVE_CMD}!="", RUN+="$env{REMOVE_CMD}" 5 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.[78] 2 | *.html 3 | udev.pc 4 | libudev.pc 5 | udev*.service 6 | -------------------------------------------------------------------------------- /src/accelerometer/61-accelerometer.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | SUBSYSTEM=="input", ACTION!="remove", ENV{ID_INPUT_ACCELEROMETER}=="1", IMPORT{program}="accelerometer %p" 4 | -------------------------------------------------------------------------------- /src/cdrom_id/60-cdrom_id.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="cdrom_end" 4 | SUBSYSTEM!="block", GOTO="cdrom_end" 5 | KERNEL!="sr[0-9]*|xvd*", GOTO="cdrom_end" 6 | ENV{DEVTYPE}!="disk", GOTO="cdrom_end" 7 | 8 | # unconditionally tag device as CDROM 9 | KERNEL=="sr[0-9]*", ENV{ID_CDROM}="1" 10 | 11 | # media eject button pressed 12 | ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end" 13 | 14 | # import device and media properties and lock tray to 15 | # enable the receiving of media eject button events 16 | IMPORT{program}="cdrom_id --lock-media $devnode" 17 | 18 | KERNEL=="sr0", SYMLINK+="cdrom", OPTIONS+="link_priority=-100" 19 | 20 | LABEL="cdrom_end" 21 | -------------------------------------------------------------------------------- /src/docs/.gitignore: -------------------------------------------------------------------------------- 1 | libudev-overrides.txt 2 | html/ 3 | tmpl/ 4 | xml/ 5 | *.stamp 6 | *.bak 7 | version.xml 8 | libudev-decl-list.txt 9 | libudev-decl.txt 10 | libudev-undeclared.txt 11 | libudev-undocumented.txt 12 | libudev-unused.txt 13 | libudev.args 14 | libudev.hierarchy 15 | libudev.interfaces 16 | libudev.prerequisites 17 | libudev.signals 18 | -------------------------------------------------------------------------------- /src/docs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | # We require automake 1.10 at least. 4 | AUTOMAKE_OPTIONS = 1.10 5 | 6 | # This is a blank Makefile.am for using gtk-doc. 7 | # Copy this to your project's API docs directory and modify the variables to 8 | # suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples 9 | # of using the various options. 10 | 11 | # The name of the module, e.g. 'glib'. 12 | DOC_MODULE=libudev 13 | 14 | # Uncomment for versioned docs and specify the version of the module, e.g. '2'. 15 | #DOC_MODULE_VERSION=2 16 | 17 | # The top-level SGML file. You can change this if you want to. 18 | DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml 19 | 20 | # The directory containing the source code. Relative to $(srcdir). 21 | # gtk-doc will search all .c & .h files beneath here for inline comments 22 | # documenting the functions and macros. 23 | # e.g. DOC_SOURCE_DIR=../../../gtk 24 | DOC_SOURCE_DIR=$(top_srcdir)/src 25 | 26 | # Extra options to pass to gtkdoc-scangobj. Not normally needed. 27 | SCANGOBJ_OPTIONS= 28 | 29 | # Extra options to supply to gtkdoc-scan. 30 | # e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" 31 | SCAN_OPTIONS= 32 | 33 | # Extra options to supply to gtkdoc-mkdb. 34 | # e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml 35 | MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space udev 36 | 37 | # Extra options to supply to gtkdoc-mktmpl 38 | # e.g. MKTMPL_OPTIONS=--only-section-tmpl 39 | MKTMPL_OPTIONS= 40 | 41 | # Extra options to supply to gtkdoc-mkhtml 42 | MKHTML_OPTIONS=--path=$(abs_srcdir) --path=$(abs_builddir) 43 | 44 | # Extra options to supply to gtkdoc-fixref. Not normally needed. 45 | # e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html 46 | FIXXREF_OPTIONS= 47 | 48 | # Used for dependencies. The docs will be rebuilt if any of these change. 49 | # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h 50 | # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c 51 | HFILE_GLOB=$(top_srcdir)/src/libudev*.h 52 | CFILE_GLOB=$(top_srcdir)/src/libudev*.c 53 | 54 | # Extra header to include when scanning, which are not under DOC_SOURCE_DIR 55 | # e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h 56 | EXTRA_HFILES= 57 | 58 | # Header files to ignore when scanning. Use base file name, no paths 59 | # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h 60 | IGNORE_HFILES= libudev-private.h 61 | 62 | # Images to copy into HTML directory. 63 | # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png 64 | HTML_IMAGES= 65 | 66 | # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). 67 | # e.g. content_files=running.sgml building.sgml changes-2.0.sgml 68 | content_files = version.xml 69 | 70 | # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded 71 | # These files must be listed here *and* in content_files 72 | # e.g. expand_content_files=running.sgml 73 | expand_content_files= 74 | 75 | # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. 76 | # Only needed if you are using gtkdoc-scangobj to dynamically query widget 77 | # signals and properties. 78 | # e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) 79 | # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) 80 | GTKDOC_CFLAGS= 81 | GTKDOC_LIBS= 82 | 83 | # This includes the standard gtk-doc make rules, copied by gtkdocize. 84 | include $(top_srcdir)/gtk-doc.make 85 | 86 | # Other files to distribute 87 | # e.g. EXTRA_DIST += version.xml.in 88 | EXTRA_DIST += version.xml.in 89 | 90 | # Files not to distribute 91 | # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types 92 | # for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt 93 | #DISTCLEANFILES += 94 | 95 | # Comment this out if you want your docs-status tested during 'make check' 96 | if ENABLE_GTK_DOC 97 | #TESTS_ENVIRONMENT = cd $(srcsrc) 98 | #TESTS = $(GTKDOC_CHECK) 99 | endif 100 | -------------------------------------------------------------------------------- /src/docs/libudev-docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | ]> 7 | 8 | 9 | libudev Reference Manual 10 | for libudev version &version; 11 | 12 | 2009-2011 13 | Kay Sievers <kay.sievers@vrfy.org> 14 | 15 | 16 | 17 | 18 | libudev 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | API Index 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/docs/libudev-sections.txt: -------------------------------------------------------------------------------- 1 |
2 | libudev 3 | udev 4 | udev 5 | udev_ref 6 | udev_unref 7 | udev_new 8 | udev_set_log_fn 9 | udev_get_log_priority 10 | udev_set_log_priority 11 | udev_get_sys_path 12 | udev_get_dev_path 13 | udev_get_run_path 14 | udev_get_userdata 15 | udev_set_userdata 16 |
17 | 18 |
19 | libudev-list 20 | udev_list 21 | udev_list_entry 22 | udev_list_entry_get_next 23 | udev_list_entry_get_by_name 24 | udev_list_entry_get_name 25 | udev_list_entry_get_value 26 | udev_list_entry_foreach 27 |
28 | 29 |
30 | libudev-device 31 | udev_device 32 | udev_device 33 | udev_device_ref 34 | udev_device_unref 35 | udev_device_get_udev 36 | udev_device_new_from_syspath 37 | udev_device_new_from_devnum 38 | udev_device_new_from_subsystem_sysname 39 | udev_device_new_from_environment 40 | udev_device_get_parent 41 | udev_device_get_parent_with_subsystem_devtype 42 | udev_device_get_devpath 43 | udev_device_get_subsystem 44 | udev_device_get_devtype 45 | udev_device_get_syspath 46 | udev_device_get_sysname 47 | udev_device_get_sysnum 48 | udev_device_get_devnode 49 | udev_device_get_is_initialized 50 | udev_device_get_devlinks_list_entry 51 | udev_device_get_properties_list_entry 52 | udev_device_get_tags_list_entry 53 | udev_device_get_property_value 54 | udev_device_get_driver 55 | udev_device_get_devnum 56 | udev_device_get_action 57 | udev_device_get_sysattr_value 58 | udev_device_get_sysattr_list_entry 59 | udev_device_get_seqnum 60 | udev_device_get_usec_since_initialized 61 | udev_device_has_tag 62 |
63 | 64 |
65 | libudev-monitor 66 | udev_monitor 67 | udev_monitor 68 | udev_monitor_ref 69 | udev_monitor_unref 70 | udev_monitor_get_udev 71 | udev_monitor_new_from_netlink 72 | udev_monitor_new_from_socket 73 | udev_monitor_enable_receiving 74 | udev_monitor_set_receive_buffer_size 75 | udev_monitor_get_fd 76 | udev_monitor_receive_device 77 | udev_monitor_filter_add_match_subsystem_devtype 78 | udev_monitor_filter_add_match_tag 79 | udev_monitor_filter_update 80 | udev_monitor_filter_remove 81 |
82 | 83 |
84 | libudev-enumerate 85 | udev_enumerate 86 | udev_enumerate 87 | udev_enumerate_ref 88 | udev_enumerate_unref 89 | udev_enumerate_get_udev 90 | udev_enumerate_new 91 | udev_enumerate_add_match_subsystem 92 | udev_enumerate_add_nomatch_subsystem 93 | udev_enumerate_add_match_sysattr 94 | udev_enumerate_add_nomatch_sysattr 95 | udev_enumerate_add_match_property 96 | udev_enumerate_add_match_tag 97 | udev_enumerate_add_match_parent 98 | udev_enumerate_add_match_is_initialized 99 | udev_enumerate_add_match_sysname 100 | udev_enumerate_add_syspath 101 | udev_enumerate_scan_devices 102 | udev_enumerate_scan_subsystems 103 | udev_enumerate_get_list_entry 104 |
105 | 106 |
107 | libudev-queue 108 | udev_queue 109 | udev_queue 110 | udev_queue_ref 111 | udev_queue_unref 112 | udev_queue_get_udev 113 | udev_queue_new 114 | udev_queue_get_udev_is_active 115 | udev_queue_get_queue_is_empty 116 | udev_queue_get_seqnum_is_finished 117 | udev_queue_get_seqnum_sequence_is_finished 118 | udev_queue_get_queued_list_entry 119 | udev_queue_get_kernel_seqnum 120 | udev_queue_get_udev_seqnum 121 |
122 | 123 |
124 | libudev-util 125 | udev_util 126 | udev_util_encode_string 127 |
128 | -------------------------------------------------------------------------------- /src/docs/libudev.types: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavlinux/udev/bc43e87ea1d21d8b723265dbb6b5a03c82806548/src/docs/libudev.types -------------------------------------------------------------------------------- /src/docs/version.xml.in: -------------------------------------------------------------------------------- 1 | @VERSION@ 2 | -------------------------------------------------------------------------------- /src/floppy/60-floppy.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | SUBSYSTEM=="block", KERNEL=="fd[0-9]", ACTION=="add", ATTRS{cmos}=="?*", ENV{CMOS_TYPE}="$attr{cmos}", \ 4 | RUN+="create_floppy_devices -c -t $env{CMOS_TYPE} -m %M -M 0660 -G floppy $root/%k" 5 | -------------------------------------------------------------------------------- /src/floppy/create_floppy_devices.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Create all possible floppy device based on the CMOS type. 3 | * Based upon code from drivers/block/floppy.c 4 | * 5 | * Copyright(C) 2005, SUSE Linux Products GmbH 6 | * 7 | * Author: Hannes Reinecke 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "libudev.h" 34 | #include "libudev-private.h" 35 | 36 | static char *table[] = { 37 | "", "d360", "h1200", "u360", "u720", "h360", "h720", 38 | "u1440", "u2880", "CompaQ", "h1440", "u1680", "h410", 39 | "u820", "h1476", "u1722", "h420", "u830", "h1494", "u1743", 40 | "h880", "u1040", "u1120", "h1600", "u1760", "u1920", 41 | "u3200", "u3520", "u3840", "u1840", "u800", "u1600", 42 | NULL 43 | }; 44 | 45 | static int t360[] = { 1, 0 }; 46 | static int t1200[] = { 2, 5, 6, 10, 12, 14, 16, 18, 20, 23, 0 }; 47 | static int t3in[] = { 8, 9, 26, 27, 28, 7, 11, 15, 19, 24, 25, 29, 31, 3, 4, 13, 17, 21, 22, 30, 0 }; 48 | static int *table_sup[] = { NULL, t360, t1200, t3in+5+8, t3in+5, t3in, t3in }; 49 | 50 | static void log_fn(struct udev *udev, int priority, 51 | const char *file, int line, const char *fn, 52 | const char *format, va_list args) 53 | { 54 | vsyslog(priority, format, args); 55 | } 56 | 57 | int main(int argc, char **argv) 58 | { 59 | struct udev *udev; 60 | char *dev; 61 | char *devname; 62 | char node[64]; 63 | int type = 0, i, fdnum, c; 64 | int major = 2, minor; 65 | uid_t uid = 0; 66 | gid_t gid = 0; 67 | mode_t mode = 0660; 68 | int create_nodes = 0; 69 | int print_nodes = 0; 70 | int is_err = 0; 71 | 72 | udev = udev_new(); 73 | if (udev == NULL) 74 | goto exit; 75 | 76 | udev_log_init("create_floppy_devices"); 77 | udev_set_log_fn(udev, log_fn); 78 | udev_selinux_init(udev); 79 | 80 | while ((c = getopt(argc, argv, "cudm:U:G:M:t:")) != -1) { 81 | switch (c) { 82 | case 'c': 83 | create_nodes = 1; 84 | break; 85 | case 'd': 86 | print_nodes = 1; 87 | break; 88 | case 'U': 89 | uid = util_lookup_user(udev, optarg); 90 | break; 91 | case 'G': 92 | gid = util_lookup_group(udev, optarg); 93 | break; 94 | case 'M': 95 | mode = strtol(optarg, NULL, 0); 96 | mode = mode & 0666; 97 | break; 98 | case 'm': 99 | major = strtol(optarg, NULL, 0); 100 | break; 101 | case 't': 102 | type = strtol(optarg, NULL, 0); 103 | break; 104 | default: 105 | is_err++; 106 | break; 107 | } 108 | } 109 | 110 | if (is_err || optind >= argc) { 111 | printf("Usage: %s [OPTION] device\n" 112 | " -c create\n" 113 | " -d debug\n" 114 | " -m Major number\n" 115 | " -t floppy type number\n" 116 | " -U device node user ownership\n" 117 | " -G device node group owner\n" 118 | " -M device node mode\n" 119 | "\n", argv[0]); 120 | return 1; 121 | } 122 | 123 | dev = argv[optind]; 124 | devname = strrchr(dev, '/'); 125 | if (devname != NULL) 126 | devname = &devname[1]; 127 | else 128 | devname = dev; 129 | if (strncmp(devname, "fd", 2) != 0) { 130 | fprintf(stderr,"Device '%s' is not a floppy device\n", dev); 131 | return 1; 132 | } 133 | 134 | fdnum = strtol(&devname[2], NULL, 10); 135 | if (fdnum < 0 || fdnum > 7) { 136 | fprintf(stderr,"Floppy device number %d out of range (0-7)\n", fdnum); 137 | return 1; 138 | } 139 | if (fdnum > 3) 140 | fdnum += 124; 141 | 142 | if (major < 1) { 143 | fprintf(stderr,"Invalid major number %d\n", major); 144 | return 1; 145 | } 146 | 147 | if (type < 0 || type >= (int) ARRAY_SIZE(table_sup)) { 148 | fprintf(stderr,"Invalid CMOS type %d\n", type); 149 | return 1; 150 | } 151 | 152 | if (type == 0) 153 | return 0; 154 | 155 | i = 0; 156 | while (table_sup[type][i]) { 157 | sprintf(node, "%s%s", dev, table[table_sup[type][i]]); 158 | minor = (table_sup[type][i] << 2) + fdnum; 159 | if (print_nodes) 160 | printf("%s b %.4o %d %d\n", node, mode, major, minor); 161 | if (create_nodes) { 162 | unlink(node); 163 | udev_selinux_setfscreatecon(udev, node, S_IFBLK | mode); 164 | mknod(node, S_IFBLK | mode, makedev(major,minor)); 165 | udev_selinux_resetfscreatecon(udev); 166 | chown(node, uid, gid); 167 | chmod(node, S_IFBLK | mode); 168 | } 169 | i++; 170 | } 171 | 172 | udev_selinux_exit(udev); 173 | udev_unref(udev); 174 | udev_log_close(); 175 | exit: 176 | return 0; 177 | } 178 | -------------------------------------------------------------------------------- /src/gudev/.gitignore: -------------------------------------------------------------------------------- 1 | gtk-doc.make 2 | docs/version.xml 3 | gudev-1.0.pc 4 | gudevenumtypes.c 5 | gudevenumtypes.h 6 | gudevmarshal.c 7 | gudevmarshal.h 8 | GUdev-1.0.gir 9 | GUdev-1.0.typelib 10 | -------------------------------------------------------------------------------- /src/gudev/docs/.gitignore: -------------------------------------------------------------------------------- 1 | gudev-overrides.txt 2 | gudev-decl-list.txt 3 | gudev-decl.txt 4 | gudev-undeclared.txt 5 | gudev-undocumented.txt 6 | gudev-unused.txt 7 | gudev.args 8 | gudev.hierarchy 9 | gudev.interfaces 10 | gudev.prerequisites 11 | gudev.signals 12 | html.stamp 13 | html/* 14 | xml/* 15 | tmpl/* 16 | *.stamp 17 | -------------------------------------------------------------------------------- /src/gudev/docs/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | # We require automake 1.10 at least. 4 | AUTOMAKE_OPTIONS = 1.10 5 | 6 | # This is a blank Makefile.am for using gtk-doc. 7 | # Copy this to your project's API docs directory and modify the variables to 8 | # suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples 9 | # of using the various options. 10 | 11 | # The name of the module, e.g. 'glib'. 12 | DOC_MODULE=gudev 13 | 14 | # Uncomment for versioned docs and specify the version of the module, e.g. '2'. 15 | #DOC_MODULE_VERSION=2 16 | 17 | # The top-level SGML file. You can change this if you want to. 18 | DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml 19 | 20 | # The directory containing the source code. Relative to $(srcdir). 21 | # gtk-doc will search all .c & .h files beneath here for inline comments 22 | # documenting the functions and macros. 23 | # e.g. DOC_SOURCE_DIR=../../../gtk 24 | DOC_SOURCE_DIR=$(top_srcdir)/src 25 | 26 | # Extra options to pass to gtkdoc-scangobj. Not normally needed. 27 | SCANGOBJ_OPTIONS= 28 | 29 | # Extra options to supply to gtkdoc-scan. 30 | # e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" 31 | SCAN_OPTIONS= 32 | 33 | # Extra options to supply to gtkdoc-mkdb. 34 | # e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml 35 | MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=g_udev 36 | 37 | # Extra options to supply to gtkdoc-mktmpl 38 | # e.g. MKTMPL_OPTIONS=--only-section-tmpl 39 | MKTMPL_OPTIONS= 40 | 41 | # Extra options to supply to gtkdoc-mkhtml 42 | MKHTML_OPTIONS=--path=$(abs_srcdir) --path=$(abs_builddir) 43 | 44 | # Extra options to supply to gtkdoc-fixref. Not normally needed. 45 | # e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html 46 | FIXXREF_OPTIONS= 47 | 48 | # Used for dependencies. The docs will be rebuilt if any of these change. 49 | # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h 50 | # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c 51 | HFILE_GLOB=$(top_srcdir)/src/gudev/*.h 52 | CFILE_GLOB=$(top_srcdir)/src/gudev/*.c 53 | 54 | # Extra header to include when scanning, which are not under DOC_SOURCE_DIR 55 | # e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h 56 | EXTRA_HFILES= 57 | 58 | # Header files to ignore when scanning. Use base file name, no paths 59 | # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h 60 | IGNORE_HFILES= 61 | 62 | # Images to copy into HTML directory. 63 | # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png 64 | HTML_IMAGES= 65 | 66 | # Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). 67 | # e.g. content_files=running.sgml building.sgml changes-2.0.sgml 68 | content_files = version.xml 69 | 70 | # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded 71 | # These files must be listed here *and* in content_files 72 | # e.g. expand_content_files=running.sgml 73 | expand_content_files= 74 | 75 | # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. 76 | # Only needed if you are using gtkdoc-scangobj to dynamically query widget 77 | # signals and properties. 78 | # e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) 79 | # e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) 80 | GTKDOC_CFLAGS = \ 81 | $(DBUS_GLIB_CFLAGS) \ 82 | $(GLIB_CFLAGS) \ 83 | -I$(top_srcdir)/src/gudev \ 84 | -I$(top_builddir)/src/gudev 85 | 86 | GTKDOC_LIBS = \ 87 | $(GLIB_LIBS) \ 88 | $(top_builddir)/libgudev-1.0.la 89 | 90 | # This includes the standard gtk-doc make rules, copied by gtkdocize. 91 | include $(top_srcdir)/gtk-doc.make 92 | 93 | # Other files to distribute 94 | # e.g. EXTRA_DIST += version.xml.in 95 | EXTRA_DIST += version.xml.in 96 | 97 | # Files not to distribute 98 | # for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types 99 | # for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt 100 | #DISTCLEANFILES += 101 | 102 | # Comment this out if you want your docs-status tested during 'make check' 103 | if ENABLE_GTK_DOC 104 | #TESTS_ENVIRONMENT = cd $(srcsrc) 105 | #TESTS = $(GTKDOC_CHECK) 106 | endif 107 | -------------------------------------------------------------------------------- /src/gudev/docs/gudev-docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | ]> 6 | 7 | 8 | GUDev Reference Manual 9 | For GUdev version &version; 10 | 11 | 12 | David 13 | Zeuthen 14 | 15 |
16 | davidz@redhat.com 17 |
18 |
19 |
20 | 21 | Bastien 22 | Nocera 23 | 24 |
25 | hadess@hadess.net 26 |
27 |
28 |
29 |
30 | 31 | 32 | 2011 33 | The GUDev Authors 34 | 35 | 36 | 37 | 38 | Permission is granted to copy, distribute and/or modify this 39 | document under the terms of the GNU Free 40 | Documentation License, Version 1.1 or any later 41 | version published by the Free Software Foundation with no 42 | Invariant Sections, no Front-Cover Texts, and no Back-Cover 43 | Texts. You may obtain a copy of the GNU Free 44 | Documentation License from the Free Software 45 | Foundation by visiting their Web site or by writing 47 | to: 48 | 49 |
50 | The Free Software Foundation, Inc., 51 | 59 Temple Place - Suite 330, 52 | Boston, MA 02111-1307, 53 | USA 54 |
55 |
56 | 57 | 58 | Many of the names used by companies to distinguish their 59 | products and services are claimed as trademarks. Where those 60 | names appear in any freedesktop.org documentation, and those 61 | trademarks are made aware to the members of the 62 | freedesktop.org Project, the names have been printed in caps 63 | or initial caps. 64 | 65 |
66 |
67 | 68 | 69 | API Reference 70 | 71 | 72 | This part presents the class and function reference for the 73 | libgudev library. 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Object Hierarchy 83 | 84 | 85 | 86 | Index 87 | 88 | 89 | Index of new symbols in 165 90 | 91 | 92 | 93 |
94 | -------------------------------------------------------------------------------- /src/gudev/docs/gudev-sections.txt: -------------------------------------------------------------------------------- 1 |
2 | gudevclient 3 | GUdevClient 4 | GUdevClient 5 | GUdevClientClass 6 | GUdevDeviceType 7 | GUdevDeviceNumber 8 | g_udev_client_new 9 | g_udev_client_query_by_subsystem 10 | g_udev_client_query_by_device_number 11 | g_udev_client_query_by_device_file 12 | g_udev_client_query_by_sysfs_path 13 | g_udev_client_query_by_subsystem_and_name 14 | 15 | G_UDEV_CLIENT 16 | G_UDEV_IS_CLIENT 17 | G_UDEV_TYPE_CLIENT 18 | g_udev_client_get_type 19 | G_UDEV_CLIENT_CLASS 20 | G_UDEV_IS_CLIENT_CLASS 21 | G_UDEV_CLIENT_GET_CLASS 22 | 23 | GUdevClientPrivate 24 |
25 | 26 |
27 | gudevdevice 28 | GUdevDevice 29 | GUdevDevice 30 | GUdevDeviceClass 31 | g_udev_device_get_subsystem 32 | g_udev_device_get_devtype 33 | g_udev_device_get_name 34 | g_udev_device_get_number 35 | g_udev_device_get_sysfs_path 36 | g_udev_device_get_driver 37 | g_udev_device_get_action 38 | g_udev_device_get_seqnum 39 | g_udev_device_get_device_type 40 | g_udev_device_get_device_number 41 | g_udev_device_get_device_file 42 | g_udev_device_get_device_file_symlinks 43 | g_udev_device_get_parent 44 | g_udev_device_get_parent_with_subsystem 45 | g_udev_device_get_tags 46 | g_udev_device_get_is_initialized 47 | g_udev_device_get_usec_since_initialized 48 | g_udev_device_get_property_keys 49 | g_udev_device_has_property 50 | g_udev_device_get_property 51 | g_udev_device_get_property_as_int 52 | g_udev_device_get_property_as_uint64 53 | g_udev_device_get_property_as_double 54 | g_udev_device_get_property_as_boolean 55 | g_udev_device_get_property_as_strv 56 | g_udev_device_get_sysfs_attr 57 | g_udev_device_get_sysfs_attr_as_int 58 | g_udev_device_get_sysfs_attr_as_uint64 59 | g_udev_device_get_sysfs_attr_as_double 60 | g_udev_device_get_sysfs_attr_as_boolean 61 | g_udev_device_get_sysfs_attr_as_strv 62 | 63 | G_UDEV_DEVICE 64 | G_UDEV_IS_DEVICE 65 | G_UDEV_TYPE_DEVICE 66 | g_udev_device_get_type 67 | G_UDEV_DEVICE_CLASS 68 | G_UDEV_IS_DEVICE_CLASS 69 | G_UDEV_DEVICE_GET_CLASS 70 | 71 | GUdevDevicePrivate 72 |
73 | 74 |
75 | gudevenumerator 76 | GUdevEnumerator 77 | GUdevEnumerator 78 | GUdevEnumeratorClass 79 | g_udev_enumerator_new 80 | g_udev_enumerator_add_match_subsystem 81 | g_udev_enumerator_add_nomatch_subsystem 82 | g_udev_enumerator_add_match_sysfs_attr 83 | g_udev_enumerator_add_nomatch_sysfs_attr 84 | g_udev_enumerator_add_match_property 85 | g_udev_enumerator_add_match_name 86 | g_udev_enumerator_add_match_tag 87 | g_udev_enumerator_add_match_is_initialized 88 | g_udev_enumerator_add_sysfs_path 89 | g_udev_enumerator_execute 90 | 91 | G_UDEV_ENUMERATOR 92 | G_UDEV_IS_ENUMERATOR 93 | G_UDEV_TYPE_ENUMERATOR 94 | g_udev_enumerator_get_type 95 | G_UDEV_ENUMERATOR_CLASS 96 | G_UDEV_IS_ENUMERATOR_CLASS 97 | G_UDEV_ENUMERATOR_GET_CLASS 98 | 99 | GUdevEnumeratorPrivate 100 |
101 | 102 |
103 | gudevmarshal 104 | 105 | g_udev_marshal_VOID__STRING_OBJECT 106 |
107 | 108 |
109 | gudevenumtypes 110 | 111 | G_TYPE_UDEV_DEVICE_TYPE 112 | g_udev_device_type_get_type 113 |
114 | -------------------------------------------------------------------------------- /src/gudev/docs/gudev.types: -------------------------------------------------------------------------------- 1 | g_udev_device_type_get_type 2 | g_udev_device_get_type 3 | g_udev_client_get_type 4 | g_udev_enumerator_get_type 5 | -------------------------------------------------------------------------------- /src/gudev/docs/version.xml.in: -------------------------------------------------------------------------------- 1 | @VERSION@ 2 | -------------------------------------------------------------------------------- /src/gudev/gjs-example.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gjs-console 2 | 3 | // This currently depends on the following patches to gjs 4 | // 5 | // http://bugzilla.gnome.org/show_bug.cgi?id=584558 6 | // http://bugzilla.gnome.org/show_bug.cgi?id=584560 7 | // http://bugzilla.gnome.org/show_bug.cgi?id=584568 8 | 9 | const GUdev = imports.gi.GUdev; 10 | const Mainloop = imports.mainloop; 11 | 12 | function print_device (device) { 13 | print (" subsystem: " + device.get_subsystem ()); 14 | print (" devtype: " + device.get_devtype ()); 15 | print (" name: " + device.get_name ()); 16 | print (" number: " + device.get_number ()); 17 | print (" sysfs_path: " + device.get_sysfs_path ()); 18 | print (" driver: " + device.get_driver ()); 19 | print (" action: " + device.get_action ()); 20 | print (" seqnum: " + device.get_seqnum ()); 21 | print (" device type: " + device.get_device_type ()); 22 | print (" device number: " + device.get_device_number ()); 23 | print (" device file: " + device.get_device_file ()); 24 | print (" device file symlinks: " + device.get_device_file_symlinks ()); 25 | print (" foo: " + device.get_sysfs_attr_as_strv ("stat")); 26 | var keys = device.get_property_keys (); 27 | for (var n = 0; n < keys.length; n++) { 28 | print (" " + keys[n] + "=" + device.get_property (keys[n])); 29 | } 30 | } 31 | 32 | function on_uevent (client, action, device) { 33 | print ("action " + action + " on device " + device.get_sysfs_path()); 34 | print_device (device); 35 | print (""); 36 | } 37 | 38 | var client = new GUdev.Client ({subsystems: ["block", "usb/usb_interface"]}); 39 | client.connect ("uevent", on_uevent); 40 | 41 | var block_devices = client.query_by_subsystem ("block"); 42 | for (var n = 0; n < block_devices.length; n++) { 43 | print ("block device: " + block_devices[n].get_device_file ()); 44 | } 45 | 46 | var d; 47 | 48 | d = client.query_by_device_number (GUdev.DeviceType.BLOCK, 0x0810); 49 | if (d == null) { 50 | print ("query_by_device_number 0x810 -> null"); 51 | } else { 52 | print ("query_by_device_number 0x810 -> " + d.get_device_file ()); 53 | var dd = d.get_parent_with_subsystem ("usb", null); 54 | print_device (dd); 55 | print ("--------------------------------------------------------------------------"); 56 | while (d != null) { 57 | print_device (d); 58 | print (""); 59 | d = d.get_parent (); 60 | } 61 | } 62 | 63 | d = client.query_by_sysfs_path ("/sys/block/sda/sda1"); 64 | print ("query_by_sysfs_path (\"/sys/block/sda1\") -> " + d.get_device_file ()); 65 | 66 | d = client.query_by_subsystem_and_name ("block", "sda2"); 67 | print ("query_by_subsystem_and_name (\"block\", \"sda2\") -> " + d.get_device_file ()); 68 | 69 | d = client.query_by_device_file ("/dev/sda"); 70 | print ("query_by_device_file (\"/dev/sda\") -> " + d.get_device_file ()); 71 | 72 | d = client.query_by_device_file ("/dev/block/8:0"); 73 | print ("query_by_device_file (\"/dev/block/8:0\") -> " + d.get_device_file ()); 74 | 75 | Mainloop.run('udev-example'); 76 | -------------------------------------------------------------------------------- /src/gudev/gudev-1.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: gudev-1.0 7 | Description: GObject bindings for libudev 8 | Version: @VERSION@ 9 | Requires: glib-2.0, gobject-2.0 10 | Libs: -L${libdir} -lgudev-1.0 11 | Cflags: -I${includedir}/gudev-1.0 12 | -------------------------------------------------------------------------------- /src/gudev/gudev.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright (C) 2008 David Zeuthen 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #ifndef __G_UDEV_H__ 22 | #define __G_UDEV_H__ 23 | 24 | #define _GUDEV_INSIDE_GUDEV_H 1 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #undef _GUDEV_INSIDE_GUDEV_H 32 | 33 | #endif /* __G_UDEV_H__ */ 34 | -------------------------------------------------------------------------------- /src/gudev/gudevclient.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright (C) 2008 David Zeuthen 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #if !defined (_GUDEV_COMPILATION) && !defined(_GUDEV_INSIDE_GUDEV_H) 22 | #error "Only can be included directly, this file may disappear or change contents." 23 | #endif 24 | 25 | #ifndef __G_UDEV_CLIENT_H__ 26 | #define __G_UDEV_CLIENT_H__ 27 | 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define G_UDEV_TYPE_CLIENT (g_udev_client_get_type ()) 33 | #define G_UDEV_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_UDEV_TYPE_CLIENT, GUdevClient)) 34 | #define G_UDEV_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_UDEV_TYPE_CLIENT, GUdevClientClass)) 35 | #define G_UDEV_IS_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_UDEV_TYPE_CLIENT)) 36 | #define G_UDEV_IS_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_UDEV_TYPE_CLIENT)) 37 | #define G_UDEV_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_UDEV_TYPE_CLIENT, GUdevClientClass)) 38 | 39 | typedef struct _GUdevClientClass GUdevClientClass; 40 | typedef struct _GUdevClientPrivate GUdevClientPrivate; 41 | 42 | /** 43 | * GUdevClient: 44 | * 45 | * The #GUdevClient struct is opaque and should not be accessed directly. 46 | */ 47 | struct _GUdevClient 48 | { 49 | GObject parent; 50 | 51 | /*< private >*/ 52 | GUdevClientPrivate *priv; 53 | }; 54 | 55 | /** 56 | * GUdevClientClass: 57 | * @parent_class: Parent class. 58 | * @uevent: Signal class handler for the #GUdevClient::uevent signal. 59 | * 60 | * Class structure for #GUdevClient. 61 | */ 62 | struct _GUdevClientClass 63 | { 64 | GObjectClass parent_class; 65 | 66 | /* signals */ 67 | void (*uevent) (GUdevClient *client, 68 | const gchar *action, 69 | GUdevDevice *device); 70 | 71 | /*< private >*/ 72 | /* Padding for future expansion */ 73 | void (*reserved1) (void); 74 | void (*reserved2) (void); 75 | void (*reserved3) (void); 76 | void (*reserved4) (void); 77 | void (*reserved5) (void); 78 | void (*reserved6) (void); 79 | void (*reserved7) (void); 80 | void (*reserved8) (void); 81 | }; 82 | 83 | GType g_udev_client_get_type (void) G_GNUC_CONST; 84 | GUdevClient *g_udev_client_new (const gchar* const *subsystems); 85 | GList *g_udev_client_query_by_subsystem (GUdevClient *client, 86 | const gchar *subsystem); 87 | GUdevDevice *g_udev_client_query_by_device_number (GUdevClient *client, 88 | GUdevDeviceType type, 89 | GUdevDeviceNumber number); 90 | GUdevDevice *g_udev_client_query_by_device_file (GUdevClient *client, 91 | const gchar *device_file); 92 | GUdevDevice *g_udev_client_query_by_sysfs_path (GUdevClient *client, 93 | const gchar *sysfs_path); 94 | GUdevDevice *g_udev_client_query_by_subsystem_and_name (GUdevClient *client, 95 | const gchar *subsystem, 96 | const gchar *name); 97 | 98 | G_END_DECLS 99 | 100 | #endif /* __G_UDEV_CLIENT_H__ */ 101 | -------------------------------------------------------------------------------- /src/gudev/gudevenumerator.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright (C) 2008-2010 David Zeuthen 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #if !defined (_GUDEV_COMPILATION) && !defined(_GUDEV_INSIDE_GUDEV_H) 22 | #error "Only can be included directly, this file may disappear or change contents." 23 | #endif 24 | 25 | #ifndef __G_UDEV_ENUMERATOR_H__ 26 | #define __G_UDEV_ENUMERATOR_H__ 27 | 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define G_UDEV_TYPE_ENUMERATOR (g_udev_enumerator_get_type ()) 33 | #define G_UDEV_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_UDEV_TYPE_ENUMERATOR, GUdevEnumerator)) 34 | #define G_UDEV_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_UDEV_TYPE_ENUMERATOR, GUdevEnumeratorClass)) 35 | #define G_UDEV_IS_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_UDEV_TYPE_ENUMERATOR)) 36 | #define G_UDEV_IS_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_UDEV_TYPE_ENUMERATOR)) 37 | #define G_UDEV_ENUMERATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_UDEV_TYPE_ENUMERATOR, GUdevEnumeratorClass)) 38 | 39 | typedef struct _GUdevEnumeratorClass GUdevEnumeratorClass; 40 | typedef struct _GUdevEnumeratorPrivate GUdevEnumeratorPrivate; 41 | 42 | /** 43 | * GUdevEnumerator: 44 | * 45 | * The #GUdevEnumerator struct is opaque and should not be accessed directly. 46 | * 47 | * Since: 165 48 | */ 49 | struct _GUdevEnumerator 50 | { 51 | GObject parent; 52 | 53 | /*< private >*/ 54 | GUdevEnumeratorPrivate *priv; 55 | }; 56 | 57 | /** 58 | * GUdevEnumeratorClass: 59 | * @parent_class: Parent class. 60 | * 61 | * Class structure for #GUdevEnumerator. 62 | * 63 | * Since: 165 64 | */ 65 | struct _GUdevEnumeratorClass 66 | { 67 | GObjectClass parent_class; 68 | 69 | /*< private >*/ 70 | /* Padding for future expansion */ 71 | void (*reserved1) (void); 72 | void (*reserved2) (void); 73 | void (*reserved3) (void); 74 | void (*reserved4) (void); 75 | void (*reserved5) (void); 76 | void (*reserved6) (void); 77 | void (*reserved7) (void); 78 | void (*reserved8) (void); 79 | }; 80 | 81 | GType g_udev_enumerator_get_type (void) G_GNUC_CONST; 82 | GUdevEnumerator *g_udev_enumerator_new (GUdevClient *client); 83 | GUdevEnumerator *g_udev_enumerator_add_match_subsystem (GUdevEnumerator *enumerator, 84 | const gchar *subsystem); 85 | GUdevEnumerator *g_udev_enumerator_add_nomatch_subsystem (GUdevEnumerator *enumerator, 86 | const gchar *subsystem); 87 | GUdevEnumerator *g_udev_enumerator_add_match_sysfs_attr (GUdevEnumerator *enumerator, 88 | const gchar *name, 89 | const gchar *value); 90 | GUdevEnumerator *g_udev_enumerator_add_nomatch_sysfs_attr (GUdevEnumerator *enumerator, 91 | const gchar *name, 92 | const gchar *value); 93 | GUdevEnumerator *g_udev_enumerator_add_match_property (GUdevEnumerator *enumerator, 94 | const gchar *name, 95 | const gchar *value); 96 | GUdevEnumerator *g_udev_enumerator_add_match_name (GUdevEnumerator *enumerator, 97 | const gchar *name); 98 | GUdevEnumerator *g_udev_enumerator_add_match_tag (GUdevEnumerator *enumerator, 99 | const gchar *tag); 100 | GUdevEnumerator *g_udev_enumerator_add_match_is_initialized (GUdevEnumerator *enumerator); 101 | GUdevEnumerator *g_udev_enumerator_add_sysfs_path (GUdevEnumerator *enumerator, 102 | const gchar *sysfs_path); 103 | GList *g_udev_enumerator_execute (GUdevEnumerator *enumerator); 104 | 105 | G_END_DECLS 106 | 107 | #endif /* __G_UDEV_ENUMERATOR_H__ */ 108 | -------------------------------------------------------------------------------- /src/gudev/gudevenums.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright (C) 2008 David Zeuthen 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #if !defined (_GUDEV_COMPILATION) && !defined(_GUDEV_INSIDE_GUDEV_H) 22 | #error "Only can be included directly, this file may disappear or change contents." 23 | #endif 24 | 25 | #ifndef __G_UDEV_ENUMS_H__ 26 | #define __G_UDEV_ENUMS_H__ 27 | 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | /** 33 | * GUdevDeviceType: 34 | * @G_UDEV_DEVICE_TYPE_NONE: Device does not have a device file. 35 | * @G_UDEV_DEVICE_TYPE_BLOCK: Device is a block device. 36 | * @G_UDEV_DEVICE_TYPE_CHAR: Device is a character device. 37 | * 38 | * Enumeration used to specify a the type of a device. 39 | */ 40 | typedef enum 41 | { 42 | G_UDEV_DEVICE_TYPE_NONE = 0, 43 | G_UDEV_DEVICE_TYPE_BLOCK = 'b', 44 | G_UDEV_DEVICE_TYPE_CHAR = 'c', 45 | } GUdevDeviceType; 46 | 47 | G_END_DECLS 48 | 49 | #endif /* __G_UDEV_ENUMS_H__ */ 50 | -------------------------------------------------------------------------------- /src/gudev/gudevenumtypes.c.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #include 3 | 4 | /*** END file-header ***/ 5 | 6 | /*** BEGIN file-production ***/ 7 | /* enumerations from "@filename@" */ 8 | /*** END file-production ***/ 9 | 10 | /*** BEGIN value-header ***/ 11 | GType 12 | @enum_name@_get_type (void) 13 | { 14 | static volatile gsize g_define_type_id__volatile = 0; 15 | 16 | if (g_once_init_enter (&g_define_type_id__volatile)) 17 | { 18 | static const G@Type@Value values[] = { 19 | /*** END value-header ***/ 20 | 21 | /*** BEGIN value-production ***/ 22 | { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, 23 | /*** END value-production ***/ 24 | 25 | /*** BEGIN value-tail ***/ 26 | { 0, NULL, NULL } 27 | }; 28 | GType g_define_type_id = 29 | g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); 30 | g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); 31 | } 32 | 33 | return g_define_type_id__volatile; 34 | } 35 | 36 | /*** END value-tail ***/ 37 | 38 | /*** BEGIN file-tail ***/ 39 | /*** END file-tail ***/ 40 | -------------------------------------------------------------------------------- /src/gudev/gudevenumtypes.h.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | #ifndef __GUDEV_ENUM_TYPES_H__ 3 | #define __GUDEV_ENUM_TYPES_H__ 4 | 5 | #include 6 | 7 | G_BEGIN_DECLS 8 | /*** END file-header ***/ 9 | 10 | /*** BEGIN file-production ***/ 11 | 12 | /* enumerations from "@filename@" */ 13 | /*** END file-production ***/ 14 | 15 | /*** BEGIN value-header ***/ 16 | GType @enum_name@_get_type (void) G_GNUC_CONST; 17 | #define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) 18 | /*** END value-header ***/ 19 | 20 | /*** BEGIN file-tail ***/ 21 | G_END_DECLS 22 | 23 | #endif /* __GUDEV_ENUM_TYPES_H__ */ 24 | /*** END file-tail ***/ 25 | -------------------------------------------------------------------------------- /src/gudev/gudevmarshal.list: -------------------------------------------------------------------------------- 1 | VOID:STRING,OBJECT 2 | -------------------------------------------------------------------------------- /src/gudev/gudevprivate.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright (C) 2008 David Zeuthen 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #if !defined (_GUDEV_COMPILATION) && !defined(_GUDEV_INSIDE_GUDEV_H) 22 | #error "Only can be included directly, this file may disappear or change contents." 23 | #endif 24 | 25 | #ifndef __G_UDEV_PRIVATE_H__ 26 | #define __G_UDEV_PRIVATE_H__ 27 | 28 | #include 29 | 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | GUdevDevice * 35 | _g_udev_device_new (struct udev_device *udevice); 36 | 37 | struct udev *_g_udev_client_get_udev (GUdevClient *client); 38 | 39 | G_END_DECLS 40 | 41 | #endif /* __G_UDEV_PRIVATE_H__ */ 42 | -------------------------------------------------------------------------------- /src/gudev/gudevtypes.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright (C) 2008 David Zeuthen 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | * Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #if !defined (_GUDEV_COMPILATION) && !defined(_GUDEV_INSIDE_GUDEV_H) 22 | #error "Only can be included directly, this file may disappear or change contents." 23 | #endif 24 | 25 | #ifndef __G_UDEV_TYPES_H__ 26 | #define __G_UDEV_TYPES_H__ 27 | 28 | #include 29 | #include 30 | 31 | G_BEGIN_DECLS 32 | 33 | typedef struct _GUdevClient GUdevClient; 34 | typedef struct _GUdevDevice GUdevDevice; 35 | typedef struct _GUdevEnumerator GUdevEnumerator; 36 | 37 | /** 38 | * GUdevDeviceNumber: 39 | * 40 | * Corresponds to the standard #dev_t type as defined by POSIX (Until 41 | * bug 584517 is resolved this work-around is needed). 42 | */ 43 | #ifdef _GUDEV_WORK_AROUND_DEV_T_BUG 44 | typedef guint64 GUdevDeviceNumber; /* __UQUAD_TYPE */ 45 | #else 46 | typedef dev_t GUdevDeviceNumber; 47 | #endif 48 | 49 | G_END_DECLS 50 | 51 | #endif /* __G_UDEV_TYPES_H__ */ 52 | -------------------------------------------------------------------------------- /src/gudev/seed-example-enum.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env seed 2 | 3 | const GLib = imports.gi.GLib; 4 | const GUdev = imports.gi.GUdev; 5 | 6 | function print_device(device) { 7 | print(" initialized: " + device.get_is_initialized()); 8 | print(" usec since initialized: " + device.get_usec_since_initialized()); 9 | print(" subsystem: " + device.get_subsystem()); 10 | print(" devtype: " + device.get_devtype()); 11 | print(" name: " + device.get_name()); 12 | print(" number: " + device.get_number()); 13 | print(" sysfs_path: " + device.get_sysfs_path()); 14 | print(" driver: " + device.get_driver()); 15 | print(" action: " + device.get_action()); 16 | print(" seqnum: " + device.get_seqnum()); 17 | print(" device type: " + device.get_device_type()); 18 | print(" device number: " + device.get_device_number()); 19 | print(" device file: " + device.get_device_file()); 20 | print(" device file symlinks: " + device.get_device_file_symlinks()); 21 | print(" tags: " + device.get_tags()); 22 | var keys = device.get_property_keys(); 23 | for (var n = 0; n < keys.length; n++) { 24 | print(" " + keys[n] + "=" + device.get_property(keys[n])); 25 | } 26 | } 27 | 28 | var client = new GUdev.Client({subsystems: []}); 29 | var enumerator = new GUdev.Enumerator({client: client}); 30 | enumerator.add_match_subsystem('b*') 31 | 32 | var devices = enumerator.execute(); 33 | 34 | for (var n=0; n < devices.length; n++) { 35 | var device = devices[n]; 36 | print_device(device); 37 | print(""); 38 | } 39 | -------------------------------------------------------------------------------- /src/gudev/seed-example.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env seed 2 | 3 | // seed example 4 | 5 | const GLib = imports.gi.GLib; 6 | const GUdev = imports.gi.GUdev; 7 | 8 | function print_device (device) { 9 | print (" subsystem: " + device.get_subsystem ()); 10 | print (" devtype: " + device.get_devtype ()); 11 | print (" name: " + device.get_name ()); 12 | print (" number: " + device.get_number ()); 13 | print (" sysfs_path: " + device.get_sysfs_path ()); 14 | print (" driver: " + device.get_driver ()); 15 | print (" action: " + device.get_action ()); 16 | print (" seqnum: " + device.get_seqnum ()); 17 | print (" device type: " + device.get_device_type ()); 18 | print (" device number: " + device.get_device_number ()); 19 | print (" device file: " + device.get_device_file ()); 20 | print (" device file symlinks: " + device.get_device_file_symlinks ()); 21 | print (" foo: " + device.get_sysfs_attr_as_strv ("stat")); 22 | var keys = device.get_property_keys (); 23 | for (var n = 0; n < keys.length; n++) { 24 | print (" " + keys[n] + "=" + device.get_property (keys[n])); 25 | } 26 | } 27 | 28 | function on_uevent (client, action, device) { 29 | print ("action " + action + " on device " + device.get_sysfs_path()); 30 | print_device (device); 31 | print (""); 32 | } 33 | 34 | var client = new GUdev.Client ({subsystems: ["block", "usb/usb_interface"]}); 35 | client.signal.connect ("uevent", on_uevent); 36 | 37 | var block_devices = client.query_by_subsystem ("block"); 38 | for (var n = 0; n < block_devices.length; n++) { 39 | print ("block device: " + block_devices[n].get_device_file ()); 40 | } 41 | 42 | var d; 43 | 44 | d = client.query_by_device_number (GUdev.DeviceType.BLOCK, 0x0810); 45 | if (d == null) { 46 | print ("query_by_device_number 0x810 -> null"); 47 | } else { 48 | print ("query_by_device_number 0x810 -> " + d.get_device_file ()); 49 | dd = d.get_parent_with_subsystem ("usb", null); 50 | print_device (dd); 51 | print ("--------------------------------------------------------------------------"); 52 | while (d != null) { 53 | print_device (d); 54 | print (""); 55 | d = d.get_parent (); 56 | } 57 | } 58 | 59 | d = client.query_by_sysfs_path ("/sys/block/sda/sda1"); 60 | print ("query_by_sysfs_path (\"/sys/block/sda1\") -> " + d.get_device_file ()); 61 | 62 | d = client.query_by_subsystem_and_name ("block", "sda2"); 63 | print ("query_by_subsystem_and_name (\"block\", \"sda2\") -> " + d.get_device_file ()); 64 | 65 | d = client.query_by_device_file ("/dev/sda"); 66 | print ("query_by_device_file (\"/dev/sda\") -> " + d.get_device_file ()); 67 | 68 | d = client.query_by_device_file ("/dev/block/8:0"); 69 | print ("query_by_device_file (\"/dev/block/8:0\") -> " + d.get_device_file ()); 70 | 71 | var mainloop = GLib.main_loop_new (); 72 | GLib.main_loop_run (mainloop); 73 | -------------------------------------------------------------------------------- /src/keymap/.gitignore: -------------------------------------------------------------------------------- 1 | keyboard-force-release.sh 2 | keys-from-name.gperf 3 | keys-from-name.h 4 | keys-to-name.h 5 | keys.txt 6 | -------------------------------------------------------------------------------- /src/keymap/95-keyboard-force-release.rules: -------------------------------------------------------------------------------- 1 | # Set model specific atkbd force_release quirk 2 | # 3 | # Several laptops have hotkeys which don't generate release events, 4 | # which can cause problems with software key repeat. 5 | # The atkbd driver has a quirk handler for generating synthetic 6 | # release events, which can be configured via sysfs since 2.6.32. 7 | # Simply add a file with a list of scancodes for your laptop model 8 | # in /usr/lib/udev/keymaps, and add a rule here. 9 | # If the hotkeys also need a keymap assignment you can copy the 10 | # scancodes from the keymap file, otherwise you can run 11 | # /usr/lib/udev/keymap -i /dev/input/eventX 12 | # on a Linux vt to find out. 13 | 14 | ACTION=="remove", GOTO="force_release_end" 15 | SUBSYSTEM!="serio", GOTO="force_release_end" 16 | KERNEL!="serio*", GOTO="force_release_end" 17 | DRIVER!="atkbd", GOTO="force_release_end" 18 | 19 | ENV{DMI_VENDOR}="$attr{[dmi/id]sys_vendor}" 20 | 21 | ENV{DMI_VENDOR}=="[sS][aA][mM][sS][uU][nN][gG]*", RUN+="keyboard-force-release.sh $devpath samsung-other" 22 | ENV{DMI_VENDOR}=="[sS][aA][mM][sS][uU][nN][gG]*", ATTR{[dmi/id]product_name}=="*90X3A*", RUN+="keyboard-force-release.sh $devpath samsung-90x3a" 23 | 24 | ENV{DMI_VENDOR}=="Dell Inc.", ATTR{[dmi/id]product_name}=="Studio 1557|Studio 1558", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 25 | ENV{DMI_VENDOR}=="Dell Inc.", ATTR{[dmi/id]product_name}=="Latitude E*|Precision M*", RUN+="keyboard-force-release.sh $devpath dell-touchpad" 26 | ENV{DMI_VENDOR}=="Dell Inc.", ATTR{[dmi/id]product_name}=="XPS*", RUN+="keyboard-force-release.sh $devpath dell-xps" 27 | 28 | ENV{DMI_VENDOR}=="FUJITSU SIEMENS", ATTR{[dmi/id]product_name}=="AMILO Si 1848+u|AMILO Xi 2428", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 29 | 30 | ENV{DMI_VENDOR}=="FOXCONN", ATTR{[dmi/id]product_name}=="QBOOK", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 31 | 32 | ENV{DMI_VENDOR}=="MTC", ATTR{[dmi/id]product_version}=="A0", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 33 | 34 | ENV{DMI_VENDOR}=="PEGATRON CORP.", ATTR{[dmi/id]product_name}=="Spring Peak", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 35 | 36 | ENV{DMI_VENDOR}=="TOSHIBA", ATTR{[dmi/id]product_name}=="Satellite [uU]300*|Satellite Pro [uU]300*|Satellite [uU]305*|SATELLITE [uU]500*", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 37 | 38 | ENV{DMI_VENDOR}=="Viooo Corporation", ATTR{[dmi/id]product_name}=="PT17", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 39 | 40 | # These are all the HP laptops that setup a touchpad toggle key 41 | ENV{DMI_VENDOR}=="Hewlett-Packard*", ATTR{[dmi/id]product_name}=="*[pP][aA][vV][iI][lL][iI][oO][nN]*", RUN+="keyboard-force-release.sh $devpath hp-other" 42 | ENV{DMI_VENDOR}=="Hewlett-Packard*", ATTR{[dmi/id]product_name}=="*[tT][xX]2*", RUN+="keyboard-force-release.sh $devpath hp-other" 43 | ENV{DMI_VENDOR}=="Hewlett-Packard*", ATTR{[dmi/id]product_name}=="*2510p*|*2530p*|HP G60 Notebook PC", RUN+="keyboard-force-release.sh $devpath hp-other" 44 | 45 | ENV{DMI_VENDOR}=="Zepto", ATTR{[dmi/id]product_name}=="Znote 6615WD", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 46 | 47 | ENV{DMI_VENDOR}=="Zepto", ATTR{[dmi/id]product_name}=="Znote", ATTR{[dmi/id]product_version}=="6625WD", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 48 | 49 | ENV{DMI_VENDOR}=="HANNspree", ATTR{[dmi/id]product_name}=="SN10E100", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 50 | 51 | ENV{DMI_VENDOR}=="GIGABYTE", ATTR{[dmi/id]product_name}=="i1520M", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 52 | 53 | ENV{DMI_VENDOR}=="BenQ", ATTR{[dmi/id]product_name}=="*nScreen*", RUN+="keyboard-force-release.sh $devpath common-volume-keys" 54 | 55 | LABEL="force_release_end" 56 | -------------------------------------------------------------------------------- /src/keymap/README.keymap.txt: -------------------------------------------------------------------------------- 1 | = The udev keymap tool = 2 | 3 | == Introduction == 4 | 5 | This udev extension configures computer model specific key mappings. This is 6 | particularly necessary for the non-standard extra keys found on many laptops, 7 | such as "brightness up", "next song", "www browser", or "suspend". Often these 8 | are accessed with the Fn key. 9 | 10 | Every key produces a "scan code", which is highly vendor/model specific for the 11 | nonstandard keys. This tool maintains mappings for these scan codes to standard 12 | "key codes", which denote the "meaning" of the key. The key codes are defined 13 | in /usr/include/linux/input.h. 14 | 15 | If some of your keys on your keyboard are not working at all, or produce the 16 | wrong effect, then a very likely cause of this is that the scan code -> key 17 | code mapping is incorrect on your computer. 18 | 19 | == Structure == 20 | 21 | udev-keymap consists of the following parts: 22 | 23 | keymaps/*:: mappings of scan codes to key code names 24 | 25 | 95-keymap.rules:: udev rules for mapping system vendor/product names and 26 | input module names to one of the keymaps above 27 | 28 | keymap:: manipulate an evdev input device: 29 | * write a key map file into a device (used by udev rules) 30 | * dump current scan → key code mapping 31 | * interactively display scan and key codes of pressed keys 32 | 33 | findkeyboards:: display evdev input devices which belong to actual keyboards, 34 | i. e. those suitable for the keymap program 35 | 36 | fdi2rules.py:: convert hal keymap FDIs into udev rules and key map files 37 | (Please note that this is far from perfect, since the mapping between fdi and 38 | udev rules is not straightforward, and impossible in some cases.) 39 | 40 | == Fixing broken keys == 41 | 42 | In order to make a broken key work on your system and send it back to upstream 43 | for inclusion you need to do the following steps: 44 | 45 | 1. Find the keyboard device. 46 | 47 | Run /usr/lib/udev/findkeyboards. This should always give you an "AT 48 | keyboard" and possibly a "module". Some laptops (notably Thinkpads, Sonys, and 49 | Acers) have multimedia/function keys on a separate input device instead of the 50 | primary keyboard. The keyboard device should have a name like "input/event3". 51 | In the following commands, the name will be written as "input/eventX" (replace 52 | X with the appropriate number). 53 | 54 | 2. Find broken scan codes: 55 | 56 | sudo /usr/lib/udev/keymap -i input/eventX 57 | 58 | Press all multimedia/function keys and check if the key name that gets printed 59 | out is plausible. If it is unknown or wrong, write down the scan code (looks 60 | like "0x1E") and the intended functionality of this key. Look in 61 | /usr/include/linux/input.h for an available KEY_XXXXX constant which most 62 | closely approximates this functionality and write it down as the new key code. 63 | 64 | For example, you might press a key labeled "web browser" which currently 65 | produces "unknown". Note down this: 66 | 67 | 0x1E www # Fn+F2 web browser 68 | 69 | Repeat that for all other keys. Write the resulting list into a file. Look at 70 | /usr/lib/udev/keymaps/ for existing key map files and make sure that you use the 71 | same structure. 72 | 73 | If the key only ever works once and then your keyboard (or the entire desktop) 74 | gets stuck for a long time, then it is likely that the BIOS fails to send a 75 | corresponding "key release" event after the key press event. Please note down 76 | this case as well, as it can be worked around in 77 | /usr/lib/udev/keymaps/95-keyboard-force-release.rules . 78 | 79 | 3. Find out your system vendor and product: 80 | 81 | cat /sys/class/dmi/id/sys_vendor 82 | cat /sys/class/dmi/id/product_name 83 | 84 | 4. Generate a device dump with "udevadm info --export-db > /tmp/udev-db.txt". 85 | 86 | 6. Send the system vendor/product names, the key mapping from step 2, 87 | and /tmp/udev-db.txt from step 4 to the linux-hotplug@vger.kernel.org mailing 88 | list, so that they can be included in the next release. 89 | 90 | For local testing, copy your map file to /usr/lib/udev/keymaps/ with an appropriate 91 | name, and add an appropriate udev rule to /usr/lib/udev/rules.d/95-keymap.rules: 92 | 93 | * If you selected an "AT keyboard", add the rule to the section after 94 | 'LABEL="keyboard_vendorcheck"'. 95 | 96 | * If you selected a "module", add the rule to the top section where the 97 | "ThinkPad Extra Buttons" are. 98 | 99 | == Author == 100 | 101 | keymap is written and maintained by Martin Pitt . 102 | -------------------------------------------------------------------------------- /src/keymap/check-keymaps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # check that all key names in keymaps/* are known in 4 | # and that all key maps listed in the rules are valid and present in 5 | # Makefile.am 6 | SRCDIR=${1:-.} 7 | KEYLIST=${2:-src/keymap/keys.txt} 8 | KEYMAPS_DIR=$SRCDIR/src/keymap/keymaps 9 | RULES=$SRCDIR/src/keymap/95-keymap.rules 10 | 11 | [ -e "$KEYLIST" ] || { 12 | echo "need $KEYLIST please build first" >&2 13 | exit 1 14 | } 15 | 16 | missing=$(join -v 2 <(awk '{print tolower(substr($1,5))}' $KEYLIST | sort -u) \ 17 | <(grep -hv '^#' ${KEYMAPS_DIR}/*| awk '{print $2}' | sort -u)) 18 | [ -z "$missing" ] || { 19 | echo "ERROR: unknown key names in src/keymap/keymaps/*:" >&2 20 | echo "$missing" >&2 21 | exit 1 22 | } 23 | 24 | # check that all maps referred to in $RULES exist 25 | maps=$(sed -rn '/keymap \$name/ { s/^.*\$name ([^"[:space:]]+).*$/\1/; p }' $RULES) 26 | for m in $maps; do 27 | # ignore inline mappings 28 | [ "$m" = "${m#0x}" ] || continue 29 | 30 | [ -e ${KEYMAPS_DIR}/$m ] || { 31 | echo "ERROR: unknown map name in $RULES: $m" >&2 32 | exit 1 33 | } 34 | grep -q "src/keymap/keymaps/$m\>" $SRCDIR/Makefile.am || { 35 | echo "ERROR: map file $m is not added to Makefile.am" >&2 36 | exit 1 37 | } 38 | done 39 | -------------------------------------------------------------------------------- /src/keymap/findkeyboards: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # Find "real" keyboard devices and print their device path. 3 | # Author: Martin Pitt 4 | # 5 | # Copyright (C) 2009, Canonical Ltd. 6 | # 7 | # This program is free software; you can redistribute it and/or modify it 8 | # under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # General Public License for more details. 16 | 17 | # returns OK if $1 contains $2 18 | strstr() { 19 | [ "${1#*$2*}" != "$1" ] 20 | } 21 | 22 | # returns OK if $1 contains $2 at the beginning 23 | str_starts() { 24 | [ "${1#$2*}" != "$1" ] 25 | } 26 | 27 | str_line_starts() { 28 | while read a; do str_starts "$a" "$1" && return 0;done 29 | return 1; 30 | } 31 | 32 | # print a list of input devices which are keyboard-like 33 | keyboard_devices() { 34 | # standard AT keyboard 35 | for dev in `udevadm trigger --dry-run --verbose --property-match=ID_INPUT_KEYBOARD=1`; do 36 | walk=`udevadm info --attribute-walk --path=$dev` 37 | env=`udevadm info --query=env --path=$dev` 38 | # filter out non-event devices, such as the parent input devices which have no devnode 39 | if ! echo "$env" | str_line_starts 'DEVNAME='; then 40 | continue 41 | fi 42 | if strstr "$walk" 'DRIVERS=="atkbd"'; then 43 | echo -n 'AT keyboard: ' 44 | elif echo "$env" | str_line_starts 'ID_USB_DRIVER=usbhid'; then 45 | echo -n 'USB keyboard: ' 46 | else 47 | echo -n 'Unknown type: ' 48 | fi 49 | udevadm info --query=name --path=$dev 50 | done 51 | 52 | # modules 53 | module=$(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='*Extra Buttons') 54 | module="$module 55 | $(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='*extra buttons')" 56 | module="$module 57 | $(udevadm trigger --verbose --dry-run --subsystem-match=input --attr-match=name='Sony Vaio Keys')" 58 | for m in $module; do 59 | for evdev in $m/event*/dev; do 60 | if [ -e "$evdev" ]; then 61 | echo -n 'module: ' 62 | udevadm info --query=name --path=${evdev%%/dev} 63 | fi 64 | done 65 | done 66 | } 67 | 68 | keyboard_devices 69 | -------------------------------------------------------------------------------- /src/keymap/force-release-maps/common-volume-keys: -------------------------------------------------------------------------------- 1 | 0xa0 #mute 2 | 0xae #volume down 3 | 0xb0 #volume up 4 | -------------------------------------------------------------------------------- /src/keymap/force-release-maps/dell-touchpad: -------------------------------------------------------------------------------- 1 | 0x9E 2 | -------------------------------------------------------------------------------- /src/keymap/force-release-maps/dell-xps: -------------------------------------------------------------------------------- 1 | 0x8C 2 | -------------------------------------------------------------------------------- /src/keymap/force-release-maps/hp-other: -------------------------------------------------------------------------------- 1 | # list of scancodes (hex or decimal), optional comment 2 | 0xd8 # Touchpad off 3 | 0xd9 # Touchpad on 4 | -------------------------------------------------------------------------------- /src/keymap/force-release-maps/samsung-90x3a: -------------------------------------------------------------------------------- 1 | # list of scancodes (hex or decimal), optional comment 2 | 0xCE # Fn+F8 keyboard backlit up 3 | 0x8D # Fn+F7 keyboard backlit down 4 | 0x97 # Fn+F12 wifi on/off 5 | 0x96 # Fn+F1 performance mode (?) 6 | 0xD5 # Fn+F6 battery life extender 7 | -------------------------------------------------------------------------------- /src/keymap/force-release-maps/samsung-other: -------------------------------------------------------------------------------- 1 | # list of scancodes (hex or decimal), optional comment 2 | 0x82 # Fn+F4 CRT/LCD 3 | 0x83 # Fn+F2 battery 4 | 0x84 # Fn+F5 backlight on/off 5 | 0x86 # Fn+F9 WLAN 6 | 0x88 # Fn-Up brightness up 7 | 0x89 # Fn-Down brightness down 8 | 0xB3 # Fn+F8 switch power mode (battery/dynamic/performance) 9 | 0xF7 # Fn+F10 Touchpad on 10 | 0xF9 # Fn+F10 Touchpad off 11 | -------------------------------------------------------------------------------- /src/keymap/keyboard-force-release.sh.in: -------------------------------------------------------------------------------- 1 | #!@rootprefix@/bin/sh -e 2 | # read list of scancodes, convert hex to decimal and 3 | # append to the atkbd force_release sysfs attribute 4 | # $1 sysfs devpath for serioX 5 | # $2 file with scancode list (hex or dec) 6 | 7 | case "$2" in 8 | /*) scf="$2" ;; 9 | *) scf="@pkglibexecdir@/keymaps/force-release/$2" ;; 10 | esac 11 | 12 | read attr <"/sys/$1/force_release" 13 | while read scancode dummy; do 14 | case "$scancode" in 15 | \#*) ;; 16 | *) 17 | scancode=$(($scancode)) 18 | attr="$attr${attr:+,}$scancode" 19 | ;; 20 | esac 21 | done <"$scf" 22 | echo "$attr" >"/sys/$1/force_release" 23 | -------------------------------------------------------------------------------- /src/keymap/keymaps/acer: -------------------------------------------------------------------------------- 1 | 0xA5 help # Fn+F1 2 | 0xA6 setup # Fn+F2 Acer eSettings 3 | 0xA7 battery # Fn+F3 Power Management 4 | 0xA9 switchvideomode # Fn+F5 5 | 0xB3 euro 6 | 0xB4 dollar 7 | 0xCE brightnessup # Fn+Right 8 | 0xD4 bluetooth # (toggle) off-to-on 9 | 0xD5 wlan # (toggle) on-to-off 10 | 0xD6 wlan # (toggle) off-to-on 11 | 0xD7 bluetooth # (toggle) on-to-off 12 | 0xD8 bluetooth # (toggle) off-to-on 13 | 0xD9 brightnessup # Fn+Right 14 | 0xEE brightnessup # Fn+Right 15 | 0xEF brightnessdown # Fn+Left 16 | 0xF1 f22 # Fn+F7 Touchpad toggle (off-to-on) 17 | 0xF2 f23 # Fn+F7 Touchpad toggle (on-to-off) 18 | 0xF3 prog2 # "P2" programmable button 19 | 0xF4 prog1 # "P1" programmable button 20 | 0xF5 presentation 21 | 0xF8 fn 22 | 0xF9 f23 # Launch NTI shadow 23 | -------------------------------------------------------------------------------- /src/keymap/keymaps/acer-aspire_5720: -------------------------------------------------------------------------------- 1 | 0x84 bluetooth # sent when bluetooth module missing, and key pressed 2 | 0x92 media # acer arcade 3 | 0xD4 bluetooth # bluetooth on 4 | 0xD9 bluetooth # bluetooth off 5 | -------------------------------------------------------------------------------- /src/keymap/keymaps/acer-aspire_5920g: -------------------------------------------------------------------------------- 1 | 0x8A media 2 | 0x92 media 3 | 0xA6 setup 4 | 0xB2 www 5 | 0xD9 bluetooth # (toggle) on-to-off 6 | -------------------------------------------------------------------------------- /src/keymap/keymaps/acer-aspire_6920: -------------------------------------------------------------------------------- 1 | 0xD9 bluetooth # (toggle) on-to-off 2 | 0x92 media 3 | 0x9E back 4 | 0x83 rewind 5 | 0x89 fastforward 6 | -------------------------------------------------------------------------------- /src/keymap/keymaps/acer-aspire_8930: -------------------------------------------------------------------------------- 1 | 0xCA prog3 # key 'HOLD' on cine dash media console 2 | 0x83 rewind 3 | 0x89 fastforward 4 | 0x92 media # key 'ARCADE' on cine dash media console 5 | 0x9E back 6 | -------------------------------------------------------------------------------- /src/keymap/keymaps/acer-travelmate_c300: -------------------------------------------------------------------------------- 1 | 0x67 f24 # FIXME: rotate screen 2 | 0x68 up 3 | 0x69 down 4 | 0x6B fn 5 | 0x6C screenlock # FIXME: lock tablet device/buttons 6 | -------------------------------------------------------------------------------- /src/keymap/keymaps/asus: -------------------------------------------------------------------------------- 1 | 0xED volumeup 2 | 0xEE volumedown 3 | 0xEF mute 4 | -------------------------------------------------------------------------------- /src/keymap/keymaps/compaq-e_evo: -------------------------------------------------------------------------------- 1 | 0xA3 www # I key 2 | 0x9A search 3 | 0x9E email 4 | 0x9F homepage 5 | -------------------------------------------------------------------------------- /src/keymap/keymaps/dell: -------------------------------------------------------------------------------- 1 | 0x81 playpause # Play/Pause 2 | 0x82 stopcd # Stop 3 | 0x83 previoussong # Previous song 4 | 0x84 nextsong # Next song 5 | 0x85 brightnessdown # Fn+Down arrow Brightness Down 6 | 0x86 brightnessup # Fn+Up arrow Brightness Up 7 | 0x87 battery # Fn+F3 battery icon 8 | 0x88 unknown # Fn+F2 Turn On/Off Wireless - handled in hardware 9 | 0x89 ejectclosecd # Fn+F10 Eject CD 10 | 0x8A suspend # Fn+F1 hibernate 11 | 0x8B switchvideomode # Fn+F8 CRT/LCD (high keycode: "displaytoggle") 12 | 0x8C f23 # Fn+Right arrow Auto Brightness 13 | 0x8F switchvideomode # Fn+F7 aspect ratio 14 | 0x90 previoussong # Front panel previous song 15 | 0x91 prog1 # Wifi Catcher (DELL Specific) 16 | 0x92 media # MediaDirect button (house icon) 17 | 0x93 f23 # FIXME Fn+Left arrow Auto Brightness 18 | 0x95 camera # Shutter button Takes a picture if optional camera available 19 | 0x97 email # Tablet email button 20 | 0x98 f21 # FIXME: Tablet screen rotatation 21 | 0x99 nextsong # Front panel next song 22 | 0x9A setup # Tablet tools button 23 | 0x9B switchvideomode # Display Toggle button 24 | 0x9E f21 #touchpad toggle 25 | 0xA2 playpause # Front panel play/pause 26 | 0xA4 stopcd # Front panel stop 27 | 0xED media # MediaDirect button 28 | 0xD8 screenlock # FIXME: Tablet lock button 29 | 0xD9 f21 # touchpad toggle 30 | -------------------------------------------------------------------------------- /src/keymap/keymaps/dell-latitude-xt2: -------------------------------------------------------------------------------- 1 | 0x9B up # tablet rocker up 2 | 0x9E enter # tablet rocker press 3 | 0x9F back # tablet back 4 | 0xA3 down # tablet rocker down 5 | -------------------------------------------------------------------------------- /src/keymap/keymaps/everex-xt5000: -------------------------------------------------------------------------------- 1 | 0x5C media 2 | 0x65 f21 # Fn+F5 Touchpad toggle 3 | 0x67 prog3 # Fan Speed Control button 4 | 0x6F brightnessup 5 | 0x7F brightnessdown 6 | 0xB2 www 7 | 0xEC mail 8 | -------------------------------------------------------------------------------- /src/keymap/keymaps/fujitsu-amilo_li_2732: -------------------------------------------------------------------------------- 1 | 0xD9 brightnessdown # Fn+F8 brightness down 2 | 0xEF brightnessup # Fn+F9 brightness up 3 | 0xA9 switchvideomode # Fn+F10 Cycle between available video outputs 4 | -------------------------------------------------------------------------------- /src/keymap/keymaps/fujitsu-amilo_pa_2548: -------------------------------------------------------------------------------- 1 | 0xE0 volumedown 2 | 0xE1 volumeup 3 | 0xE5 prog1 4 | -------------------------------------------------------------------------------- /src/keymap/keymaps/fujitsu-amilo_pro_edition_v3505: -------------------------------------------------------------------------------- 1 | 0xA5 help # Fn-F1 2 | 0xA9 switchvideomode # Fn-F3 3 | 0xD9 brightnessdown # Fn-F8 4 | 0xE0 brightnessup # Fn-F9 5 | -------------------------------------------------------------------------------- /src/keymap/keymaps/fujitsu-amilo_pro_v3205: -------------------------------------------------------------------------------- 1 | 0xF4 f21 # FIXME: silent-mode decrease CPU/GPU clock 2 | 0xF7 switchvideomode # Fn+F3 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/fujitsu-amilo_si_1520: -------------------------------------------------------------------------------- 1 | 0xE1 wlan 2 | 0xF3 wlan 3 | 0xEE brightnessdown 4 | 0xE0 brightnessup 5 | 0xE2 bluetooth 6 | 0xF7 video 7 | -------------------------------------------------------------------------------- /src/keymap/keymaps/fujitsu-esprimo_mobile_v5: -------------------------------------------------------------------------------- 1 | 0xA9 switchvideomode 2 | 0xD9 brightnessdown 3 | 0xDF sleep 4 | 0xEF brightnessup 5 | -------------------------------------------------------------------------------- /src/keymap/keymaps/fujitsu-esprimo_mobile_v6: -------------------------------------------------------------------------------- 1 | 0xCE brightnessup 2 | 0xEF brightnessdown 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/genius-slimstar-320: -------------------------------------------------------------------------------- 1 | # Genius SlimStar 320 2 | # 3 | # Only buttons which are not properly mapped yet are configured below 4 | 5 | # "Scroll wheel", a circular up/down/left/right button. Aimed for scolling, 6 | # but since there are no scrollleft/scrollright, let's map to back/forward. 7 | 0x900f0 scrollup 8 | 0x900f1 scrolldown 9 | 0x900f3 back 10 | 0x900f2 forward 11 | 12 | # Multimedia buttons, left side (from left to right) 13 | # [W] 14 | 0x900f5 wordprocessor 15 | # [Ex] 16 | 0x900f6 spreadsheet 17 | # [P] 18 | 0x900f4 presentation 19 | # Other five (calculator, playpause, stop, mute and eject) are OK 20 | 21 | # Right side, from left to right 22 | # [e] 23 | 0xc0223 www 24 | # "man" 25 | 0x900f7 chat 26 | # "Y" 27 | 0x900fb prog1 28 | # [X] 29 | 0x900f8 close 30 | # "picture" 31 | 0x900f9 graphicseditor 32 | # "two windows" 33 | 0x900fd scale 34 | # "lock" 35 | 0x900fc screenlock 36 | -------------------------------------------------------------------------------- /src/keymap/keymaps/hewlett-packard: -------------------------------------------------------------------------------- 1 | 0x81 fn_esc 2 | 0x89 battery # FnF8 3 | 0x8A screenlock # FnF6 4 | 0x8B camera 5 | 0x8C media # music 6 | 0x8E dvd 7 | 0xB1 help 8 | 0xB3 f23 # FIXME: Auto brightness 9 | 0xD7 wlan 10 | 0x92 brightnessdown # FnF7 (FnF9 on 6730b) 11 | 0x97 brightnessup # FnF8 (FnF10 on 6730b) 12 | 0xEE switchvideomode # FnF4 13 | -------------------------------------------------------------------------------- /src/keymap/keymaps/hewlett-packard-2510p_2530p: -------------------------------------------------------------------------------- 1 | 0xD8 f23 # touchpad off 2 | 0xD9 f22 # touchpad on 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/hewlett-packard-compaq_elitebook: -------------------------------------------------------------------------------- 1 | 0x88 presentation 2 | 0xD9 help # I key (high keycode: "info") 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/hewlett-packard-pavilion: -------------------------------------------------------------------------------- 1 | 0x88 media # FIXME: quick play 2 | 0xD8 f23 # touchpad off 3 | 0xD9 f22 # touchpad on 4 | -------------------------------------------------------------------------------- /src/keymap/keymaps/hewlett-packard-presario-2100: -------------------------------------------------------------------------------- 1 | 0xF0 help 2 | 0xF1 screenlock 3 | 0xF3 search 4 | -------------------------------------------------------------------------------- /src/keymap/keymaps/hewlett-packard-tablet: -------------------------------------------------------------------------------- 1 | 0x82 prog2 # Funny Key 2 | 0x83 prog1 # Q 3 | 0x84 tab 4 | 0x85 esc 5 | 0x86 pageup 6 | 0x87 pagedown 7 | -------------------------------------------------------------------------------- /src/keymap/keymaps/hewlett-packard-tx2: -------------------------------------------------------------------------------- 1 | 0xC2 media 2 | 0xD8 f23 # Toggle touchpad button on tx2 (OFF) 3 | 0xD9 f22 # Toggle touchpad button on tx2 (ON) 4 | -------------------------------------------------------------------------------- /src/keymap/keymaps/ibm-thinkpad-usb-keyboard-trackpoint: -------------------------------------------------------------------------------- 1 | 0x900f0 screenlock 2 | 0x900f1 wlan 3 | 0x900f2 switchvideomode 4 | 0x900f3 suspend 5 | 0x900f4 brightnessup 6 | 0x900f5 brightnessdown 7 | 0x900f8 zoom 8 | -------------------------------------------------------------------------------- /src/keymap/keymaps/inventec-symphony_6.0_7.0: -------------------------------------------------------------------------------- 1 | 0xF3 prog2 2 | 0xF4 prog1 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/lenovo-3000: -------------------------------------------------------------------------------- 1 | 0x8B switchvideomode # Fn+F7 video 2 | 0x96 wlan # Fn+F5 wireless 3 | 0x97 sleep # Fn+F4 suspend 4 | 0x98 suspend # Fn+F12 hibernate 5 | 0xB4 prog1 # Lenovo Care 6 | -------------------------------------------------------------------------------- /src/keymap/keymaps/lenovo-ideapad: -------------------------------------------------------------------------------- 1 | # Key codes observed on S10-3, assumed valid on other IdeaPad models 2 | 0x81 rfkill # does nothing in BIOS 3 | 0x83 display_off # BIOS toggles screen state 4 | 0xB9 brightnessup # does nothing in BIOS 5 | 0xBA brightnessdown # does nothing in BIOS 6 | 0xF1 camera # BIOS toggles camera power 7 | 0xf2 f21 # touchpad toggle (key alternately emits f2 and f3) 8 | 0xf3 f21 9 | -------------------------------------------------------------------------------- /src/keymap/keymaps/lenovo-thinkpad-usb-keyboard-trackpoint: -------------------------------------------------------------------------------- 1 | 0x90012 screenlock # Fn+F2 2 | 0x90013 battery # Fn+F3 3 | 0x90014 wlan # Fn+F5 4 | 0x90016 switchvideomode # Fn+F7 5 | 0x90017 f21 # Fn+F8 touchpadtoggle 6 | 0x90019 suspend # Fn+F12 7 | 0x9001A brightnessup # Fn+Home 8 | 0x9001B brightnessdown # Fn+End 9 | 0x9001D zoom # Fn+Space 10 | 0x90011 prog1 # Thinkvantage button 11 | 12 | 0x90015 camera # Fn+F6 headset/camera VoIP key ?? 13 | 0x90010 micmute # Microphone mute button 14 | -------------------------------------------------------------------------------- /src/keymap/keymaps/lenovo-thinkpad_x200_tablet: -------------------------------------------------------------------------------- 1 | 0x5D menu 2 | 0x63 fn 3 | 0x66 screenlock 4 | 0x67 cyclewindows # bezel circular arrow 5 | 0x68 setup # bezel setup / menu 6 | 0x6c direction # rotate screen 7 | -------------------------------------------------------------------------------- /src/keymap/keymaps/lenovo-thinkpad_x6_tablet: -------------------------------------------------------------------------------- 1 | 0x6C f21 # rotate 2 | 0x68 screenlock # screenlock 3 | 0x6B esc # escape 4 | 0x6D right # right on d-pad 5 | 0x6E left # left on d-pad 6 | 0x71 up # up on d-pad 7 | 0x6F down # down on d-pad 8 | 0x69 enter # enter on d-pad 9 | -------------------------------------------------------------------------------- /src/keymap/keymaps/lg-x110: -------------------------------------------------------------------------------- 1 | 0xA0 mute # Fn-F9 2 | 0xAE volumedown # Fn-Left 3 | 0xAF search # Fn-F3 4 | 0xB0 volumeup # Fn-Right 5 | 0xB1 battery # Fn-F10 Info 6 | 0xB3 suspend # Fn-F12 7 | 0xDF sleep # Fn-F4 8 | # 0xE2 bluetooth # satellite dish2 9 | 0xE4 f21 # Fn-F5 Touchpad disable 10 | 0xF6 wlan # Fn-F6 11 | 0xF7 reserved # brightnessdown # Fn-Down 12 | 0xF8 reserved # brightnessup # Fn-Up 13 | -------------------------------------------------------------------------------- /src/keymap/keymaps/logitech-wave: -------------------------------------------------------------------------------- 1 | 0x9001C scale #expo 2 | 0x9001F zoomout #zoom out 3 | 0x90020 zoomin #zoom in 4 | 0x9003D prog1 #gadget 5 | 0x90005 camera #camera 6 | 0x90018 media #media center 7 | 0x90041 wordprocessor #fn+f1 (word) 8 | 0x90042 spreadsheet #fn+f2 (excel) 9 | 0x90043 calendar #fn+f3 (calendar) 10 | 0x90044 prog2 #fn+f4 (program a) 11 | 0x90045 prog3 #fn+f5 (program b) 12 | 0x90046 prog4 #fn+f6 (program c) 13 | 0x90048 messenger #fn+f8 (msn messenger) 14 | 0x9002D find #fn+f10 (search www) 15 | 0x9004B search #fn+f11 (search pc) 16 | 0x9004C ejectclosecd #fn+f12 (eject) 17 | -------------------------------------------------------------------------------- /src/keymap/keymaps/logitech-wave-cordless: -------------------------------------------------------------------------------- 1 | 0xD4 zoomin 2 | 0xCC zoomout 3 | 0xC0183 media 4 | 0xC1005 camera 5 | 0xC101F zoomout 6 | 0xC1020 zoomin 7 | 0xC1041 wordprocessor 8 | 0xC1042 spreadsheet 9 | 0xC1043 calendar 10 | 0xC1044 prog2 #fn+f4 (program a) 11 | 0xC1045 prog3 #fn+f5 (program b) 12 | 0xC1046 prog4 #fn+f6 (program c) 13 | 0xC1048 messenger 14 | 0xC104A find #fn+f10 (search www) 15 | 0xC104C ejectclosecd 16 | -------------------------------------------------------------------------------- /src/keymap/keymaps/logitech-wave-pro-cordless: -------------------------------------------------------------------------------- 1 | 0xC01B6 camera 2 | 0xC0183 media 3 | 0xC0184 wordprocessor 4 | 0xC0186 spreadsheet 5 | 0xC018E calendar 6 | 0xC0223 homepage 7 | 0xC01BC messenger 8 | 0xC018A mail 9 | 0xC0221 search 10 | 0xC00B8 ejectcd 11 | 0xC022D zoomin 12 | 0xC022E zoomout 13 | -------------------------------------------------------------------------------- /src/keymap/keymaps/maxdata-pro_7000: -------------------------------------------------------------------------------- 1 | 0x97 prog2 2 | 0x9F prog1 3 | 0xA0 mute # Fn-F5 4 | 0x82 www 5 | 0xEC email 6 | 0xAE volumedown # Fn-Down 7 | 0xB0 volumeup # Fn-Up 8 | 0xDF suspend # Fn+F2 9 | 0xF5 help 10 | -------------------------------------------------------------------------------- /src/keymap/keymaps/medion-fid2060: -------------------------------------------------------------------------------- 1 | 0x6B channeldown # Thottle Down 2 | 0x6D channelup # Thottle Up 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/medionnb-a555: -------------------------------------------------------------------------------- 1 | 0x63 www # N button 2 | 0x66 prog1 # link 1 button 3 | 0x67 email # envelope button 4 | 0x69 prog2 # link 2 button 5 | -------------------------------------------------------------------------------- /src/keymap/keymaps/micro-star: -------------------------------------------------------------------------------- 1 | 0xA0 mute # Fn-F9 2 | 0xAE volumedown # Fn-F7 3 | 0xB0 volumeup # Fn-F8 4 | 0xB2 www # e button 5 | 0xDF sleep # Fn-F12 6 | 0xE2 bluetooth # satellite dish2 7 | 0xE4 f21 # Fn-F3 Touchpad disable 8 | 0xEC email # envelope button 9 | 0xEE camera # Fn-F6 camera disable 10 | 0xF6 wlan # satellite dish1 11 | 0xF7 brightnessdown # Fn-F4 12 | 0xF8 brightnessup # Fn-F5 13 | 0xF9 search 14 | -------------------------------------------------------------------------------- /src/keymap/keymaps/module-asus-w3j: -------------------------------------------------------------------------------- 1 | 0x41 nextsong 2 | 0x45 playpause 3 | 0x43 stopcd 4 | 0x40 previoussong 5 | 0x4C ejectclosecd 6 | 0x32 mute 7 | 0x31 volumedown 8 | 0x30 volumeup 9 | 0x5D wlan 10 | 0x7E bluetooth 11 | 0x8A media # high keycode: "tv" 12 | -------------------------------------------------------------------------------- /src/keymap/keymaps/module-ibm: -------------------------------------------------------------------------------- 1 | 0x01 battery # Fn+F2 2 | 0x02 screenlock # Fn+F3 3 | 0x03 sleep # Fn+F4 4 | 0x04 wlan # Fn+F5 5 | 0x06 switchvideomode # Fn+F7 6 | 0x07 zoom # Fn+F8 screen expand 7 | 0x08 f24 # Fn+F9 undock 8 | 0x0B suspend # Fn+F12 9 | 0x0F brightnessup # Fn+Home 10 | 0x10 brightnessdown # Fn+End 11 | 0x11 kbdillumtoggle # Fn+PgUp - ThinkLight 12 | 0x13 zoom # Fn+Space 13 | 0x14 volumeup 14 | 0x15 volumedown 15 | 0x16 mute 16 | 0x17 prog1 # ThinkPad/ThinkVantage button (high keycode: "vendor") 17 | -------------------------------------------------------------------------------- /src/keymap/keymaps/module-lenovo: -------------------------------------------------------------------------------- 1 | 0x1 screenlock # Fn+F2 2 | 0x2 battery # Fn+F3 3 | 0x3 sleep # Fn+F4 4 | 0x4 wlan # Fn+F5 5 | 0x6 switchvideomode # Fn+F7 6 | 0x7 f21 # Fn+F8 touchpadtoggle 7 | 0x8 f24 # Fn+F9 undock 8 | 0xB suspend # Fn+F12 9 | 0xF brightnessup # Fn+Home 10 | 0x10 brightnessdown # Fn+End 11 | 0x11 kbdillumtoggle # Fn+PgUp - ThinkLight 12 | 0x13 zoom # Fn+Space 13 | 0x14 volumeup 14 | 0x15 volumedown 15 | 0x16 mute 16 | 0x17 prog1 # ThinkPad/ThinkVantage button (high keycode: "vendor") 17 | 0x1A micmute # Microphone mute 18 | -------------------------------------------------------------------------------- /src/keymap/keymaps/module-sony: -------------------------------------------------------------------------------- 1 | 0x06 mute # Fn+F2 2 | 0x07 volumedown # Fn+F3 3 | 0x08 volumeup # Fn+F4 4 | 0x09 brightnessdown # Fn+F5 5 | 0x0A brightnessup # Fn+F6 6 | 0x0B switchvideomode # Fn+F7 7 | 0x0E zoom # Fn+F10 8 | 0x10 suspend # Fn+F12 9 | -------------------------------------------------------------------------------- /src/keymap/keymaps/module-sony-old: -------------------------------------------------------------------------------- 1 | 0x06 battery 2 | 0x07 mute 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/module-sony-vgn: -------------------------------------------------------------------------------- 1 | 0x00 brightnessdown # Fn+F5 2 | 0x10 brightnessup # Fn+F6 3 | 0x11 switchvideomode # Fn+F7 4 | 0x12 zoomout 5 | 0x14 zoomin 6 | 0x15 suspend # Fn+F12 7 | 0x17 prog1 8 | 0x20 media 9 | -------------------------------------------------------------------------------- /src/keymap/keymaps/olpc-xo: -------------------------------------------------------------------------------- 1 | 0x59 fn 2 | 0x81 fn_esc 3 | 0xF9 camera 4 | 0xF8 sound # Fn-CAMERA = Mic 5 | 6 | 7 | # Function key mappings, as per 8 | # http://dev.laptop.org/ticket/10213#comment:20 9 | # 10 | # Unmodified F1-F8 produce F1-F8, so no remap necessary. 11 | # Unmodified F9-F12 control brightness and volume. 12 | 0x43 brightnessdown 13 | 0x44 brightnessup 14 | 0x57 volumedown 15 | 0x58 volumeup 16 | 17 | # fn-modified fkeys all produce the unmodified version of the key. 18 | 0xBB f1 19 | 0xBC f2 20 | 0xBD f3 21 | 0xBE f4 22 | 0xBF f5 23 | 0xC0 f6 24 | 0xC1 f7 25 | 0xC2 f8 26 | 0xC3 f9 27 | 0xC4 f10 28 | 0xD7 f11 29 | 0xD8 f12 30 | 31 | 32 | # Using F13-F21 for the .5 F keys right now. 33 | 0xF7 f13 34 | 0xF6 f14 35 | 0xF5 f15 36 | 0xF4 f16 37 | 0xF3 f17 38 | 0xF2 f18 39 | 0xF1 f19 40 | 0xF0 f20 41 | 0xEF f21 42 | 43 | 0xEE chat 44 | 0xE4 chat # Just mapping Fn-Chat to Chat for now 45 | 0xDD menu # Frame 46 | 0xDA prog1 # Fn-Frame 47 | 48 | # The FN of some keys is other keys 49 | 0xD3 delete 50 | 0xD2 insert 51 | 0xC9 pageup 52 | 0xD1 pagedown 53 | 0xC7 home 54 | 0xCF end 55 | 56 | # Language key - don't ask what they are doing as KEY_HP 57 | 0x73 hp 58 | 0x7E hp 59 | 60 | 0xDB leftmeta # left grab 61 | 0xDC rightmeta # right grab 62 | 0x85 rightmeta # Right grab releases on a different scancode 63 | 0xD6 kbdillumtoggle # Fn-space 64 | 0x69 switchvideomode # Brightness key 65 | 66 | # Game keys 67 | 0x65 kp8 # up 68 | 0x66 kp2 # down 69 | 0x67 kp4 # left 70 | 0x68 kp6 # right 71 | 0xE5 kp9 # pgup 72 | 0xE6 kp3 # pgdn 73 | 0xE7 kp7 # home 74 | 0xE8 kp1 # end 75 | -------------------------------------------------------------------------------- /src/keymap/keymaps/onkyo: -------------------------------------------------------------------------------- 1 | 0xA0 mute # Fn+D 2 | 0xAE volumedown # Fn+F 3 | 0xB0 volumeup # Fn+G 4 | 0xDF sleep # Fn+W 5 | 0xE0 bluetooth # Fn+H 6 | 0xE2 cyclewindows # Fn+Esc 7 | 0xEE battery # Fn+Q 8 | 0xF0 media # Fn+R 9 | 0xF5 switchvideomode # Fn+E 10 | 0xF6 camera # Fn+T 11 | 0xF7 f21 # Fn+Y (touchpad toggle) 12 | 0xF8 brightnessup # Fn+S 13 | 0xF9 brightnessdown # Fn+A 14 | 0xFB wlan # Fn+J 15 | -------------------------------------------------------------------------------- /src/keymap/keymaps/oqo-model2: -------------------------------------------------------------------------------- 1 | 0x8E wlan 2 | 0xF0 switchvideomode 3 | 0xF1 mute 4 | 0xF2 volumedown 5 | 0xF3 volumeup 6 | -------------------------------------------------------------------------------- /src/keymap/keymaps/samsung-90x3a: -------------------------------------------------------------------------------- 1 | 0x96 kbdillumup         # Fn+F8 keyboard backlit up 2 | 0x97 kbdillumdown       # Fn+F7 keyboard backlit down 3 | 0xD5 wlan               # Fn+F12 wifi on/off 4 | 0xCE prog1              # Fn+F1 performance mode 5 | 0x8D prog2              # Fn+F6 battery life extender 6 | -------------------------------------------------------------------------------- /src/keymap/keymaps/samsung-other: -------------------------------------------------------------------------------- 1 | 0x74 prog1 # User key 2 | 0x75 www 3 | 0x78 mail 4 | 0x82 switchvideomode # Fn+F4 CRT/LCD (high keycode: "displaytoggle") 5 | 0x83 battery # Fn+F2 6 | 0x84 prog1 # Fn+F5 backlight on/off 7 | 0x86 wlan # Fn+F9 8 | 0x88 brightnessup # Fn-Up 9 | 0x89 brightnessdown # Fn-Down 10 | 0xB1 prog2 # Fn+F7 run Samsung Magic Doctor (keypressed event is generated twice) 11 | 0xB3 prog3 # Fn+F8 switch power mode (battery/dynamic/performance) 12 | 0xB4 wlan # Fn+F9 (X60P) 13 | 0xF7 f22 # Fn+F10 Touchpad on 14 | 0xF9 f23 # Fn+F10 Touchpad off 15 | -------------------------------------------------------------------------------- /src/keymap/keymaps/samsung-sq1us: -------------------------------------------------------------------------------- 1 | 0xD4 menu 2 | 0xD8 f1 3 | 0xD9 f10 4 | 0xD6 f3 5 | 0xD7 f9 6 | 0xE4 f5 7 | 0xEE f11 8 | -------------------------------------------------------------------------------- /src/keymap/keymaps/samsung-sx20s: -------------------------------------------------------------------------------- 1 | 0x74 mute 2 | 0x75 mute 3 | 0x77 f22 # Touchpad on 4 | 0x79 f23 # Touchpad off 5 | -------------------------------------------------------------------------------- /src/keymap/keymaps/toshiba-satellite_a100: -------------------------------------------------------------------------------- 1 | 0xA4 stopcd 2 | 0xB2 www 3 | -------------------------------------------------------------------------------- /src/keymap/keymaps/toshiba-satellite_a110: -------------------------------------------------------------------------------- 1 | 0x92 stop 2 | 0x93 www 3 | 0x94 media 4 | 0x9E f22 # Touchpad on 5 | 0x9F f23 # Touchpad off 6 | 0xB9 nextsong 7 | 0xD9 brightnessup 8 | 0xEE screenlock 9 | 0xF4 previoussong 10 | 0xF7 playpause 11 | -------------------------------------------------------------------------------- /src/keymap/keymaps/toshiba-satellite_m30x: -------------------------------------------------------------------------------- 1 | 0xef brightnessdown 2 | 0xd9 brightnessup 3 | 0xee screenlock 4 | 0x93 media 5 | 0x9e f22 #touchpad_enable 6 | 0x9f f23 #touchpad_disable 7 | -------------------------------------------------------------------------------- /src/keymap/keymaps/zepto-znote: -------------------------------------------------------------------------------- 1 | 0x93 switchvideomode # Fn+F3 Toggle Video Output 2 | 0x95 brightnessdown # Fn+F4 Brightness Down 3 | 0x91 brightnessup # Fn+F5 Brightness Up 4 | 0xA5 f23 # Fn+F6 Disable Touchpad 5 | 0xA6 f22 # Fn+F6 Enable Touchpad 6 | 0xA7 bluetooth # Fn+F10 Enable Bluetooth 7 | 0XA9 bluetooth # Fn+F10 Disable Bluetooth 8 | 0xF1 wlan # RF Switch Off 9 | 0xF2 wlan # RF Switch On 10 | 0xF4 prog1 # P1 Button 11 | 0xF3 prog2 # P2 Button 12 | -------------------------------------------------------------------------------- /src/libudev-selinux-private.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libudev - interface to udev device information 3 | * 4 | * Copyright (C) 2008 Kay Sievers 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "libudev.h" 20 | #include "libudev-private.h" 21 | 22 | static int selinux_enabled; 23 | security_context_t selinux_prev_scontext; 24 | 25 | void udev_selinux_init(struct udev *udev) 26 | { 27 | /* record the present security context */ 28 | selinux_enabled = (is_selinux_enabled() > 0); 29 | info(udev, "selinux=%i\n", selinux_enabled); 30 | if (!selinux_enabled) 31 | return; 32 | matchpathcon_init_prefix(NULL, udev_get_dev_path(udev)); 33 | if (getfscreatecon(&selinux_prev_scontext) < 0) { 34 | err(udev, "getfscreatecon failed\n"); 35 | selinux_prev_scontext = NULL; 36 | } 37 | } 38 | 39 | void udev_selinux_exit(struct udev *udev) 40 | { 41 | if (!selinux_enabled) 42 | return; 43 | freecon(selinux_prev_scontext); 44 | selinux_prev_scontext = NULL; 45 | } 46 | 47 | void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int mode) 48 | { 49 | security_context_t scontext = NULL; 50 | 51 | if (!selinux_enabled) 52 | return; 53 | if (matchpathcon(file, mode, &scontext) < 0) { 54 | err(udev, "matchpathcon(%s) failed\n", file); 55 | return; 56 | } 57 | if (lsetfilecon(file, scontext) < 0) 58 | err(udev, "setfilecon %s failed: %m\n", file); 59 | freecon(scontext); 60 | } 61 | 62 | void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned int mode) 63 | { 64 | security_context_t scontext = NULL; 65 | 66 | if (!selinux_enabled) 67 | return; 68 | 69 | if (matchpathcon(file, mode, &scontext) < 0) { 70 | err(udev, "matchpathcon(%s) failed\n", file); 71 | return; 72 | } 73 | if (setfscreatecon(scontext) < 0) 74 | err(udev, "setfscreatecon %s failed: %m\n", file); 75 | freecon(scontext); 76 | } 77 | 78 | void udev_selinux_resetfscreatecon(struct udev *udev) 79 | { 80 | if (!selinux_enabled) 81 | return; 82 | if (setfscreatecon(selinux_prev_scontext) < 0) 83 | err(udev, "setfscreatecon failed: %m\n"); 84 | } 85 | 86 | void udev_selinux_setfscreateconat(struct udev *udev, int dfd, const char *file, unsigned int mode) 87 | { 88 | char filename[UTIL_PATH_SIZE]; 89 | 90 | if (!selinux_enabled) 91 | return; 92 | 93 | /* resolve relative filename */ 94 | if (file[0] != '/') { 95 | char procfd[UTIL_PATH_SIZE]; 96 | char target[UTIL_PATH_SIZE]; 97 | ssize_t len; 98 | 99 | snprintf(procfd, sizeof(procfd), "/proc/%u/fd/%u", getpid(), dfd); 100 | len = readlink(procfd, target, sizeof(target)); 101 | if (len <= 0 || len == sizeof(target)) 102 | return; 103 | target[len] = '\0'; 104 | 105 | util_strscpyl(filename, sizeof(filename), target, "/", file, NULL); 106 | file = filename; 107 | } 108 | udev_selinux_setfscreatecon(udev, file, mode); 109 | } 110 | -------------------------------------------------------------------------------- /src/libudev.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libudev 7 | Description: Library to access udev device information 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -ludev -lrt 10 | Libs.private: 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /src/mtd_probe/75-probe_mtd.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION!="add", GOTO="mtd_probe_end" 4 | 5 | KERNEL=="mtd*ro", IMPORT{program}="mtd_probe $devnode" 6 | KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", IMPORT{builtin}="kmod load sm_ftl" 7 | 8 | LABEL="mtd_probe_end" 9 | -------------------------------------------------------------------------------- /src/mtd_probe/mtd_probe.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 - Maxim Levitsky 3 | * 4 | * mtd_probe is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mtd_probe is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with mtd_probe; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | */ 19 | #include "mtd_probe.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int main(int argc, char** argv) 30 | { 31 | if (argc != 2) { 32 | printf("usage: mtd_probe /dev/mtd[n]\n"); 33 | return 1; 34 | } 35 | 36 | int mtd_fd = open(argv[1], O_RDONLY); 37 | if (mtd_fd == -1) { 38 | perror("open"); 39 | exit(-1); 40 | } 41 | 42 | mtd_info_t mtd_info; 43 | int error = ioctl(mtd_fd, MEMGETINFO, &mtd_info); 44 | if (error == -1) { 45 | perror("ioctl"); 46 | exit(-1); 47 | } 48 | 49 | probe_smart_media(mtd_fd, &mtd_info); 50 | return -1; 51 | } 52 | -------------------------------------------------------------------------------- /src/mtd_probe/mtd_probe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 - Maxim Levitsky 3 | * 4 | * mtd_probe is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mtd_probe is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with mtd_probe; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | /* Full oob structure as written on the flash */ 23 | struct sm_oob { 24 | uint32_t reserved; 25 | uint8_t data_status; 26 | uint8_t block_status; 27 | uint8_t lba_copy1[2]; 28 | uint8_t ecc2[3]; 29 | uint8_t lba_copy2[2]; 30 | uint8_t ecc1[3]; 31 | } __attribute__((packed)); 32 | 33 | 34 | /* one sector is always 512 bytes, but it can consist of two nand pages */ 35 | #define SM_SECTOR_SIZE 512 36 | 37 | /* oob area is also 16 bytes, but might be from two pages */ 38 | #define SM_OOB_SIZE 16 39 | 40 | /* This is maximum zone size, and all devices that have more that one zone 41 | have this size */ 42 | #define SM_MAX_ZONE_SIZE 1024 43 | 44 | /* support for small page nand */ 45 | #define SM_SMALL_PAGE 256 46 | #define SM_SMALL_OOB_SIZE 8 47 | 48 | 49 | void probe_smart_media(int mtd_fd, mtd_info_t *info); 50 | -------------------------------------------------------------------------------- /src/mtd_probe/probe_smartmedia.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 - Maxim Levitsky 3 | * 4 | * mtd_probe is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * mtd_probe is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with mtd_probe; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, 17 | * Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "mtd_probe.h" 31 | 32 | static const uint8_t cis_signature[] = { 33 | 0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20 34 | }; 35 | 36 | 37 | void probe_smart_media(int mtd_fd, mtd_info_t* info) 38 | { 39 | char* cis_buffer = malloc(SM_SECTOR_SIZE); 40 | 41 | if (!cis_buffer) 42 | return; 43 | 44 | if (info->type != MTD_NANDFLASH) 45 | goto exit; 46 | 47 | int sector_size = info->writesize; 48 | int block_size = info->erasesize; 49 | int size_in_megs = info->size / (1024 * 1024); 50 | int spare_count; 51 | 52 | 53 | if (sector_size != SM_SECTOR_SIZE && sector_size != SM_SMALL_PAGE) 54 | goto exit; 55 | 56 | switch(size_in_megs) { 57 | case 1: 58 | case 2: 59 | spare_count = 6; 60 | break; 61 | case 4: 62 | spare_count = 12; 63 | break; 64 | default: 65 | spare_count = 24; 66 | break; 67 | } 68 | 69 | 70 | int offset; 71 | int cis_found = 0; 72 | 73 | for (offset = 0 ; offset < block_size * spare_count ; 74 | offset += sector_size) { 75 | 76 | lseek(mtd_fd, SEEK_SET, offset); 77 | if (read(mtd_fd, cis_buffer, SM_SECTOR_SIZE) == SM_SECTOR_SIZE){ 78 | cis_found = 1; 79 | break; 80 | } 81 | } 82 | 83 | if (!cis_found) 84 | goto exit; 85 | 86 | if (memcmp(cis_buffer, cis_signature, sizeof(cis_signature)) != 0 && 87 | (memcmp(cis_buffer + SM_SMALL_PAGE, cis_signature, 88 | sizeof(cis_signature)) != 0)) 89 | goto exit; 90 | 91 | printf("MTD_FTL=smartmedia\n"); 92 | free(cis_buffer); 93 | exit(0); 94 | exit: 95 | free(cis_buffer); 96 | return; 97 | } 98 | -------------------------------------------------------------------------------- /src/rule_generator/75-cd-aliases-generator.rules: -------------------------------------------------------------------------------- 1 | # these rules generate rules for the /dev/{cdrom,dvd,...} symlinks 2 | 3 | # the "path" of usb/ieee1394 devices changes frequently, use "id" 4 | ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb|ieee1394", ENV{ID_CDROM}=="?*", ENV{GENERATED}!="?*", \ 5 | PROGRAM="write_cd_rules by-id", SYMLINK+="%c", GOTO="persistent_cd_end" 6 | 7 | ACTION=="add", SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{GENERATED}!="?*", PROGRAM="write_cd_rules", SYMLINK+="%c" 8 | 9 | LABEL="persistent_cd_end" 10 | -------------------------------------------------------------------------------- /src/rule_generator/75-persistent-net-generator.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | # these rules generate rules for persistent network device naming 4 | # 5 | # variables used to communicate: 6 | # MATCHADDR MAC address used for the match 7 | # MATCHID bus_id used for the match 8 | # MATCHDRV driver name used for the match 9 | # MATCHIFTYPE interface type match 10 | # COMMENT comment to add to the generated rule 11 | # INTERFACE_NAME requested name supplied by external tool 12 | # INTERFACE_NEW new interface name returned by rule writer 13 | 14 | ACTION!="add", GOTO="persistent_net_generator_end" 15 | SUBSYSTEM!="net", GOTO="persistent_net_generator_end" 16 | 17 | # ignore the interface if a name has already been set 18 | NAME=="?*", GOTO="persistent_net_generator_end" 19 | 20 | # device name whitelist 21 | KERNEL!="eth*|ath*|wlan*[0-9]|msh*|ra*|sta*|ctc*|lcs*|hsi*", GOTO="persistent_net_generator_end" 22 | 23 | # ignore Xen virtual interfaces 24 | SUBSYSTEMS=="xen", GOTO="persistent_net_generator_end" 25 | 26 | # read MAC address 27 | ENV{MATCHADDR}="$attr{address}" 28 | 29 | # match interface type 30 | ENV{MATCHIFTYPE}="$attr{type}" 31 | 32 | # ignore KVM virtual interfaces 33 | ENV{MATCHADDR}=="52:54:00:*", GOTO="persistent_net_generator_end" 34 | # ignore VMWare virtual interfaces 35 | ENV{MATCHADDR}=="00:0c:29:*|00:50:56:*", GOTO="persistent_net_generator_end" 36 | # ignore Hyper-V virtual interfaces 37 | ENV{MATCHADDR}=="00:15:5d:*", GOTO="persistent_net_generator_end" 38 | 39 | # These vendors are known to violate the local MAC address assignment scheme 40 | # Interlan, DEC (UNIBUS or QBUS), Apollo, Cisco, Racal-Datacom 41 | ENV{MATCHADDR}=="02:07:01:*", GOTO="globally_administered_whitelist" 42 | # 3Com 43 | ENV{MATCHADDR}=="02:60:60:*", GOTO="globally_administered_whitelist" 44 | # 3Com IBM PC; Imagen; Valid; Cisco; Apple 45 | ENV{MATCHADDR}=="02:60:8c:*", GOTO="globally_administered_whitelist" 46 | # Intel 47 | ENV{MATCHADDR}=="02:a0:c9:*", GOTO="globally_administered_whitelist" 48 | # Olivetti 49 | ENV{MATCHADDR}=="02:aa:3c:*", GOTO="globally_administered_whitelist" 50 | # CMC Masscomp; Silicon Graphics; Prime EXL 51 | ENV{MATCHADDR}=="02:cf:1f:*", GOTO="globally_administered_whitelist" 52 | # Prominet Corporation Gigabit Ethernet Switch 53 | ENV{MATCHADDR}=="02:e0:3b:*", GOTO="globally_administered_whitelist" 54 | # BTI (Bus-Tech, Inc.) IBM Mainframes 55 | ENV{MATCHADDR}=="02:e6:d3:*", GOTO="globally_administered_whitelist" 56 | # Realtek 57 | ENV{MATCHADDR}=="52:54:00:*", GOTO="globally_administered_whitelist" 58 | # Novell 2000 59 | ENV{MATCHADDR}=="52:54:4c:*", GOTO="globally_administered_whitelist" 60 | # Realtec 61 | ENV{MATCHADDR}=="52:54:ab:*", GOTO="globally_administered_whitelist" 62 | # Kingston Technologies 63 | ENV{MATCHADDR}=="e2:0c:0f:*", GOTO="globally_administered_whitelist" 64 | # Xensource 65 | ENV{MATCHADDR}=="00:16:3e:*", GOTO="globally_administered_whitelist" 66 | 67 | # match interface dev_id 68 | ATTR{dev_id}=="?*", ENV{MATCHDEVID}="$attr{dev_id}" 69 | 70 | # do not use "locally administered" MAC address 71 | ENV{MATCHADDR}=="?[2367abef]:*", ENV{MATCHADDR}="" 72 | 73 | # do not use empty address 74 | ENV{MATCHADDR}=="00:00:00:00:00:00", ENV{MATCHADDR}="" 75 | 76 | LABEL="globally_administered_whitelist" 77 | 78 | # build comment line for generated rule: 79 | SUBSYSTEMS=="pci", ENV{COMMENT}="PCI device $attr{vendor}:$attr{device} ($driver)" 80 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="?*", ENV{COMMENT}="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($driver)" 81 | SUBSYSTEMS=="pcmcia", ENV{COMMENT}="PCMCIA device $attr{card_id}:$attr{manf_id} ($driver)" 82 | SUBSYSTEMS=="ieee1394", ENV{COMMENT}="Firewire device $attr{host_id})" 83 | 84 | # ibmveth likes to use "locally administered" MAC addresses 85 | DRIVERS=="ibmveth", ENV{MATCHADDR}="$attr{address}", ENV{COMMENT}="ibmveth ($id)" 86 | 87 | # S/390 uses id matches only, do not use MAC address match 88 | SUBSYSTEMS=="ccwgroup", ENV{COMMENT}="S/390 $driver device at $id", ENV{MATCHID}="$id", ENV{MATCHDRV}="$driver", ENV{MATCHADDR}="" 89 | 90 | # see if we got enough data to create a rule 91 | ENV{MATCHADDR}=="", ENV{MATCHID}=="", ENV{INTERFACE_NAME}=="", GOTO="persistent_net_generator_end" 92 | 93 | # default comment 94 | ENV{COMMENT}=="", ENV{COMMENT}="net device ($attr{driver})" 95 | 96 | # write rule 97 | DRIVERS=="?*", IMPORT{program}="write_net_rules" 98 | 99 | # rename interface if needed 100 | ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}" 101 | 102 | LABEL="persistent_net_generator_end" 103 | -------------------------------------------------------------------------------- /src/rule_generator/rule_generator.functions: -------------------------------------------------------------------------------- 1 | # functions used by the udev rule generator 2 | 3 | # Copyright (C) 2006 Marco d'Itri 4 | 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | PATH='/usr/bin:/bin:/usr/sbin:/sbin' 19 | 20 | # Read a single line from file $1 in the $DEVPATH directory. 21 | # The function must not return an error even if the file does not exist. 22 | sysread() { 23 | local file="$1" 24 | [ -e "/sys$DEVPATH/$file" ] || return 0 25 | local value 26 | read value < "/sys$DEVPATH/$file" || return 0 27 | echo "$value" 28 | } 29 | 30 | sysreadlink() { 31 | local file="$1" 32 | [ -e "/sys$DEVPATH/$file" ] || return 0 33 | readlink -f /sys$DEVPATH/$file 2> /dev/null || true 34 | } 35 | 36 | # Return true if a directory is writeable. 37 | writeable() { 38 | if ln -s test-link $1/.is-writeable 2> /dev/null; then 39 | rm -f $1/.is-writeable 40 | return 0 41 | else 42 | return 1 43 | fi 44 | } 45 | 46 | # Create a lock file for the current rules file. 47 | lock_rules_file() { 48 | RUNDIR=$(udevadm info --run) 49 | [ -e "$RUNDIR" ] || return 0 50 | 51 | RULES_LOCK="$RUNDIR/.lock-${RULES_FILE##*/}" 52 | 53 | retry=30 54 | while ! mkdir $RULES_LOCK 2> /dev/null; do 55 | if [ $retry -eq 0 ]; then 56 | echo "Cannot lock $RULES_FILE!" >&2 57 | exit 2 58 | fi 59 | sleep 1 60 | retry=$(($retry - 1)) 61 | done 62 | } 63 | 64 | unlock_rules_file() { 65 | [ "$RULES_LOCK" ] || return 0 66 | rmdir $RULES_LOCK || true 67 | } 68 | 69 | # Choose the real rules file if it is writeable or a temporary file if not. 70 | # Both files should be checked later when looking for existing rules. 71 | choose_rules_file() { 72 | RUNDIR=$(udevadm info --run) 73 | local tmp_rules_file="$RUNDIR/tmp-rules--${RULES_FILE##*/}" 74 | [ -e "$RULES_FILE" -o -e "$tmp_rules_file" ] || PRINT_HEADER=1 75 | 76 | if writeable ${RULES_FILE%/*}; then 77 | RO_RULES_FILE='/dev/null' 78 | else 79 | RO_RULES_FILE=$RULES_FILE 80 | RULES_FILE=$tmp_rules_file 81 | fi 82 | } 83 | 84 | # Return the name of the first free device. 85 | raw_find_next_available() { 86 | local links="$1" 87 | 88 | local basename=${links%%[ 0-9]*} 89 | local max=-1 90 | for name in $links; do 91 | local num=${name#$basename} 92 | [ "$num" ] || num=0 93 | [ $num -gt $max ] && max=$num 94 | done 95 | 96 | local max=$(($max + 1)) 97 | # "name0" actually is just "name" 98 | [ $max -eq 0 ] && return 99 | echo "$max" 100 | } 101 | 102 | # Find all rules matching a key (with action) and a pattern. 103 | find_all_rules() { 104 | local key="$1" 105 | local linkre="$2" 106 | local match="$3" 107 | 108 | local search='.*[[:space:],]'"$key"'"('"$linkre"')".*' 109 | echo $(sed -n -r -e 's/^#.*//' -e "${match}s/${search}/\1/p" \ 110 | $RO_RULES_FILE \ 111 | $([ -e $RULES_FILE ] && echo $RULES_FILE) \ 112 | 2>/dev/null) 113 | } 114 | -------------------------------------------------------------------------------- /src/rule_generator/write_cd_rules: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | # This script is run if an optical drive lacks a rule for persistent naming. 4 | # 5 | # It adds symlinks for optical drives based on the device class determined 6 | # by cdrom_id and used ID_PATH to identify the device. 7 | 8 | # (C) 2006 Marco d'Itri 9 | # 10 | # This program is free software: you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation, either version 2 of the License, or 13 | # (at your option) any later version. 14 | 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # debug, if UDEV_LOG= 24 | if [ -n "$UDEV_LOG" ]; then 25 | if [ "$UDEV_LOG" -ge 7 ]; then 26 | set -x 27 | fi 28 | fi 29 | 30 | RULES_FILE="/etc/udev/rules.d/70-persistent-cd.rules" 31 | 32 | . /lib/udev/rule_generator.functions 33 | 34 | find_next_available() { 35 | raw_find_next_available "$(find_all_rules 'SYMLINK\+=' "$1")" 36 | } 37 | 38 | write_rule() { 39 | local match="$1" 40 | local link="$2" 41 | local comment="$3" 42 | 43 | { 44 | if [ "$PRINT_HEADER" ]; then 45 | PRINT_HEADER= 46 | echo "# This file was automatically generated by the $0" 47 | echo "# program, run by the cd-aliases-generator.rules rules file." 48 | echo "#" 49 | echo "# You can modify it, as long as you keep each rule on a single" 50 | echo "# line, and set the \$GENERATED variable." 51 | echo "" 52 | fi 53 | 54 | [ "$comment" ] && echo "# $comment" 55 | echo "$match, SYMLINK+=\"$link\", ENV{GENERATED}=\"1\"" 56 | } >> $RULES_FILE 57 | SYMLINKS="$SYMLINKS $link" 58 | } 59 | 60 | if [ -z "$DEVPATH" ]; then 61 | echo "Missing \$DEVPATH." >&2 62 | exit 1 63 | fi 64 | if [ -z "$ID_CDROM" ]; then 65 | echo "$DEVPATH is not a CD reader." >&2 66 | exit 1 67 | fi 68 | 69 | if [ "$1" ]; then 70 | METHOD="$1" 71 | else 72 | METHOD='by-path' 73 | fi 74 | 75 | case "$METHOD" in 76 | by-path) 77 | if [ -z "$ID_PATH" ]; then 78 | echo "$DEVPATH not supported by path_id. by-id may work." >&2 79 | exit 1 80 | fi 81 | RULE="ENV{ID_PATH}==\"$ID_PATH\"" 82 | ;; 83 | 84 | by-id) 85 | if [ "$ID_SERIAL" ]; then 86 | RULE="ENV{ID_SERIAL}==\"$ID_SERIAL\"" 87 | elif [ "$ID_MODEL" -a "$ID_REVISION" ]; then 88 | RULE="ENV{ID_MODEL}==\"$ID_MODEL\", ENV{ID_REVISION}==\"$ID_REVISION\"" 89 | else 90 | echo "$DEVPATH not supported by ata_id. by-path may work." >&2 91 | exit 1 92 | fi 93 | ;; 94 | 95 | *) 96 | echo "Invalid argument (must be either by-path or by-id)." >&2 97 | exit 1 98 | ;; 99 | esac 100 | 101 | # Prevent concurrent processes from modifying the file at the same time. 102 | lock_rules_file 103 | 104 | # Check if the rules file is writeable. 105 | choose_rules_file 106 | 107 | link_num=$(find_next_available 'cdrom[0-9]*') 108 | 109 | match="SUBSYSTEM==\"block\", ENV{ID_CDROM}==\"?*\", $RULE" 110 | 111 | comment="$ID_MODEL ($ID_PATH)" 112 | 113 | write_rule "$match" "cdrom$link_num" "$comment" 114 | [ "$ID_CDROM_CD_R" -o "$ID_CDROM_CD_RW" ] && \ 115 | write_rule "$match" "cdrw$link_num" 116 | [ "$ID_CDROM_DVD" ] && \ 117 | write_rule "$match" "dvd$link_num" 118 | [ "$ID_CDROM_DVD_R" -o "$ID_CDROM_DVD_RW" -o "$ID_CDROM_DVD_RAM" ] && \ 119 | write_rule "$match" "dvdrw$link_num" 120 | echo >> $RULES_FILE 121 | 122 | unlock_rules_file 123 | 124 | echo $SYMLINKS 125 | 126 | exit 0 127 | -------------------------------------------------------------------------------- /src/rule_generator/write_net_rules: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | # This script is run to create persistent network device naming rules 4 | # based on properties of the device. 5 | # If the interface needs to be renamed, INTERFACE_NEW= will be printed 6 | # on stdout to allow udev to IMPORT it. 7 | 8 | # variables used to communicate: 9 | # MATCHADDR MAC address used for the match 10 | # MATCHID bus_id used for the match 11 | # MATCHDEVID dev_id used for the match 12 | # MATCHDRV driver name used for the match 13 | # MATCHIFTYPE interface type match 14 | # COMMENT comment to add to the generated rule 15 | # INTERFACE_NAME requested name supplied by external tool 16 | # INTERFACE_NEW new interface name returned by rule writer 17 | 18 | # Copyright (C) 2006 Marco d'Itri 19 | # Copyright (C) 2007 Kay Sievers 20 | # 21 | # This program is free software: you can redistribute it and/or modify 22 | # it under the terms of the GNU General Public License as published by 23 | # the Free Software Foundation, either version 2 of the License, or 24 | # (at your option) any later version. 25 | # 26 | # This program is distributed in the hope that it will be useful, 27 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | # GNU General Public License for more details. 30 | # 31 | # You should have received a copy of the GNU General Public License 32 | # along with this program. If not, see . 33 | 34 | # debug, if UDEV_LOG= 35 | if [ -n "$UDEV_LOG" ]; then 36 | if [ "$UDEV_LOG" -ge 7 ]; then 37 | set -x 38 | fi 39 | fi 40 | 41 | RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules' 42 | 43 | . /lib/udev/rule_generator.functions 44 | 45 | interface_name_taken() { 46 | local value="$(find_all_rules 'NAME=' $INTERFACE)" 47 | if [ "$value" ]; then 48 | return 0 49 | else 50 | return 1 51 | fi 52 | } 53 | 54 | find_next_available() { 55 | raw_find_next_available "$(find_all_rules 'NAME=' "$1")" 56 | } 57 | 58 | write_rule() { 59 | local match="$1" 60 | local name="$2" 61 | local comment="$3" 62 | 63 | { 64 | if [ "$PRINT_HEADER" ]; then 65 | PRINT_HEADER= 66 | echo "# This file was automatically generated by the $0" 67 | echo "# program, run by the persistent-net-generator.rules rules file." 68 | echo "#" 69 | echo "# You can modify it, as long as you keep each rule on a single" 70 | echo "# line, and change only the value of the NAME= key." 71 | fi 72 | 73 | echo "" 74 | [ "$comment" ] && echo "# $comment" 75 | echo "SUBSYSTEM==\"net\", ACTION==\"add\"$match, NAME=\"$name\"" 76 | } >> $RULES_FILE 77 | } 78 | 79 | if [ -z "$INTERFACE" ]; then 80 | echo "missing \$INTERFACE" >&2 81 | exit 1 82 | fi 83 | 84 | # Prevent concurrent processes from modifying the file at the same time. 85 | lock_rules_file 86 | 87 | # Check if the rules file is writeable. 88 | choose_rules_file 89 | 90 | # the DRIVERS key is needed to not match bridges and VLAN sub-interfaces 91 | if [ "$MATCHADDR" ]; then 92 | match="$match, DRIVERS==\"?*\", ATTR{address}==\"$MATCHADDR\"" 93 | fi 94 | 95 | if [ "$MATCHDRV" ]; then 96 | match="$match, DRIVERS==\"$MATCHDRV\"" 97 | fi 98 | 99 | if [ "$MATCHDEVID" ]; then 100 | match="$match, ATTR{dev_id}==\"$MATCHDEVID\"" 101 | fi 102 | 103 | if [ "$MATCHID" ]; then 104 | match="$match, KERNELS==\"$MATCHID\"" 105 | fi 106 | 107 | if [ "$MATCHIFTYPE" ]; then 108 | match="$match, ATTR{type}==\"$MATCHIFTYPE\"" 109 | fi 110 | 111 | if [ -z "$match" ]; then 112 | echo "missing valid match" >&2 113 | unlock_rules_file 114 | exit 1 115 | fi 116 | 117 | basename=${INTERFACE%%[0-9]*} 118 | match="$match, KERNEL==\"$basename*\"" 119 | 120 | if [ "$INTERFACE_NAME" ]; then 121 | # external tools may request a custom name 122 | COMMENT="$COMMENT (custom name provided by external tool)" 123 | if [ "$INTERFACE_NAME" != "$INTERFACE" ]; then 124 | INTERFACE=$INTERFACE_NAME; 125 | echo "INTERFACE_NEW=$INTERFACE" 126 | fi 127 | else 128 | # if a rule using the current name already exists, find a new name 129 | if interface_name_taken; then 130 | INTERFACE="$basename$(find_next_available "$basename[0-9]*")" 131 | # prevent INTERFACE from being "eth" instead of "eth0" 132 | [ "$INTERFACE" = "${INTERFACE%%[ \[\]0-9]*}" ] && INTERFACE=${INTERFACE}0 133 | echo "INTERFACE_NEW=$INTERFACE" 134 | fi 135 | fi 136 | 137 | write_rule "$match" "$INTERFACE" "$COMMENT" 138 | 139 | unlock_rules_file 140 | 141 | exit 0 142 | -------------------------------------------------------------------------------- /src/scsi_id/.gitignore: -------------------------------------------------------------------------------- 1 | scsi_id_version.h 2 | -------------------------------------------------------------------------------- /src/scsi_id/README: -------------------------------------------------------------------------------- 1 | scsi_id - generate a SCSI unique identifier for a given SCSI device 2 | 3 | Please send questions, comments or patches to or 4 | . 5 | -------------------------------------------------------------------------------- /src/scsi_id/scsi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * scsi.h 3 | * 4 | * General scsi and linux scsi specific defines and structs. 5 | * 6 | * Copyright (C) IBM Corp. 2003 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation version 2 of the License. 11 | */ 12 | 13 | #include 14 | 15 | struct scsi_ioctl_command { 16 | unsigned int inlen; /* excluding scsi command length */ 17 | unsigned int outlen; 18 | unsigned char data[1]; 19 | /* on input, scsi command starts here then opt. data */ 20 | }; 21 | 22 | /* 23 | * Default 5 second timeout 24 | */ 25 | #define DEF_TIMEOUT 5000 26 | 27 | #define SENSE_BUFF_LEN 32 28 | 29 | /* 30 | * The request buffer size passed to the SCSI INQUIRY commands, use 254, 31 | * as this is a nice value for some devices, especially some of the usb 32 | * mass storage devices. 33 | */ 34 | #define SCSI_INQ_BUFF_LEN 254 35 | 36 | /* 37 | * SCSI INQUIRY vendor and model (really product) lengths. 38 | */ 39 | #define VENDOR_LENGTH 8 40 | #define MODEL_LENGTH 16 41 | 42 | #define INQUIRY_CMD 0x12 43 | #define INQUIRY_CMDLEN 6 44 | 45 | /* 46 | * INQUIRY VPD page 0x83 identifier descriptor related values. Reference the 47 | * SCSI Primary Commands specification for details. 48 | */ 49 | 50 | /* 51 | * id type values of id descriptors. These are assumed to fit in 4 bits. 52 | */ 53 | #define SCSI_ID_VENDOR_SPECIFIC 0 54 | #define SCSI_ID_T10_VENDOR 1 55 | #define SCSI_ID_EUI_64 2 56 | #define SCSI_ID_NAA 3 57 | #define SCSI_ID_RELPORT 4 58 | #define SCSI_ID_TGTGROUP 5 59 | #define SCSI_ID_LUNGROUP 6 60 | #define SCSI_ID_MD5 7 61 | #define SCSI_ID_NAME 8 62 | 63 | /* 64 | * Supported NAA values. These fit in 4 bits, so the "don't care" value 65 | * cannot conflict with real values. 66 | */ 67 | #define SCSI_ID_NAA_DONT_CARE 0xff 68 | #define SCSI_ID_NAA_IEEE_REG 5 69 | #define SCSI_ID_NAA_IEEE_REG_EXTENDED 6 70 | 71 | /* 72 | * Supported Code Set values. 73 | */ 74 | #define SCSI_ID_BINARY 1 75 | #define SCSI_ID_ASCII 2 76 | 77 | struct scsi_id_search_values { 78 | u_char id_type; 79 | u_char naa_type; 80 | u_char code_set; 81 | }; 82 | 83 | /* 84 | * Following are the "true" SCSI status codes. Linux has traditionally 85 | * used a 1 bit right and masked version of these. So now CHECK_CONDITION 86 | * and friends (in ) are deprecated. 87 | */ 88 | #define SCSI_CHECK_CONDITION 0x2 89 | #define SCSI_CONDITION_MET 0x4 90 | #define SCSI_BUSY 0x8 91 | #define SCSI_IMMEDIATE 0x10 92 | #define SCSI_IMMEDIATE_CONDITION_MET 0x14 93 | #define SCSI_RESERVATION_CONFLICT 0x18 94 | #define SCSI_COMMAND_TERMINATED 0x22 95 | #define SCSI_TASK_SET_FULL 0x28 96 | #define SCSI_ACA_ACTIVE 0x30 97 | #define SCSI_TASK_ABORTED 0x40 98 | -------------------------------------------------------------------------------- /src/scsi_id/scsi_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) IBM Corp. 2003 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #define MAX_PATH_LEN 512 19 | 20 | /* 21 | * MAX_ATTR_LEN: maximum length of the result of reading a sysfs 22 | * attribute. 23 | */ 24 | #define MAX_ATTR_LEN 256 25 | 26 | /* 27 | * MAX_SERIAL_LEN: the maximum length of the serial number, including 28 | * added prefixes such as vendor and product (model) strings. 29 | */ 30 | #define MAX_SERIAL_LEN 256 31 | 32 | /* 33 | * MAX_BUFFER_LEN: maximum buffer size and line length used while reading 34 | * the config file. 35 | */ 36 | #define MAX_BUFFER_LEN 256 37 | 38 | struct scsi_id_device { 39 | char vendor[9]; 40 | char model[17]; 41 | char revision[5]; 42 | char type[33]; 43 | char kernel[64]; 44 | char serial[MAX_SERIAL_LEN]; 45 | char serial_short[MAX_SERIAL_LEN]; 46 | int use_sg; 47 | 48 | /* Always from page 0x80 e.g. 'B3G1P8500RWT' - may not be unique */ 49 | char unit_serial_number[MAX_SERIAL_LEN]; 50 | 51 | /* NULs if not set - otherwise hex encoding using lower-case e.g. '50014ee0016eb572' */ 52 | char wwn[17]; 53 | 54 | /* NULs if not set - otherwise hex encoding using lower-case e.g. '0xe00000d80000' */ 55 | char wwn_vendor_extension[17]; 56 | 57 | /* NULs if not set - otherwise decimal number */ 58 | char tgpt_group[8]; 59 | }; 60 | 61 | extern int scsi_std_inquiry(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname); 62 | extern int scsi_get_serial (struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname, 63 | int page_code, int len); 64 | 65 | /* 66 | * Page code values. 67 | */ 68 | enum page_code { 69 | PAGE_83_PRE_SPC3 = -0x83, 70 | PAGE_UNSPECIFIED = 0x00, 71 | PAGE_80 = 0x80, 72 | PAGE_83 = 0x83, 73 | }; 74 | -------------------------------------------------------------------------------- /src/test-udev.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003-2004 Greg Kroah-Hartman 3 | * Copyright (C) 2004-2008 Kay Sievers 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "udev.h" 32 | 33 | void udev_main_log(struct udev *udev, int priority, 34 | const char *file, int line, const char *fn, 35 | const char *format, va_list args) {} 36 | 37 | int main(int argc, char *argv[]) 38 | { 39 | struct udev *udev; 40 | struct udev_event *event = NULL; 41 | struct udev_device *dev = NULL; 42 | struct udev_rules *rules = NULL; 43 | char syspath[UTIL_PATH_SIZE]; 44 | const char *devpath; 45 | const char *action; 46 | sigset_t mask, sigmask_orig; 47 | int err = -EINVAL; 48 | 49 | udev = udev_new(); 50 | if (udev == NULL) 51 | exit(1); 52 | info(udev, "version %s\n", VERSION); 53 | udev_selinux_init(udev); 54 | 55 | sigprocmask(SIG_SETMASK, NULL, &sigmask_orig); 56 | 57 | action = argv[1]; 58 | if (action == NULL) { 59 | err(udev, "action missing\n"); 60 | goto out; 61 | } 62 | 63 | devpath = argv[2]; 64 | if (devpath == NULL) { 65 | err(udev, "devpath missing\n"); 66 | goto out; 67 | } 68 | 69 | rules = udev_rules_new(udev, 1); 70 | 71 | util_strscpyl(syspath, sizeof(syspath), udev_get_sys_path(udev), devpath, NULL); 72 | dev = udev_device_new_from_syspath(udev, syspath); 73 | if (dev == NULL) { 74 | info(udev, "unknown device '%s'\n", devpath); 75 | goto out; 76 | } 77 | 78 | udev_device_set_action(dev, action); 79 | event = udev_event_new(dev); 80 | 81 | sigfillset(&mask); 82 | sigprocmask(SIG_SETMASK, &mask, &sigmask_orig); 83 | event->fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC); 84 | if (event->fd_signal < 0) { 85 | fprintf(stderr, "error creating signalfd\n"); 86 | goto out; 87 | } 88 | 89 | /* do what devtmpfs usually provides us */ 90 | if (udev_device_get_devnode(dev) != NULL) { 91 | mode_t mode; 92 | 93 | if (strcmp(udev_device_get_subsystem(dev), "block") == 0) 94 | mode |= S_IFBLK; 95 | else 96 | mode |= S_IFCHR; 97 | 98 | if (strcmp(action, "remove") != 0) { 99 | util_create_path(udev, udev_device_get_devnode(dev)); 100 | mknod(udev_device_get_devnode(dev), mode, udev_device_get_devnum(dev)); 101 | } else { 102 | unlink(udev_device_get_devnode(dev)); 103 | util_delete_path(udev, udev_device_get_devnode(dev)); 104 | } 105 | } 106 | 107 | err = udev_event_execute_rules(event, rules, &sigmask_orig); 108 | if (err == 0) 109 | udev_event_execute_run(event, NULL); 110 | out: 111 | if (event != NULL && event->fd_signal >= 0) 112 | close(event->fd_signal); 113 | udev_event_unref(event); 114 | udev_device_unref(dev); 115 | udev_rules_unref(rules); 116 | udev_selinux_exit(udev); 117 | udev_unref(udev); 118 | if (err != 0) 119 | return 1; 120 | return 0; 121 | } 122 | -------------------------------------------------------------------------------- /src/udev-builtin-firmware.c: -------------------------------------------------------------------------------- 1 | /* 2 | * firmware - Kernel firmware loader 3 | * 4 | * Copyright (C) 2009 Piter Punk 5 | * Copyright (C) 2009-2011 Kay Sievers 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License as 9 | * published by the Free Software Foundation; either version 2 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details:* 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "udev.h" 29 | 30 | static bool set_loading(struct udev *udev, char *loadpath, const char *state) 31 | { 32 | FILE *ldfile; 33 | 34 | ldfile = fopen(loadpath, "we"); 35 | if (ldfile == NULL) { 36 | err(udev, "error: can not open '%s'\n", loadpath); 37 | return false; 38 | }; 39 | fprintf(ldfile, "%s\n", state); 40 | fclose(ldfile); 41 | return true; 42 | } 43 | 44 | static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size) 45 | { 46 | char *buf; 47 | FILE *fsource = NULL, *ftarget = NULL; 48 | bool ret = false; 49 | 50 | buf = malloc(size); 51 | if (buf == NULL) { 52 | err(udev,"No memory available to load firmware file"); 53 | return false; 54 | } 55 | 56 | info(udev, "writing '%s' (%zi) to '%s'\n", source, size, target); 57 | 58 | fsource = fopen(source, "re"); 59 | if (fsource == NULL) 60 | goto exit; 61 | ftarget = fopen(target, "we"); 62 | if (ftarget == NULL) 63 | goto exit; 64 | if (fread(buf, size, 1, fsource) != 1) 65 | goto exit; 66 | if (fwrite(buf, size, 1, ftarget) == 1) 67 | ret = true; 68 | exit: 69 | if (ftarget != NULL) 70 | fclose(ftarget); 71 | if (fsource != NULL) 72 | fclose(fsource); 73 | free(buf); 74 | return ret; 75 | } 76 | 77 | static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], bool test) 78 | { 79 | struct udev *udev = udev_device_get_udev(dev); 80 | static const char *searchpath[] = { FIRMWARE_PATH }; 81 | char fwencpath[UTIL_PATH_SIZE]; 82 | char misspath[UTIL_PATH_SIZE]; 83 | char loadpath[UTIL_PATH_SIZE]; 84 | char datapath[UTIL_PATH_SIZE]; 85 | char fwpath[UTIL_PATH_SIZE]; 86 | const char *firmware; 87 | FILE *fwfile; 88 | struct utsname kernel; 89 | struct stat statbuf; 90 | unsigned int i; 91 | int rc = EXIT_SUCCESS; 92 | 93 | firmware = udev_device_get_property_value(dev, "FIRMWARE"); 94 | if (firmware == NULL) { 95 | err(udev, "firmware parameter missing\n\n"); 96 | rc = EXIT_FAILURE; 97 | goto exit; 98 | } 99 | 100 | /* lookup firmware file */ 101 | uname(&kernel); 102 | for (i = 0; i < ARRAY_SIZE(searchpath); i++) { 103 | util_strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL); 104 | dbg(udev, "trying %s\n", fwpath); 105 | fwfile = fopen(fwpath, "re"); 106 | if (fwfile != NULL) 107 | break; 108 | 109 | util_strscpyl(fwpath, sizeof(fwpath), searchpath[i], firmware, NULL); 110 | dbg(udev, "trying %s\n", fwpath); 111 | fwfile = fopen(fwpath, "re"); 112 | if (fwfile != NULL) 113 | break; 114 | } 115 | 116 | util_path_encode(firmware, fwencpath, sizeof(fwencpath)); 117 | util_strscpyl(misspath, sizeof(misspath), udev_get_run_path(udev), "/firmware-missing/", fwencpath, NULL); 118 | util_strscpyl(loadpath, sizeof(loadpath), udev_device_get_syspath(dev), "/loading", NULL); 119 | 120 | if (fwfile == NULL) { 121 | int err; 122 | 123 | /* This link indicates the missing firmware file and the associated device */ 124 | info(udev, "did not find firmware file '%s'\n", firmware); 125 | do { 126 | err = util_create_path(udev, misspath); 127 | if (err != 0 && err != -ENOENT) 128 | break; 129 | err = symlink(udev_device_get_devpath(dev), misspath); 130 | if (err != 0) 131 | err = -errno; 132 | } while (err == -ENOENT); 133 | rc = EXIT_FAILURE; 134 | set_loading(udev, loadpath, "-1"); 135 | goto exit; 136 | } 137 | 138 | if (stat(fwpath, &statbuf) < 0 || statbuf.st_size == 0) { 139 | rc = EXIT_FAILURE; 140 | goto exit; 141 | } 142 | if (unlink(misspath) == 0) 143 | util_delete_path(udev, misspath); 144 | 145 | if (!set_loading(udev, loadpath, "1")) 146 | goto exit; 147 | 148 | util_strscpyl(datapath, sizeof(datapath), udev_device_get_syspath(dev), "/data", NULL); 149 | if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) { 150 | err(udev, "error sending firmware '%s' to device\n", firmware); 151 | set_loading(udev, loadpath, "-1"); 152 | rc = EXIT_FAILURE; 153 | goto exit; 154 | }; 155 | 156 | set_loading(udev, loadpath, "0"); 157 | exit: 158 | if (fwfile) 159 | fclose(fwfile); 160 | return rc; 161 | } 162 | 163 | const struct udev_builtin udev_builtin_firmware = { 164 | .name = "firmware", 165 | .cmd = builtin_firmware, 166 | .help = "kernel firmware loader", 167 | .run_once = true, 168 | }; 169 | -------------------------------------------------------------------------------- /src/udev-builtin-kmod.c: -------------------------------------------------------------------------------- 1 | /* 2 | * load kernel modules 3 | * 4 | * Copyright (C) 2011 Kay Sievers 5 | * Copyright (C) 2011 ProFUSION embedded systems 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "udev.h" 33 | 34 | static struct kmod_ctx *ctx; 35 | 36 | static int load_module(struct udev *udev, const char *alias) 37 | { 38 | struct kmod_list *list = NULL; 39 | struct kmod_list *l; 40 | int err; 41 | 42 | err = kmod_module_new_from_lookup(ctx, alias, &list); 43 | if (err < 0) 44 | return err; 45 | 46 | if (list == NULL) 47 | info(udev, "no module matches '%s'\n", alias); 48 | 49 | kmod_list_foreach(l, list) { 50 | struct kmod_module *mod = kmod_module_get_module(l); 51 | 52 | err = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL); 53 | if (err == KMOD_PROBE_APPLY_BLACKLIST) 54 | info(udev, "module '%s' is blacklisted\n", kmod_module_get_name(mod)); 55 | else if (err == 0) 56 | info(udev, "inserted '%s'\n", kmod_module_get_name(mod)); 57 | else 58 | info(udev, "failed to insert '%s'\n", kmod_module_get_name(mod)); 59 | 60 | kmod_module_unref(mod); 61 | } 62 | 63 | kmod_module_unref_list(list); 64 | return err; 65 | } 66 | 67 | static void udev_kmod_log(void *data, int priority, const char *file, int line, 68 | const char *fn, const char *format, va_list args) 69 | { 70 | udev_main_log(data, priority, file, line, fn, format, args); 71 | } 72 | 73 | /* needs to re-instantiate the context after a reload */ 74 | static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) 75 | { 76 | struct udev *udev = udev_device_get_udev(dev); 77 | int i; 78 | 79 | if (!ctx) { 80 | ctx = kmod_new(NULL, NULL); 81 | if (!ctx) 82 | return -ENOMEM; 83 | 84 | info(udev, "load module index\n"); 85 | kmod_set_log_fn(ctx, udev_kmod_log, udev); 86 | kmod_load_resources(ctx); 87 | } 88 | 89 | if (argc < 3 || strcmp(argv[1], "load")) { 90 | err(udev, "expect: %s load \n", argv[0]); 91 | return EXIT_FAILURE; 92 | } 93 | 94 | for (i = 2; argv[i]; i++) { 95 | info(udev, "execute '%s' '%s'\n", argv[1], argv[i]); 96 | load_module(udev, argv[i]); 97 | } 98 | 99 | return EXIT_SUCCESS; 100 | } 101 | 102 | /* called at udev startup */ 103 | static int builtin_kmod_init(struct udev *udev) 104 | { 105 | if (ctx) 106 | return 0; 107 | 108 | ctx = kmod_new(NULL, NULL); 109 | if (!ctx) 110 | return -ENOMEM; 111 | 112 | info(udev, "load module index\n"); 113 | kmod_set_log_fn(ctx, udev_kmod_log, udev); 114 | kmod_load_resources(ctx); 115 | return 0; 116 | } 117 | 118 | /* called on udev shutdown and reload request */ 119 | static void builtin_kmod_exit(struct udev *udev) 120 | { 121 | info(udev, "unload module index\n"); 122 | ctx = kmod_unref(ctx); 123 | } 124 | 125 | /* called every couple of seconds during event activity; 'true' if config has changed */ 126 | static bool builtin_kmod_validate(struct udev *udev) 127 | { 128 | info(udev, "validate module index\n"); 129 | if (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK) 130 | return true; 131 | return false; 132 | } 133 | 134 | const struct udev_builtin udev_builtin_kmod = { 135 | .name = "kmod", 136 | .cmd = builtin_kmod, 137 | .init = builtin_kmod_init, 138 | .exit = builtin_kmod_exit, 139 | .validate = builtin_kmod_validate, 140 | .help = "kernel module loader", 141 | .run_once = false, 142 | }; 143 | -------------------------------------------------------------------------------- /src/udev-builtin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2009 Kay Sievers 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "udev.h" 27 | 28 | static const struct udev_builtin *builtins[] = { 29 | [UDEV_BUILTIN_BLKID] = &udev_builtin_blkid, 30 | [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware, 31 | [UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id, 32 | [UDEV_BUILTIN_KMOD] = &udev_builtin_kmod, 33 | [UDEV_BUILTIN_PATH_ID] = &udev_builtin_path_id, 34 | [UDEV_BUILTIN_PCI_DB] = &udev_builtin_pci_db, 35 | [UDEV_BUILTIN_USB_DB] = &udev_builtin_usb_db, 36 | [UDEV_BUILTIN_USB_ID] = &udev_builtin_usb_id, 37 | }; 38 | 39 | int udev_builtin_init(struct udev *udev) 40 | { 41 | unsigned int i; 42 | int err; 43 | 44 | for (i = 0; i < ARRAY_SIZE(builtins); i++) { 45 | if (builtins[i]->init) { 46 | err = builtins[i]->init(udev); 47 | if (err < 0) 48 | break; 49 | } 50 | } 51 | return err; 52 | } 53 | 54 | void udev_builtin_exit(struct udev *udev) 55 | { 56 | unsigned int i; 57 | 58 | for (i = 0; i < ARRAY_SIZE(builtins); i++) 59 | if (builtins[i]->exit) 60 | builtins[i]->exit(udev); 61 | } 62 | 63 | bool udev_builtin_validate(struct udev *udev) 64 | { 65 | unsigned int i; 66 | bool change = false; 67 | 68 | for (i = 0; i < ARRAY_SIZE(builtins); i++) 69 | if (builtins[i]->validate) 70 | if (builtins[i]->validate(udev)) 71 | change = true; 72 | return change; 73 | } 74 | 75 | void udev_builtin_list(struct udev *udev) 76 | { 77 | unsigned int i; 78 | 79 | for (i = 0; i < ARRAY_SIZE(builtins); i++) 80 | fprintf(stderr, " %-12s %s\n", builtins[i]->name, builtins[i]->help); 81 | } 82 | 83 | const char *udev_builtin_name(enum udev_builtin_cmd cmd) 84 | { 85 | return builtins[cmd]->name; 86 | } 87 | 88 | bool udev_builtin_run_once(enum udev_builtin_cmd cmd) 89 | { 90 | return builtins[cmd]->run_once; 91 | } 92 | 93 | enum udev_builtin_cmd udev_builtin_lookup(const char *command) 94 | { 95 | char name[UTIL_PATH_SIZE]; 96 | enum udev_builtin_cmd i; 97 | char *pos; 98 | 99 | util_strscpy(name, sizeof(name), command); 100 | pos = strchr(name, ' '); 101 | if (pos) 102 | pos[0] = '\0'; 103 | for (i = 0; i < ARRAY_SIZE(builtins); i++) 104 | if (strcmp(builtins[i]->name, name) == 0) 105 | return i; 106 | return UDEV_BUILTIN_MAX; 107 | } 108 | 109 | int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test) 110 | { 111 | char arg[UTIL_PATH_SIZE]; 112 | int argc; 113 | char *argv[128]; 114 | 115 | optind = 0; 116 | util_strscpy(arg, sizeof(arg), command); 117 | udev_build_argv(udev_device_get_udev(dev), arg, &argc, argv); 118 | return builtins[cmd]->cmd(dev, argc, argv, test); 119 | } 120 | 121 | int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val) 122 | { 123 | struct udev_list_entry *entry; 124 | 125 | entry = udev_device_add_property(dev, key, val); 126 | /* store in db, skip private keys */ 127 | if (key[0] != '.') 128 | udev_list_entry_set_num(entry, true); 129 | 130 | info(udev_device_get_udev(dev), "%s=%s\n", key, val); 131 | if (test) 132 | printf("%s=%s\n", key, val); 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /src/udev-control.socket: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=udev Control Socket 3 | DefaultDependencies=no 4 | ConditionCapability=CAP_MKNOD 5 | 6 | [Socket] 7 | Service=udev.service 8 | ListenSequentialPacket=/run/udev/control 9 | SocketMode=0600 10 | PassCredentials=yes 11 | -------------------------------------------------------------------------------- /src/udev-kernel.socket: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=udev Kernel Socket 3 | DefaultDependencies=no 4 | ConditionCapability=CAP_MKNOD 5 | 6 | [Socket] 7 | Service=udev.service 8 | ReceiveBuffer=134217728 9 | ListenNetlink=kobject-uevent 1 10 | PassCredentials=yes 11 | -------------------------------------------------------------------------------- /src/udev-settle.service.in: -------------------------------------------------------------------------------- 1 | # This service is usually not enabled by default. If enabled, it 2 | # acts as a barrier for basic.target -- so all later services will 3 | # wait for udev completely finishing its coldplug run. 4 | # 5 | # If needed, to work around broken or non-hotplug-aware services, 6 | # it might be enabled unconditionally, or pulled-in on-demand by 7 | # the services that assume a fully populated /dev at startup. It 8 | # should not be used or pulled-in ever on systems without such 9 | # legacy services running. 10 | 11 | [Unit] 12 | Description=udev Wait for Complete Device Initialization 13 | DefaultDependencies=no 14 | Wants=udev.service 15 | After=udev-trigger.service 16 | Before=basic.target 17 | 18 | [Service] 19 | Type=oneshot 20 | TimeoutSec=180 21 | RemainAfterExit=yes 22 | ExecStart=@bindir@/udevadm settle 23 | 24 | [Install] 25 | WantedBy=basic.target 26 | -------------------------------------------------------------------------------- /src/udev-trigger.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=udev Coldplug all Devices 3 | Wants=udev.service 4 | After=udev-kernel.socket udev-control.socket 5 | DefaultDependencies=no 6 | 7 | [Service] 8 | Type=oneshot 9 | RemainAfterExit=yes 10 | ExecStart=@bindir@/udevadm trigger --type=subsystems --action=add ; @bindir@/udevadm trigger --type=devices --action=add 11 | -------------------------------------------------------------------------------- /src/udev-watch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004-2010 Kay Sievers 3 | * Copyright (C) 2009 Canonical Ltd. 4 | * Copyright (C) 2009 Scott James Remnant 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "udev.h" 32 | 33 | static int inotify_fd = -1; 34 | 35 | /* inotify descriptor, will be shared with rules directory; 36 | * set to cloexec since we need our children to be able to add 37 | * watches for us 38 | */ 39 | int udev_watch_init(struct udev *udev) 40 | { 41 | inotify_fd = inotify_init1(IN_CLOEXEC); 42 | if (inotify_fd < 0) 43 | err(udev, "inotify_init failed: %m\n"); 44 | return inotify_fd; 45 | } 46 | 47 | /* move any old watches directory out of the way, and then restore 48 | * the watches 49 | */ 50 | void udev_watch_restore(struct udev *udev) 51 | { 52 | char filename[UTIL_PATH_SIZE], oldname[UTIL_PATH_SIZE]; 53 | 54 | if (inotify_fd < 0) 55 | return; 56 | 57 | util_strscpyl(oldname, sizeof(oldname), udev_get_run_path(udev), "/watch.old", NULL); 58 | util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/watch", NULL); 59 | if (rename(filename, oldname) == 0) { 60 | DIR *dir; 61 | struct dirent *ent; 62 | 63 | dir = opendir(oldname); 64 | if (dir == NULL) { 65 | err(udev, "unable to open old watches dir '%s', old watches will not be restored: %m", oldname); 66 | return; 67 | } 68 | 69 | for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) { 70 | char device[UTIL_PATH_SIZE]; 71 | char *s; 72 | size_t l; 73 | ssize_t len; 74 | struct udev_device *dev; 75 | 76 | if (ent->d_name[0] == '.') 77 | continue; 78 | 79 | s = device; 80 | l = util_strpcpy(&s, sizeof(device), udev_get_sys_path(udev)); 81 | len = readlinkat(dirfd(dir), ent->d_name, s, l); 82 | if (len <= 0 || len == (ssize_t)l) 83 | goto unlink; 84 | s[len] = '\0'; 85 | 86 | dev = udev_device_new_from_id_filename(udev, s); 87 | if (dev == NULL) 88 | goto unlink; 89 | 90 | info(udev, "restoring old watch on '%s'\n", udev_device_get_devnode(dev)); 91 | udev_watch_begin(udev, dev); 92 | udev_device_unref(dev); 93 | unlink: 94 | unlinkat(dirfd(dir), ent->d_name, 0); 95 | } 96 | 97 | closedir(dir); 98 | rmdir(oldname); 99 | 100 | } else if (errno != ENOENT) { 101 | err(udev, "unable to move watches dir '%s', old watches will not be restored: %m", filename); 102 | } 103 | } 104 | 105 | void udev_watch_begin(struct udev *udev, struct udev_device *dev) 106 | { 107 | char filename[UTIL_PATH_SIZE]; 108 | int wd; 109 | 110 | if (inotify_fd < 0) 111 | return; 112 | 113 | info(udev, "adding watch on '%s'\n", udev_device_get_devnode(dev)); 114 | wd = inotify_add_watch(inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); 115 | if (wd < 0) { 116 | err(udev, "inotify_add_watch(%d, %s, %o) failed: %m\n", 117 | inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); 118 | return; 119 | } 120 | 121 | snprintf(filename, sizeof(filename), "%s/watch/%d", udev_get_run_path(udev), wd); 122 | util_create_path(udev, filename); 123 | unlink(filename); 124 | symlink(udev_device_get_id_filename(dev), filename); 125 | 126 | udev_device_set_watch_handle(dev, wd); 127 | } 128 | 129 | void udev_watch_end(struct udev *udev, struct udev_device *dev) 130 | { 131 | int wd; 132 | char filename[UTIL_PATH_SIZE]; 133 | 134 | if (inotify_fd < 0) 135 | return; 136 | 137 | wd = udev_device_get_watch_handle(dev); 138 | if (wd < 0) 139 | return; 140 | 141 | info(udev, "removing watch on '%s'\n", udev_device_get_devnode(dev)); 142 | inotify_rm_watch(inotify_fd, wd); 143 | 144 | snprintf(filename, sizeof(filename), "%s/watch/%d", udev_get_run_path(udev), wd); 145 | unlink(filename); 146 | 147 | udev_device_set_watch_handle(dev, -1); 148 | } 149 | 150 | struct udev_device *udev_watch_lookup(struct udev *udev, int wd) 151 | { 152 | char filename[UTIL_PATH_SIZE]; 153 | char majmin[UTIL_PATH_SIZE]; 154 | char *s; 155 | size_t l; 156 | ssize_t len; 157 | 158 | if (inotify_fd < 0 || wd < 0) 159 | return NULL; 160 | 161 | snprintf(filename, sizeof(filename), "%s/watch/%d", udev_get_run_path(udev), wd); 162 | s = majmin; 163 | l = util_strpcpy(&s, sizeof(majmin), udev_get_sys_path(udev)); 164 | len = readlink(filename, s, l); 165 | if (len <= 0 || (size_t)len == l) 166 | return NULL; 167 | s[len] = '\0'; 168 | 169 | return udev_device_new_from_id_filename(udev, s); 170 | } 171 | -------------------------------------------------------------------------------- /src/udev.conf: -------------------------------------------------------------------------------- 1 | # see udev(7) for details 2 | 3 | #udev_log="info" 4 | -------------------------------------------------------------------------------- /src/udev.pc.in: -------------------------------------------------------------------------------- 1 | Name: udev 2 | Description: udev 3 | Version: @VERSION@ 4 | 5 | udevdir=@pkglibexecdir@ 6 | -------------------------------------------------------------------------------- /src/udev.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=udev Kernel Device Manager 3 | Wants=udev-control.socket udev-kernel.socket 4 | After=udev-control.socket udev-kernel.socket 5 | Before=basic.target 6 | DefaultDependencies=no 7 | ConditionCapability=CAP_MKNOD 8 | 9 | [Service] 10 | Type=notify 11 | OOMScoreAdjust=-1000 12 | Sockets=udev-control.socket udev-kernel.socket 13 | Restart=on-failure 14 | ExecStart=@pkglibexecdir@/udevd 15 | -------------------------------------------------------------------------------- /src/udevadm-test-builtin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Kay Sievers 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "udev.h" 36 | 37 | static void help(struct udev *udev) 38 | { 39 | fprintf(stderr, "\n"); 40 | fprintf(stderr, "Usage: udevadm builtin [--help] \n"); 41 | udev_builtin_list(udev); 42 | fprintf(stderr, "\n"); 43 | } 44 | 45 | static int adm_builtin(struct udev *udev, int argc, char *argv[]) 46 | { 47 | static const struct option options[] = { 48 | { "help", no_argument, NULL, 'h' }, 49 | {} 50 | }; 51 | char *command = NULL; 52 | char *syspath = NULL; 53 | char filename[UTIL_PATH_SIZE]; 54 | struct udev_device *dev = NULL; 55 | enum udev_builtin_cmd cmd; 56 | int rc = EXIT_SUCCESS; 57 | 58 | dbg(udev, "version %s\n", VERSION); 59 | 60 | for (;;) { 61 | int option; 62 | 63 | option = getopt_long(argc, argv, "h", options, NULL); 64 | if (option == -1) 65 | break; 66 | 67 | switch (option) { 68 | case 'h': 69 | help(udev); 70 | goto out; 71 | } 72 | } 73 | 74 | command = argv[optind++]; 75 | if (command == NULL) { 76 | fprintf(stderr, "command missing\n"); 77 | help(udev); 78 | rc = 2; 79 | goto out; 80 | } 81 | 82 | syspath = argv[optind++]; 83 | if (syspath == NULL) { 84 | fprintf(stderr, "syspath missing\n\n"); 85 | rc = 3; 86 | goto out; 87 | } 88 | 89 | udev_builtin_init(udev); 90 | 91 | cmd = udev_builtin_lookup(command); 92 | if (cmd >= UDEV_BUILTIN_MAX) { 93 | fprintf(stderr, "unknown command '%s'\n", command); 94 | help(udev); 95 | rc = 5; 96 | goto out; 97 | } 98 | 99 | /* add /sys if needed */ 100 | if (strncmp(syspath, udev_get_sys_path(udev), strlen(udev_get_sys_path(udev))) != 0) 101 | util_strscpyl(filename, sizeof(filename), udev_get_sys_path(udev), syspath, NULL); 102 | else 103 | util_strscpy(filename, sizeof(filename), syspath); 104 | util_remove_trailing_chars(filename, '/'); 105 | 106 | dev = udev_device_new_from_syspath(udev, filename); 107 | if (dev == NULL) { 108 | fprintf(stderr, "unable to open device '%s'\n\n", filename); 109 | rc = 4; 110 | goto out; 111 | } 112 | 113 | if (udev_builtin_run(dev, cmd, command, true) < 0) { 114 | fprintf(stderr, "error executing '%s'\n\n", command); 115 | rc = 6; 116 | } 117 | out: 118 | udev_device_unref(dev); 119 | udev_builtin_exit(udev); 120 | return rc; 121 | } 122 | 123 | const struct udevadm_cmd udevadm_test_builtin = { 124 | .name = "test-builtin", 125 | .cmd = adm_builtin, 126 | .help = "test a built-in command", 127 | .debug = true, 128 | }; 129 | -------------------------------------------------------------------------------- /src/udevadm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2009 Kay Sievers 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "udev.h" 27 | 28 | static bool debug; 29 | 30 | void udev_main_log(struct udev *udev, int priority, 31 | const char *file, int line, const char *fn, 32 | const char *format, va_list args) 33 | { 34 | if (debug) { 35 | fprintf(stderr, "%s: ", fn); 36 | vfprintf(stderr, format, args); 37 | } else { 38 | va_list args2; 39 | 40 | va_copy(args2, args); 41 | vfprintf(stderr, format, args2); 42 | va_end(args2); 43 | vsyslog(priority, format, args); 44 | } 45 | } 46 | 47 | static int adm_version(struct udev *udev, int argc, char *argv[]) 48 | { 49 | printf("%s\n", VERSION); 50 | return 0; 51 | } 52 | static const struct udevadm_cmd udevadm_version = { 53 | .name = "version", 54 | .cmd = adm_version, 55 | }; 56 | 57 | static int adm_help(struct udev *udev, int argc, char *argv[]); 58 | static const struct udevadm_cmd udevadm_help = { 59 | .name = "help", 60 | .cmd = adm_help, 61 | }; 62 | 63 | static const struct udevadm_cmd *udevadm_cmds[] = { 64 | &udevadm_info, 65 | &udevadm_trigger, 66 | &udevadm_settle, 67 | &udevadm_control, 68 | &udevadm_monitor, 69 | &udevadm_test, 70 | &udevadm_test_builtin, 71 | &udevadm_version, 72 | &udevadm_help, 73 | }; 74 | 75 | static int adm_help(struct udev *udev, int argc, char *argv[]) 76 | { 77 | unsigned int i; 78 | 79 | fprintf(stderr, "Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS]\n"); 80 | for (i = 0; i < ARRAY_SIZE(udevadm_cmds); i++) 81 | if (udevadm_cmds[i]->help != NULL) 82 | printf(" %-12s %s\n", udevadm_cmds[i]->name, udevadm_cmds[i]->help); 83 | fprintf(stderr, "\n"); 84 | return 0; 85 | } 86 | 87 | static int run_command(struct udev *udev, const struct udevadm_cmd *cmd, int argc, char *argv[]) 88 | { 89 | if (cmd->debug) { 90 | debug = true; 91 | if (udev_get_log_priority(udev) < LOG_INFO) 92 | udev_set_log_priority(udev, LOG_INFO); 93 | } 94 | info(udev, "calling: %s\n", cmd->name); 95 | return cmd->cmd(udev, argc, argv); 96 | } 97 | 98 | int main(int argc, char *argv[]) 99 | { 100 | struct udev *udev; 101 | static const struct option options[] = { 102 | { "debug", no_argument, NULL, 'd' }, 103 | { "help", no_argument, NULL, 'h' }, 104 | { "version", no_argument, NULL, 'V' }, 105 | {} 106 | }; 107 | const char *command; 108 | unsigned int i; 109 | int rc = 1; 110 | 111 | udev = udev_new(); 112 | if (udev == NULL) 113 | goto out; 114 | 115 | udev_log_init("udevadm"); 116 | udev_set_log_fn(udev, udev_main_log); 117 | udev_selinux_init(udev); 118 | 119 | for (;;) { 120 | int option; 121 | 122 | option = getopt_long(argc, argv, "+dhV", options, NULL); 123 | if (option == -1) 124 | break; 125 | 126 | switch (option) { 127 | case 'd': 128 | debug = true; 129 | if (udev_get_log_priority(udev) < LOG_INFO) 130 | udev_set_log_priority(udev, LOG_INFO); 131 | break; 132 | case 'h': 133 | rc = adm_help(udev, argc, argv); 134 | goto out; 135 | case 'V': 136 | rc = adm_version(udev, argc, argv); 137 | goto out; 138 | default: 139 | goto out; 140 | } 141 | } 142 | command = argv[optind]; 143 | 144 | info(udev, "runtime dir '%s'\n", udev_get_run_path(udev)); 145 | 146 | if (command != NULL) 147 | for (i = 0; i < ARRAY_SIZE(udevadm_cmds); i++) { 148 | if (strcmp(udevadm_cmds[i]->name, command) == 0) { 149 | argc -= optind; 150 | argv += optind; 151 | optind = 0; 152 | rc = run_command(udev, udevadm_cmds[i], argc, argv); 153 | goto out; 154 | } 155 | } 156 | 157 | fprintf(stderr, "missing or unknown command\n\n"); 158 | adm_help(udev, argc, argv); 159 | rc = 2; 160 | out: 161 | udev_selinux_exit(udev); 162 | udev_unref(udev); 163 | udev_log_close(); 164 | return rc; 165 | } 166 | -------------------------------------------------------------------------------- /src/udevd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | udevd 9 | udev 10 | 11 | 12 | 13 | udevd 14 | 8 15 | 16 | 17 | 18 | 19 | udevdevent managing daemon 20 | 21 | 22 | 23 | 24 | udevd 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Description 36 | udevd listens to kernel uevents. For every event, udevd executes matching 37 | instructions specified in udev rules. See 38 | udev7 39 | . 40 | On startup the content of the directory /usr/lib/udev/devices 41 | is copied to /dev. If kernel modules specify static device 42 | nodes, these nodes are created even without a corresponding kernel device, to 43 | allow on-demand loading of kernel modules. Matching permissions specified in udev 44 | rules are applied to these static device nodes. 45 | The behavior of the running daemon can be changed with 46 | udevadm control. 47 | 48 | 49 | Options 50 | 51 | 52 | 53 | 54 | Detach and run in the background. 55 | 56 | 57 | 58 | 59 | 60 | Print debug messages to stderr. 61 | 62 | 63 | 64 | 65 | 66 | Limit the number of parallel executed events. 67 | 68 | 69 | 70 | 71 | 72 | Number of seconds to delay the execution of RUN instructions. 73 | This might be useful when debugging system crashes during coldplug 74 | cause by loading non-working kernel modules. 75 | 76 | 77 | 78 | 79 | 80 | Specify when udevd should resolve names of users and groups. 81 | When set to (the default) names will be 82 | resolved when the rules are parsed. When set to 83 | names will be resolved for every event. 84 | When set to names will never be resolved 85 | and all devices will be owned by root. 86 | 87 | 88 | 89 | 90 | 91 | Print version number. 92 | 93 | 94 | 95 | 96 | 97 | Print help text. 98 | 99 | 100 | 101 | 102 | 103 | Environment 104 | 105 | 106 | UDEV_LOG= 107 | 108 | Set the logging priority. 109 | 110 | 111 | 112 | 113 | 114 | Kernel command line 115 | 116 | 117 | udev.log-priority= 118 | 119 | Set the logging priority. 120 | 121 | 122 | 123 | udev.children-max= 124 | 125 | Limit the number of parallel executed events. 126 | 127 | 128 | 129 | udev.exec-delay= 130 | 131 | Number of seconds to delay the execution of RUN instructions. 132 | This might be useful when debugging system crashes during coldplug 133 | cause by loading non-working kernel modules. 134 | 135 | 136 | 137 | 138 | 139 | Author 140 | Written by Kay Sievers kay.sievers@vrfy.org. 141 | 142 | 143 | 144 | See Also 145 | 146 | udev7 147 | , 148 | udevadm8 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /src/v4l_id/60-persistent-v4l.rules: -------------------------------------------------------------------------------- 1 | # do not edit this file, it will be overwritten on update 2 | 3 | ACTION=="remove", GOTO="persistent_v4l_end" 4 | SUBSYSTEM!="video4linux", GOTO="persistent_v4l_end" 5 | ENV{MAJOR}=="", GOTO="persistent_v4l_end" 6 | 7 | IMPORT{program}="v4l_id $devnode" 8 | 9 | SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id" 10 | KERNEL=="video*", ENV{ID_SERIAL}=="?*", SYMLINK+="v4l/by-id/$env{ID_BUS}-$env{ID_SERIAL}-video-index$attr{index}" 11 | 12 | # check for valid "index" number 13 | TEST!="index", GOTO="persistent_v4l_end" 14 | ATTR{index}!="?*", GOTO="persistent_v4l_end" 15 | 16 | IMPORT{builtin}="path_id" 17 | ENV{ID_PATH}=="?*", KERNEL=="video*|vbi*", SYMLINK+="v4l/by-path/$env{ID_PATH}-video-index$attr{index}" 18 | ENV{ID_PATH}=="?*", KERNEL=="audio*", SYMLINK+="v4l/by-path/$env{ID_PATH}-audio-index$attr{index}" 19 | 20 | LABEL="persistent_v4l_end" 21 | -------------------------------------------------------------------------------- /src/v4l_id/v4l_id.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Kay Sievers 3 | * Copyright (c) 2009 Filippo Argiolas 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License as 7 | * published by the Free Software Foundation; either version 2 of the 8 | * License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * General Public License for more details: 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | int main (int argc, char *argv[]) 34 | { 35 | static const struct option options[] = { 36 | { "help", no_argument, NULL, 'h' }, 37 | {} 38 | }; 39 | int fd; 40 | char *device; 41 | struct v4l2_capability v2cap; 42 | 43 | while (1) { 44 | int option; 45 | 46 | option = getopt_long(argc, argv, "h", options, NULL); 47 | if (option == -1) 48 | break; 49 | 50 | switch (option) { 51 | case 'h': 52 | printf("Usage: v4l_id [--help] \n\n"); 53 | return 0; 54 | default: 55 | return 1; 56 | } 57 | } 58 | device = argv[optind]; 59 | 60 | if (device == NULL) 61 | return 2; 62 | fd = open (device, O_RDONLY); 63 | if (fd < 0) 64 | return 3; 65 | 66 | if (ioctl (fd, VIDIOC_QUERYCAP, &v2cap) == 0) { 67 | printf("ID_V4L_VERSION=2\n"); 68 | printf("ID_V4L_PRODUCT=%s\n", v2cap.card); 69 | printf("ID_V4L_CAPABILITIES=:"); 70 | if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0) 71 | printf("capture:"); 72 | if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0) 73 | printf("video_output:"); 74 | if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0) 75 | printf("video_overlay:"); 76 | if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0) 77 | printf("audio:"); 78 | if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0) 79 | printf("tuner:"); 80 | if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0) 81 | printf("radio:"); 82 | printf("\n"); 83 | } 84 | 85 | close (fd); 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /test/rule-syntax-check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Simple udev rules syntax checker 3 | # 4 | # (C) 2010 Canonical Ltd. 5 | # Author: Martin Pitt 6 | # 7 | # This program is free software; you can redistribute it and/or modify it 8 | # under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software Foundation, 19 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 | 21 | import re 22 | import sys 23 | 24 | if len(sys.argv) < 2: 25 | print >> sys.stderr, 'Usage: %s [...]' % sys.argv[0] 26 | sys.exit(2) 27 | 28 | no_args_tests = re.compile('(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|RESULT|TEST)\s*(?:=|!)=\s*"([^"]*)"$') 29 | args_tests = re.compile('(ATTRS?|ENV|TEST){([a-zA-Z0-9/_.*%-]+)}\s*(?:=|!)=\s*"([^"]*)"$') 30 | no_args_assign = re.compile('(NAME|SYMLINK|OWNER|GROUP|MODE|TAG|PROGRAM|RUN|LABEL|GOTO|WAIT_FOR|OPTIONS|IMPORT)\s*(?:\+=|:=|=)\s*"([^"]*)"$') 31 | args_assign = re.compile('(ATTR|ENV|IMPORT){([a-zA-Z0-9/_.*%-]+)}\s*=\s*"([^"]*)"$') 32 | 33 | result = 0 34 | buffer = '' 35 | for path in sys.argv[1:]: 36 | lineno = 0 37 | for line in open(path): 38 | lineno += 1 39 | 40 | # handle line continuation 41 | if line.endswith('\\\n'): 42 | buffer += line[:-2] 43 | continue 44 | else: 45 | line = buffer + line 46 | buffer = '' 47 | 48 | # filter out comments and empty lines 49 | line = line.strip() 50 | if not line or line.startswith('#'): 51 | continue 52 | 53 | for clause in line.split(','): 54 | clause = clause.strip() 55 | if not (no_args_tests.match(clause) or args_tests.match(clause) or 56 | no_args_assign.match(clause) or args_assign.match(clause)): 57 | 58 | print('Invalid line %s:%i: %s' % (path, lineno, line)) 59 | print(' clause:', clause) 60 | print() 61 | result = 1 62 | break 63 | 64 | sys.exit(result) 65 | -------------------------------------------------------------------------------- /test/rules-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Call the udev rule syntax checker on all rules that we ship 3 | # 4 | # (C) 2010 Canonical Ltd. 5 | # Author: Martin Pitt 6 | 7 | [ -n "$srcdir" ] || srcdir=`dirname $0`/.. 8 | 9 | # skip if we don't have python 10 | type python >/dev/null 2>&1 || { 11 | echo "$0: No python installed, skipping udev rule syntax check" 12 | exit 0 13 | } 14 | 15 | $srcdir/test/rule-syntax-check.py `find $srcdir/rules -name '*.rules'` 16 | -------------------------------------------------------------------------------- /test/sys.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavlinux/udev/bc43e87ea1d21d8b723265dbb6b5a03c82806548/test/sys.tar.xz --------------------------------------------------------------------------------