#include "sd-daemon.h"
#include "cgroup-util.h"
#include "dev-setup.h"
+#include "fileio.h"
static bool debug;
dev_t devnum;
int ifindex;
bool is_block;
+#ifdef ENABLE_FIRMWARE
bool nodelay;
+#endif
};
static inline struct event *node_to_event(struct udev_list_node *node)
event->devnum = udev_device_get_devnum(dev);
event->is_block = streq("block", udev_device_get_subsystem(dev));
event->ifindex = udev_device_get_ifindex(dev);
+#ifdef ENABLE_FIRMWARE
if (streq(udev_device_get_subsystem(dev), "firmware"))
event->nodelay = true;
+#endif
udev_queue_export_device_queued(udev_queue_export, dev);
log_debug("seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(dev),
return true;
/* check our old name */
- if (event->devpath_old != NULL && strcmp(loop_event->devpath, event->devpath_old) == 0) {
+ if (event->devpath_old != NULL && streq(loop_event->devpath, event->devpath_old)) {
event->delaying_seqnum = loop_event->seqnum;
return true;
}
return true;
}
+#ifdef ENABLE_FIRMWARE
/* allow to bypass the dependency tracking */
if (event->nodelay)
continue;
+#endif
/* parent device event found */
if (event->devpath[common] == '/') {
int fd;
log_debug("device %s closed, synthesising 'change'\n", udev_device_get_devnode(dev));
- util_strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
+ strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
fd = open(filename, O_WRONLY);
if (fd >= 0) {
if (write(fd, "change", 6) < 0)
FILE *f;
uname(&kernel);
- util_strscpyl(modules, sizeof(modules), ROOTPREFIX "/lib/modules/", kernel.release, "/modules.devname", NULL);
+ strscpyl(modules, sizeof(modules), ROOTPREFIX "/lib/modules/", kernel.release, "/modules.devname", NULL);
f = fopen(modules, "re");
if (f == NULL)
return;
else
continue;
- util_strscpyl(filename, sizeof(filename), "/dev/", devname, NULL);
+ strscpyl(filename, sizeof(filename), "/dev/", devname, NULL);
mkdir_parents_label(filename, 0755);
label_context_set(filename, mode);
log_debug("mknod '%s' %c%u:%u\n", filename, type, maj, min);
return memsize;
}
-static int convert_db(struct udev *udev)
-{
- char filename[UTIL_PATH_SIZE];
- struct udev_enumerate *udev_enumerate;
- struct udev_list_entry *list_entry;
-
- /* current database */
- if (access("/run/udev/data", F_OK) >= 0)
- return 0;
-
- /* make sure we do not get here again */
- mkdir_p("/run/udev/data", 0755);
-
- /* old database */
- util_strscpyl(filename, sizeof(filename), "/dev/.udev/db", NULL);
- if (access(filename, F_OK) < 0)
- return 0;
-
- print_kmsg("converting old udev database\n");
-
- udev_enumerate = udev_enumerate_new(udev);
- if (udev_enumerate == NULL)
- return -1;
- udev_enumerate_scan_devices(udev_enumerate);
- udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(udev_enumerate)) {
- struct udev_device *device;
-
- device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry));
- if (device == NULL)
- continue;
-
- /* try to find the old database for devices without a current one */
- if (udev_device_read_db(device, NULL) < 0) {
- bool have_db;
- const char *id;
- struct stat stats;
- char devpath[UTIL_PATH_SIZE];
- char from[UTIL_PATH_SIZE];
-
- have_db = false;
-
- /* find database in old location */
- id = udev_device_get_id_filename(device);
- util_strscpyl(from, sizeof(from), "/dev/.udev/db/", id, NULL);
- if (lstat(from, &stats) == 0) {
- if (!have_db) {
- udev_device_read_db(device, from);
- have_db = true;
- }
- unlink(from);
- }
-
- /* find old database with $subsys:$sysname name */
- util_strscpyl(from, sizeof(from), "/dev/.udev/db/",
- udev_device_get_subsystem(device), ":", udev_device_get_sysname(device), NULL);
- if (lstat(from, &stats) == 0) {
- if (!have_db) {
- udev_device_read_db(device, from);
- have_db = true;
- }
- unlink(from);
- }
-
- /* find old database with the encoded devpath name */
- util_path_encode(udev_device_get_devpath(device), devpath, sizeof(devpath));
- util_strscpyl(from, sizeof(from), "/dev/.udev/db/", devpath, NULL);
- if (lstat(from, &stats) == 0) {
- if (!have_db) {
- udev_device_read_db(device, from);
- have_db = true;
- }
- unlink(from);
- }
-
- /* write out new database */
- if (have_db)
- udev_device_update_db(device);
- }
- udev_device_unref(device);
- }
- udev_enumerate_unref(udev_enumerate);
- return 0;
-}
-
static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
{
int ctrl = -1, netlink = -1;
for (;;) {
int option;
- option = getopt_long(argc, argv, "c:deDtN:hV", options, NULL);
+ option = getopt_long(argc, argv, "c:de:DtN:hV", options, NULL);
if (option == -1)
break;
udev_set_log_priority(udev, LOG_DEBUG);
break;
case 'N':
- if (strcmp (optarg, "early") == 0) {
+ if (streq(optarg, "early")) {
resolve_names = 1;
- } else if (strcmp (optarg, "late") == 0) {
+ } else if (streq(optarg, "late")) {
resolve_names = 0;
- } else if (strcmp (optarg, "never") == 0) {
+ } else if (streq(optarg, "never")) {
resolve_names = -1;
} else {
fprintf(stderr, "resolve-names must be early, late or never\n");
goto exit;
}
- /* if needed, convert old database from earlier udev version */
- convert_db(udev);
-
if (children_max <= 0) {
int memsize = mem_size_mb();