[systemd-devel] [PATCH 5/5] udev: make firmware loading optional and disable by default
Tom Gundersen
teg at jklm.no
Mon Mar 18 06:17:28 PDT 2013
Distros that whish to support old kernels should set
--with-firmware-dirs="/usr/lib/firmware/updates:/usr/lib/firmware"
to retain the old behaviour.
The hack which makes firmware events skip the dependency tracking is still
preserved, this would allow adding back firmware handling by a custom udev rule
and external tool, even if udev itself is built without firmware support.
This feature is probably not hugely useful, but I'd rather not add the ifdefry
to udevd.c itself.
---
Makefile.am | 16 ++++++++++++----
configure.ac | 7 ++++---
rules/50-firmware.rules | 1 +
rules/50-udev-default.rules | 1 -
src/udev/udev-builtin.c | 2 ++
src/udev/udev.h | 4 ++++
6 files changed, 23 insertions(+), 8 deletions(-)
create mode 100644 rules/50-firmware.rules
diff --git a/Makefile.am b/Makefile.am
index 7e9cdfd..37eeb01 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1352,12 +1352,10 @@ rootlibexec_PROGRAMS += \
nodist_systemunit_DATA += \
units/systemd-modules-load.service
+
SYSINIT_TARGET_WANTS += \
systemd-modules-load.service
-dist_udevrules_DATA += \
- rules/80-drivers.rules
-
endif
EXTRA_DIST += \
@@ -1809,7 +1807,6 @@ libudev_core_la_SOURCES = \
src/udev/udev-ctrl.c \
src/udev/udev-builtin.c \
src/udev/udev-builtin-btrfs.c \
- src/udev/udev-builtin-firmware.c \
src/udev/udev-builtin-hwdb.c \
src/udev/udev-builtin-input_id.c \
src/udev/udev-builtin-net_id.c \
@@ -1833,9 +1830,20 @@ libudev_core_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
-DFIRMWARE_PATH="$(FIRMWARE_PATH)"
+if ENABLE_FIRMWARE
+libudev_core_la_SOURCES += \
+ src/udev/udev-builtin-firmware.c
+
+dist_udevrules_DATA += \
+ rules/50-firmware.rules
+endif
+
if HAVE_KMOD
libudev_core_la_SOURCES += \
src/udev/udev-builtin-kmod.c
+
+dist_udevrules_DATA += \
+ rules/80-drivers.rules
endif
if HAVE_BLKID
diff --git a/configure.ac b/configure.ac
index 28d7286..14411e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -705,8 +705,8 @@ AM_CONDITIONAL(HAVE_MYHOSTNAME, [test "$have_myhostname" = "yes"])
# ------------------------------------------------------------------------------
AC_ARG_WITH(firmware-path,
AS_HELP_STRING([--with-firmware-path=DIR[[[:DIR[...]]]]],
- [Firmware search path (default=ROOTPREFIX/lib/firmware/updates:ROOTPREFIX/lib/firmware)]),
- [], [with_firmware_path="$rootprefix/lib/firmware/updates:$rootprefix/lib/firmware"])
+ [Firmware search path (default="")]),
+ [], [with_firmware_path=""])
OLD_IFS=$IFS
IFS=:
for i in $with_firmware_path; do
@@ -717,7 +717,8 @@ for i in $with_firmware_path; do
fi
done
IFS=$OLD_IFS
-AC_SUBST([FIRMWARE_PATH], [$FIRMWARE_PATH])
+AC_SUBST(FIRMWARE_PATH)
+AM_CONDITIONAL(ENABLE_FIRMWARE, [test "x${FIRMWARE_PATH}" != "x"])
# ------------------------------------------------------------------------------
AC_ARG_ENABLE([gudev],
diff --git a/rules/50-firmware.rules b/rules/50-firmware.rules
new file mode 100644
index 0000000..ca98b40
--- /dev/null
+++ b/rules/50-firmware.rules
@@ -0,0 +1 @@
+SUBSYSTEM=="firmware", ACTION=="add", RUN{builtin}="firmware"
diff --git a/rules/50-udev-default.rules b/rules/50-udev-default.rules
index 56e4c8b..9d17cf7 100644
--- a/rules/50-udev-default.rules
+++ b/rules/50-udev-default.rules
@@ -64,5 +64,4 @@ SUBSYSTEM=="virtio-ports", KERNEL=="vport*", ATTR{name}=="?*", SYMLINK+="virtio-
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb"
SUBSYSTEM=="input", ENV{ID_INPUT}=="", IMPORT{builtin}="input_id"
-SUBSYSTEM=="firmware", ACTION=="add", RUN{builtin}="firmware"
ENV{MODALIAS}!="", IMPORT{builtin}="hwdb --subsystem=$env{SUBSYSTEM}"
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index 57d75a1..13922d3 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -34,7 +34,9 @@ static const struct udev_builtin *builtins[] = {
[UDEV_BUILTIN_BLKID] = &udev_builtin_blkid,
#endif
[UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs,
+#ifdef ENABLE_FIRMWARE
[UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware,
+#endif
[UDEV_BUILTIN_HWDB] = &udev_builtin_hwdb,
[UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
#ifdef HAVE_KMOD
diff --git a/src/udev/udev.h b/src/udev/udev.h
index b54cb58..aa2edbe 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -140,7 +140,9 @@ enum udev_builtin_cmd {
UDEV_BUILTIN_BLKID,
#endif
UDEV_BUILTIN_BTRFS,
+#ifdef ENABLE_FIRMWARE
UDEV_BUILTIN_FIRMWARE,
+#endif
UDEV_BUILTIN_HWDB,
UDEV_BUILTIN_INPUT_ID,
#ifdef HAVE_KMOD
@@ -167,7 +169,9 @@ struct udev_builtin {
extern const struct udev_builtin udev_builtin_blkid;
#endif
extern const struct udev_builtin udev_builtin_btrfs;
+#ifdef ENABLE_FIRMWARE
extern const struct udev_builtin udev_builtin_firmware;
+#endif
extern const struct udev_builtin udev_builtin_hwdb;
extern const struct udev_builtin udev_builtin_input_id;
#ifdef HAVE_KMOD
--
1.8.2
More information about the systemd-devel
mailing list