[systemd-commits] 8 commits - man/systemd-analyze.xml man/systemd-readahead-replay.service.xml man/systemd-run.xml man/systemd-tmpfiles.xml src/activate src/analyze src/ask-password src/binfmt src/boot src/cgls src/cgtop src/core src/delta src/detect-virt src/hostname src/journal src/libsystemd-bus src/locale src/login src/machine src/machine-id-setup src/modules-load src/notify src/nspawn src/readahead src/run src/shared src/sleep src/socket-proxy src/sysctl src/systemctl src/timedate src/tmpfiles src/tty-ask-password-agent
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Nov 6 18:31:24 CET 2013
man/systemd-analyze.xml | 30 ++++++
man/systemd-readahead-replay.service.xml | 7 +
man/systemd-run.xml | 9 +
man/systemd-tmpfiles.xml | 23 ++--
src/activate/activate.c | 8 -
src/analyze/analyze.c | 94 +++++++++++---------
src/ask-password/ask-password.c | 8 -
src/binfmt/binfmt.c | 20 +++-
src/boot/bootctl.c | 10 +-
src/cgls/cgls.c | 12 +-
src/cgtop/cgtop.c | 17 +--
src/core/load-fragment.c | 3
src/delta/delta.c | 15 +--
src/detect-virt/detect-virt.c | 8 -
src/hostname/hostnamectl.c | 16 +--
src/journal/cat.c | 11 +-
src/journal/coredumpctl.c | 11 +-
src/journal/journal-gatewayd.c | 13 +-
src/journal/journalctl.c | 14 +-
src/libsystemd-bus/busctl.c | 50 ++++++----
src/locale/localectl.c | 20 +---
src/login/inhibit.c | 16 +--
src/login/loginctl.c | 8 -
src/machine-id-setup/machine-id-setup-main.c | 8 -
src/machine/machinectl.c | 24 +----
src/modules-load/modules-load.c | 20 +++-
src/notify/notify.c | 8 -
src/nspawn/nspawn.c | 8 -
src/readahead/readahead.c | 21 +++-
src/run/run.c | 30 +++---
src/shared/path-util.c | 30 +++---
src/sleep/sleep.c | 8 -
src/socket-proxy/socket-proxyd.c | 47 ++++------
src/sysctl/sysctl.c | 15 ++-
src/systemctl/systemctl.c | 39 +++-----
src/timedate/timedatectl.c | 20 +---
src/tmpfiles/tmpfiles.c | 15 ++-
src/tty-ask-password-agent/tty-ask-password-agent.c | 8 -
38 files changed, 396 insertions(+), 328 deletions(-)
New commits:
commit 5f7e83e8ad6f83095569c452bff2d0702ac02987
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 18:29:24 2013 +0100
socket-proxy: clean-up indenting
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 8f60ab8..a449b0e 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -110,11 +110,11 @@ static int remove_event_from_connection(struct connection *c, uint32_t events) {
}
if (c->events == 0) {
- r = sd_event_source_set_enabled(c->w, SD_EVENT_OFF);
- if (r < 0) {
- log_error("Error %d disabling source: %s", r, strerror(-r));
- return r;
- }
+ r = sd_event_source_set_enabled(c->w, SD_EVENT_OFF);
+ if (r < 0) {
+ log_error("Error %d disabling source: %s", r, strerror(-r));
+ return r;
+ }
}
return 0;
@@ -155,11 +155,11 @@ static int send_buffer(struct connection *sender) {
/* If the buffer is full, disable events coming for recv. */
if (sender->buffer_filled_len == BUFFER_SIZE) {
- r = remove_event_from_connection(sender, EPOLLIN);
- if (r < 0) {
- log_error("Error %d disabling EPOLLIN for fd=%d: %s", r, sender->fd, strerror(-r));
- return r;
- }
+ r = remove_event_from_connection(sender, EPOLLIN);
+ if (r < 0) {
+ log_error("Error %d disabling EPOLLIN for fd=%d: %s", r, sender->fd, strerror(-r));
+ return r;
+ }
}
/* Watch for when the recipient can be sent data again. */
@@ -218,8 +218,7 @@ static int transfer_data_cb(sd_event_source *s, int fd, uint32_t revents, void *
if (errno != EWOULDBLOCK && errno != EAGAIN) {
log_error("Error %d in recv from fd=%d: %m", errno, fd);
return -errno;
- }
- else {
+ } else {
/* recv() is in a blocking state. */
break;
}
@@ -280,7 +279,7 @@ static int connected_to_server_cb(sd_event_source *s, int fd, uint32_t revents,
}
c_client_to_server->events = EPOLLIN;
-goto finish;
+ goto finish;
fail:
free_connection(c_client_to_server);
commit eb9da376d76b48585b3b63b4f91903b54f7abd36
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 18:28:39 2013 +0100
clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
diff --git a/man/systemd-readahead-replay.service.xml b/man/systemd-readahead-replay.service.xml
index 806d460..b075f57 100644
--- a/man/systemd-readahead-replay.service.xml
+++ b/man/systemd-readahead-replay.service.xml
@@ -124,6 +124,13 @@
</varlistentry>
<varlistentry>
+ <term><option>--version</option></term>
+
+ <listitem><para>Prints a short version
+ string and exits.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--max-files=</option></term>
<listitem><para>Maximum number of
diff --git a/man/systemd-tmpfiles.xml b/man/systemd-tmpfiles.xml
index ba727e1..b90bd75 100644
--- a/man/systemd-tmpfiles.xml
+++ b/man/systemd-tmpfiles.xml
@@ -91,6 +91,20 @@
<para>The following options are understood:</para>
<variablelist>
+ <varlistentry>
+ <term><option>-h</option></term>
+ <term><option>--help</option></term>
+
+ <listitem><para>Prints a short help
+ text and exits.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+
+ <listitem><para>Prints a short version
+ string and exits.</para></listitem>
+ </varlistentry>
<varlistentry>
<term><option>--create</option></term>
@@ -131,15 +145,6 @@
prefix. This option can be specified
multiple times.</para></listitem>
</varlistentry>
-
-
- <varlistentry>
- <term><option>--help</option></term>
-
- <listitem><para>Prints a short help
- text and exits.</para></listitem>
- </varlistentry>
-
</variablelist>
<para>It is possible to combine
diff --git a/src/activate/activate.c b/src/activate/activate.c
index 83d25b1..43ab458 100644
--- a/src/activate/activate.c
+++ b/src/activate/activate.c
@@ -336,7 +336,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "listen", required_argument, NULL, 'l' },
{ "accept", no_argument, NULL, 'a' },
{ "environment", required_argument, NULL, 'E' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -347,8 +347,7 @@ static int parse_argv(int argc, char *argv[]) {
while ((c = getopt_long(argc, argv, "+hl:saE:", options, NULL)) >= 0)
switch(c) {
case 'h':
- help();
- return 0 /* done */;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -379,8 +378,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
if (optind == argc) {
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 8f965e7..3b793f6 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -1151,7 +1151,7 @@ static int set_log_level(sd_bus *bus, char **args) {
return 0;
}
-static void help(void) {
+static int help(void) {
pager_open_if_enabled();
@@ -1186,11 +1186,11 @@ static void help(void) {
/* When updating this list, including descriptions, apply
* changes to shell-completion/bash/systemd and
* shell-completion/systemd-zsh-completion.zsh too. */
+
+ return 0;
}
static int parse_argv(int argc, char *argv[]) {
- int r;
-
enum {
ARG_VERSION = 0x100,
ARG_ORDER,
@@ -1214,18 +1214,20 @@ static int parse_argv(int argc, char *argv[]) {
{ "to-pattern", required_argument, NULL, ARG_DOT_TO_PATTERN },
{ "fuzz", required_argument, NULL, ARG_FUZZ },
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
- { NULL, 0, NULL, 0 }
+ {}
};
+ int r, c;
+
assert(argc >= 0);
assert(argv);
- for (;;) {
- switch (getopt_long(argc, argv, "hH:M:", options, NULL)) {
+ while ((c = getopt_long(argc, argv, "hH:M:", options, NULL)) >= 0) {
+
+ switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -1280,9 +1282,6 @@ static int parse_argv(int argc, char *argv[]) {
arg_host = optarg;
break;
- case -1:
- return 1;
-
case '?':
return -EINVAL;
@@ -1290,6 +1289,8 @@ static int parse_argv(int argc, char *argv[]) {
assert_not_reached("Unhandled option");
}
}
+
+ return 1;
}
int main(int argc, char *argv[]) {
diff --git a/src/ask-password/ask-password.c b/src/ask-password/ask-password.c
index 238cf12..ea0c623 100644
--- a/src/ask-password/ask-password.c
+++ b/src/ask-password/ask-password.c
@@ -81,7 +81,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "no-tty", no_argument, NULL, ARG_NO_TTY },
{ "accept-cached", no_argument, NULL, ARG_ACCEPT_CACHED },
{ "multiple", no_argument, NULL, ARG_MULTIPLE },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -94,8 +94,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_ICON:
arg_icon = optarg;
@@ -124,8 +123,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 5a42b3d..3487602 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -34,6 +34,7 @@
#include "util.h"
#include "conf-files.h"
#include "fileio.h"
+#include "build.h"
static const char conf_file_dirs[] =
"/etc/binfmt.d\0"
@@ -125,7 +126,8 @@ static int help(void) {
printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n"
"Registers binary formats.\n\n"
- " -h --help Show this help\n",
+ " -h --help Show this help\n"
+ " --version Show package version\n",
program_invocation_short_name);
return 0;
@@ -133,9 +135,14 @@ static int help(void) {
static int parse_argv(int argc, char *argv[]) {
+ enum {
+ ARG_VERSION = 0x100,
+ };
+
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
- { NULL, 0, NULL, 0 }
+ { "version", no_argument, NULL, ARG_VERSION },
+ {}
};
int c;
@@ -148,15 +155,18 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
+ return help();
+
+ case ARG_VERSION:
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case '?':
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index d25ddef..9387e05 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -33,6 +33,7 @@
#include "utf8.h"
static int help(void) {
+
printf("%s [OPTIONS...] COMMAND ...\n\n"
"Query or change firmware and boot manager settings.\n\n"
" -h --help Show this help\n"
@@ -52,20 +53,20 @@ static int parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
assert(argc >= 0);
assert(argv);
+
while ((c = getopt_long(argc, argv, "+hH:P", options, NULL)) >= 0) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -76,8 +77,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c
index c689b5c..b8e275d 100644
--- a/src/cgls/cgls.c
+++ b/src/cgls/cgls.c
@@ -42,7 +42,7 @@ static bool arg_all = false;
static int arg_full = -1;
static char* arg_machine = NULL;
-static void help(void) {
+static int help(void) {
printf("%s [OPTIONS...] [CGROUP...]\n\n"
"Recursively show control group contents.\n\n"
@@ -54,6 +54,8 @@ static void help(void) {
" -k Include kernel threads in output\n"
" -M --machine Show container\n",
program_invocation_short_name);
+
+ return 0;
}
static int parse_argv(int argc, char *argv[]) {
@@ -70,7 +72,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "all", no_argument, NULL, 'a' },
{ "full", no_argument, NULL, 'l' },
{ "machine", required_argument, NULL, 'M' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -83,8 +85,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -115,8 +116,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 293a211..e5fc262 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -548,7 +548,7 @@ static int display(Hashmap *a) {
return 0;
}
-static void help(void) {
+static int help(void) {
printf("%s [OPTIONS...]\n\n"
"Show top control groups by their resource usage.\n\n"
@@ -565,10 +565,8 @@ static void help(void) {
" -b --batch Run in batch mode, accepting no input\n"
" --depth=DEPTH Maximum traversal depth (default: %d)\n",
program_invocation_short_name, arg_depth);
-}
-static void version(void) {
- puts(PACKAGE_STRING " cgtop");
+ return 0;
}
static int parse_argv(int argc, char *argv[]) {
@@ -587,7 +585,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "batch", no_argument, NULL, 'b' },
{ "depth", required_argument, NULL, ARG_DEPTH },
{ "cpu", optional_argument, NULL, ARG_CPU_TYPE},
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -601,11 +599,11 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
- version();
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case ARG_CPU_TYPE:
@@ -674,8 +672,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/delta/delta.c b/src/delta/delta.c
index b3272d9..4aaf1df 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -431,7 +431,7 @@ static int process_suffix_chop(const char *prefixes, const char *suffix, const c
return -EINVAL;
}
-static void help(void) {
+static int help(void) {
printf("%s [OPTIONS...] [SUFFIX...]\n\n"
"Find overridden configuration files.\n\n"
@@ -441,6 +441,8 @@ static void help(void) {
" --diff[=1|0] Show a diff when overridden files differ\n"
" -t --type=LIST... Only display a selected set of override types\n",
program_invocation_short_name);
+
+ return 0;
}
static int parse_flags(const char *flag_str, int flags) {
@@ -482,7 +484,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "diff", optional_argument, NULL, ARG_DIFF },
{ "type", required_argument, NULL, 't' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -507,9 +509,6 @@ static int parse_argv(int argc, char *argv[]) {
arg_no_pager = true;
break;
- case '?':
- return -EINVAL;
-
case 't': {
int f;
f = parse_flags(optarg, arg_flags);
@@ -538,9 +537,11 @@ static int parse_argv(int argc, char *argv[]) {
}
break;
- default:
- log_error("Unknown option code %c", c);
+ case '?':
return -EINVAL;
+
+ default:
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/detect-virt/detect-virt.c b/src/detect-virt/detect-virt.c
index 72ff2a8..2f8b0eb 100644
--- a/src/detect-virt/detect-virt.c
+++ b/src/detect-virt/detect-virt.c
@@ -62,7 +62,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "container", no_argument, NULL, 'c' },
{ "vm", optional_argument, NULL, 'v' },
{ "quiet", no_argument, NULL, 'q' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -75,8 +75,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -99,8 +98,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index d8657fa..af42817 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -314,13 +314,13 @@ static int parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
- { "transient", no_argument, NULL, ARG_TRANSIENT },
- { "static", no_argument, NULL, ARG_STATIC },
- { "pretty", no_argument, NULL, ARG_PRETTY },
+ { "transient", no_argument, NULL, ARG_TRANSIENT },
+ { "static", no_argument, NULL, ARG_STATIC },
+ { "pretty", no_argument, NULL, ARG_PRETTY },
{ "host", required_argument, NULL, 'H' },
{ "machine", required_argument, NULL, 'M' },
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -333,8 +333,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -371,8 +370,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/journal/cat.c b/src/journal/cat.c
index ea61578..02b7564 100644
--- a/src/journal/cat.c
+++ b/src/journal/cat.c
@@ -63,7 +63,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "identifier", required_argument, NULL, 't' },
{ "priority", required_argument, NULL, 'p' },
{ "level-prefix", required_argument, NULL, ARG_LEVEL_PREFIX },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -76,8 +76,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -115,9 +114,11 @@ static int parse_argv(int argc, char *argv[]) {
break;
}
- default:
- log_error("Unknown option code %c", c);
+ case '?':
return -EINVAL;
+
+ default:
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index 75c96cc..bcfee46 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -155,7 +155,7 @@ static int parse_argv(int argc, char *argv[], Set *matches) {
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
{ "output", required_argument, NULL, 'o' },
{ "field", required_argument, NULL, 'F' },
- { NULL, 0, NULL, 0 }
+ {}
};
assert(argc >= 0);
@@ -163,15 +163,15 @@ static int parse_argv(int argc, char *argv[], Set *matches) {
while ((c = getopt_long(argc, argv, "ho:F:", options, NULL)) >= 0)
switch(c) {
+
case 'h':
- help();
arg_action = ACTION_NONE;
- return 0;
+ return help();
case ARG_VERSION:
+ arg_action = ACTION_NONE;
puts(PACKAGE_STRING);
puts(SYSTEMD_FEATURES);
- arg_action = ACTION_NONE;
return 0;
case ARG_NO_PAGER:
@@ -209,8 +209,7 @@ static int parse_argv(int argc, char *argv[], Set *matches) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
if (optind < argc) {
diff --git a/src/journal/journal-gatewayd.c b/src/journal/journal-gatewayd.c
index d4d4b7e..093dc74 100644
--- a/src/journal/journal-gatewayd.c
+++ b/src/journal/journal-gatewayd.c
@@ -935,22 +935,24 @@ static int parse_argv(int argc, char *argv[]) {
{ "version", no_argument, NULL, ARG_VERSION },
{ "key", required_argument, NULL, ARG_KEY },
{ "cert", required_argument, NULL, ARG_CERT },
- { NULL, 0, NULL, 0 }
+ {}
};
assert(argc >= 0);
assert(argv);
while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
+
switch(c) {
+
+ case 'h':
+ return help();
+
case ARG_VERSION:
puts(PACKAGE_STRING);
puts(SYSTEMD_FEATURES);
return 0;
- case 'h':
- return help();
-
case ARG_KEY:
if (key_pem) {
log_error("Key file specified twice");
@@ -981,8 +983,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
if (optind < argc) {
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index e38721d..a509104 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -248,7 +248,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "dump-catalog", no_argument, NULL, ARG_DUMP_CATALOG },
{ "update-catalog", no_argument, NULL, ARG_UPDATE_CATALOG },
{ "reverse", no_argument, NULL, 'r' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c, r;
@@ -261,8 +261,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -543,9 +542,6 @@ static int parse_argv(int argc, char *argv[]) {
return log_oom();
break;
- case '?':
- return -EINVAL;
-
case 'F':
arg_field = optarg;
break;
@@ -570,9 +566,11 @@ static int parse_argv(int argc, char *argv[]) {
arg_reverse = true;
break;
- default:
- log_error("Unknown option code %c", c);
+ case '?':
return -EINVAL;
+
+ default:
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/libsystemd-bus/busctl.c b/src/libsystemd-bus/busctl.c
index 92072b2..717b911 100644
--- a/src/libsystemd-bus/busctl.c
+++ b/src/libsystemd-bus/busctl.c
@@ -220,7 +220,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "address", required_argument, NULL, ARG_ADDRESS },
{ "no-unique", no_argument, NULL, ARG_NO_UNIQUE },
{ "match", required_argument, NULL, ARG_MATCH },
- { NULL, 0, NULL, 0 },
+ {},
};
int c;
@@ -279,8 +279,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index c70470f..e8bf510 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -654,7 +654,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "machine", required_argument, NULL, 'M' },
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
{ "no-convert", no_argument, NULL, ARG_NO_CONVERT },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -667,8 +667,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -701,8 +700,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/login/inhibit.c b/src/login/inhibit.c
index 404881b..8c0056e 100644
--- a/src/login/inhibit.c
+++ b/src/login/inhibit.c
@@ -160,7 +160,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "why", required_argument, NULL, ARG_WHY },
{ "mode", required_argument, NULL, ARG_MODE },
{ "list", no_argument, NULL, ARG_LIST },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -173,8 +173,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -201,9 +200,11 @@ static int parse_argv(int argc, char *argv[]) {
arg_action = ACTION_LIST;
break;
- default:
- log_error("Unknown option code %c", c);
+ case '?':
return -EINVAL;
+
+ default:
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 736db6a..dc96e4b 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1396,7 +1396,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "host", required_argument, NULL, 'H' },
{ "privileged", no_argument, NULL, 'P' },
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -1409,8 +1409,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -1475,8 +1474,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c
index eb2d514..84af925 100644
--- a/src/machine-id-setup/machine-id-setup-main.c
+++ b/src/machine-id-setup/machine-id-setup-main.c
@@ -49,7 +49,7 @@ static int parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -62,8 +62,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -74,8 +73,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index ee802b1..894309c 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -686,7 +686,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "host", required_argument, NULL, 'H' },
{ "machine", required_argument, NULL, 'M' },
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
- { NULL, 0, NULL, 0 }
+ {}
};
int c, r;
@@ -699,8 +699,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -760,8 +759,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 7772e3d..d37eec3 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -34,6 +34,7 @@
#include "strv.h"
#include "conf-files.h"
#include "fileio.h"
+#include "build.h"
static char **arg_proc_cmdline_modules = NULL;
@@ -217,7 +218,8 @@ static int help(void) {
printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n"
"Loads statically configured kernel modules.\n\n"
- " -h --help Show this help\n",
+ " -h --help Show this help\n"
+ " --version Show package version\n",
program_invocation_short_name);
return 0;
@@ -225,9 +227,14 @@ static int help(void) {
static int parse_argv(int argc, char *argv[]) {
+ enum {
+ ARG_VERSION = 0x100,
+ };
+
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
- { NULL, 0, NULL, 0 }
+ { "version", no_argument, NULL, ARG_VERSION },
+ {}
};
int c;
@@ -240,15 +247,18 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
+ return help();
+
+ case ARG_VERSION:
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case '?':
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/notify/notify.c b/src/notify/notify.c
index a688a9f..a145b8f 100644
--- a/src/notify/notify.c
+++ b/src/notify/notify.c
@@ -77,7 +77,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "status", required_argument, NULL, ARG_STATUS },
{ "booted", no_argument, NULL, ARG_BOOTED },
{ "readahead", required_argument, NULL, ARG_READAHEAD },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -90,8 +90,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -130,8 +129,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 9f88713..34a0daf 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -165,7 +165,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "bind-ro", required_argument, NULL, ARG_BIND_RO },
{ "machine", required_argument, NULL, 'M' },
{ "slice", required_argument, NULL, 'S' },
- { NULL, 0, NULL, 0 }
+ {}
};
int c, r;
@@ -178,8 +178,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -329,8 +328,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/readahead/readahead.c b/src/readahead/readahead.c
index 29255c9..d6729ec 100644
--- a/src/readahead/readahead.c
+++ b/src/readahead/readahead.c
@@ -29,6 +29,7 @@
#include "util.h"
#include "def.h"
+#include "build.h"
#include "readahead-common.h"
unsigned arg_files_max = 16*1024;
@@ -40,6 +41,7 @@ static int help(void) {
printf("%s [OPTIONS...] collect [DIRECTORY]\n\n"
"Collect read-ahead data on early boot.\n\n"
" -h --help Show this help\n"
+ " --version Show package version\n"
" --max-files=INT Maximum number of files to read ahead\n"
" --file-size-max=BYTES Maximum size of files to read ahead\n"
" --timeout=USEC Maximum time to spend collecting data\n\n\n",
@@ -48,12 +50,14 @@ static int help(void) {
printf("%s [OPTIONS...] replay [DIRECTORY]\n\n"
"Replay collected read-ahead data on early boot.\n\n"
" -h --help Show this help\n"
+ " --version Show package version\n"
" --file-size-max=BYTES Maximum size of files to read ahead\n\n\n",
program_invocation_short_name);
printf("%s [OPTIONS...] analyze [PACK FILE]\n\n"
"Analyze collected read-ahead data.\n\n"
- " -h --help Show this help\n",
+ " -h --help Show this help\n"
+ " --version Show package version\n",
program_invocation_short_name);
return 0;
@@ -62,17 +66,19 @@ static int help(void) {
static int parse_argv(int argc, char *argv[]) {
enum {
- ARG_FILES_MAX = 0x100,
+ ARG_VERSION = 0x100,
+ ARG_FILES_MAX,
ARG_FILE_SIZE_MAX,
ARG_TIMEOUT
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, ARG_VERSION },
{ "files-max", required_argument, NULL, ARG_FILES_MAX },
{ "file-size-max", required_argument, NULL, ARG_FILE_SIZE_MAX },
{ "timeout", required_argument, NULL, ARG_TIMEOUT },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -85,7 +91,11 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
+ return help();
+
+ case ARG_VERSION:
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case ARG_FILES_MAX:
@@ -119,8 +129,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/run/run.c b/src/run/run.c
index 567fd97..3fb72e6 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -85,7 +85,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "send-sighup", no_argument, NULL, ARG_SEND_SIGHUP },
{ "host", required_argument, NULL, 'H' },
{ "machine", required_argument, NULL, 'M' },
- { NULL, 0, NULL, 0 },
+ {},
};
int c;
@@ -98,8 +98,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -152,8 +151,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index a56ab89..b6a6f60 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -154,7 +154,7 @@ static int parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -165,8 +165,7 @@ static int parse_argv(int argc, char *argv[]) {
while ((c = getopt_long(argc, argv, "+h", options, NULL)) >= 0)
switch(c) {
case 'h':
- help();
- return 0 /* done */;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -177,8 +176,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
if (argc - optind != 1) {
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 05ea88a..8f60ab8 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -37,6 +37,7 @@
#include "socket-util.h"
#include "util.h"
#include "event-util.h"
+#include "build.h"
#define BUFFER_SIZE 16384
#define _cleanup_freeaddrinfo_ _cleanup_(freeaddrinfop)
@@ -511,10 +512,6 @@ static int help(void) {
return 0;
}
-static void version(void) {
- puts(PACKAGE_STRING " socket-proxyd");
-}
-
static int parse_argv(int argc, char *argv[], struct proxy *p) {
enum {
@@ -526,7 +523,7 @@ static int parse_argv(int argc, char *argv[], struct proxy *p) {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "ignore-env", no_argument, NULL, ARG_IGNORE_ENV},
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -539,23 +536,22 @@ static int parse_argv(int argc, char *argv[], struct proxy *p) {
switch (c) {
case 'h':
- help();
- return 0;
-
- case '?':
- return -EINVAL;
+ return help();
case ARG_VERSION:
- version();
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case ARG_IGNORE_ENV:
p->ignore_env = true;
continue;
- default:
- log_error("Unknown option code %c", c);
+ case '?':
return -EINVAL;
+
+ default:
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index b5670db..67c7872 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -35,6 +35,7 @@
#include "path-util.h"
#include "conf-files.h"
#include "fileio.h"
+#include "build.h"
static char **arg_prefixes = NULL;
@@ -205,6 +206,7 @@ static int help(void) {
printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n"
"Applies kernel sysctl settings.\n\n"
" -h --help Show this help\n"
+ " --version Show package version\n"
" --prefix=PATH Only apply rules that apply to paths with the specified prefix\n",
program_invocation_short_name);
@@ -214,13 +216,15 @@ static int help(void) {
static int parse_argv(int argc, char *argv[]) {
enum {
+ ARG_VERSION = 0x100,
ARG_PREFIX
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, ARG_VERSION },
{ "prefix", required_argument, NULL, ARG_PREFIX },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -233,7 +237,11 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
+ return help();
+
+ case ARG_VERSION:
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case ARG_PREFIX: {
@@ -258,8 +266,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 9f5e273..9d22aad 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4961,7 +4961,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
{ "output", required_argument, NULL, 'o' },
{ "plain", no_argument, NULL, ARG_PLAIN },
{ "state", required_argument, NULL, ARG_STATE },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -4974,8 +4974,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- systemctl_help();
- return 0;
+ return systemctl_help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -5221,8 +5220,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code '%c'.", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
@@ -5252,7 +5250,7 @@ static int halt_parse_argv(int argc, char *argv[]) {
{ "wtmp-only", no_argument, NULL, 'w' },
{ "no-wtmp", no_argument, NULL, 'd' },
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
- { NULL, 0, NULL, 0 }
+ {}
};
int c, runlevel;
@@ -5268,8 +5266,7 @@ static int halt_parse_argv(int argc, char *argv[]) {
switch (c) {
case ARG_HELP:
- halt_help();
- return 0;
+ return halt_help();
case ARG_HALT:
arg_action = ACTION_HALT;
@@ -5310,8 +5307,7 @@ static int halt_parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code '%c'.", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
@@ -5386,7 +5382,7 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
{ "reboot", no_argument, NULL, 'r' },
{ "kexec", no_argument, NULL, 'K' }, /* not documented extension */
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
- { NULL, 0, NULL, 0 }
+ {}
};
int c, r;
@@ -5398,8 +5394,7 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
switch (c) {
case ARG_HELP:
- shutdown_help();
- return 0;
+ return shutdown_help();
case 'H':
arg_action = ACTION_HALT;
@@ -5446,8 +5441,7 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code '%c'.", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
@@ -5482,7 +5476,7 @@ static int telinit_parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, ARG_HELP },
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
- { NULL, 0, NULL, 0 }
+ {}
};
static const struct {
@@ -5514,8 +5508,7 @@ static int telinit_parse_argv(int argc, char *argv[]) {
switch (c) {
case ARG_HELP:
- telinit_help();
- return 0;
+ return telinit_help();
case ARG_NO_WALL:
arg_no_wall = true;
@@ -5525,8 +5518,7 @@ static int telinit_parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code '%c'.", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
@@ -5569,7 +5561,7 @@ static int runlevel_parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, ARG_HELP },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -5581,15 +5573,14 @@ static int runlevel_parse_argv(int argc, char *argv[]) {
switch (c) {
case ARG_HELP:
- runlevel_help();
+ return runlevel_help();
return 0;
case '?':
return -EINVAL;
default:
- log_error("Unknown option code '%c'.", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 9926a8a..7ce9a82 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -445,7 +445,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "machine", required_argument, NULL, 'M' },
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PASSWORD },
{ "adjust-system-clock", no_argument, NULL, ARG_ADJUST_SYSTEM_CLOCK },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -458,8 +458,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -492,8 +491,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 8051cb3..b7f6a2e 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -52,6 +52,7 @@
#include "conf-files.h"
#include "capability.h"
#include "specifier.h"
+#include "build.h"
/* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates
* them in the file system. This is intended to be used to create
@@ -1266,6 +1267,7 @@ static int help(void) {
printf("%s [OPTIONS...] [CONFIGURATION FILE...]\n\n"
"Creates, deletes and cleans up volatile and temporary files and directories.\n\n"
" -h --help Show this help\n"
+ " --version Show package version\n"
" --create Create marked files/directories\n"
" --clean Clean up marked directories\n"
" --remove Remove marked files/directories\n"
@@ -1279,6 +1281,7 @@ static int help(void) {
static int parse_argv(int argc, char *argv[]) {
enum {
+ ARG_VERSION = 0x100,
ARG_CREATE,
ARG_CLEAN,
ARG_REMOVE,
@@ -1288,12 +1291,13 @@ static int parse_argv(int argc, char *argv[]) {
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, ARG_VERSION },
{ "create", no_argument, NULL, ARG_CREATE },
{ "clean", no_argument, NULL, ARG_CLEAN },
{ "remove", no_argument, NULL, ARG_REMOVE },
{ "prefix", required_argument, NULL, ARG_PREFIX },
{ "exclude-prefix", required_argument, NULL, ARG_EXCLUDE_PREFIX },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -1306,7 +1310,11 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
+ return help();
+
+ case ARG_VERSION:
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case ARG_CREATE:
@@ -1335,8 +1343,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index f463662..c0451c0 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -666,7 +666,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "wall", no_argument, NULL, ARG_WALL },
{ "plymouth", no_argument, NULL, ARG_PLYMOUTH },
{ "console", no_argument, NULL, ARG_CONSOLE },
- { NULL, 0, NULL, 0 }
+ {}
};
int c;
@@ -679,8 +679,7 @@ static int parse_argv(int argc, char *argv[]) {
switch (c) {
case 'h':
- help();
- return 0;
+ return help();
case ARG_VERSION:
puts(PACKAGE_STRING);
@@ -715,8 +714,7 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
}
commit 4087cb9e8fb90957d90d577e62e8ba056c2258cf
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 17:34:54 2013 +0100
path-util: paths_check_timestamp() opimizations
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index fcacf54..6c4efbf 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -428,6 +428,8 @@ int path_is_os_tree(const char *path) {
int find_binary(const char *name, char **filename) {
assert(name);
+ assert(filename);
+
if (strchr(name, '/')) {
char *p;
@@ -474,33 +476,37 @@ int find_binary(const char *name, char **filename) {
}
}
-bool paths_check_timestamp(char **paths, usec_t *timestamp, bool update)
-{
- unsigned int i;
+bool paths_check_timestamp(char **paths, usec_t *timestamp, bool update) {
bool changed = false;
+ char **i;
assert(timestamp);
if (paths == NULL)
- goto out;
+ return false;
- for (i = 0; paths[i]; i++) {
+ STRV_FOREACH(i, paths) {
struct stat stats;
+ usec_t u;
- if (stat(paths[i], &stats) < 0)
+ if (stat(*i, &stats) < 0)
continue;
+ u = timespec_load(&stats.st_mtim);
+
/* first check */
- if (*timestamp >= timespec_load(&stats.st_mtim))
+ if (*timestamp >= u)
continue;
- log_debug("timestamp of '%s' changed\n", paths[i]);
- changed = true;
+ log_debug("timestamp of '%s' changed\n", *i);
/* update timestamp */
- if (update)
- *timestamp = timespec_load(&stats.st_mtim);
+ if (update) {
+ *timestamp = u;
+ changed = true;
+ } else
+ return true;
}
-out:
+
return changed;
}
commit 45a7c6b5d373170eda2fa7bdb8fa81b49865f316
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 17:33:44 2013 +0100
inhibit: don't return error code on --help
diff --git a/src/login/inhibit.c b/src/login/inhibit.c
index 3ab86ac..404881b 100644
--- a/src/login/inhibit.c
+++ b/src/login/inhibit.c
@@ -27,7 +27,6 @@
#include <fcntl.h>
#include "sd-bus.h"
-
#include "bus-util.h"
#include "bus-error.h"
#include "util.h"
@@ -228,8 +227,10 @@ int main(int argc, char *argv[]) {
log_open();
r = parse_argv(argc, argv);
- if (r <= 0)
+ if (r < 0)
return EXIT_FAILURE;
+ if (r == 0)
+ return EXIT_SUCCESS;
r = sd_bus_open_system(&bus);
if (r < 0) {
commit d75edbd619b87337717d80496f15e59cbbd6c793
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 17:33:24 2013 +0100
busctl: port over to use bus_open_transport()
diff --git a/src/libsystemd-bus/busctl.c b/src/libsystemd-bus/busctl.c
index cb7d258..92072b2 100644
--- a/src/libsystemd-bus/busctl.c
+++ b/src/libsystemd-bus/busctl.c
@@ -34,9 +34,11 @@
static bool arg_no_pager = false;
static char *arg_address = NULL;
-static bool arg_user = false;
static bool arg_no_unique = false;
static char **arg_matches = NULL;
+static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
+static char *arg_host = NULL;
+static bool arg_user = false;
static void pager_open_if_enabled(void) {
@@ -179,17 +181,19 @@ static int help(void) {
printf("%s [OPTIONS...] {COMMAND} ...\n\n"
"Introspect the bus.\n\n"
- " -h --help Show this help\n"
- " --version Show package version\n"
- " --system Connect to system bus\n"
- " --user Connect to user bus\n"
- " --address=ADDRESS Connect to bus specified by address\n"
- " --no-unique Only show well-known names\n"
- " --match=MATCH Only show matching messages\n"
- " --no-pager Do not pipe output into a pager\n\n"
+ " -h --help Show this help\n"
+ " --version Show package version\n"
+ " --system Connect to system bus\n"
+ " --user Connect to user bus\n"
+ " -H --host=[USER@]HOST Operate on remote host\n"
+ " -M --machine=CONTAINER Operate on local container\n"
+ " --address=ADDRESS Connect to bus specified by address\n"
+ " --no-unique Only show well-known names\n"
+ " --match=MATCH Only show matching messages\n"
+ " --no-pager Do not pipe output into a pager\n\n"
"Commands:\n"
- " list List bus names\n"
- " monitor [SERVICE...] Show bus traffic\n",
+ " list List bus names\n"
+ " monitor [SERVICE...] Show bus traffic\n",
program_invocation_short_name);
return 0;
@@ -224,7 +228,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hH:M:", options, NULL)) >= 0) {
switch (c) {
@@ -261,6 +265,16 @@ static int parse_argv(int argc, char *argv[]) {
return log_oom();
break;
+ case 'H':
+ arg_transport = BUS_TRANSPORT_REMOTE;
+ arg_host = optarg;
+ break;
+
+ case 'M':
+ arg_transport = BUS_TRANSPORT_CONTAINER;
+ arg_host = optarg;
+ break;
+
case '?':
return -EINVAL;
@@ -321,10 +335,8 @@ int main(int argc, char *argv[]) {
}
r = sd_bus_start(bus);
- } else if (arg_user)
- r = sd_bus_open_user(&bus);
- else
- r = sd_bus_open_system(&bus);
+ } else
+ r = bus_open_transport(arg_transport, arg_host, arg_user, &bus);
if (r < 0) {
log_error("Failed to connect to bus: %s", strerror(-r));
@@ -335,6 +347,7 @@ int main(int argc, char *argv[]) {
finish:
pager_close();
+
strv_free(arg_matches);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
commit 84f6181c2ac99a0514ca5e0c8fc8c8e284caf789
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 17:32:51 2013 +0100
clients: various simplifications
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 4067930..b7e848c 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -34,8 +34,7 @@
#include <sys/time.h>
#include <sys/resource.h>
-#include <systemd/sd-messages.h>
-
+#include "sd-messages.h"
#include "unit.h"
#include "strv.h"
#include "conf-parser.h"
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index cc7db67..d8657fa 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -458,8 +458,8 @@ static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
- int r;
_cleanup_bus_unref_ sd_bus *bus = NULL;
+ int r;
setlocale(LC_ALL, "");
log_parse_environment();
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index e3d98c4..c70470f 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -794,33 +794,27 @@ static int localectl_main(sd_bus *bus, int argc, char *argv[]) {
}
int main(int argc, char*argv[]) {
- int r, ret = EXIT_FAILURE;
_cleanup_bus_unref_ sd_bus *bus = NULL;
+ int r;
setlocale(LC_ALL, "");
log_parse_environment();
log_open();
r = parse_argv(argc, argv);
- if (r < 0)
+ if (r <= 0)
goto finish;
- else if (r == 0) {
- ret = EXIT_SUCCESS;
- goto finish;
- }
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
log_error("Failed to create bus connection: %s", strerror(-r));
- ret = EXIT_FAILURE;
goto finish;
}
r = localectl_main(bus, argc, argv);
- ret = r < 0 ? EXIT_FAILURE : r;
finish:
pager_close();
- return ret;
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 8468436..ee802b1 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -849,35 +849,29 @@ static int machinectl_main(sd_bus *bus, int argc, char *argv[]) {
}
int main(int argc, char*argv[]) {
- int r, ret = EXIT_FAILURE;
_cleanup_bus_unref_ sd_bus *bus = NULL;
+ int r;
setlocale(LC_ALL, "");
log_parse_environment();
log_open();
r = parse_argv(argc, argv);
- if (r < 0)
+ if (r <= 0)
goto finish;
- else if (r == 0) {
- ret = EXIT_SUCCESS;
- goto finish;
- }
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
log_error("Failed to create bus connection: %s", strerror(-r));
- ret = EXIT_FAILURE;
goto finish;
}
r = machinectl_main(bus, argc, argv);
- ret = r < 0 ? EXIT_FAILURE : r;
finish:
- strv_free(arg_property);
-
pager_close();
- return ret;
+ strv_free(arg_property);
+
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 461540e..9926a8a 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -581,33 +581,27 @@ static int timedatectl_main(sd_bus *bus, int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
- int r, ret = EXIT_FAILURE;
_cleanup_bus_unref_ sd_bus *bus = NULL;
+ int r;
setlocale(LC_ALL, "");
log_parse_environment();
log_open();
r = parse_argv(argc, argv);
- if (r < 0)
+ if (r <= 0)
goto finish;
- else if (r == 0) {
- ret = EXIT_SUCCESS;
- goto finish;
- }
r = bus_open_transport(arg_transport, arg_host, false, &bus);
if (r < 0) {
log_error("Failed to create bus connection: %s", strerror(-r));
- ret = EXIT_FAILURE;
goto finish;
}
r = timedatectl_main(bus, argc, argv);
- ret = r < 0 ? EXIT_FAILURE : r;
finish:
pager_close();
- return ret;
+ return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
commit 66b1e746055b9c56fd72c0451a4cfb2b06cf3f20
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 17:31:20 2013 +0100
run: support --system to match other commands, even if redundant
diff --git a/man/systemd-run.xml b/man/systemd-run.xml
index cc8a68a..031c207 100644
--- a/man/systemd-run.xml
+++ b/man/systemd-run.xml
@@ -113,6 +113,15 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
</varlistentry>
<varlistentry>
+ <term><option>--system</option></term>
+
+ <listitem>
+ <para>Talk to the service manager of the system. This is the
+ implied default.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-H</option></term>
<term><option>--host=</option></term>
diff --git a/src/run/run.c b/src/run/run.c
index fc7a3fc..567fd97 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -46,8 +46,8 @@ static int help(void) {
" -h --help Show this help\n"
" --version Show package version\n"
" --user Run as user unit\n"
- " -H --host=[USER@]HOST Operate on remote host\n"
- " -M --machine=CONTAINER Operate on local container\n"
+ " -H --host=[USER@]HOST Operate on remote host\n"
+ " -M --machine=CONTAINER Operate on local container\n"
" --scope Run this as scope rather than service\n"
" --unit=UNIT Run under the specified unit name\n"
" --description=TEXT Description for unit\n"
@@ -64,6 +64,7 @@ static int parse_argv(int argc, char *argv[]) {
enum {
ARG_VERSION = 0x100,
ARG_USER,
+ ARG_SYSTEM,
ARG_SCOPE,
ARG_UNIT,
ARG_DESCRIPTION,
@@ -75,6 +76,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "user", no_argument, NULL, ARG_USER },
+ { "system", no_argument, NULL, ARG_SYSTEM },
{ "scope", no_argument, NULL, ARG_SCOPE },
{ "unit", required_argument, NULL, ARG_UNIT },
{ "description", required_argument, NULL, ARG_DESCRIPTION },
@@ -108,6 +110,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_user = true;
break;
+ case ARG_SYSTEM:
+ arg_user = false;
+ break;
+
case ARG_SCOPE:
arg_scope = true;
break;
@@ -358,12 +364,12 @@ int main(int argc, char* argv[]) {
r = parse_argv(argc, argv);
if (r <= 0)
- goto fail;
+ goto finish;
r = find_binary(argv[optind], &command);
if (r < 0) {
log_error("Failed to find executable %s: %s", argv[optind], strerror(-r));
- goto fail;
+ goto finish;
}
argv[optind] = command;
@@ -371,7 +377,7 @@ int main(int argc, char* argv[]) {
description = strv_join(argv + optind, " ");
if (!description) {
r = log_oom();
- goto fail;
+ goto finish;
}
arg_description = description;
@@ -380,7 +386,7 @@ int main(int argc, char* argv[]) {
r = bus_open_transport(arg_transport, arg_host, arg_user, &bus);
if (r < 0) {
log_error("Failed to create bus connection: %s", strerror(-r));
- goto fail;
+ goto finish;
}
if (arg_scope)
@@ -390,9 +396,9 @@ int main(int argc, char* argv[]) {
if (r < 0) {
log_error("Failed start transient unit: %s", error.message ? error.message : strerror(-r));
sd_bus_error_free(&error);
- goto fail;
+ goto finish;
}
-fail:
+finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
commit 3cd26e7cb24bf1408902c352ab9d2b9a27d4c74f
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 6 17:30:39 2013 +0100
analyze: port over to use bus_open_transport()
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index aefbfc8..3141361 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -198,6 +198,36 @@
</varlistentry>
<varlistentry>
+ <term><option>--system</option></term>
+
+ <listitem><para>Shows performance data
+ of the system manager. This is the
+ implied default.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-H</option></term>
+ <term><option>--host=</option></term>
+
+ <listitem><para>Execute operation
+ remotely. Specify a hostname, or
+ username and hostname separated by
+ <literal>@</literal>, to connect
+ to. This will use SSH to talk to the
+ remote machine manager
+ instance.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>-M</option></term>
+ <term><option>--machine=</option></term>
+
+ <listitem><para>Execute operation on a
+ local container. Specify a container
+ name to connect to.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--order</option></term>
<term><option>--require</option></term>
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 9becc72..8f965e7 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -62,7 +62,6 @@
svg("</text>\n"); \
} while(false)
-static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
static enum dot {
DEP_ALL,
DEP_ORDER,
@@ -72,6 +71,9 @@ static char** arg_dot_from_patterns = NULL;
static char** arg_dot_to_patterns = NULL;
static usec_t arg_fuzz = 0;
static bool arg_no_pager = false;
+static BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
+static char *arg_host = NULL;
+static bool arg_user = false;
struct boot_times {
usec_t firmware_time;
@@ -1149,34 +1151,36 @@ static int set_log_level(sd_bus *bus, char **args) {
return 0;
}
-static void analyze_help(void) {
+static void help(void) {
pager_open_if_enabled();
printf("%s [OPTIONS...] {COMMAND} ...\n\n"
- "Process systemd profiling information\n\n"
- " -h --help Show this help\n"
- " --version Show package version\n"
- " --system Connect to system manager\n"
- " --user Connect to user service manager\n"
- " --order When generating a dependency graph, show only order\n"
- " --require When generating a dependency graph, show only requirement\n"
+ "Process systemd profiling information.\n\n"
+ " -h --help Show this help\n"
+ " --version Show package version\n"
+ " --system Connect to system manager\n"
+ " --user Connect to user manager\n"
+ " -H --host=[USER@]HOST Operate on remote host\n"
+ " -M --machine=CONTAINER Operate on local container\n"
+ " --order When generating a dependency graph, show only order\n"
+ " --require When generating a dependency graph, show only requirement\n"
" --from-pattern=GLOB, --to-pattern=GLOB\n"
- " When generating a dependency graph, filter only origins\n"
- " or destinations, respectively\n"
- " --fuzz=TIMESPAN When printing the tree of the critical chain, print also\n"
- " services, which finished TIMESPAN earlier, than the\n"
- " latest in the branch. The unit of TIMESPAN is seconds\n"
- " unless specified with a different unit, i.e. 50ms\n"
- " --no-pager Do not pipe output into a pager\n\n"
+ " When generating a dependency graph, filter only origins\n"
+ " or destinations, respectively\n"
+ " --fuzz=TIMESPAN When printing the tree of the critical chain, print also\n"
+ " services, which finished TIMESPAN earlier, than the\n"
+ " latest in the branch. The unit of TIMESPAN is seconds\n"
+ " unless specified with a different unit, i.e. 50ms\n"
+ " --no-pager Do not pipe output into a pager\n\n"
"Commands:\n"
- " time Print time spent in the kernel before reaching userspace\n"
- " blame Print list of running units ordered by time to init\n"
- " critical-chain Print a tree of the time critical chain of units\n"
- " plot Output SVG graphic showing service initialization\n"
- " dot Output dependency graph in dot(1) format\n"
- " set-log-level LEVEL Set logging threshold for systemd\n"
- " dump Output state serialization of service manager\n",
+ " time Print time spent in the kernel before reaching userspace\n"
+ " blame Print list of running units ordered by time to init\n"
+ " critical-chain Print a tree of the time critical chain of units\n"
+ " plot Output SVG graphic showing service initialization\n"
+ " dot Output dependency graph in dot(1) format\n"
+ " set-log-level LEVEL Set logging threshold for systemd\n"
+ " dump Output state serialization of service manager\n",
program_invocation_short_name);
/* When updating this list, including descriptions, apply
@@ -1217,22 +1221,23 @@ static int parse_argv(int argc, char *argv[]) {
assert(argv);
for (;;) {
- switch (getopt_long(argc, argv, "h", options, NULL)) {
+ switch (getopt_long(argc, argv, "hH:M:", options, NULL)) {
case 'h':
- analyze_help();
+ help();
return 0;
case ARG_VERSION:
- puts(PACKAGE_STRING "\n" SYSTEMD_FEATURES);
+ puts(PACKAGE_STRING);
+ puts(SYSTEMD_FEATURES);
return 0;
case ARG_USER:
- arg_scope = UNIT_FILE_USER;
+ arg_user = true;
break;
case ARG_SYSTEM:
- arg_scope = UNIT_FILE_SYSTEM;
+ arg_user = false;
break;
case ARG_ORDER:
@@ -1265,6 +1270,16 @@ static int parse_argv(int argc, char *argv[]) {
arg_no_pager = true;
break;
+ case 'H':
+ arg_transport = BUS_TRANSPORT_REMOTE;
+ arg_host = optarg;
+ break;
+
+ case 'M':
+ arg_transport = BUS_TRANSPORT_CONTAINER;
+ arg_host = optarg;
+ break;
+
case -1:
return 1;
@@ -1290,13 +1305,9 @@ int main(int argc, char *argv[]) {
if (r <= 0)
goto finish;
- if (arg_scope == UNIT_FILE_SYSTEM)
- r = sd_bus_open_system(&bus);
- else
- r = sd_bus_open_user(&bus);
-
+ r = bus_open_transport(arg_transport, arg_host, arg_user, &bus);
if (r < 0) {
- log_error("Failed to connect to bus: %s", strerror(-r));
+ log_error("Failed to create bus connection: %s", strerror(-r));
goto finish;
}
More information about the systemd-commits
mailing list