diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-10-19 16:38:47 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-10-20 14:09:30 +0200 |
commit | 8dbab37dec924021b9b3398c91e7e0ecf01c9709 (patch) | |
tree | df7dc72a259665cb0ac1c4c576dab08c2aa5d900 /src/core/dbus-mount.c | |
parent | execute: Add more helper functions (diff) | |
download | systemd-8dbab37dec924021b9b3398c91e7e0ecf01c9709.tar.xz systemd-8dbab37dec924021b9b3398c91e7e0ecf01c9709.zip |
mount: Add more helpers
Diffstat (limited to 'src/core/dbus-mount.c')
-rw-r--r-- | src/core/dbus-mount.c | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c index 89f7d4fa0f..7dbbdd07f5 100644 --- a/src/core/dbus-mount.c +++ b/src/core/dbus-mount.c @@ -22,21 +22,13 @@ static int property_get_what( _cleanup_free_ char *escaped = NULL; Mount *m = ASSERT_PTR(userdata); - const char *s = NULL; assert(bus); assert(reply); - if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.what) - s = m->parameters_proc_self_mountinfo.what; - else if (m->from_fragment && m->parameters_fragment.what) - s = m->parameters_fragment.what; - - if (s) { - escaped = utf8_escape_invalid(s); - if (!escaped) - return -ENOMEM; - } + escaped = mount_get_what_escaped(m); + if (!escaped) + return -ENOMEM; return sd_bus_message_append_basic(reply, 's', escaped); } @@ -52,33 +44,17 @@ static int property_get_options( _cleanup_free_ char *escaped = NULL; Mount *m = ASSERT_PTR(userdata); - const char *s = NULL; assert(bus); assert(reply); - if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.options) - s = m->parameters_proc_self_mountinfo.options; - else if (m->from_fragment && m->parameters_fragment.options) - s = m->parameters_fragment.options; - - if (s) { - escaped = utf8_escape_invalid(s); - if (!escaped) - return -ENOMEM; - } + escaped = mount_get_options_escaped(m); + if (!escaped) + return -ENOMEM; return sd_bus_message_append_basic(reply, 's', escaped); } -static const char *mount_get_fstype(const Mount *m) { - if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.fstype) - return m->parameters_proc_self_mountinfo.fstype; - else if (m->from_fragment && m->parameters_fragment.fstype) - return m->parameters_fragment.fstype; - return NULL; -} - static BUS_DEFINE_PROPERTY_GET(property_get_type, "s", Mount, mount_get_fstype); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, mount_result, MountResult); |