diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/bootchart/svg.c | 6 | ||||
-rw-r--r-- | src/shared/install.c | 2 | ||||
-rw-r--r-- | src/test/test-copy.c | 4 | ||||
-rw-r--r-- | src/udev/ata_id/ata_id.c | 4 | ||||
-rw-r--r-- | src/udev/udev-builtin-hwdb.c | 9 | ||||
-rw-r--r-- | src/udev/udev-event.c | 38 | ||||
-rw-r--r-- | src/udev/udevadm-trigger.c | 62 | ||||
-rw-r--r-- | src/udev/udevd.c | 7 |
9 files changed, 99 insertions, 35 deletions
diff --git a/Makefile.am b/Makefile.am index 0f1028b48a..d6e0b4ce39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6356,7 +6356,7 @@ exported-%: % $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@ exported: $(addprefix exported-, $(lib_LTLIBRARIES)) - $(AM_V_GEN)cat $^ > $@ + $(AM_V_GEN)sort -u $^ > $@ .PHONY: check-api-docs check-api-docs: exported man diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c index 0132475e10..f442200b66 100644 --- a/src/bootchart/svg.c +++ b/src/bootchart/svg.c @@ -69,7 +69,7 @@ static double esize = 0; static struct list_sample_data *sampledata; static struct list_sample_data *prev_sampledata; -static void svg_header(FILE *of, struct list_sample_data *head, double graph_start) { +static void svg_header(FILE *of, struct list_sample_data *head, double graph_start, int n_cpus) { double w; double h; struct list_sample_data *sampledata_last; @@ -90,7 +90,7 @@ static void svg_header(FILE *of, struct list_sample_data *head, double graph_sta /* height is variable based on pss, psize, ksize */ h = 400.0 + (arg_scale_y * 30.0) /* base graphs and title */ + (arg_pss ? (100.0 * arg_scale_y) + (arg_scale_y * 7.0) : 0.0) /* pss estimate */ - + psize + ksize + esize; + + psize + ksize + esize + (n_cpus * 15 * arg_scale_y); fprintf(of, "<?xml version=\"1.0\" standalone=\"no\"?>\n"); fprintf(of, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "); @@ -1314,7 +1314,7 @@ int svg_do(FILE *of, esize = (arg_entropy ? arg_scale_y * 7 : 0); /* after this, we can draw the header with proper sizing */ - svg_header(of, head, graph_start); + svg_header(of, head, graph_start, arg_percpu ? n_cpus : 0); fprintf(of, "<rect class=\"bg\" width=\"100%%\" height=\"100%%\" />\n\n"); fprintf(of, "<g transform=\"translate(10,400)\">\n"); diff --git a/src/shared/install.c b/src/shared/install.c index 6172c42d69..559fda211d 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -220,7 +220,7 @@ static int remove_marked_symlinks_fd( instance_whitelist && !strv_contains(instance_whitelist, de->d_name)) { - _cleanup_free_ char *w; + _cleanup_free_ char *w = NULL; /* OK, the file is not listed directly * in the whitelist, so let's check if diff --git a/src/test/test-copy.c b/src/test/test-copy.c index e55ffaa16a..b1385b8b87 100644 --- a/src/test/test-copy.c +++ b/src/test/test-copy.c @@ -139,7 +139,9 @@ static void test_copy_bytes(void) { int r, r2; char buf[1024], buf2[1024]; - infd = open("/etc/os-release", O_RDONLY|O_CLOEXEC); + infd = open("/usr/lib/os-release", O_RDONLY|O_CLOEXEC); + if (infd < 0) + infd = open("/etc/os-release", O_RDONLY|O_CLOEXEC); assert_se(infd >= 0); assert_se(pipe2(pipefd, O_CLOEXEC) == 0); diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index cc1bf45ae9..7ba0b7fc8f 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -639,8 +639,8 @@ int main(int argc, char *argv[]) */ word = identify.wyde[108]; if ((word & 0xf000) == 0x5000) - printf("ID_WWN=0x%1$"PRIu64"x\n" - "ID_WWN_WITH_EXTENSION=0x%1$"PRIu64"x\n", + printf("ID_WWN=0x%1$" PRIx64 "\n" + "ID_WWN_WITH_EXTENSION=0x%1$" PRIx64 "\n", identify.octa[108/4]); /* from Linux's include/linux/ata.h */ diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c index 7dfc74e6fa..b656204c46 100644 --- a/src/udev/udev-builtin-hwdb.c +++ b/src/udev/udev-builtin-hwdb.c @@ -26,6 +26,7 @@ #include "sd-hwdb.h" #include "hwdb-util.h" +#include "udev-util.h" static sd_hwdb *hwdb; @@ -87,6 +88,9 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device assert(dev); + if (!srcdev) + srcdev = dev; + for (d = srcdev; d && !last; d = udev_device_get_parent(d)) { const char *dsubsys; const char *modalias = NULL; @@ -133,7 +137,7 @@ static int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool te const char *device = NULL; const char *subsystem = NULL; const char *prefix = NULL; - struct udev_device *srcdev; + _cleanup_udev_device_unref_ struct udev_device *srcdev = NULL; if (!hwdb) return EXIT_FAILURE; @@ -176,8 +180,7 @@ static int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool te srcdev = udev_device_new_from_device_id(udev_device_get_udev(dev), device); if (!srcdev) return EXIT_FAILURE; - } else - srcdev = dev; + } if (udev_builtin_hwdb_search(dev, srcdev, subsystem, prefix, filter, test) > 0) return EXIT_SUCCESS; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 5516a792eb..1092071e26 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -389,26 +389,44 @@ static int spawn_exec(struct udev_event *event, const char *cmd, char *const argv[], char **envp, int fd_stdout, int fd_stderr) { _cleanup_close_ int fd = -1; + int r; /* discard child output or connect to pipe */ fd = open("/dev/null", O_RDWR); if (fd >= 0) { - dup2(fd, STDIN_FILENO); - if (fd_stdout < 0) - dup2(fd, STDOUT_FILENO); - if (fd_stderr < 0) - dup2(fd, STDERR_FILENO); + r = dup2(fd, STDIN_FILENO); + if (r < 0) + log_warning_errno(errno, "redirecting stdin failed: %m"); + + if (fd_stdout < 0) { + r = dup2(fd, STDOUT_FILENO); + if (r < 0) + log_warning_errno(errno, "redirecting stdout failed: %m"); + } + + if (fd_stderr < 0) { + r = dup2(fd, STDERR_FILENO); + if (r < 0) + log_warning_errno(errno, "redirecting stderr failed: %m"); + } } else - log_error_errno(errno, "open /dev/null failed: %m"); + log_warning_errno(errno, "open /dev/null failed: %m"); /* connect pipes to std{out,err} */ if (fd_stdout >= 0) { - dup2(fd_stdout, STDOUT_FILENO); - safe_close(fd_stdout); + r = dup2(fd_stdout, STDOUT_FILENO); + if (r < 0) + log_warning_errno(errno, "redirecting stdout failed: %m"); + + fd_stdout = safe_close(fd_stdout); } + if (fd_stderr >= 0) { - dup2(fd_stderr, STDERR_FILENO); - safe_close(fd_stderr); + r = dup2(fd_stderr, STDERR_FILENO); + if (r < 0) + log_warning_errno(errno, "redirecting stdout failed: %m"); + + fd_stderr = safe_close(fd_stderr); } /* terminate child in case parent goes away */ diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 11e83f355f..7af9665f8a 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -116,7 +116,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { } device_type = TYPE_DEVICES; const char *action = "change"; _cleanup_udev_enumerate_unref_ struct udev_enumerate *udev_enumerate = NULL; - int c; + int c, r; udev_enumerate = udev_enumerate_new(udev); if (udev_enumerate == NULL) @@ -153,28 +153,56 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { break; case 's': - udev_enumerate_add_match_subsystem(udev_enumerate, optarg); + r = udev_enumerate_add_match_subsystem(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add subsystem match '%s': %m", optarg); + return 2; + } break; case 'S': - udev_enumerate_add_nomatch_subsystem(udev_enumerate, optarg); + r = udev_enumerate_add_nomatch_subsystem(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add negative subsystem match '%s': %m", optarg); + return 2; + } break; case 'a': key = keyval(optarg, &val, buf, sizeof(buf)); - udev_enumerate_add_match_sysattr(udev_enumerate, key, val); + r = udev_enumerate_add_match_sysattr(udev_enumerate, key, val); + if (r < 0) { + log_error_errno(r, "could not add sysattr match '%s=%s': %m", key, val); + return 2; + } break; case 'A': key = keyval(optarg, &val, buf, sizeof(buf)); - udev_enumerate_add_nomatch_sysattr(udev_enumerate, key, val); + r = udev_enumerate_add_nomatch_sysattr(udev_enumerate, key, val); + if (r < 0) { + log_error_errno(r, "could not add negative sysattr match '%s=%s': %m", key, val); + return 2; + } break; case 'p': key = keyval(optarg, &val, buf, sizeof(buf)); - udev_enumerate_add_match_property(udev_enumerate, key, val); + r = udev_enumerate_add_match_property(udev_enumerate, key, val); + if (r < 0) { + log_error_errno(r, "could not add property match '%s=%s': %m", key, val); + return 2; + } break; case 'g': - udev_enumerate_add_match_tag(udev_enumerate, optarg); + r = udev_enumerate_add_match_tag(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add tag match '%s': %m", optarg); + return 2; + } break; case 'y': - udev_enumerate_add_match_sysname(udev_enumerate, optarg); + r = udev_enumerate_add_match_sysname(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add sysname match '%s': %m", optarg); + return 2; + } break; case 'b': { _cleanup_udev_device_unref_ struct udev_device *dev; @@ -185,7 +213,11 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { return 2; } - udev_enumerate_add_match_parent(udev_enumerate, dev); + r = udev_enumerate_add_match_parent(udev_enumerate, dev); + if (r < 0) { + log_error_errno(r, "could not add parent match '%s': %m", optarg); + return 2; + } break; } @@ -198,7 +230,11 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { return 2; } - udev_enumerate_add_match_parent(udev_enumerate, dev); + r = udev_enumerate_add_match_parent(udev_enumerate, dev); + if (r < 0) { + log_error_errno(r, "could not add parent match '%s': %m", optarg); + return 2; + } break; } @@ -221,7 +257,11 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { return 2; } - udev_enumerate_add_match_parent(udev_enumerate, dev); + r = udev_enumerate_add_match_parent(udev_enumerate, dev); + if (r < 0) { + log_error_errno(r, "could not add tag match '%s': %m", optarg); + return 2; + } } switch (device_type) { diff --git a/src/udev/udevd.c b/src/udev/udevd.c index ff15664cb4..cf15ddf641 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -327,6 +327,7 @@ static void worker_spawn(Manager *manager, struct event *event) { struct udev *udev = event->udev; _cleanup_udev_monitor_unref_ struct udev_monitor *worker_monitor = NULL; pid_t pid; + int r = 0; /* listen for new events */ worker_monitor = udev_monitor_new_from_netlink(udev, NULL); @@ -334,7 +335,9 @@ static void worker_spawn(Manager *manager, struct event *event) { return; /* allow the main daemon netlink address to send devices to the worker */ udev_monitor_allow_unicast_sender(worker_monitor, manager->monitor); - udev_monitor_enable_receiving(worker_monitor); + r = udev_monitor_enable_receiving(worker_monitor); + if (r < 0) + log_error_errno(r, "worker: could not enable receiving of device: %m"); pid = fork(); switch (pid) { @@ -346,7 +349,6 @@ static void worker_spawn(Manager *manager, struct event *event) { struct epoll_event ep_signal = { .events = EPOLLIN }; struct epoll_event ep_monitor = { .events = EPOLLIN }; sigset_t mask; - int r = 0; /* take initial device from queue */ dev = event->dev; @@ -528,7 +530,6 @@ out: default: { struct worker *worker; - int r; r = worker_new(&worker, manager, worker_monitor, pid); if (r < 0) |