From 3d3145100d77a059b145a488df3d31763fdf1920 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 1 Oct 2015 14:26:42 +0200 Subject: man: minor wording improvements to USB FunctionFS documentation --- man/systemd.socket.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'man/systemd.socket.xml') diff --git a/man/systemd.socket.xml b/man/systemd.socket.xml index bb75b69cea..210bd71913 100644 --- a/man/systemd.socket.xml +++ b/man/systemd.socket.xml @@ -262,14 +262,15 @@ ListenUSBFunction= - Specifies a - functionfs - endpoint location to - listen on. This expects an absolute file system path as the - argument. Behavior otherwise is very similar to the - ListenFIFO= directive above. Use this to - open functionfs endpoint ep0. When using - this option, activated service has to have the + Specifies a USB + FunctionFS endpoint location to listen on, for + implementation of USB gadget functions. This expects an + absolute file system path as the argument. Behavior otherwise + is very similar to the ListenFIFO= + directive above. Use this to open FunctionFS endpoint + ep0. When using this option, the + activated service has to have the USBFunctionDescriptors= and USBFunctionStrings= options set. -- cgit v1.2.3-54-g00ecf From 55301ec028937eab4722c9fd586fd77ffdbc50dd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 1 Oct 2015 14:28:13 +0200 Subject: core: add new setting Writable= to ListenSpecial= socket units Writable= is a new boolean setting. If ture, then ListenSpecial= will open the specified path in O_RDWR mode, rather than just O_RDONLY. This is useful for implementing services like rfkill, where /dev/rfkill is more useful when opened in write mode, if we want to not only save but also restore its state. --- man/systemd.socket.xml | 8 ++++++++ src/core/dbus-socket.c | 1 + src/core/load-fragment-gperf.gperf.m4 | 1 + src/core/socket.c | 8 +++++--- src/core/socket.h | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) (limited to 'man/systemd.socket.xml') diff --git a/man/systemd.socket.xml b/man/systemd.socket.xml index 210bd71913..212764075d 100644 --- a/man/systemd.socket.xml +++ b/man/systemd.socket.xml @@ -381,6 +381,14 @@ For SOCK_RAW the port is the IP protocol. + + Writable= + Takes a boolean argument. May only be used in + conjunction with ListenSpecial=. If true, + the specified special file is opened in read-write mode, if + false in read-only mode. Defaults to false. + + MaxConnections= The maximum number of connections to diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c index 86732e2a45..4611ad5f86 100644 --- a/src/core/dbus-socket.c +++ b/src/core/dbus-socket.c @@ -95,6 +95,7 @@ const sd_bus_vtable bus_socket_vtable[] = { SD_BUS_PROPERTY("SocketMode", "u", bus_property_get_mode, offsetof(Socket, socket_mode), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Socket, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Accept", "b", bus_property_get_bool, offsetof(Socket, accept), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("Writable", "b", bus_property_get_bool, offsetof(Socket, writable), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("KeepAlive", "b", bus_property_get_bool, offsetof(Socket, keep_alive), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("KeepAliveTimeUSec", "t", bus_property_get_usec, offsetof(Socket, keep_alive_time), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("KeepAliveIntervalUSec", "t", bus_property_get_usec, offsetof(Socket, keep_alive_interval), SD_BUS_VTABLE_PROPERTY_CONST), diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4 index 27159aa4c7..2333926e7d 100644 --- a/src/core/load-fragment-gperf.gperf.m4 +++ b/src/core/load-fragment-gperf.gperf.m4 @@ -261,6 +261,7 @@ Socket.SocketGroup, config_parse_unit_string_printf, 0, Socket.SocketMode, config_parse_mode, 0, offsetof(Socket, socket_mode) Socket.DirectoryMode, config_parse_mode, 0, offsetof(Socket, directory_mode) Socket.Accept, config_parse_bool, 0, offsetof(Socket, accept) +Socket.Writable, config_parse_bool, 0, offsetof(Socket, writable) Socket.MaxConnections, config_parse_unsigned, 0, offsetof(Socket, max_connections) Socket.KeepAlive, config_parse_bool, 0, offsetof(Socket, keep_alive) Socket.KeepAliveTimeSec, config_parse_sec, 0, offsetof(Socket, keep_alive_time) diff --git a/src/core/socket.c b/src/core/socket.c index a0b5bba1b9..3250e7efc6 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -507,6 +507,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) { "%sPassSecurity: %s\n" "%sTCPCongestion: %s\n" "%sRemoveOnStop: %s\n" + "%sWritable: %s\n" "%sSELinuxContextFromNet: %s\n", prefix, socket_state_to_string(s->state), prefix, socket_result_to_string(s->result), @@ -523,6 +524,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) { prefix, yes_no(s->pass_sec), prefix, strna(s->tcp_congestion), prefix, yes_no(s->remove_on_stop), + prefix, yes_no(s->writable), prefix, yes_no(s->selinux_context_from_net)); if (s->control_pid > 0) @@ -1031,14 +1033,14 @@ fail: return r; } -static int special_address_create(const char *path) { +static int special_address_create(const char *path, bool writable) { _cleanup_close_ int fd = -1; struct stat st; int r; assert(path); - fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW); + fd = open(path, (writable ? O_RDWR : O_RDONLY)|O_CLOEXEC|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW); if (fd < 0) return -errno; @@ -1280,7 +1282,7 @@ static int socket_open_fds(Socket *s) { case SOCKET_SPECIAL: - p->fd = special_address_create(p->path); + p->fd = special_address_create(p->path, s->writable); if (p->fd < 0) { r = p->fd; goto rollback; diff --git a/src/core/socket.h b/src/core/socket.h index aee0d34a27..d20dc8d81a 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -118,6 +118,7 @@ struct Socket { bool accept; bool remove_on_stop; + bool writable; /* Socket options */ bool keep_alive; -- cgit v1.2.3-54-g00ecf