]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/dbus-automount.c
license: LGPL-2.1+ -> LGPL-2.1-or-later
[thirdparty/systemd.git] / src / core / dbus-automount.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "automount.h"
4 #include "bus-get-properties.h"
5 #include "dbus-automount.h"
6 #include "dbus-util.h"
7 #include "string-util.h"
8
9 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, automount_result, AutomountResult);
10
11 const sd_bus_vtable bus_automount_vtable[] = {
12 SD_BUS_VTABLE_START(0),
13 SD_BUS_PROPERTY("Where", "s", NULL, offsetof(Automount, where), SD_BUS_VTABLE_PROPERTY_CONST),
14 SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Automount, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
15 SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Automount, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
16 SD_BUS_PROPERTY("TimeoutIdleUSec", "t", bus_property_get_usec, offsetof(Automount, timeout_idle_usec), SD_BUS_VTABLE_PROPERTY_CONST),
17 SD_BUS_VTABLE_END
18 };
19
20 static int bus_automount_set_transient_property(
21 Automount *a,
22 const char *name,
23 sd_bus_message *message,
24 UnitWriteFlags flags,
25 sd_bus_error *error) {
26
27 Unit *u = UNIT(a);
28
29 assert(a);
30 assert(name);
31 assert(message);
32
33 flags |= UNIT_PRIVATE;
34
35 if (streq(name, "Where"))
36 return bus_set_transient_path(u, name, &a->where, message, flags, error);
37
38 if (streq(name, "TimeoutIdleUSec"))
39 return bus_set_transient_usec_fix_0(u, name, &a->timeout_idle_usec, message, flags, error);
40
41 if (streq(name, "DirectoryMode"))
42 return bus_set_transient_mode_t(u, name, &a->directory_mode, message, flags, error);
43
44 return 0;
45 }
46
47 int bus_automount_set_property(
48 Unit *u,
49 const char *name,
50 sd_bus_message *message,
51 UnitWriteFlags flags,
52 sd_bus_error *error) {
53
54 Automount *a = AUTOMOUNT(u);
55
56 assert(a);
57 assert(name);
58 assert(message);
59
60 if (u->transient && u->load_state == UNIT_STUB) /* This is a transient unit? let's load a little more */
61 return bus_automount_set_transient_property(a, name, message, flags, error);
62
63 return 0;
64 }