mirror of
https://github.com/Poltern/lfs-ru.git
synced 2024-10-18 11:50:21 +03:00
Added udev-lfs
This commit is contained in:
parent
b9127d642e
commit
de9758f017
14
udev-lfs/55-lfs.rules
Normal file
14
udev-lfs/55-lfs.rules
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# /etc/udev/rules.d/55-lfs.rules: Rule definitions for LFS.
|
||||||
|
|
||||||
|
# Core kernel devices
|
||||||
|
|
||||||
|
# This causes the system clock to be set as soon as /dev/rtc becomes available.
|
||||||
|
SUBSYSTEM=="rtc", ACTION=="add", MODE="0644", RUN+="/etc/rc.d/init.d/setclock start"
|
||||||
|
KERNEL=="rtc", ACTION=="add", MODE="0644", RUN+="/etc/rc.d/init.d/setclock start"
|
||||||
|
|
||||||
|
# Comms devices
|
||||||
|
|
||||||
|
KERNEL=="ippp[0-9]*", GROUP="dialout"
|
||||||
|
KERNEL=="isdn[0-9]*", GROUP="dialout"
|
||||||
|
KERNEL=="isdnctrl[0-9]*", GROUP="dialout"
|
||||||
|
KERNEL=="dcbri[0-9]*", GROUP="dialout"
|
20
udev-lfs/55-lfs.txt
Normal file
20
udev-lfs/55-lfs.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Purpose of rules file:
|
||||||
|
|
||||||
|
Most of the rules installed by Udev itself create devices with the correct
|
||||||
|
properties. This file contains rules that have not been merged upstream yet.
|
||||||
|
|
||||||
|
Description of rules:
|
||||||
|
|
||||||
|
By default, Udev creates device nodes with UID 0, GID 0, and permissions 0660.
|
||||||
|
|
||||||
|
ISDN-related devices should be owned by the 'dialout' group, hence the following
|
||||||
|
rule (and similar):
|
||||||
|
|
||||||
|
KERNEL=="ippp[0-9]*", GROUP="dialout"
|
||||||
|
|
||||||
|
The RTC-related rules cause the setclock bootscript to be run as soon as the
|
||||||
|
RTC device has been created by Udev, meaning that times in log files, for
|
||||||
|
example, are as accurate as possible as quickly as possible.
|
||||||
|
|
||||||
|
A final word of caution: Any particular rule must be written on one line, and a
|
||||||
|
comma must separate each part of the rule.
|
3
udev-lfs/81-cdrom.rules
Normal file
3
udev-lfs/81-cdrom.rules
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# /etc/udev/rules.d/81-cdrom.rules: Set CD-ROM permissions and get device capabilities
|
||||||
|
|
||||||
|
ACTION=="add", SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", IMPORT{program}="cdrom_id --export $tempnode", GROUP="cdrom"
|
13
udev-lfs/83-cdrom-symlinks.rules
Normal file
13
udev-lfs/83-cdrom-symlinks.rules
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# /etc/udev/rules.d/83-cdrom-symlinks.rules: Determine CD drive capability.
|
||||||
|
|
||||||
|
ACTION!="add", GOTO="cd_aliases_generator_end"
|
||||||
|
SUBSYSTEM!="block", GOTO="cd_aliases_generator_end"
|
||||||
|
ENV{GENERATED}=="?*", GOTO="cd_aliases_generator_end"
|
||||||
|
|
||||||
|
# Fail the uevent if the autogenerated rules cannot be saved
|
||||||
|
ENV{ID_CDROM}=="?*", PROGRAM="/bin/grep -c ' / [^[:space:]]* rw' /proc/mounts", \
|
||||||
|
RESULT!="1", RUN+="/bin/false", GOTO="cd_aliases_generator_end"
|
||||||
|
|
||||||
|
ENV{ID_CDROM}=="?*", PROGRAM="write_cd_rules", SYMLINK+="%c"
|
||||||
|
|
||||||
|
LABEL="cd_aliases_generator_end"
|
264
udev-lfs/ChangeLog
Normal file
264
udev-lfs/ChangeLog
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
2017-10-27 <bdubbs@linuxfromscratch.org>
|
||||||
|
* 83-cdrom-symlinks.rules: Adjust test for writable root directory.
|
||||||
|
|
||||||
|
2014-03-02 <bdubbs@linuxfromscratch.org>
|
||||||
|
* Makefile.lfs: Remove build procedures leaving only LFS rules
|
||||||
|
|
||||||
|
2014-02-16 <bdubbs@linuxfromscratch.org>
|
||||||
|
* Makefile.lfs: Adjust warning flags. Adjust linking rules to
|
||||||
|
allow build with util-linux in LFS's /tools directory.
|
||||||
|
|
||||||
|
2010-01-26 Matt Burgess <matthew@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Remove lots of rules that have been merged upstream.
|
||||||
|
* 61-cdrom.rules: Remove as upstream has a replacement.
|
||||||
|
* doc/*: Cleanup and rewrite now that the rules are much simpler.
|
||||||
|
|
||||||
|
2009-09-25 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Make the RTC rule (which runs setclock) work for people
|
||||||
|
that don't use the RTC-class driver -- add another copy of the rule,
|
||||||
|
using KERNEL=="rtc" instead of SUBSYSTEM=="rtc". Also move the ACTION
|
||||||
|
match before the assignment to MODE.
|
||||||
|
|
||||||
|
2009-05-23 Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Set the rtc by udev upon boot. Removed aio device from
|
||||||
|
udev configuration so defaults are used.
|
||||||
|
|
||||||
|
2009-05-16 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Adopt udev permissions for random, urandom, kmsg, and
|
||||||
|
input devices (including psaux, which probably doesn't exist anymore
|
||||||
|
anyway).
|
||||||
|
|
||||||
|
2009-05-16 Matt Burgess <matthew@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Remove the block rule as it was only setting
|
||||||
|
permissions that Udev will set by default
|
||||||
|
* 55-lfs.rules: Remove the rfcomm rule as the group it sets is already
|
||||||
|
included in upstream's rule
|
||||||
|
* 55-lfs-rules: Remove the tape rules as the group they sets is already
|
||||||
|
included in upstream's rules
|
||||||
|
|
||||||
|
2009-03-15 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Remove the ISDN-handling rules (replaced with upstream's
|
||||||
|
version, which has a better match via SUBSYSTEM).
|
||||||
|
* 55-lfs.rules: Replace "uucp" with "dialout" now that udev has decided
|
||||||
|
to standardize on a Debian-like setup (uucp is for UUCP daemons to use
|
||||||
|
for privilege separation; dialout is for users and devices).
|
||||||
|
|
||||||
|
2008-12-07 Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Change one line to use continuation so it does
|
||||||
|
not overflow the book's width.
|
||||||
|
|
||||||
|
2008-12-07 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Remove several rules that are either provided by upstream,
|
||||||
|
or that don't have any effect (there is no /dev/js or /dev/djs according
|
||||||
|
to devices.txt).
|
||||||
|
* 55-lfs.rules, 61-cdrom.rules: Replace ACTION=="add" with "add|change"
|
||||||
|
everywhere, per upstream's general request.
|
||||||
|
|
||||||
|
2008-11-11 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules, 61-cdrom.rules: Fix comments to use the right rule
|
||||||
|
numbers. Thanks to Trent Shea for the fix. Closes #2278.
|
||||||
|
|
||||||
|
2008-10-15 DJ Lucas <dj@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Override default perms on floppy disk devices provided
|
||||||
|
by 50-udev-default.rules. Thanks to Bruce Dubbs for the fix. Closes
|
||||||
|
LFS ticket #2076.
|
||||||
|
|
||||||
|
2008-05-21 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 81-firmware.rules, doc/81-firmware.txt: Remove. This rule is
|
||||||
|
already handled by udev's 50-udev-default.rules file. The docs
|
||||||
|
can be added back later if needed.
|
||||||
|
* Makefile: Don't install the above deleted files.
|
||||||
|
* 55-lfs.rules: Remove the device-mapper rule, since the upstream
|
||||||
|
50-udev-default.rules file handles it properly.
|
||||||
|
|
||||||
|
2008-04-02 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* Makefile: Make the package DESTDIR-friendly by installing the docs
|
||||||
|
into a fixed $(PREFIX)/share/doc/udev-config directory, instead of
|
||||||
|
trying to figure out what version of udev was just installed.
|
||||||
|
|
||||||
|
2007-10-30 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 55-lfs.rules: Since the dialout group was renamed to uucp, delete
|
||||||
|
the rules that override upstream's assignment of the dialout group.
|
||||||
|
Replace "dialout" with "uucp" on the remaining rules.
|
||||||
|
|
||||||
|
2007-10-29 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 51-lfs.rules: Move to 55-lfs.rules.
|
||||||
|
* doc/51-lfs.rules: Move to doc/55-lfs.rules.
|
||||||
|
|
||||||
|
2007-10-27 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 25-lfs.rules: Some rules in here are duplicates of rules from udev's
|
||||||
|
new 50-udev-defaults.rules file; remove them. Override permissions
|
||||||
|
where needed elsewhere (and document overrides in comments).
|
||||||
|
* 26-modprobe.rules: Provided by udev's 80-drivers.rules and built-in
|
||||||
|
modaliases for SCSI device-type modules in 2.6.22+ kernels; remove.
|
||||||
|
|
||||||
|
* 25-lfs.rules: Move to 51-lfs.rules.
|
||||||
|
* 27-firmware.rules: Move to 81-firmware.rules.
|
||||||
|
* 81-cdrom.rules: Move to 61-cdrom.rules.
|
||||||
|
|
||||||
|
* doc/25-lfs.txt: Rename to 51-lfs.txt.
|
||||||
|
* doc/26-modprobe.txt: Rename to 80-drivers.txt, and modify to reflect
|
||||||
|
the upstream rules.
|
||||||
|
* doc/27-firmware.txt: Rename to 81-firmware.txt.
|
||||||
|
* doc/81-cdrom.txt: Rename to 61-cdrom.txt.
|
||||||
|
|
||||||
|
* Makefile: Use new filenames.
|
||||||
|
|
||||||
|
2007-07-31 Dan Nicholson <dnicholson@linuxfromscratch.org>
|
||||||
|
* 25-lfs.rules: Changed the usb_device rule tto create /dev/bus/usb
|
||||||
|
nodes if the usb_device in 2.6.22+ kernels. The rule was also changed
|
||||||
|
to only trigger on "add" events. This change is not backwards
|
||||||
|
compatible with older kernels.
|
||||||
|
|
||||||
|
2007-06-12 Dan Nicholson <dnicholson@linuxfromscratch.org>
|
||||||
|
* 25-lfs.rules: Fix the CPUID nodes from cpu/%n/cpu to cpu/%n/cpuid,
|
||||||
|
which is what's expected in userspace apps such as x86info.
|
||||||
|
|
||||||
|
2007-06-08 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 25-lfs.rules: Add rules for DVB devices (create nodes in /dev/dvb/)
|
||||||
|
and floppies (create extra nodes based on CMOS type), copied from
|
||||||
|
the SuSE rules file. Thanks to Alexander Patrakov for the bugreport.
|
||||||
|
|
||||||
|
2007-03-04 Matthew Burgess <matthew@linuxfromscratch.org>
|
||||||
|
* Makefile: Use `udevd --version' to work out what version of Udev is
|
||||||
|
installed (requires Udev >= 106)
|
||||||
|
|
||||||
|
2007-01-02 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 25-lfs.rules: Change CPU devices (cpu, msr, microcode) to be in
|
||||||
|
/dev/cpu/ and /dev/cpu/N/, to match Documentation/devices.txt.
|
||||||
|
|
||||||
|
2006-10-21 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* Makefile: Add a missing backslash in install-extra-doc.
|
||||||
|
|
||||||
|
* 05-udev-early.rules, 60-persistent-input.rules,
|
||||||
|
60-persistent-storage.rules, 95-udev-late.rules: Remove. The book
|
||||||
|
will install these files from udev's etc/udev/rules.d directory
|
||||||
|
instead.
|
||||||
|
* Makefile: Don't install these rules files after all. Also, only
|
||||||
|
install corresponding docs if requested.
|
||||||
|
|
||||||
|
2006-10-20 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* Makefile: Added; contains targets to install rules and doc files.
|
||||||
|
From Dan Nicholson.
|
||||||
|
|
||||||
|
2006-10-14 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 05-udev-early.rules, 60-persistent-storage.rules: Sync up with
|
||||||
|
upstream sample rules files (from udev-102), except for one rule
|
||||||
|
which is more specific in our tarball and should probably be changed
|
||||||
|
upstream.
|
||||||
|
* doc/60-persistent-storage.txt: Modify to match the changes. Also
|
||||||
|
fix a couple typos.
|
||||||
|
|
||||||
|
* 25-lfs.rules: Remove duplicate rules (ttyS[0-9]* is also matched by
|
||||||
|
tty[BC...S...][0-9]*, and ttyUSB[0-9]* is in there twice).
|
||||||
|
|
||||||
|
* 25-lfs.rules: Fix Alsa device KERNEL rules. Udev uses shell-style
|
||||||
|
glob matching, not regular expressions, so the old rules would match
|
||||||
|
nonsense device names like hw0asdf and pcmDzxcv. As long as the first
|
||||||
|
character after the "fixed" portion was in the list, the rule would
|
||||||
|
match; it wouldn't apply the same character range to later characters.
|
||||||
|
|
||||||
|
* doc/25-lfs.txt: Add a note on interaction between permissions and
|
||||||
|
symlinks.
|
||||||
|
|
||||||
|
2006-10-09 Bryan Kadzban <bryan@linuxfromscrtach.org>
|
||||||
|
* 25-lfs.rules: Fix fb[0-9]* device permissions (should use the default
|
||||||
|
0660).
|
||||||
|
|
||||||
|
* doc/25-lfs.txt: Fix typo: /dev/ptmx is given mode 0666, not 0660.
|
||||||
|
Also tweak the comment about other TTY devices.
|
||||||
|
|
||||||
|
2006-10-04 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 05-udev-early.rules: Remove WAIT_FOR_SYSFS="bus" rule. With kernel
|
||||||
|
2.6.18, this rule is no longer required.
|
||||||
|
|
||||||
|
* doc/05-udev-early.txt: Update to match.
|
||||||
|
|
||||||
|
2006-09-28 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* doc/60-persistent-storage.txt: Explain persistent storage rules, or
|
||||||
|
at least the parts I understand. (I don't use DASD or netblock or
|
||||||
|
several other supported configurations.)
|
||||||
|
|
||||||
|
* doc/81-cdrom.txt: Explain 81-cdrom.rules.
|
||||||
|
|
||||||
|
* doc/95-udev-late.txt: Explain 95-udev-late.rules. Documentation is
|
||||||
|
now finished.
|
||||||
|
|
||||||
|
2006-09-26 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* doc/60-persistent-input.txt: Explain (in probably too much detail)
|
||||||
|
60-persistent-input.rules.
|
||||||
|
|
||||||
|
2006-09-24 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* doc/05-udev-early.txt: Rewrap to fit 80 columns.
|
||||||
|
|
||||||
|
* doc/26-modprobe.txt: Explain 26-modprobe.rules, and modaliases.
|
||||||
|
|
||||||
|
* doc/27-firmware.txt: Explain 27-firmware.rules.
|
||||||
|
|
||||||
|
2006-09-24 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* doc/25-lfs.txt: Explain 25-lfs.rules.
|
||||||
|
|
||||||
|
* 25-lfs.rules: Use SYMLINK+= for isdn/capi20 also.
|
||||||
|
|
||||||
|
2006-09-23 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* doc: New subdirectory to contain documentation of rules
|
||||||
|
* doc/README: New file, top-level documentation
|
||||||
|
* doc/*.txt: New documentation files, one for each rules file. Only
|
||||||
|
05-udev-early.txt has anything in it.
|
||||||
|
|
||||||
|
2006-09-23 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 25-lfs.rules: Add "ignore_device" to OPTIONS for DRI devices, instead
|
||||||
|
of setting NAME to an empty string. This matches the way we ignore
|
||||||
|
devmapper / LVM devices.
|
||||||
|
|
||||||
|
2006-09-22 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 60-persistent-input.rules, 95-udev-late.rules: Import from udev-100.
|
||||||
|
60-persistent-input.rules creates persistent symlinks for input
|
||||||
|
devices, and 95-udev-late.rules enables udevmonitor.
|
||||||
|
|
||||||
|
* 60-persistent-storage.rules: Replace ATTRS{../removable} with just
|
||||||
|
ATTRS{removable} on partition devices. Replace ATTRS{removable}
|
||||||
|
with ATTR{removable} on whole-disk devices.
|
||||||
|
|
||||||
|
2006-09-20 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* 05-early.rules: Missed a rule in the last change. ENV{PHYSDEVBUS}
|
||||||
|
in the rule that waits for the "bus" symlink should be replaced by
|
||||||
|
SUBSYSTEMS.
|
||||||
|
|
||||||
|
2006-09-20 Bryan Kadzban <bryan@linuxfromscratch.org>
|
||||||
|
* Adapted rules to the new matches used in udev-098 and above (e.g.,
|
||||||
|
SYSFS becomes ATTRS). Prevents warnings, and support for the old
|
||||||
|
matches will be removed eventually. These rules will not work with
|
||||||
|
udev-097 and before!
|
||||||
|
* Fixed several bugs in the rules left over from previous udev
|
||||||
|
versions (missing commas, overwriting user symlinks using ="..."
|
||||||
|
instead of +="...", and matching against "*" instead of "?*").
|
||||||
|
|
||||||
|
* Renamed CHANGELOG to ChangeLog, started using pseudo-GNU-format
|
||||||
|
entries. (See standards.info; search it for "changelog" to get
|
||||||
|
the general gist.)
|
||||||
|
|
||||||
|
dnicholson - Jul 14, 2006
|
||||||
|
* Fixed usbdev PROGRAM so that it works with the BusyBox sh. Thanks
|
||||||
|
to Anthony Wright.
|
||||||
|
|
||||||
|
n/a - Jul 12, 2006
|
||||||
|
* Added options so temporary nodes are not created with device-mapper
|
||||||
|
* Adapted cdrom rules to identify CD-ROM drives correctly by adding
|
||||||
|
SUBSYSTEM=="block" test.
|
||||||
|
* Added simple 81-cdrom.rules file to set cdrom group ownership
|
||||||
|
|
||||||
|
n/a - Jun 07, 2006
|
||||||
|
* Removed nvidia rules
|
||||||
|
* Removed bug reporting rule
|
||||||
|
* Moved Debian-based persistent CD-ROM rules to contrib
|
||||||
|
* Adapted firmware rule to udev-093
|
||||||
|
|
||||||
|
n/a - May 15, 2006
|
||||||
|
* Part one of 25-lfs.rules rewrite
|
||||||
|
* Some minor tweaking of the layout
|
||||||
|
|
||||||
|
n/a - May 12, 2006
|
||||||
|
* Initial import of the udev-config directory.
|
||||||
|
* Reorganized and modularized the rules files.
|
||||||
|
* Added explanatory comments
|
31
udev-lfs/Makefile.lfs
Normal file
31
udev-lfs/Makefile.lfs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Custom systemd Makefile that installs udev rules for LFS
|
||||||
|
# Bruce Dubbs 2014-04-02
|
||||||
|
|
||||||
|
# vim: tabstop=3
|
||||||
|
|
||||||
|
VERSION=20171102
|
||||||
|
SHELL=/bin/bash
|
||||||
|
|
||||||
|
ifeq ($(V),)
|
||||||
|
VB = @
|
||||||
|
else
|
||||||
|
VB =
|
||||||
|
endif
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo "Use the install target"
|
||||||
|
|
||||||
|
install:
|
||||||
|
@mkdir -pv $(DESTDIR)/lib/udev/rules.d \
|
||||||
|
$(DESTDIR)/etc/udev/rules.d \
|
||||||
|
$(DESTDIR)/usr/share/doc/udev-$(VERSION)/lfs
|
||||||
|
|
||||||
|
# Copy rules
|
||||||
|
@cp -v udev-lfs-$(VERSION)/*.rules $(DESTDIR)/etc/udev/rules.d
|
||||||
|
@cp -v udev-lfs-$(VERSION)/*_rules \
|
||||||
|
udev-lfs-$(VERSION)/init-net-rules.sh \
|
||||||
|
udev-lfs-$(VERSION)/rule_generator.functions $(DESTDIR)/lib/udev
|
||||||
|
|
||||||
|
# Copy documentation
|
||||||
|
@cp -v udev-lfs-$(VERSION)/README $(DESTDIR)/usr/share/doc/udev-$(VERSION)/lfs
|
||||||
|
@cp -v udev-lfs-$(VERSION)/*.txt $(DESTDIR)/usr/share/doc/udev-$(VERSION)/lfs
|
32
udev-lfs/README
Normal file
32
udev-lfs/README
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
The udev-lfs set of files is a customization of systemd.
|
||||||
|
In 2012, udev was merged with systemd and a build methodology
|
||||||
|
incompatible with LFS. These files add cusom udev rules
|
||||||
|
for LFS.
|
||||||
|
|
||||||
|
These files are distributed in the form of a tar file available
|
||||||
|
from the LFS file mirrors. The tarball is created with:
|
||||||
|
|
||||||
|
mkdir /tmp/udev-lfs-$VERSION
|
||||||
|
cp -av * /tmp/udev-lfs-$VERSION
|
||||||
|
tar -jcf /tmp/udev-lfs-$VERSION.tar.bz2 -C /tmp udev-lfs-$VERSION
|
||||||
|
|
||||||
|
Makefile.lfs - The LFS Makefile. Installs udev rules for LFS.
|
||||||
|
|
||||||
|
contrib - Useful rules from debian
|
||||||
|
contrib/debian
|
||||||
|
contrib/debian/83-cdrom-symlinks.rules
|
||||||
|
contrib/debian/write_cd_aliases
|
||||||
|
contrib/debian/81-cdrom.rules
|
||||||
|
|
||||||
|
55-lfs.rules - LFS custom rules
|
||||||
|
write_net_rules - Scripts for LFS rules
|
||||||
|
write_cd_rules
|
||||||
|
rule_generator.functions
|
||||||
|
|
||||||
|
55-lfs.txt - Documentation for LFS installed rules
|
||||||
|
|
||||||
|
ChangeLog - Log of changes to 55-lfs-rules
|
||||||
|
|
||||||
|
init-net-rules.sh - A script for establishing persistent network
|
||||||
|
rules before the first LFS boot
|
||||||
|
|
3
udev-lfs/contrib/debian/81-cdrom.rules
Normal file
3
udev-lfs/contrib/debian/81-cdrom.rules
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# /etc/udev/rules.d/81-cdrom.rules: Set CD-ROM permissions and get device capabilities
|
||||||
|
|
||||||
|
ACTION=="add", SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", IMPORT{program}="cdrom_id --export $tempnode", GROUP="cdrom"
|
12
udev-lfs/contrib/debian/83-cdrom-symlinks.rules
Normal file
12
udev-lfs/contrib/debian/83-cdrom-symlinks.rules
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# /etc/udev/rules.d/83-cdrom-symlinks.rules: Determine CD drive capability.
|
||||||
|
|
||||||
|
ACTION!="add", GOTO="cd_aliases_generator_end"
|
||||||
|
SUBSYSTEM!="block", GOTO="cd_aliases_generator_end"
|
||||||
|
ENV{GENERATED}=="?*", GOTO="cd_aliases_generator_end"
|
||||||
|
|
||||||
|
# Fail the uevent if the autogenerated rules cannot be saved
|
||||||
|
ENV{ID_CDROM}=="?*", PROGRAM="/bin/grep -c ' / [^[:space:]]* rw' /proc/mounts", RESULT!="2", RUN+="/bin/false", GOTO="cd_aliases_generator_end"
|
||||||
|
|
||||||
|
ENV{ID_CDROM}=="?*", PROGRAM="write_cd_aliases", SYMLINK+="%c"
|
||||||
|
|
||||||
|
LABEL="cd_aliases_generator_end"
|
120
udev-lfs/contrib/debian/write_cd_aliases
Normal file
120
udev-lfs/contrib/debian/write_cd_aliases
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
# Updated for LFS by B. Dubbs, 2012-09-23
|
||||||
|
# Fix RULES_LOCK location
|
||||||
|
|
||||||
|
|
||||||
|
RULES_FILE="/etc/udev/rules.d/82-persistent-cd.rules"
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
lock_rules_file() {
|
||||||
|
RULES_LOCK="/run/udev/lock-${RULES_FILE##*/}"
|
||||||
|
|
||||||
|
if [ ! -d /run/udev/ ]; then
|
||||||
|
echo "write_cd_aliases: /run/udev does not exist!" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
retry=10
|
||||||
|
while ! mkdir $RULES_LOCK 2> /dev/null; do
|
||||||
|
if [ $retry -eq 0 ]; then
|
||||||
|
echo "Cannot lock $RULES_FILE!" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
retry=$(($retry - 1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock_rules_file() {
|
||||||
|
rmdir $RULES_LOCK || true
|
||||||
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
find_next_available() {
|
||||||
|
# use echo to convert newlines to spaces
|
||||||
|
local links=`echo $(find_all_symlinks $1)`
|
||||||
|
local basename=${links%%[ 0-9]*}
|
||||||
|
local max=-1
|
||||||
|
for name in $links; do
|
||||||
|
local num=${name#$basename}
|
||||||
|
[ "$num" ] || num=0
|
||||||
|
[ $num -gt $max ] && max=$num
|
||||||
|
done
|
||||||
|
|
||||||
|
max=$(($max + 1))
|
||||||
|
# "name0" actually is just "name"
|
||||||
|
[ $max -eq 0 ] && return
|
||||||
|
echo "$max"
|
||||||
|
}
|
||||||
|
|
||||||
|
find_all_symlinks() {
|
||||||
|
local linkre="$1"
|
||||||
|
local match="$2"
|
||||||
|
|
||||||
|
[ -e $RULES_FILE ] || return
|
||||||
|
|
||||||
|
local search='.*[[:space:],]SYMLINK+="\('"$linkre"'\)"[[:space:]]*\(,.*\|\\\|\)$'
|
||||||
|
|
||||||
|
sed -n -e "${match}s/${search}/\1/p" $RULES_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
write_rule() {
|
||||||
|
local match="$1"
|
||||||
|
local link="$2"
|
||||||
|
local comment="$3"
|
||||||
|
|
||||||
|
[ -e "$RULES_FILE" ] || PRINT_HEADER=1
|
||||||
|
{
|
||||||
|
if [ "$PRINT_HEADER" ]; then
|
||||||
|
PRINT_HEADER=
|
||||||
|
echo "# This file was automatically generated by the $0"
|
||||||
|
echo "# program, probably run by the 83-cdrom.rules rules file."
|
||||||
|
echo "#"
|
||||||
|
echo "# You can modify it, as long as you keep each rule on a single line"
|
||||||
|
echo "# and set the \$GENERATED variable."
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$comment" ] && echo "# $comment"
|
||||||
|
echo "ACTION==\"add\", SUBSYSTEM==\"block\", $match, ENV{ID_CDROM}==\"1\", SYMLINK+=\"$link\", ENV{GENERATED}=\"1\""
|
||||||
|
} >> $RULES_FILE
|
||||||
|
SYMLINKS="$SYMLINKS $link"
|
||||||
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
if [ -z "$DEVPATH" ]; then
|
||||||
|
echo "Missing \$DEVPATH." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$ID_CDROM" ]; then
|
||||||
|
echo "$DEVPATH is not a CD reader." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prevent parallel processes from modifying the file at the same time.
|
||||||
|
lock_rules_file
|
||||||
|
|
||||||
|
link_num=$(find_next_available 'cdrom[0-9]*')
|
||||||
|
|
||||||
|
#match="ENV{ID_PATH}==\"$ID_PATH\""
|
||||||
|
|
||||||
|
#kernel=${DEVPATH##*/}
|
||||||
|
#match="KERNEL==\"$kernel\""
|
||||||
|
|
||||||
|
id=${PHYSDEVPATH##*/}
|
||||||
|
match="BUS==\"$PHYSDEVBUS\", ID==\"$id\""
|
||||||
|
|
||||||
|
comment="$ID_MODEL ($ID_PATH)"
|
||||||
|
|
||||||
|
write_rule "$match" "cdrom$link_num" "$comment"
|
||||||
|
[ "$ID_CDROM_CD_RW" ] && write_rule "$match" "cdrw$link_num"
|
||||||
|
[ "$ID_CDROM_DVD" ] && write_rule "$match" "dvd$link_num"
|
||||||
|
[ "$ID_CDROM_DVD_RW" ] && write_rule "$match" "dvdrw$link_num"
|
||||||
|
|
||||||
|
unlock_rules_file
|
||||||
|
|
||||||
|
echo $SYMLINKS
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
129
udev-lfs/init-net-rules.sh
Normal file
129
udev-lfs/init-net-rules.sh
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# This script generates rules for persistent network device naming
|
||||||
|
# Data from udev-182 75-persistent-net-generator.rules
|
||||||
|
# Updated fof udev-197 (DEVICES=en*)
|
||||||
|
|
||||||
|
RULES=/etc/udev/rules.d/70-persistent-net.rules
|
||||||
|
DEVICES=$(eval echo /sys/class/net/{en*,eth*,ath*,wlan*[0-9],msh*,ra*,sta*,ctc*,lcs*,hsi*})
|
||||||
|
|
||||||
|
function usage
|
||||||
|
{
|
||||||
|
echo $msg
|
||||||
|
echo "init-net-rules.sh is an LFS-specific script to initialize"
|
||||||
|
echo "$RULES"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
declare -A VENDORS_IGNORED
|
||||||
|
VENDORS_IGNORED['52:54:00:']="kvm"
|
||||||
|
VENDORS_IGNORED['00:0c:29:']="vmware"
|
||||||
|
VENDORS_IGNORED['00:50:56:']="vmware"
|
||||||
|
VENDORS_IGNORED['00:15:5d:']="hyper-v"
|
||||||
|
VENDORS_IGNORED['00:00:00:']="invalid"
|
||||||
|
|
||||||
|
declare -A VENDORS
|
||||||
|
VENDORS['02:07:01:']="Interlan, DEC, etc"
|
||||||
|
VENDORS['02:60:60:']="3com"
|
||||||
|
VENDORS['02:60:8c:']="3Com IBM PC; Imagen. etc"
|
||||||
|
VENDORS['02:a0:c9:']="intel"
|
||||||
|
VENDORS['02:aa:3c:']="Olivetti"
|
||||||
|
VENDORS['02:cf:1f:']="Masscomp, Silicon Graphics, etc"
|
||||||
|
VENDORS['02:e0:3b:']="Gigabit"
|
||||||
|
VENDORS['02:e6:d3:']="BTI"
|
||||||
|
VENDORS['52:54:00:']="Realtek"
|
||||||
|
VENDORS['52:54:4c:']="Novell"
|
||||||
|
VENDORS['52:54:ab:']="Realtek"
|
||||||
|
VENDORS['e2:0c:0f:']="Kingston"
|
||||||
|
VENDORS['00:16:3e:']="Xensource"
|
||||||
|
|
||||||
|
function ignore_if
|
||||||
|
{
|
||||||
|
if [[ "${VENDORS_IGNORED[$VENDOR]}" != "" ]]; then return 0; fi
|
||||||
|
if [[ "${VENDORS[$VENDOR]}" != "" ]]; then return 1; fi
|
||||||
|
|
||||||
|
byte2=$(echo $VENDOR | cut -c2)
|
||||||
|
if echo $byte2 | grep -q "[2367abef]"; then return 0; fi
|
||||||
|
|
||||||
|
return 1 # Default is to not ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
function comment
|
||||||
|
{
|
||||||
|
# Not implemented
|
||||||
|
# SUBSYSTEMS=="pci"
|
||||||
|
# export COMMENT="PCI device $attr{vendor}:$attr{device} ($driver)"
|
||||||
|
|
||||||
|
# SUBSYSTEMS=="usb", ATTRS{idVendor}=="?*"
|
||||||
|
# export COMMENT="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($driver)"
|
||||||
|
|
||||||
|
# SUBSYSTEMS=="pcmcia",
|
||||||
|
# export COMMENT="PCMCIA device $attr{card_id}:$attr{manf_id} ($driver)"
|
||||||
|
|
||||||
|
# SUBSYSTEMS=="ieee1394",
|
||||||
|
# export COMMENT="Firewire device $attr{host_id})"
|
||||||
|
|
||||||
|
# ibmveth likes to use "locally administered" MAC addresses
|
||||||
|
# DRIVERS=="ibmveth",
|
||||||
|
# export COMMENT="ibmveth ($id)"
|
||||||
|
|
||||||
|
# S/390 uses id matches only, do not use MAC address match
|
||||||
|
# SUBSYSTEMS=="ccwgroup",
|
||||||
|
# export COMMENT="S/390 $driver device at $id",
|
||||||
|
# export MATCHID="$id"
|
||||||
|
# export MATCHDRV="$driver"
|
||||||
|
# export MATCHADDR=""
|
||||||
|
|
||||||
|
# Default
|
||||||
|
driver=$(basename $(readlink -f $NIC/device/driver/module))
|
||||||
|
export COMMENT="net device ${driver}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! mountpoint -q /sys; then
|
||||||
|
msg="/sys must be mounted"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! mountpoint -q /proc; then
|
||||||
|
msg="/proc must be mounted"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e $RULES ]; then
|
||||||
|
msg="The rules file already exists"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ignore Xen virtual interfaces
|
||||||
|
if [ -e /proc/xen ]; then
|
||||||
|
msg="The rules file should not be created in the Xen environment"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Variables used to communicate with write_net_rules:
|
||||||
|
# INTERFACE simple interface name
|
||||||
|
# MATCHADDR MAC address used for the match
|
||||||
|
# MATCHID bus_id used for the match
|
||||||
|
# MATCHDRV driver name used for the match
|
||||||
|
# MATCHIFTYPE interface type match
|
||||||
|
# COMMENT comment to add to the generated rule
|
||||||
|
# INTERFACE_NAME requested name supplied by external tool
|
||||||
|
# INTERFACE_NEW new interface name returned by rule writer
|
||||||
|
|
||||||
|
for NIC in $DEVICES; do
|
||||||
|
IF=${NIC##*/}
|
||||||
|
if echo $NIC | grep -q '*' ; then continue; fi
|
||||||
|
|
||||||
|
export INTERFACE=${NIC##*/} # Simple interface name
|
||||||
|
export MATCHADDR="$(cat $NIC/address)" # Read MAC address
|
||||||
|
|
||||||
|
VENDOR=$(echo $MATCHADDR | cut -c-9)
|
||||||
|
if ignore_if; then continue; fi
|
||||||
|
|
||||||
|
export MATCHDEVID="$(cat $NIC/dev_id)"
|
||||||
|
export MATCHIFTYPE="$(cat $NIC/type)" # Read interface type
|
||||||
|
comment
|
||||||
|
|
||||||
|
/lib/udev/write_net_rules
|
||||||
|
done
|
||||||
|
|
115
udev-lfs/rule_generator.functions
Normal file
115
udev-lfs/rule_generator.functions
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
# functions used by the udev rule generator
|
||||||
|
|
||||||
|
# Copyright (C) 2006 Marco d'Itri <md@Linux.IT>
|
||||||
|
# Updated for LFS by Bruce Dubbs <bdubbs@linuxfromscratch.org>
|
||||||
|
# Hardcoded RUNDIR
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
PATH='/usr/bin:/bin:/usr/sbin:/sbin'
|
||||||
|
|
||||||
|
# Read a single line from file $1 in the $DEVPATH directory.
|
||||||
|
# The function must not return an error even if the file does not exist.
|
||||||
|
sysread() {
|
||||||
|
local file="$1"
|
||||||
|
[ -e "/sys$DEVPATH/$file" ] || return 0
|
||||||
|
local value
|
||||||
|
read value < "/sys$DEVPATH/$file" || return 0
|
||||||
|
echo "$value"
|
||||||
|
}
|
||||||
|
|
||||||
|
sysreadlink() {
|
||||||
|
local file="$1"
|
||||||
|
[ -e "/sys$DEVPATH/$file" ] || return 0
|
||||||
|
readlink -f /sys$DEVPATH/$file 2> /dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return true if a directory is writeable.
|
||||||
|
writeable() {
|
||||||
|
if ln -s test-link $1/.is-writeable 2> /dev/null; then
|
||||||
|
rm -f $1/.is-writeable
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a lock file for the current rules file.
|
||||||
|
lock_rules_file() {
|
||||||
|
RUNDIR=/run/udev
|
||||||
|
[ -e "$RUNDIR" ] || return 0
|
||||||
|
|
||||||
|
RULES_LOCK="$RUNDIR/.lock-${RULES_FILE##*/}"
|
||||||
|
|
||||||
|
retry=30
|
||||||
|
while ! mkdir $RULES_LOCK 2> /dev/null; do
|
||||||
|
if [ $retry -eq 0 ]; then
|
||||||
|
echo "Cannot lock $RULES_FILE!" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
retry=$(($retry - 1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock_rules_file() {
|
||||||
|
[ "$RULES_LOCK" ] || return 0
|
||||||
|
rmdir $RULES_LOCK || true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Choose the real rules file if it is writeable or a temporary file if not.
|
||||||
|
# Both files should be checked later when looking for existing rules.
|
||||||
|
choose_rules_file() {
|
||||||
|
RUNDIR=/run/udev
|
||||||
|
local tmp_rules_file="$RUNDIR/tmp-rules--${RULES_FILE##*/}"
|
||||||
|
[ -e "$RULES_FILE" -o -e "$tmp_rules_file" ] || PRINT_HEADER=1
|
||||||
|
|
||||||
|
if writeable ${RULES_FILE%/*}; then
|
||||||
|
RO_RULES_FILE='/dev/null'
|
||||||
|
else
|
||||||
|
RO_RULES_FILE=$RULES_FILE
|
||||||
|
RULES_FILE=$tmp_rules_file
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return the name of the first free device.
|
||||||
|
raw_find_next_available() {
|
||||||
|
local links="$1"
|
||||||
|
|
||||||
|
local basename=${links%%[ 0-9]*}
|
||||||
|
local max=-1
|
||||||
|
for name in $links; do
|
||||||
|
local num=${name#$basename}
|
||||||
|
[ "$num" ] || num=0
|
||||||
|
[ $num -gt $max ] && max=$num
|
||||||
|
done
|
||||||
|
|
||||||
|
local max=$(($max + 1))
|
||||||
|
# "name0" actually is just "name"
|
||||||
|
[ $max -eq 0 ] && return
|
||||||
|
echo "$max"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find all rules matching a key (with action) and a pattern.
|
||||||
|
find_all_rules() {
|
||||||
|
local key="$1"
|
||||||
|
local linkre="$2"
|
||||||
|
local match="$3"
|
||||||
|
|
||||||
|
local search='.*[[:space:],]'"$key"'"('"$linkre"')".*'
|
||||||
|
echo $(sed -n -r -e 's/^#.*//' -e "${match}s/${search}/\1/p" \
|
||||||
|
$RO_RULES_FILE \
|
||||||
|
$([ -e $RULES_FILE ] && echo $RULES_FILE) \
|
||||||
|
2>/dev/null)
|
||||||
|
}
|
126
udev-lfs/write_cd_rules
Normal file
126
udev-lfs/write_cd_rules
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
# This script is run if an optical drive lacks a rule for persistent naming.
|
||||||
|
#
|
||||||
|
# It adds symlinks for optical drives based on the device class determined
|
||||||
|
# by cdrom_id and used ID_PATH to identify the device.
|
||||||
|
|
||||||
|
# (C) 2006 Marco d'Itri <md@Linux.IT>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# debug, if UDEV_LOG=<debug>
|
||||||
|
if [ -n "$UDEV_LOG" ]; then
|
||||||
|
if [ "$UDEV_LOG" -ge 7 ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
RULES_FILE="/etc/udev/rules.d/70-persistent-cd.rules"
|
||||||
|
|
||||||
|
. /lib/udev/rule_generator.functions
|
||||||
|
|
||||||
|
find_next_available() {
|
||||||
|
raw_find_next_available "$(find_all_rules 'SYMLINK\+=' "$1")"
|
||||||
|
}
|
||||||
|
|
||||||
|
write_rule() {
|
||||||
|
local match="$1"
|
||||||
|
local link="$2"
|
||||||
|
local comment="$3"
|
||||||
|
|
||||||
|
{
|
||||||
|
if [ "$PRINT_HEADER" ]; then
|
||||||
|
PRINT_HEADER=
|
||||||
|
echo "# This file was automatically generated by the $0"
|
||||||
|
echo "# program, run by the cd-aliases-generator.rules rules file."
|
||||||
|
echo "#"
|
||||||
|
echo "# You can modify it, as long as you keep each rule on a single"
|
||||||
|
echo "# line, and set the \$GENERATED variable."
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$comment" ] && echo "# $comment"
|
||||||
|
echo "$match, SYMLINK+=\"$link\", ENV{GENERATED}=\"1\""
|
||||||
|
} >> $RULES_FILE
|
||||||
|
SYMLINKS="$SYMLINKS $link"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$DEVPATH" ]; then
|
||||||
|
echo "Missing \$DEVPATH." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$ID_CDROM" ]; then
|
||||||
|
echo "$DEVPATH is not a CD reader." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" ]; then
|
||||||
|
METHOD="$1"
|
||||||
|
else
|
||||||
|
METHOD='by-path'
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$METHOD" in
|
||||||
|
by-path)
|
||||||
|
if [ -z "$ID_PATH" ]; then
|
||||||
|
echo "$DEVPATH not supported by path_id. by-id may work." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
RULE="ENV{ID_PATH}==\"$ID_PATH\""
|
||||||
|
;;
|
||||||
|
|
||||||
|
by-id)
|
||||||
|
if [ "$ID_SERIAL" ]; then
|
||||||
|
RULE="ENV{ID_SERIAL}==\"$ID_SERIAL\""
|
||||||
|
elif [ "$ID_MODEL" -a "$ID_REVISION" ]; then
|
||||||
|
RULE="ENV{ID_MODEL}==\"$ID_MODEL\", ENV{ID_REVISION}==\"$ID_REVISION\""
|
||||||
|
else
|
||||||
|
echo "$DEVPATH not supported by ata_id. by-path may work." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Invalid argument (must be either by-path or by-id)." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Prevent concurrent processes from modifying the file at the same time.
|
||||||
|
lock_rules_file
|
||||||
|
|
||||||
|
# Check if the rules file is writeable.
|
||||||
|
choose_rules_file
|
||||||
|
|
||||||
|
link_num=$(find_next_available 'cdrom[0-9]*')
|
||||||
|
|
||||||
|
match="SUBSYSTEM==\"block\", ENV{ID_CDROM}==\"?*\", $RULE"
|
||||||
|
|
||||||
|
comment="$ID_MODEL ($ID_PATH)"
|
||||||
|
|
||||||
|
write_rule "$match" "cdrom$link_num" "$comment"
|
||||||
|
[ "$ID_CDROM_CD_R" -o "$ID_CDROM_CD_RW" ] && \
|
||||||
|
write_rule "$match" "cdrw$link_num"
|
||||||
|
[ "$ID_CDROM_DVD" ] && \
|
||||||
|
write_rule "$match" "dvd$link_num"
|
||||||
|
[ "$ID_CDROM_DVD_R" -o "$ID_CDROM_DVD_RW" -o "$ID_CDROM_DVD_RAM" ] && \
|
||||||
|
write_rule "$match" "dvdrw$link_num"
|
||||||
|
echo >> $RULES_FILE
|
||||||
|
|
||||||
|
unlock_rules_file
|
||||||
|
|
||||||
|
echo $SYMLINKS
|
||||||
|
|
||||||
|
exit 0
|
140
udev-lfs/write_net_rules
Normal file
140
udev-lfs/write_net_rules
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
# This script is run to create persistent network device naming rules
|
||||||
|
# based on properties of the device.
|
||||||
|
# If the interface needs to be renamed, INTERFACE_NEW=<name> will be printed
|
||||||
|
# on stdout to allow udev to IMPORT it.
|
||||||
|
|
||||||
|
# variables used to communicate:
|
||||||
|
# MATCHADDR MAC address used for the match
|
||||||
|
# MATCHID bus_id used for the match
|
||||||
|
# MATCHDEVID dev_id used for the match
|
||||||
|
# MATCHDRV driver name used for the match
|
||||||
|
# MATCHIFTYPE interface type match
|
||||||
|
# COMMENT comment to add to the generated rule
|
||||||
|
# INTERFACE_NAME requested name supplied by external tool
|
||||||
|
# INTERFACE_NEW new interface name returned by rule writer
|
||||||
|
|
||||||
|
# Copyright (C) 2006 Marco d'Itri <md@Linux.IT>
|
||||||
|
# Copyright (C) 2007 Kay Sievers <kay.sievers@vrfy.org>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# debug, if UDEV_LOG=<debug>
|
||||||
|
if [ -n "$UDEV_LOG" ]; then
|
||||||
|
if [ "$UDEV_LOG" -ge 7 ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules'
|
||||||
|
|
||||||
|
. /lib/udev/rule_generator.functions
|
||||||
|
|
||||||
|
interface_name_taken() {
|
||||||
|
local value="$(find_all_rules 'NAME=' $INTERFACE)"
|
||||||
|
if [ "$value" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
find_next_available() {
|
||||||
|
raw_find_next_available "$(find_all_rules 'NAME=' "$1")"
|
||||||
|
}
|
||||||
|
|
||||||
|
write_rule() {
|
||||||
|
local match="$1"
|
||||||
|
local name="$2"
|
||||||
|
local comment="$3"
|
||||||
|
|
||||||
|
{
|
||||||
|
if [ "$PRINT_HEADER" ]; then
|
||||||
|
PRINT_HEADER=
|
||||||
|
echo "# This file was automatically generated by the $0"
|
||||||
|
echo "# program, run by the persistent-net-generator.rules rules file."
|
||||||
|
echo "#"
|
||||||
|
echo "# You can modify it, as long as you keep each rule on a single"
|
||||||
|
echo "# line, and change only the value of the NAME= key."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
[ "$comment" ] && echo "# $comment"
|
||||||
|
echo "SUBSYSTEM==\"net\", ACTION==\"add\"$match, NAME=\"$name\""
|
||||||
|
} >> $RULES_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$INTERFACE" ]; then
|
||||||
|
echo "missing \$INTERFACE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prevent concurrent processes from modifying the file at the same time.
|
||||||
|
lock_rules_file
|
||||||
|
|
||||||
|
# Check if the rules file is writeable.
|
||||||
|
choose_rules_file
|
||||||
|
|
||||||
|
# the DRIVERS key is needed to not match bridges and VLAN sub-interfaces
|
||||||
|
if [ "$MATCHADDR" ]; then
|
||||||
|
match="$match, DRIVERS==\"?*\", ATTR{address}==\"$MATCHADDR\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MATCHDRV" ]; then
|
||||||
|
match="$match, DRIVERS==\"$MATCHDRV\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MATCHDEVID" ]; then
|
||||||
|
match="$match, ATTR{dev_id}==\"$MATCHDEVID\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MATCHID" ]; then
|
||||||
|
match="$match, KERNELS==\"$MATCHID\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$MATCHIFTYPE" ]; then
|
||||||
|
match="$match, ATTR{type}==\"$MATCHIFTYPE\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$match" ]; then
|
||||||
|
echo "missing valid match" >&2
|
||||||
|
unlock_rules_file
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
basename=${INTERFACE%%[0-9]*}
|
||||||
|
|
||||||
|
if [ "$INTERFACE_NAME" ]; then
|
||||||
|
# external tools may request a custom name
|
||||||
|
COMMENT="$COMMENT (custom name provided by external tool)"
|
||||||
|
if [ "$INTERFACE_NAME" != "$INTERFACE" ]; then
|
||||||
|
INTERFACE=$INTERFACE_NAME;
|
||||||
|
echo "INTERFACE_NEW=$INTERFACE"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# if a rule using the current name already exists, find a new name
|
||||||
|
if interface_name_taken; then
|
||||||
|
INTERFACE="$basename$(find_next_available "$basename[0-9]*")"
|
||||||
|
# prevent INTERFACE from being "eth" instead of "eth0"
|
||||||
|
[ "$INTERFACE" = "${INTERFACE%%[ \[\]0-9]*}" ] && INTERFACE=${INTERFACE}0
|
||||||
|
echo "INTERFACE_NEW=$INTERFACE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
write_rule "$match" "$INTERFACE" "$COMMENT"
|
||||||
|
|
||||||
|
unlock_rules_file
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user