[systemd-commits] 5 commits - Makefile.am man/systemd.unit.xml src/bus-driverd src/libsystemd-bus src/shared src/systemctl
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Mon Dec 16 20:28:27 PST 2013
Makefile.am | 7 ++
man/systemd.unit.xml | 2
src/bus-driverd/bus-driverd.c | 12 +---
src/libsystemd-bus/.gitignore | 1
src/libsystemd-bus/bus-error-mapping.gperf | 49 +++++++++++++++++
src/libsystemd-bus/bus-error.c | 79 +----------------------------
src/libsystemd-bus/bus-error.h | 8 ++
src/shared/util.h | 5 +
src/systemctl/systemctl.c | 7 +-
9 files changed, 85 insertions(+), 85 deletions(-)
New commits:
commit a94200d0b4a8f98e5d9433282642300082de7d59
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Dec 16 22:40:09 2013 -0500
bus-driverd: actually add --version
diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c
index e3d32ec..ce2e1b2 100644
--- a/src/bus-driverd/bus-driverd.c
+++ b/src/bus-driverd/bus-driverd.c
@@ -81,8 +81,9 @@ static int parse_argv(int argc, char *argv[]) {
};
static const struct option options[] = {
- { "help", no_argument, NULL, 'h' },
- { NULL, 0, NULL, 0 }
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, ARG_VERSION },
+ {}
};
int c;
@@ -90,8 +91,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, "h", options, NULL)) >= 0)
switch (c) {
case 'h':
@@ -107,10 +107,8 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unknown option");
}
- }
return 1;
}
commit c0fdf09885ce83cc7edc31f51b03ef284980dfa8
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Dec 16 22:34:07 2013 -0500
systemctl: highlight filenames in cat
diff --git a/src/shared/util.h b/src/shared/util.h
index 57689e9..dd51e89 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -64,6 +64,7 @@ union dirent_storage {
#define ANSI_GREEN_ON "\x1B[32m"
#define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
#define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
+#define ANSI_HIGHLIGHT_BLUE_ON "\x1B[1;34m"
#define ANSI_HIGHLIGHT_OFF "\x1B[0m"
#define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
@@ -399,6 +400,10 @@ static inline const char *ansi_highlight_yellow(void) {
return on_tty() ? ANSI_HIGHLIGHT_YELLOW_ON : "";
}
+static inline const char *ansi_highlight_blue(void) {
+ return on_tty() ? ANSI_HIGHLIGHT_BLUE_ON : "";
+}
+
static inline const char *ansi_highlight_off(void) {
return on_tty() ? ANSI_HIGHLIGHT_OFF : "";
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 327eb85..aab92c4 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3797,7 +3797,10 @@ static int cat(sd_bus *bus, char **args) {
}
if (!isempty(fragment_path)) {
- fprintf(stdout, "# %s\n", fragment_path);
+ fprintf(stdout, "%s# %s%s\n",
+ ansi_highlight_blue(),
+ fragment_path,
+ ansi_highlight_off());
fflush(stdout);
r = sendfile_full(STDOUT_FILENO, fragment_path);
commit c0ea486f6e14dcd12390fc674e4ee33426444a3a
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Dec 16 22:33:45 2013 -0500
systemctl: fix return value from cat
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 3e6a688..327eb85 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3821,7 +3821,7 @@ static int cat(sd_bus *bus, char **args) {
}
}
- return r;
+ return r < 0 ? r : 0;
}
static int show(sd_bus *bus, char **args) {
commit 15f2a3a9930eb42e8a858c601f198431979b0b60
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Dec 16 22:10:21 2013 -0500
man: reword awkward phrase
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index 6a065d2..918bbc4 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -1304,7 +1304,7 @@
</row>
<row>
<entry><literal>%R</literal></entry>
- <entry>Root control group path where slices and units are placed below</entry>
+ <entry>Root control group path below which slices and units are placed</entry>
<entry>For system instances, this resolves to <filename>/</filename>, except in containers, where this maps to the container's root control group path.</entry>
</row>
<row>
commit 0b6c04bb45c3947f32ae5116f8c2a485cd32b734
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Dec 15 20:35:22 2013 -0500
bus: use gperf to map error string to errno
diff --git a/Makefile.am b/Makefile.am
index 3f47bc8..6c30a05 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2024,6 +2024,9 @@ libsystemd_bus_la_SOURCES = \
src/libsystemd-bus/event-util.h \
src/libsystemd-bus/bus-protocol.h
+nodist_libsystemd_bus_la_SOURCES = \
+ src/libsystemd-bus/bus-error-mapping.c
+
libsystemd_bus_la_LIBADD = \
libsystemd-id128-internal.la \
libsystemd-daemon-internal.la \
@@ -2042,6 +2045,7 @@ pkgconfiglib_DATA += \
src/libsystemd-bus/libsystemd-bus.pc
EXTRA_DIST += \
+ src/libsystemd-bus/bus-error-mapping.gperf \
src/libsystemd-bus/libsystemd-bus.pc.in \
src/libsystemd-bus/DIFFERENCES \
src/libsystemd-bus/GVARIANT-SERIALIZATION
@@ -2052,6 +2056,9 @@ lib_LTLIBRARIES += \
libsystemd_bus_internal_la_SOURCES = \
$(libsystemd_bus_la_SOURCES)
+nodist_libsystemd_bus_internal_la_SOURCES = \
+ $(nodist_libsystemd_bus_la_SOURCES)
+
libsystemd_bus_internal_la_CFLAGS = \
$(libsystemd_bus_la_CFLAGS)
diff --git a/src/libsystemd-bus/.gitignore b/src/libsystemd-bus/.gitignore
index 5f797a2..fcfd804 100644
--- a/src/libsystemd-bus/.gitignore
+++ b/src/libsystemd-bus/.gitignore
@@ -1 +1,2 @@
/libsystemd-bus.pc
+/bus-error-mapping.c
diff --git a/src/libsystemd-bus/bus-error-mapping.gperf b/src/libsystemd-bus/bus-error-mapping.gperf
new file mode 100644
index 0000000..df2c4d4
--- /dev/null
+++ b/src/libsystemd-bus/bus-error-mapping.gperf
@@ -0,0 +1,49 @@
+%{
+#include <errno.h>
+#include "bus-error.h"
+%}
+name_error_mapping;
+%null_strings
+%language=ANSI-C
+%define slot-name name
+%define hash-function-name bus_error_mapping_hash
+%define lookup-function-name bus_error_mapping_lookup
+%readonly-tables
+%omit-struct-type
+%struct-type
+%includes
+%%
+org.freedesktop.DBus.Error.Failed, EACCES
+org.freedesktop.DBus.Error.NoMemory, ENOMEM
+org.freedesktop.DBus.Error.ServiceUnknown, EHOSTUNREACH
+org.freedesktop.DBus.Error.NameHasNoOwner, ENXIO
+org.freedesktop.DBus.Error.NoReply, ETIMEDOUT
+org.freedesktop.DBus.Error.IOError, EIO
+org.freedesktop.DBus.Error.BadAddress, EADDRNOTAVAIL
+org.freedesktop.DBus.Error.NotSupported, ENOTSUP
+org.freedesktop.DBus.Error.LimitsExceeded, ENOBUFS
+org.freedesktop.DBus.Error.AccessDenied, EACCES
+org.freedesktop.DBus.Error.AuthFailed, EACCES
+org.freedesktop.DBus.Error.NoServer, EHOSTDOWN
+org.freedesktop.DBus.Error.Timeout, ETIMEDOUT
+org.freedesktop.DBus.Error.NoNetwork, ENONET
+org.freedesktop.DBus.Error.AddressInUse, EADDRINUSE
+org.freedesktop.DBus.Error.Disconnected, ECONNRESET
+org.freedesktop.DBus.Error.InvalidArgs, EINVAL
+org.freedesktop.DBus.Error.FileNotFound, ENOENT
+org.freedesktop.DBus.Error.FileExists, EEXIST
+org.freedesktop.DBus.Error.UnknownMethod, EBADR
+org.freedesktop.DBus.Error.UnknownObject, EBADR
+org.freedesktop.DBus.Error.UnknownInterface, EBADR
+org.freedesktop.DBus.Error.UnknownProperty, EBADR
+org.freedesktop.DBus.Error.PropertyReadOnly, EROFS
+org.freedesktop.DBus.Error.UnixProcessIdUnknown, ESRCH
+org.freedesktop.DBus.Error.InvalidSignature, EINVAL
+org.freedesktop.DBus.Error.InconsistentMessage, EBADMSG
+#
+org.freedesktop.DBus.Error.TimedOut, ETIMEDOUT
+org.freedesktop.DBus.Error.MatchRuleInvalid, EINVAL
+org.freedesktop.DBus.Error.InvalidFileContent, EINVAL
+org.freedesktop.DBus.Error.MatchRuleNotFound, ENOENT
+org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown, ESRCH
+org.freedesktop.DBus.Error.ObjectPathInUse, EBUSY
diff --git a/src/libsystemd-bus/bus-error.c b/src/libsystemd-bus/bus-error.c
index 25eaf0e..35bd4f0 100644
--- a/src/libsystemd-bus/bus-error.c
+++ b/src/libsystemd-bus/bus-error.c
@@ -38,6 +38,7 @@
static int bus_error_name_to_errno(const char *name) {
const char *p;
int r;
+ const name_error_mapping *m;
if (!name)
return EINVAL;
@@ -51,81 +52,9 @@ static int bus_error_name_to_errno(const char *name) {
return r;
}
- /* Better replace this with a gperf table */
-
- if (streq(name, SD_BUS_ERROR_NO_MEMORY))
- return ENOMEM;
-
- if (streq(name, SD_BUS_ERROR_SERVICE_UNKNOWN))
- return EHOSTUNREACH;
-
- if (streq(name, SD_BUS_ERROR_NAME_HAS_NO_OWNER))
- return ENXIO;
-
- if (streq(name, SD_BUS_ERROR_NO_REPLY) ||
- streq(name, SD_BUS_ERROR_TIMEOUT) ||
- streq(name, "org.freedesktop.DBus.Error.TimedOut"))
- return ETIMEDOUT;
-
- if (streq(name, SD_BUS_ERROR_IO_ERROR))
- return EIO;
-
- if (streq(name, SD_BUS_ERROR_BAD_ADDRESS))
- return EADDRNOTAVAIL;
-
- if (streq(name, SD_BUS_ERROR_NOT_SUPPORTED))
- return ENOTSUP;
-
- if (streq(name, SD_BUS_ERROR_LIMITS_EXCEEDED))
- return ENOBUFS;
-
- if (streq(name, SD_BUS_ERROR_ACCESS_DENIED) ||
- streq(name, SD_BUS_ERROR_AUTH_FAILED))
- return EACCES;
-
- if (streq(name, SD_BUS_ERROR_NO_SERVER))
- return EHOSTDOWN;
-
- if (streq(name, SD_BUS_ERROR_NO_NETWORK))
- return ENONET;
-
- if (streq(name, SD_BUS_ERROR_ADDRESS_IN_USE))
- return EADDRINUSE;
-
- if (streq(name, SD_BUS_ERROR_DISCONNECTED))
- return ECONNRESET;
-
- if (streq(name, SD_BUS_ERROR_INVALID_ARGS) ||
- streq(name, SD_BUS_ERROR_INVALID_SIGNATURE) ||
- streq(name, "org.freedesktop.DBus.Error.MatchRuleInvalid") ||
- streq(name, "org.freedesktop.DBus.Error.InvalidFileContent"))
- return EINVAL;
-
- if (streq(name, SD_BUS_ERROR_FILE_NOT_FOUND) ||
- streq(name, "org.freedesktop.DBus.Error.MatchRuleNotFound"))
- return ENOENT;
-
- if (streq(name, SD_BUS_ERROR_FILE_EXISTS))
- return EEXIST;
-
- if (streq(name, SD_BUS_ERROR_UNKNOWN_METHOD) ||
- streq(name, SD_BUS_ERROR_UNKNOWN_OBJECT) ||
- streq(name, SD_BUS_ERROR_UNKNOWN_INTERFACE) ||
- streq(name, SD_BUS_ERROR_UNKNOWN_PROPERTY))
- return EBADR;
-
- if (streq(name, SD_BUS_ERROR_PROPERTY_READ_ONLY))
- return EROFS;
-
- if (streq(name, SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN) ||
- streq(name, "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown"))
- return ESRCH;
-
- if (streq(name, SD_BUS_ERROR_INCONSISTENT_MESSAGE))
- return EBADMSG;
-
- if (streq(name, "org.freedesktop.DBus.Error.ObjectPathInUse"))
- return EBUSY;
+ m = bus_error_mapping_lookup(name, strlen(name));
+ if (m)
+ return m->code;
return EIO;
}
diff --git a/src/libsystemd-bus/bus-error.h b/src/libsystemd-bus/bus-error.h
index f6b9824..cf0ad9d 100644
--- a/src/libsystemd-bus/bus-error.h
+++ b/src/libsystemd-bus/bus-error.h
@@ -26,6 +26,14 @@
#include "sd-bus.h"
#include "macro.h"
+struct name_error_mapping {
+ const char* name;
+ int code;
+};
+typedef struct name_error_mapping name_error_mapping;
+
+const name_error_mapping* bus_error_mapping_lookup(const char *str, unsigned int len);
+
bool bus_error_is_dirty(sd_bus_error *e);
const char *bus_error_message(const sd_bus_error *e, int error);
More information about the systemd-commits
mailing list