a->tokens = NULL;
}
+int automount_add_one_mount_link(Automount *a, Mount *m) {
+ int r;
+
+ assert(a);
+ assert(m);
+
+ if (a->meta.load_state != UNIT_LOADED ||
+ m->meta.load_state != UNIT_LOADED)
+ return 0;
+
+ if (!path_startswith(a->where, m->where))
+ return 0;
+
+ if ((r = unit_add_dependency(UNIT(m), UNIT_BEFORE, UNIT(a), true)) < 0)
+ return r;
+
+ if ((r = unit_add_dependency(UNIT(a), UNIT_REQUIRES, UNIT(m), true)) < 0)
+ return r;
+
+ return 0;
+}
+
+static int automount_add_mount_links(Automount *a) {
+ Meta *other;
+ int r;
+
+ assert(a);
+
+ LIST_FOREACH(units_per_type, other, a->meta.manager->units_per_type[UNIT_MOUNT])
+ if ((r = automount_add_one_mount_link(a, (Mount*) other)) < 0)
+ return r;
+
+ return 0;
+}
+
static int automount_verify(Automount *a) {
bool b;
char *e;
path_kill_slashes(a->where);
+ if ((r = automount_add_mount_links(a)) < 0)
+ return r;
+
if ((r = unit_load_related_unit(u, ".mount", (Unit**) &a->mount)) < 0)
return r;
- if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(a->mount))) < 0)
+ if ((r = unit_add_dependency(u, UNIT_BEFORE, UNIT(a->mount), true)) < 0)
return r;
}
unmount_autofs(a);
if (state != old_state)
- log_debug("%s changed %s → %s",
+ log_debug("%s changed %s -> %s",
UNIT(a)->meta.id,
automount_state_to_string(old_state),
automount_state_to_string(state));
return automount_state_to_string(AUTOMOUNT(u)->state);
}
+static bool automount_check_gc(Unit *u) {
+ Automount *a = AUTOMOUNT(u);
+
+ assert(a);
+
+ return UNIT_VTABLE(UNIT(a->mount))->check_gc(UNIT(a->mount));
+}
+
static void automount_fd_event(Unit *u, int fd, uint32_t events, Watch *w) {
+ Automount *a = AUTOMOUNT(u);
union autofs_v5_packet_union packet;
ssize_t l;
int r;
- Automount *a = AUTOMOUNT(u);
-
assert(a);
assert(fd == a->pipe_fd);
.active_state = automount_active_state,
.sub_state_to_string = automount_sub_state_to_string,
+ .check_gc = automount_check_gc,
+
.fd_event = automount_fd_event,
.bus_message_handler = bus_automount_message_handler,