diff options
-rw-r--r-- | Makefile.am | 25 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | extras/firmware/.gitignore | 1 | ||||
-rw-r--r-- | extras/firmware/50-firmware.rules | 4 | ||||
-rw-r--r-- | extras/firmware/firmware.c | 192 | ||||
-rw-r--r-- | rules/rules.d/50-udev-default.rules | 2 | ||||
-rw-r--r-- | udev/udev-builtin-kmod.c | 2 | ||||
-rw-r--r-- | udev/udev-builtin.c | 7 | ||||
-rw-r--r-- | udev/udev.h | 14 |
9 files changed, 32 insertions, 220 deletions
diff --git a/Makefile.am b/Makefile.am index 8c4ea4b0fb..769a6f5001 100644 --- a/Makefile.am +++ b/Makefile.am @@ -201,11 +201,12 @@ udev_common_sources = \ udev/udev-rules.c \ udev/udev-ctrl.c \ udev/udev-builtin.c \ - udev/udev-builtin-path_id.c \ - udev/udev-builtin-usb_id.c \ - udev/udev-builtin-input_id.c \ udev/udev-builtin-blkid.c \ - udev/udev-builtin-kmod.c + udev/udev-builtin-firmware.c \ + udev/udev-builtin-input_id.c \ + udev/udev-builtin-kmod.c \ + udev/udev-builtin-path_id.c \ + udev/udev-builtin-usb_id.c udev_common_CFLAGS = \ $(BLKID_CFLAGS) \ @@ -216,6 +217,10 @@ udev_common_LDADD = \ $(BLKID_LIBS) \ $(KMOD_LIBS) +udev_common_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -DFIRMWARE_PATH="$(FIRMWARE_PATH)" + udev_udevd_SOURCES = \ $(udev_common_sources) \ udev/udevd.c \ @@ -223,6 +228,7 @@ udev_udevd_SOURCES = \ udev/sd-daemon.c udev_udevd_CFLAGS = $(udev_common_CFLAGS) udev_udevd_LDADD = $(udev_common_LDADD) +udev_udevd_CPPFLAGS = $(udev_common_CPPFLAGS) udev_udevadm_SOURCES = \ $(udev_common_sources) \ @@ -236,6 +242,7 @@ udev_udevadm_SOURCES = \ udev/udevadm-test-builtin.c udev_udevadm_CFLAGS = $(udev_common_CFLAGS) udev_udevadm_LDADD = $(udev_common_LDADD) +udev_udevadm_CPPFLAGS = $(udev_common_CPPFLAGS) # ------------------------------------------------------------------------------ # udev man pages @@ -278,15 +285,7 @@ udev_test_udev_SOURCES = \ udev/test-udev.c udev_test_udev_CFLAGS = $(udev_common_CFLAGS) udev_test_udev_LDADD = $(udev_common_LDADD) - -# ------------------------------------------------------------------------------ -# firmware - firmware loading -# ------------------------------------------------------------------------------ -extras_firmware_firmware_SOURCES = extras/firmware/firmware.c -extras_firmware_firmware_LDADD = libudev/libudev-private.la -extras_firmware_firmware_CPPFLAGS = $(AM_CPPFLAGS) -DFIRMWARE_PATH="$(FIRMWARE_PATH)" -dist_udevrules_DATA += extras/firmware/50-firmware.rules -libexec_PROGRAMS += extras/firmware/firmware +udev_test_udev_CPPFLAGS = $(udev_common_CPPFLAGS) # ------------------------------------------------------------------------------ # ata_id - ATA identify @@ -15,6 +15,11 @@ The /sbin/modprobe tool is no longer executed by udev. The /sbin/blkid tool is no longer executed from udev rules. Udev links directly to libblkid now. +Firmware is loaded natively by udev now, the external firmware loading +binary is no longer used. + +All built-in tools can be listed and tested with 'udevadm test-builtin'. + The 'udevadm control --reload-rules' option has been renamed to '--reload'. It reloads the kernel module configuration. diff --git a/extras/firmware/.gitignore b/extras/firmware/.gitignore deleted file mode 100644 index 2b8800bd46..0000000000 --- a/extras/firmware/.gitignore +++ /dev/null @@ -1 +0,0 @@ -firmware diff --git a/extras/firmware/50-firmware.rules b/extras/firmware/50-firmware.rules deleted file mode 100644 index a193adbced..0000000000 --- a/extras/firmware/50-firmware.rules +++ /dev/null @@ -1,4 +0,0 @@ -# do not edit this file, it will be overwritten on update - -# firmware-class requests, copies files into the kernel -SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware --firmware=$env{FIRMWARE} --devpath=$env{DEVPATH}" diff --git a/extras/firmware/firmware.c b/extras/firmware/firmware.c deleted file mode 100644 index 36ce79054c..0000000000 --- a/extras/firmware/firmware.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * firmware - Load firmware device - * - * Copyright (C) 2009 Piter Punk <piterpunk@slackware.com> - * Copyright (C) 2009 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:* - */ - -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <getopt.h> -#include <errno.h> -#include <stdbool.h> -#include <sys/utsname.h> -#include <sys/stat.h> -#include "libudev-private.h" - -static bool set_loading(struct udev *udev, char *loadpath, const char *state) -{ - FILE *ldfile; - - ldfile = fopen(loadpath, "w"); - if (ldfile == NULL) { - err(udev, "error: can not open '%s'\n", loadpath); - return false; - }; - fprintf(ldfile, "%s\n", state); - fclose(ldfile); - return true; -} - -static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size) -{ - char *buf; - FILE *fsource = NULL, *ftarget = NULL; - bool ret = false; - - buf = malloc(size); - if (buf == NULL) { - err(udev,"No memory available to load firmware file"); - return false; - } - - fsource = fopen(source, "r"); - if (fsource == NULL) - goto exit; - ftarget = fopen(target, "w"); - if (ftarget == NULL) - goto exit; - if (fread(buf, size, 1, fsource) != 1) - goto exit; - if (fwrite(buf, size, 1, ftarget) == 1) - ret = true; -exit: - if (ftarget != NULL) - fclose(ftarget); - if (fsource != NULL) - fclose(fsource); - free(buf); - return ret; -} - -int main(int argc, char **argv) -{ - static const struct option options[] = { - { "firmware", required_argument, NULL, 'f' }, - { "devpath", required_argument, NULL, 'p' }, - { "help", no_argument, NULL, 'h' }, - {} - }; - static const char *searchpath[] = { FIRMWARE_PATH }; - char fwencpath[UTIL_PATH_SIZE]; - char misspath[UTIL_PATH_SIZE]; - char loadpath[UTIL_PATH_SIZE]; - char datapath[UTIL_PATH_SIZE]; - char fwpath[UTIL_PATH_SIZE]; - char *devpath = NULL; - char *firmware = NULL; - FILE *fwfile; - struct utsname kernel; - struct stat statbuf; - struct udev *udev = NULL; - unsigned int i; - int rc = 0; - - udev_log_init("firmware"); - - for (;;) { - int option; - - option = getopt_long(argc, argv, "f:p:h", options, NULL); - if (option == -1) - break; - - switch (option) { - case 'f': - firmware = optarg; - break; - case 'p': - devpath = optarg; - break; - case 'h': - printf("Usage: firmware --firmware=<fwfile> --devpath=<path> [--help]\n\n"); - goto exit; - } - } - - if (devpath == NULL || firmware == NULL) { - fprintf(stderr, "firmware or devpath parameter missing\n\n"); - rc = 1; - goto exit; - } - - udev = udev_new(); - if (udev == NULL) { - rc = 1; - goto exit; - }; - - /* lookup firmware file */ - uname(&kernel); - for (i = 0; i < ARRAY_SIZE(searchpath); i++) { - util_strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL); - dbg(udev, "trying %s\n", fwpath); - fwfile = fopen(fwpath, "r"); - if (fwfile != NULL) - break; - - util_strscpyl(fwpath, sizeof(fwpath), searchpath[i], firmware, NULL); - dbg(udev, "trying %s\n", fwpath); - fwfile = fopen(fwpath, "r"); - if (fwfile != NULL) - break; - } - - util_path_encode(firmware, fwencpath, sizeof(fwencpath)); - util_strscpyl(misspath, sizeof(misspath), udev_get_run_path(udev), "/firmware-missing/", fwencpath, NULL); - util_strscpyl(loadpath, sizeof(loadpath), udev_get_sys_path(udev), devpath, "/loading", NULL); - - if (fwfile == NULL) { - int err; - - /* This link indicates the missing firmware file and the associated device */ - info(udev, "did not find firmware file '%s'\n", firmware); - do { - err = util_create_path(udev, misspath); - if (err != 0 && err != -ENOENT) - break; - err = symlink(devpath, misspath); - if (err != 0) - err = -errno; - } while (err == -ENOENT); - rc = 2; - set_loading(udev, loadpath, "-1"); - goto exit; - } - - if (stat(fwpath, &statbuf) < 0 || statbuf.st_size == 0) { - rc = 3; - goto exit; - } - if (unlink(misspath) == 0) - util_delete_path(udev, misspath); - - if (!set_loading(udev, loadpath, "1")) - goto exit; - - util_strscpyl(datapath, sizeof(datapath), udev_get_sys_path(udev), devpath, "/data", NULL); - if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) { - err(udev, "error sending firmware '%s' to device\n", firmware); - set_loading(udev, loadpath, "-1"); - rc = 4; - goto exit; - }; - - set_loading(udev, loadpath, "0"); -exit: - udev_unref(udev); - udev_log_close(); - return rc; -} diff --git a/rules/rules.d/50-udev-default.rules b/rules/rules.d/50-udev-default.rules index c47cdeceb1..353e31d8b9 100644 --- a/rules/rules.d/50-udev-default.rules +++ b/rules/rules.d/50-udev-default.rules @@ -103,3 +103,5 @@ SUBSYSTEM=="rtc", DRIVERS=="rtc_cmos", SYMLINK+="rtc" KERNEL=="mmtimer", MODE="0644" KERNEL=="rflash[0-9]*", MODE="0400" KERNEL=="rrom[0-9]*", MODE="0400" + +SUBSYSTEM=="firmware", ACTION=="add", IMPORT{builtin}="firmware" diff --git a/udev/udev-builtin-kmod.c b/udev/udev-builtin-kmod.c index 6f3e2589c2..e6c4d95109 100644 --- a/udev/udev-builtin-kmod.c +++ b/udev/udev-builtin-kmod.c @@ -336,7 +336,7 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te } for (i = 2; argv[i]; i++) { - info(udev, "%s '%s'\n", argv[1], argv[i]); + info(udev, "execute '%s' '%s'\n", argv[1], argv[i]); insmod(ctx, argv[i], NULL); } diff --git a/udev/udev-builtin.c b/udev/udev-builtin.c index baf09b91b9..cf62d57e23 100644 --- a/udev/udev-builtin.c +++ b/udev/udev-builtin.c @@ -26,11 +26,12 @@ #include "udev.h" static const struct udev_builtin *builtins[] = { - [UDEV_BUILTIN_PATH_ID] = &udev_builtin_path_id, - [UDEV_BUILTIN_USB_ID] = &udev_builtin_usb_id, - [UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id, [UDEV_BUILTIN_BLKID] = &udev_builtin_blkid, + [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware, + [UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id, [UDEV_BUILTIN_KMOD] = &udev_builtin_kmod, + [UDEV_BUILTIN_PATH_ID] = &udev_builtin_path_id, + [UDEV_BUILTIN_USB_ID] = &udev_builtin_usb_id, }; int udev_builtin_init(struct udev *udev) diff --git a/udev/udev.h b/udev/udev.h index 7bd2228a6b..3327031e87 100644 --- a/udev/udev.h +++ b/udev/udev.h @@ -148,11 +148,12 @@ extern const struct udevadm_cmd udevadm_test_builtin; /* built-in commands */ enum udev_builtin_cmd { - UDEV_BUILTIN_PATH_ID, - UDEV_BUILTIN_USB_ID, - UDEV_BUILTIN_INPUT_ID, UDEV_BUILTIN_BLKID, + UDEV_BUILTIN_FIRMWARE, + UDEV_BUILTIN_INPUT_ID, UDEV_BUILTIN_KMOD, + UDEV_BUILTIN_PATH_ID, + UDEV_BUILTIN_USB_ID, UDEV_BUILTIN_MAX }; struct udev_builtin { @@ -163,11 +164,12 @@ struct udev_builtin { int (*exit)(struct udev *udev); bool run_once; }; -extern const struct udev_builtin udev_builtin_path_id; -extern const struct udev_builtin udev_builtin_usb_id; -extern const struct udev_builtin udev_builtin_input_id; extern const struct udev_builtin udev_builtin_blkid; +extern const struct udev_builtin udev_builtin_firmware; +extern const struct udev_builtin udev_builtin_input_id; extern const struct udev_builtin udev_builtin_kmod; +extern const struct udev_builtin udev_builtin_path_id; +extern const struct udev_builtin udev_builtin_usb_id; int udev_builtin_load(struct udev *udev); int udev_builtin_unload(struct udev *udev); enum udev_builtin_cmd udev_builtin_lookup(const char *command); |