]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/dbus-automount.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / core / dbus-automount.c
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
4139c1b2
LP
2/***
3 This file is part of systemd.
4
5 Copyright 2010 Lennart Poettering
6
7 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
4139c1b2
LP
10 (at your option) any later version.
11
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 15 Lesser General Public License for more details.
4139c1b2 16
5430f7f2 17 You should have received a copy of the GNU Lesser General Public License
4139c1b2
LP
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
19***/
20
718db961 21#include "automount.h"
718db961 22#include "bus-util.h"
07630cea 23#include "dbus-automount.h"
cf0fbc49 24#include "string-util.h"
4139c1b2 25
718db961 26static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, automount_result, AutomountResult);
81a5c6d0 27
718db961
LP
28const sd_bus_vtable bus_automount_vtable[] = {
29 SD_BUS_VTABLE_START(0),
556089dc
LP
30 SD_BUS_PROPERTY("Where", "s", NULL, offsetof(Automount, where), SD_BUS_VTABLE_PROPERTY_CONST),
31 SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Automount, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST),
718db961 32 SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Automount, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
deb0a77c 33 SD_BUS_PROPERTY("TimeoutIdleUSec", "t", bus_property_get_usec, offsetof(Automount, timeout_idle_usec), SD_BUS_VTABLE_PROPERTY_CONST),
718db961 34 SD_BUS_VTABLE_END
d200735e 35};
afb14803
MO
36
37static int bus_automount_set_transient_property(
38 Automount *a,
39 const char *name,
40 sd_bus_message *message,
41 UnitSetPropertiesMode mode,
42 sd_bus_error *error) {
43
44 int r;
45
46 assert(a);
47 assert(name);
48 assert(message);
49
50 if (streq(name, "TimeoutIdleUSec")) {
51 usec_t timeout_idle_usec;
52 r = sd_bus_message_read(message, "t", &timeout_idle_usec);
53 if (r < 0)
54 return r;
55
56 if (mode != UNIT_CHECK) {
57 char time[FORMAT_TIMESPAN_MAX];
58
59 a->timeout_idle_usec = timeout_idle_usec;
60 unit_write_drop_in_format(UNIT(a), mode, name, "[Automount]\nTimeoutIdleSec=%s\n",
61 format_timespan(time, sizeof(time), timeout_idle_usec, USEC_PER_MSEC));
62 }
63 } else
64 return 0;
65
66 return 1;
67}
68
69int bus_automount_set_property(
70 Unit *u,
71 const char *name,
72 sd_bus_message *message,
73 UnitSetPropertiesMode mode,
74 sd_bus_error *error) {
75
76 Automount *a = AUTOMOUNT(u);
77 int r = 0;
78
79 assert(a);
80 assert(name);
81 assert(message);
82
83 if (u->transient && u->load_state == UNIT_STUB)
84 /* This is a transient unit, let's load a little more */
85
86 r = bus_automount_set_transient_property(a, name, message, mode, error);
87
88 return r;
89}