From 669fc4e5c5d1f8b96eb62695e09354486f7bfc4c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 31 May 2018 12:04:37 +0200 Subject: [PATCH 1/7] =?UTF-8?q?tree-wide:=20some=20O=5FNDELAY=20=E2=86=92?= =?UTF-8?q?=20O=5FNONBLOCK=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Somehow the coccinelle script misses these, hence fix them manually. --- src/nspawn/nspawn.c | 4 ++-- src/run/run.c | 2 +- src/tmpfiles/tmpfiles.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 2548c989a9..5792ae9587 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1952,7 +1952,7 @@ static int setup_kmsg(int kmsg_socket) { if (r < 0) return r; - fd = open(from, O_RDWR|O_NDELAY|O_CLOEXEC); + fd = open(from, O_RDWR|O_NONBLOCK|O_CLOEXEC); if (fd < 0) return log_error_errno(errno, "Failed to open fifo: %m"); @@ -4478,7 +4478,7 @@ int main(int argc, char *argv[]) { isatty(STDIN_FILENO) > 0 && isatty(STDOUT_FILENO) > 0; - master = posix_openpt(O_RDWR|O_NOCTTY|O_CLOEXEC|O_NDELAY); + master = posix_openpt(O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK); if (master < 0) { r = log_error_errno(errno, "Failed to acquire pseudo tty: %m"); goto finish; diff --git a/src/run/run.c b/src/run/run.c index 6a271eed75..733daffb8c 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -917,7 +917,7 @@ static int start_transient_service( if (arg_stdio == ARG_STDIO_PTY) { if (arg_transport == BUS_TRANSPORT_LOCAL) { - master = posix_openpt(O_RDWR|O_NOCTTY|O_CLOEXEC|O_NDELAY); + master = posix_openpt(O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK); if (master < 0) return log_error_errno(errno, "Failed to acquire pseudo tty: %m"); diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 049e24b8bd..ae39d720a2 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -1245,7 +1245,7 @@ static int write_one_file(Item *i, const char *path) { RUN_WITH_UMASK(0000) { mac_selinux_create_file_prepare(path, S_IFREG); - fd = open(path, flags|O_NDELAY|O_CLOEXEC|O_WRONLY|O_NOCTTY, i->mode); + fd = open(path, flags|O_NONBLOCK|O_CLOEXEC|O_WRONLY|O_NOCTTY, i->mode); mac_selinux_create_file_clear(); } From 810aa42575a0431c4c9ccbd86f85017a83ec7b46 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 31 May 2018 12:05:20 +0200 Subject: [PATCH 2/7] portablectl: coccinelle says we should use TAKE_PTR() here, do so --- src/portable/portablectl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 200435caae..21057154c5 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -104,8 +104,7 @@ static int extract_prefix(const char *path, char **ret) { if (!filename_is_valid(name)) return -EINVAL; - *ret = name; - name = NULL; + *ret = TAKE_PTR(name); return 0; } From 21cffed715d1ae6f2102c63555d16acacb402379 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 31 May 2018 12:05:53 +0200 Subject: [PATCH 3/7] portablectl: don't join strv if we don't want to display it --- src/portable/portablectl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 21057154c5..5c56bce2b8 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -141,18 +141,20 @@ static int determine_matches(const char *image, char **l, bool allow_any, char * if (!arg_quiet) log_info("(Matching all unit files.)"); } else { - _cleanup_free_ char *joined = NULL; k = strv_copy(l); if (!k) return log_oom(); - joined = strv_join(k, "', '"); - if (!joined) - return log_oom(); + if (!arg_quiet) { + _cleanup_free_ char *joined = NULL; + + joined = strv_join(k, "', '"); + if (!joined) + return log_oom(); - if (!arg_quiet) log_info("(Matching unit files with prefixes '%s'.)", joined); + } } *ret = TAKE_PTR(k); From f524522bde1a29ec1589db95a787a89444617d04 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 31 May 2018 12:06:12 +0200 Subject: [PATCH 4/7] portablectl: support 'help' parameter on --copy= --- src/portable/portablectl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 5c56bce2b8..04a261297c 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -900,7 +900,12 @@ static int parse_argv(int argc, char *argv[]) { arg_copy_mode = NULL; else if (STR_IN_SET(optarg, "copy", "symlink")) arg_copy_mode = optarg; - else { + else if (streq(optarg, "help")) { + puts("auto\n" + "copy\n" + "symlink"); + return 0; + } else { log_error("Failed to parse --copy= argument: %s", optarg); return -EINVAL; } From b3c66c44970497c0100dd16fb6c6bc10853588c8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 31 May 2018 12:06:37 +0200 Subject: [PATCH 5/7] portablectl: no need to validate profile name before checking whether it is 'help' --- src/portable/portablectl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 04a261297c..4051875b76 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -884,14 +884,14 @@ static int parse_argv(int argc, char *argv[]) { break; case 'p': + if (streq(optarg, "help")) + return dump_profiles(); + if (!filename_is_valid(optarg)) { log_error("Unit profile name not valid: %s", optarg); return -EINVAL; } - if (streq(optarg, "help")) - return dump_profiles(); - arg_profile = optarg; break; From 2f0726c08f4726c5468d41bee79a660727dcfc99 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 31 May 2018 12:06:54 +0200 Subject: [PATCH 6/7] coccinelle says we should use EOPNOTSUPP rather than ENOTSUP --- src/test/test-sleep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test-sleep.c b/src/test/test-sleep.c index 1c5b56f4a0..4717423254 100644 --- a/src/test/test-sleep.c +++ b/src/test/test-sleep.c @@ -30,7 +30,7 @@ static int test_fiemap(const char *path) { if (fd < 0) return log_error_errno(errno, "failed to open %s: %m", path); r = read_fiemap(fd, &fiemap); - if (r == -ENOTSUP) { + if (r == -EOPNOTSUPP) { log_info("Skipping test, not supported"); exit(EXIT_TEST_SKIP); } From 9554591d45c8d7a12db6aea7d4ab51bd5d0cbf32 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 31 May 2018 12:19:34 +0200 Subject: [PATCH 7/7] tree-wide: drop some double newlines --- man/systemd-portabled.service.xml | 1 - src/portable/portabled-image-bus.c | 1 - 2 files changed, 2 deletions(-) diff --git a/man/systemd-portabled.service.xml b/man/systemd-portabled.service.xml index 7b1c3ae68c..91da27eba8 100644 --- a/man/systemd-portabled.service.xml +++ b/man/systemd-portabled.service.xml @@ -45,7 +45,6 @@ Most of systemd-portabled's functionality is accessible through the portablectl1 command. - See the Portable Services Documentation for details about the concepts this service implements. diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c index 1dc6b77b3b..02a2db2352 100644 --- a/src/portable/portabled-image-bus.c +++ b/src/portable/portabled-image-bus.c @@ -156,7 +156,6 @@ int bus_image_common_get_metadata( for (i = 0; i < hashmap_size(unit_files); i++) { - r = sd_bus_message_open_container(reply, 'e', "say"); if (r < 0) return r;