Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */
2 :
3 : #include "automount.h"
4 : #include "bus-util.h"
5 : #include "dbus-automount.h"
6 : #include "dbus-util.h"
7 : #include "string-util.h"
8 :
9 0 : 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 0 : 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 0 : Unit *u = UNIT(a);
28 :
29 0 : assert(a);
30 0 : assert(name);
31 0 : assert(message);
32 :
33 0 : flags |= UNIT_PRIVATE;
34 :
35 0 : if (streq(name, "Where"))
36 0 : return bus_set_transient_path(u, name, &a->where, message, flags, error);
37 :
38 0 : if (streq(name, "TimeoutIdleUSec"))
39 0 : return bus_set_transient_usec_fix_0(u, name, &a->timeout_idle_usec, message, flags, error);
40 :
41 0 : if (streq(name, "DirectoryMode"))
42 0 : return bus_set_transient_mode_t(u, name, &a->directory_mode, message, flags, error);
43 :
44 0 : return 0;
45 : }
46 :
47 0 : 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 0 : Automount *a = AUTOMOUNT(u);
55 :
56 0 : assert(a);
57 0 : assert(name);
58 0 : assert(message);
59 :
60 0 : if (u->transient && u->load_state == UNIT_STUB) /* This is a transient unit? let's load a little more */
61 0 : return bus_automount_set_transient_property(a, name, message, flags, error);
62 :
63 0 : return 0;
64 : }
|