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("ExtraOptions", "s", NULL, offsetof(Automount, extra_options), SD_BUS_VTABLE_PROPERTY_CONST),
15 SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Automount, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
16 SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Automount, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
17 SD_BUS_PROPERTY("TimeoutIdleUSec", "t", bus_property_get_usec, offsetof(Automount, timeout_idle_usec), SD_BUS_VTABLE_PROPERTY_CONST),
18 SD_BUS_VTABLE_END
19 };
20
bus_automount_set_transient_property(Automount * a,const char * name,sd_bus_message * message,UnitWriteFlags flags,sd_bus_error * error)21 static int bus_automount_set_transient_property(
22 Automount *a,
23 const char *name,
24 sd_bus_message *message,
25 UnitWriteFlags flags,
26 sd_bus_error *error) {
27
28 Unit *u = UNIT(a);
29
30 assert(a);
31 assert(name);
32 assert(message);
33
34 flags |= UNIT_PRIVATE;
35
36 if (streq(name, "Where"))
37 return bus_set_transient_path(u, name, &a->where, message, flags, error);
38
39 if (streq(name, "ExtraOptions"))
40 return bus_set_transient_string(u, name, &a->extra_options, message, flags, error);
41
42 if (streq(name, "TimeoutIdleUSec"))
43 return bus_set_transient_usec_fix_0(u, name, &a->timeout_idle_usec, message, flags, error);
44
45 if (streq(name, "DirectoryMode"))
46 return bus_set_transient_mode_t(u, name, &a->directory_mode, message, flags, error);
47
48 return 0;
49 }
50
bus_automount_set_property(Unit * u,const char * name,sd_bus_message * message,UnitWriteFlags flags,sd_bus_error * error)51 int bus_automount_set_property(
52 Unit *u,
53 const char *name,
54 sd_bus_message *message,
55 UnitWriteFlags flags,
56 sd_bus_error *error) {
57
58 Automount *a = AUTOMOUNT(u);
59
60 assert(a);
61 assert(name);
62 assert(message);
63
64 if (u->transient && u->load_state == UNIT_STUB) /* This is a transient unit? let's load a little more */
65 return bus_automount_set_transient_property(a, name, message, flags, error);
66
67 return 0;
68 }
69