2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2010-02-03 13:03:47 +01:00
|
|
|
|
2010-01-23 01:52:57 +01:00
|
|
|
#include <errno.h>
|
2010-04-16 23:24:39 +02:00
|
|
|
#include <fcntl.h>
|
2015-10-24 22:58:24 +02:00
|
|
|
#include <limits.h>
|
|
|
|
#include <linux/auto_dev-ioctl.h>
|
|
|
|
#include <linux/auto_fs4.h>
|
2010-04-16 23:24:39 +02:00
|
|
|
#include <sys/epoll.h>
|
2015-10-24 22:58:24 +02:00
|
|
|
#include <sys/mount.h>
|
2010-04-16 23:24:39 +02:00
|
|
|
#include <sys/stat.h>
|
2015-10-24 22:58:24 +02:00
|
|
|
#include <unistd.h>
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2015-10-27 03:01:06 +01:00
|
|
|
#include "alloc-util.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "async.h"
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "automount.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "bus-error.h"
|
|
|
|
#include "bus-util.h"
|
|
|
|
#include "dbus-automount.h"
|
2018-11-27 20:15:45 +01:00
|
|
|
#include "dbus-unit.h"
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "fd-util.h"
|
2016-11-07 16:14:59 +01:00
|
|
|
#include "format-util.h"
|
2015-10-25 14:08:25 +01:00
|
|
|
#include "io-util.h"
|
2010-08-11 22:58:34 +02:00
|
|
|
#include "label.h"
|
2012-04-10 21:54:31 +02:00
|
|
|
#include "mkdir.h"
|
2015-10-26 18:44:13 +01:00
|
|
|
#include "mount-util.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "mount.h"
|
2018-11-29 10:24:39 +01:00
|
|
|
#include "mountpoint-util.h"
|
2015-10-26 16:18:16 +01:00
|
|
|
#include "parse-util.h"
|
2012-05-07 21:36:12 +02:00
|
|
|
#include "path-util.h"
|
2015-04-10 19:10:00 +02:00
|
|
|
#include "process-util.h"
|
2018-10-17 20:40:09 +02:00
|
|
|
#include "serialize.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "special.h"
|
2015-10-27 01:26:31 +01:00
|
|
|
#include "stdio-util.h"
|
2015-10-26 22:31:05 +01:00
|
|
|
#include "string-table.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "string-util.h"
|
|
|
|
#include "unit-name.h"
|
|
|
|
#include "unit.h"
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2010-04-10 17:53:17 +02:00
|
|
|
static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
|
|
|
|
[AUTOMOUNT_DEAD] = UNIT_INACTIVE,
|
|
|
|
[AUTOMOUNT_WAITING] = UNIT_ACTIVE,
|
|
|
|
[AUTOMOUNT_RUNNING] = UNIT_ACTIVE,
|
2010-08-31 00:17:56 +02:00
|
|
|
[AUTOMOUNT_FAILED] = UNIT_FAILED
|
2010-04-10 17:53:17 +02:00
|
|
|
};
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
struct expire_data {
|
|
|
|
int dev_autofs_fd;
|
|
|
|
int ioctl_fd;
|
|
|
|
};
|
|
|
|
|
2019-01-15 08:12:28 +01:00
|
|
|
static void expire_data_free(struct expire_data *data) {
|
2015-04-14 22:01:48 +02:00
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
safe_close(data->dev_autofs_fd);
|
|
|
|
safe_close(data->ioctl_fd);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(struct expire_data*, expire_data_free);
|
|
|
|
|
2010-04-21 03:27:44 +02:00
|
|
|
static int open_dev_autofs(Manager *m);
|
2013-11-19 21:12:59 +01:00
|
|
|
static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, void *userdata);
|
2016-05-02 17:12:35 +02:00
|
|
|
static int automount_start_expire(Automount *a);
|
|
|
|
static void automount_stop_expire(Automount *a);
|
|
|
|
static int automount_send_ready(Automount *a, Set *tokens, int status);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2010-04-10 17:53:17 +02:00
|
|
|
static void automount_init(Unit *u) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
assert(u);
|
2012-01-15 12:04:08 +01:00
|
|
|
assert(u->load_state == UNIT_STUB);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2013-11-19 21:12:59 +01:00
|
|
|
a->pipe_fd = -1;
|
2010-07-02 01:17:21 +02:00
|
|
|
a->directory_mode = 0755;
|
2012-01-15 12:25:20 +01:00
|
|
|
UNIT(a)->ignore_on_isolate = true;
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void unmount_autofs(Automount *a) {
|
2015-10-27 14:25:58 +01:00
|
|
|
int r;
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
assert(a);
|
|
|
|
|
|
|
|
if (a->pipe_fd < 0)
|
|
|
|
return;
|
|
|
|
|
2013-11-19 21:12:59 +01:00
|
|
|
a->pipe_event_source = sd_event_source_unref(a->pipe_event_source);
|
2014-03-18 19:22:43 +01:00
|
|
|
a->pipe_fd = safe_close(a->pipe_fd);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2017-03-01 04:03:48 +01:00
|
|
|
/* If we reload/reexecute things we keep the mount point around */
|
2018-10-09 15:42:19 +02:00
|
|
|
if (!IN_SET(UNIT(a)->manager->objective, MANAGER_RELOAD, MANAGER_REEXECUTE)) {
|
2017-03-01 04:03:48 +01:00
|
|
|
|
2016-07-25 20:04:02 +02:00
|
|
|
automount_send_ready(a, a->tokens, -EHOSTDOWN);
|
|
|
|
automount_send_ready(a, a->expire_tokens, -EHOSTDOWN);
|
|
|
|
|
2017-03-01 04:03:48 +01:00
|
|
|
if (a->where) {
|
|
|
|
r = repeat_unmount(a->where, MNT_DETACH);
|
|
|
|
if (r < 0)
|
|
|
|
log_error_errno(r, "Failed to unmount: %m");
|
|
|
|
}
|
2015-10-27 14:25:58 +01:00
|
|
|
}
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void automount_done(Unit *u) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
|
|
|
|
unmount_autofs(a);
|
|
|
|
|
2015-09-08 18:43:11 +02:00
|
|
|
a->where = mfree(a->where);
|
2010-04-21 03:27:44 +02:00
|
|
|
|
2015-09-09 23:12:07 +02:00
|
|
|
a->tokens = set_free(a->tokens);
|
|
|
|
a->expire_tokens = set_free(a->expire_tokens);
|
2015-04-14 22:01:48 +02:00
|
|
|
|
|
|
|
a->expire_event_source = sd_event_source_unref(a->expire_event_source);
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
core: track why unit dependencies came to be
This replaces the dependencies Set* objects by Hashmap* objects, where
the key is the depending Unit, and the value is a bitmask encoding why
the specific dependency was created.
The bitmask contains a number of different, defined bits, that indicate
why dependencies exist, for example whether they are created due to
explicitly configured deps in files, by udev rules or implicitly.
Note that memory usage is not increased by this change, even though we
store more information, as we manage to encode the bit mask inside the
value pointer each Hashmap entry contains.
Why this all? When we know how a dependency came to be, we can update
dependencies correctly when a configuration source changes but others
are left unaltered. Specifically:
1. We can fix UDEV_WANTS dependency generation: so far we kept adding
dependencies configured that way, but if a device lost such a
dependency we couldn't them again as there was no scheme for removing
of dependencies in place.
2. We can implement "pin-pointed" reload of unit files. If we know what
dependencies were created as result of configuration in a unit file,
then we know what to flush out when we want to reload it.
3. It's useful for debugging: "systemd-analyze dump" now shows
this information, helping substantially with understanding how
systemd's dependency tree came to be the way it came to be.
2017-10-25 20:46:01 +02:00
|
|
|
static int automount_add_trigger_dependencies(Automount *a) {
|
|
|
|
Unit *x;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
|
|
|
|
r = unit_load_related_unit(UNIT(a), ".mount", &x);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return unit_add_two_dependencies(UNIT(a), UNIT_BEFORE, UNIT_TRIGGERS, x, true, UNIT_DEPENDENCY_IMPLICIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int automount_add_mount_dependencies(Automount *a) {
|
2013-09-26 20:14:24 +02:00
|
|
|
_cleanup_free_ char *parent = NULL;
|
2010-05-13 03:07:16 +02:00
|
|
|
|
|
|
|
assert(a);
|
2010-05-19 03:42:05 +02:00
|
|
|
|
2015-10-26 17:30:56 +01:00
|
|
|
parent = dirname_malloc(a->where);
|
|
|
|
if (!parent)
|
|
|
|
return -ENOMEM;
|
2010-05-13 03:07:16 +02:00
|
|
|
|
core: track why unit dependencies came to be
This replaces the dependencies Set* objects by Hashmap* objects, where
the key is the depending Unit, and the value is a bitmask encoding why
the specific dependency was created.
The bitmask contains a number of different, defined bits, that indicate
why dependencies exist, for example whether they are created due to
explicitly configured deps in files, by udev rules or implicitly.
Note that memory usage is not increased by this change, even though we
store more information, as we manage to encode the bit mask inside the
value pointer each Hashmap entry contains.
Why this all? When we know how a dependency came to be, we can update
dependencies correctly when a configuration source changes but others
are left unaltered. Specifically:
1. We can fix UDEV_WANTS dependency generation: so far we kept adding
dependencies configured that way, but if a device lost such a
dependency we couldn't them again as there was no scheme for removing
of dependencies in place.
2. We can implement "pin-pointed" reload of unit files. If we know what
dependencies were created as result of configuration in a unit file,
then we know what to flush out when we want to reload it.
3. It's useful for debugging: "systemd-analyze dump" now shows
this information, helping substantially with understanding how
systemd's dependency tree came to be the way it came to be.
2017-10-25 20:46:01 +02:00
|
|
|
return unit_require_mounts_for(UNIT(a), parent, UNIT_DEPENDENCY_IMPLICIT);
|
2010-05-13 03:07:16 +02:00
|
|
|
}
|
|
|
|
|
2010-07-12 22:55:27 +02:00
|
|
|
static int automount_add_default_dependencies(Automount *a) {
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
|
2015-11-11 20:42:39 +01:00
|
|
|
if (!UNIT(a)->default_dependencies)
|
|
|
|
return 0;
|
|
|
|
|
2016-02-24 21:24:23 +01:00
|
|
|
if (!MANAGER_IS_SYSTEM(UNIT(a)->manager))
|
2012-05-22 19:23:33 +02:00
|
|
|
return 0;
|
2010-10-29 06:04:03 +02:00
|
|
|
|
2020-04-02 10:52:24 +02:00
|
|
|
r = unit_add_dependency_by_name(UNIT(a), UNIT_BEFORE, SPECIAL_LOCAL_FS_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2019-10-25 16:57:37 +02:00
|
|
|
r = unit_add_dependency_by_name(UNIT(a), UNIT_AFTER, SPECIAL_LOCAL_FS_PRE_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2018-09-15 20:02:00 +02:00
|
|
|
r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
|
2012-05-22 19:23:33 +02:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2010-07-12 22:55:27 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
static int automount_verify(Automount *a) {
|
2014-06-24 19:00:32 +02:00
|
|
|
_cleanup_free_ char *e = NULL;
|
2015-04-30 20:21:00 +02:00
|
|
|
int r;
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
assert(a);
|
2019-10-11 12:48:33 +02:00
|
|
|
assert(UNIT(a)->load_state == UNIT_LOADED);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2010-07-10 02:41:25 +02:00
|
|
|
if (path_equal(a->where, "/")) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error(UNIT(a), "Cannot have an automount unit for the root directory. Refusing.");
|
2018-06-01 18:06:54 +02:00
|
|
|
return -ENOEXEC;
|
2010-07-10 02:41:25 +02:00
|
|
|
}
|
|
|
|
|
2015-04-30 20:21:00 +02:00
|
|
|
r = unit_name_from_path(a->where, ".automount", &e);
|
|
|
|
if (r < 0)
|
2018-06-05 20:18:47 +02:00
|
|
|
return log_unit_error_errno(UNIT(a), r, "Failed to generate unit name from path: %m");
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2015-04-30 20:21:00 +02:00
|
|
|
if (!unit_has_name(UNIT(a), e)) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error(UNIT(a), "Where= setting doesn't match unit name. Refusing.");
|
2018-06-01 18:06:54 +02:00
|
|
|
return -ENOEXEC;
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-04-10 17:53:17 +02:00
|
|
|
}
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2017-03-01 04:03:48 +01:00
|
|
|
static int automount_set_where(Automount *a) {
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
|
|
|
|
if (a->where)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
r = unit_name_to_path(UNIT(a)->id, &a->where);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2018-05-31 16:39:31 +02:00
|
|
|
path_simplify(a->where, false);
|
2017-03-01 04:03:48 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-10-11 12:48:33 +02:00
|
|
|
static int automount_add_extras(Automount *a) {
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = automount_set_where(a);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = automount_add_trigger_dependencies(a);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = automount_add_mount_dependencies(a);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return automount_add_default_dependencies(a);
|
|
|
|
}
|
|
|
|
|
2010-04-10 17:53:17 +02:00
|
|
|
static int automount_load(Unit *u) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
2013-04-23 20:53:16 +02:00
|
|
|
int r;
|
2010-04-06 02:43:58 +02:00
|
|
|
|
2010-04-10 17:53:17 +02:00
|
|
|
assert(u);
|
2012-01-15 12:04:08 +01:00
|
|
|
assert(u->load_state == UNIT_STUB);
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2010-04-10 17:53:17 +02:00
|
|
|
/* Load a .automount file */
|
2019-10-11 10:41:44 +02:00
|
|
|
r = unit_load_fragment_and_dropin(u, true);
|
2012-11-21 03:10:49 +01:00
|
|
|
if (r < 0)
|
2010-04-10 17:53:17 +02:00
|
|
|
return r;
|
2010-04-06 02:43:58 +02:00
|
|
|
|
2019-10-11 12:48:33 +02:00
|
|
|
if (u->load_state != UNIT_LOADED)
|
|
|
|
return 0;
|
2010-07-10 02:41:06 +02:00
|
|
|
|
2019-10-11 12:48:33 +02:00
|
|
|
r = automount_add_extras(a);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2010-04-06 02:43:58 +02:00
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
return automount_verify(a);
|
2010-01-23 01:52:57 +01:00
|
|
|
}
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
static void automount_set_state(Automount *a, AutomountState state) {
|
|
|
|
AutomountState old_state;
|
2010-04-10 17:53:17 +02:00
|
|
|
assert(a);
|
2010-01-26 04:18:44 +01:00
|
|
|
|
2018-11-27 20:15:45 +01:00
|
|
|
if (a->state != state)
|
|
|
|
bus_unit_send_pending_change_signal(UNIT(a), false);
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
old_state = a->state;
|
|
|
|
a->state = state;
|
|
|
|
|
2016-05-02 17:12:35 +02:00
|
|
|
if (state != AUTOMOUNT_RUNNING)
|
|
|
|
automount_stop_expire(a);
|
|
|
|
|
2017-09-29 09:58:22 +02:00
|
|
|
if (!IN_SET(state, AUTOMOUNT_WAITING, AUTOMOUNT_RUNNING))
|
2010-04-16 23:24:39 +02:00
|
|
|
unmount_autofs(a);
|
|
|
|
|
|
|
|
if (state != old_state)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(UNIT(a), "Changed %s -> %s", automount_state_to_string(old_state), automount_state_to_string(state));
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2018-06-01 19:06:19 +02:00
|
|
|
unit_notify(UNIT(a), state_translation_table[old_state], state_translation_table[state], 0);
|
2010-01-26 04:18:44 +01:00
|
|
|
}
|
|
|
|
|
2015-04-24 15:27:19 +02:00
|
|
|
static int automount_coldplug(Unit *u) {
|
2010-04-21 03:27:44 +02:00
|
|
|
Automount *a = AUTOMOUNT(u);
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
assert(a->state == AUTOMOUNT_DEAD);
|
|
|
|
|
2017-03-01 04:03:48 +01:00
|
|
|
if (a->deserialized_state == a->state)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (IN_SET(a->deserialized_state, AUTOMOUNT_WAITING, AUTOMOUNT_RUNNING)) {
|
|
|
|
|
|
|
|
r = automount_set_where(a);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2010-04-21 03:27:44 +02:00
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
r = open_dev_autofs(u->manager);
|
|
|
|
if (r < 0)
|
2010-04-21 03:27:44 +02:00
|
|
|
return r;
|
|
|
|
|
2017-03-01 04:03:48 +01:00
|
|
|
assert(a->pipe_fd >= 0);
|
|
|
|
|
|
|
|
r = sd_event_add_io(u->manager->event, &a->pipe_event_source, a->pipe_fd, EPOLLIN, automount_dispatch_io, u);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2010-04-21 03:27:44 +02:00
|
|
|
|
2017-03-01 04:03:48 +01:00
|
|
|
(void) sd_event_source_set_description(a->pipe_event_source, "automount-io");
|
|
|
|
if (a->deserialized_state == AUTOMOUNT_RUNNING) {
|
|
|
|
r = automount_start_expire(a);
|
2012-11-21 03:10:49 +01:00
|
|
|
if (r < 0)
|
2017-03-01 04:03:48 +01:00
|
|
|
log_unit_warning_errno(UNIT(a), r, "Failed to start expiration timer, ignoring: %m");
|
2010-04-21 03:27:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
automount_set_state(a, a->deserialized_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-26 21:39:06 +01:00
|
|
|
static void automount_dump(Unit *u, FILE *f, const char *prefix) {
|
2015-04-14 22:01:48 +02:00
|
|
|
char time_string[FORMAT_TIMESPAN_MAX];
|
2010-04-21 03:27:44 +02:00
|
|
|
Automount *a = AUTOMOUNT(u);
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2010-04-21 03:27:44 +02:00
|
|
|
assert(a);
|
2010-01-23 01:52:57 +01:00
|
|
|
|
|
|
|
fprintf(f,
|
2010-04-21 03:27:44 +02:00
|
|
|
"%sAutomount State: %s\n"
|
2012-02-03 03:27:25 +01:00
|
|
|
"%sResult: %s\n"
|
2010-07-02 01:17:21 +02:00
|
|
|
"%sWhere: %s\n"
|
2015-04-14 22:01:48 +02:00
|
|
|
"%sDirectoryMode: %04o\n"
|
|
|
|
"%sTimeoutIdleUSec: %s\n",
|
2010-04-21 03:27:44 +02:00
|
|
|
prefix, automount_state_to_string(a->state),
|
2012-02-03 03:27:25 +01:00
|
|
|
prefix, automount_result_to_string(a->result),
|
2010-07-02 01:17:21 +02:00
|
|
|
prefix, a->where,
|
2015-04-14 22:01:48 +02:00
|
|
|
prefix, a->directory_mode,
|
|
|
|
prefix, format_timespan(time_string, FORMAT_TIMESPAN_MAX, a->timeout_idle_usec, USEC_PER_SEC));
|
2010-01-23 01:52:57 +01:00
|
|
|
}
|
|
|
|
|
2012-02-03 03:27:25 +01:00
|
|
|
static void automount_enter_dead(Automount *a, AutomountResult f) {
|
2010-04-16 23:24:39 +02:00
|
|
|
assert(a);
|
|
|
|
|
core: remember first unit failure, not last unit failure
Previously, the result value of a unit was overriden with each failure that
took place, so that the result always reported the last failure that took
place.
With this commit this is changed, so that the first failure taking place is
stored instead. This should normally not matter much as multiple failures are
sufficiently uncommon. However, it improves one behaviour: if we send SIGABRT
to a service due to a watchdog timeout, then this currently would be reported
as "coredump" failure, rather than the "watchodg" failure it really is. Hence,
in order to report information about the type of the failure, and not about
the effect of it, let's change this from all unit type to store the first, not
the last failure.
This addresses the issue pointed out here:
https://github.com/systemd/systemd/pull/3818#discussion_r73433520
2016-08-04 21:14:27 +02:00
|
|
|
if (a->result == AUTOMOUNT_SUCCESS)
|
2012-02-03 03:27:25 +01:00
|
|
|
a->result = f;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2018-11-16 10:09:45 +01:00
|
|
|
unit_log_result(UNIT(a), a->result == AUTOMOUNT_SUCCESS, automount_result_to_string(a->result));
|
2012-02-03 03:27:25 +01:00
|
|
|
automount_set_state(a, a->result != AUTOMOUNT_SUCCESS ? AUTOMOUNT_FAILED : AUTOMOUNT_DEAD);
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int open_dev_autofs(Manager *m) {
|
|
|
|
struct autofs_dev_ioctl param;
|
|
|
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
if (m->dev_autofs_fd >= 0)
|
|
|
|
return m->dev_autofs_fd;
|
|
|
|
|
2018-03-27 07:38:26 +02:00
|
|
|
(void) label_fix("/dev/autofs", 0);
|
Systemd is causing mislabeled devices to be created and then attempting to read them.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 07/28/2010 05:57 AM, Kay Sievers wrote:
> On Wed, Jul 28, 2010 at 11:43, Lennart Poettering
> <lennart@poettering.net> wrote:
>> On Mon, 26.07.10 16:42, Daniel J Walsh (dwalsh@redhat.com) wrote:
>>> tcontext=system_u:object_r:device_t:s0 tclass=chr_file
>>> type=1400 audit(1280174589.476:7): avc: denied { read } for pid=1
>>> comm="systemd" name="autofs" dev=devtmpfs ino=9482
>>> scontext=system_u:system_r:init_t:s0
>>> tcontext=system_u:object_r:device_t:s0 tclass=chr_file
>>> type=1400 audit(1280174589.476:8): avc: denied { read } for pid=1
>>> comm="systemd" name="autofs" dev=devtmpfs ino=9482
>>> scontext=system_u:system_r:init_t:s0
>>> tcontext=system_u:object_r:device_t:s0 tclass=chr_file
>>>
>>> Lennart, we talked about this earlier. I think this is caused by the
>>> modprobe calls to create /dev/autofs. Since udev is not created at the
>>> point that init loads the kernel modules, the devices get created with
>>> the wrong label. Once udev starts the labels get fixed.
>>>
>>> I can allow init_t to read device_t chr_files.
>>
>> Hmm, I think a cleaner fix would be to make systemd relabel this device
>> properly before accessing it? Given that this is only one device this
>> should not be a problem for us to maintain, I think? How would the
>> fixing of the label work? Would we have to spawn restorecon for this, or
>> can we actually do this in C without too much work?
>
> I guess we can just do what udev is doing, and call setfilecon(), with
> a context of an earlier matchpathcon().
>
> Kay
> _______________________________________________
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Here is the updated patch with a fix for the labeling of /dev/autofs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkxQMyoACgkQrlYvE4MpobNviACfWgxsjW2xzz1qznFex8RVAQHf
gIEAmwRmRcLvGqYtwQaZ3WKIg8wmrwNk
=pC2e
2010-07-28 15:39:54 +02:00
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
|
2014-11-28 19:57:32 +01:00
|
|
|
if (m->dev_autofs_fd < 0)
|
|
|
|
return log_error_errno(errno, "Failed to open /dev/autofs: %m");
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
init_autofs_dev_ioctl(¶m);
|
|
|
|
if (ioctl(m->dev_autofs_fd, AUTOFS_DEV_IOCTL_VERSION, ¶m) < 0) {
|
2014-03-18 19:22:43 +01:00
|
|
|
m->dev_autofs_fd = safe_close(m->dev_autofs_fd);
|
2010-04-16 23:24:39 +02:00
|
|
|
return -errno;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_debug("Autofs kernel version %i.%i", param.ver_major, param.ver_minor);
|
|
|
|
|
|
|
|
return m->dev_autofs_fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int open_ioctl_fd(int dev_autofs_fd, const char *where, dev_t devid) {
|
|
|
|
struct autofs_dev_ioctl *param;
|
|
|
|
size_t l;
|
|
|
|
|
|
|
|
assert(dev_autofs_fd >= 0);
|
|
|
|
assert(where);
|
|
|
|
|
|
|
|
l = sizeof(struct autofs_dev_ioctl) + strlen(where) + 1;
|
2012-11-21 03:10:49 +01:00
|
|
|
param = alloca(l);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
init_autofs_dev_ioctl(param);
|
|
|
|
param->size = l;
|
|
|
|
param->ioctlfd = -1;
|
|
|
|
param->openmount.devid = devid;
|
|
|
|
strcpy(param->path, where);
|
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_OPENMOUNT, param) < 0)
|
|
|
|
return -errno;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
if (param->ioctlfd < 0)
|
|
|
|
return -EIO;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2015-04-21 18:43:57 +02:00
|
|
|
(void) fd_cloexec(param->ioctlfd, true);
|
2012-11-21 03:10:49 +01:00
|
|
|
return param->ioctlfd;
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int autofs_protocol(int dev_autofs_fd, int ioctl_fd) {
|
|
|
|
uint32_t major, minor;
|
|
|
|
struct autofs_dev_ioctl param;
|
|
|
|
|
|
|
|
assert(dev_autofs_fd >= 0);
|
|
|
|
assert(ioctl_fd >= 0);
|
|
|
|
|
|
|
|
init_autofs_dev_ioctl(¶m);
|
|
|
|
param.ioctlfd = ioctl_fd;
|
|
|
|
|
|
|
|
if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_PROTOVER, ¶m) < 0)
|
|
|
|
return -errno;
|
|
|
|
|
|
|
|
major = param.protover.version;
|
|
|
|
|
|
|
|
init_autofs_dev_ioctl(¶m);
|
|
|
|
param.ioctlfd = ioctl_fd;
|
|
|
|
|
|
|
|
if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_PROTOSUBVER, ¶m) < 0)
|
|
|
|
return -errno;
|
|
|
|
|
|
|
|
minor = param.protosubver.sub_version;
|
|
|
|
|
|
|
|
log_debug("Autofs protocol version %i.%i", major, minor);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
static int autofs_set_timeout(int dev_autofs_fd, int ioctl_fd, usec_t usec) {
|
2010-04-16 23:24:39 +02:00
|
|
|
struct autofs_dev_ioctl param;
|
|
|
|
|
|
|
|
assert(dev_autofs_fd >= 0);
|
|
|
|
assert(ioctl_fd >= 0);
|
|
|
|
|
|
|
|
init_autofs_dev_ioctl(¶m);
|
|
|
|
param.ioctlfd = ioctl_fd;
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2017-05-23 09:42:26 +02:00
|
|
|
if (usec == USEC_INFINITY)
|
|
|
|
param.timeout.timeout = 0;
|
|
|
|
else
|
|
|
|
/* Convert to seconds, rounding up. */
|
2018-03-20 20:36:09 +01:00
|
|
|
param.timeout.timeout = DIV_ROUND_UP(usec, USEC_PER_SEC);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
if (ioctl(dev_autofs_fd, AUTOFS_DEV_IOCTL_TIMEOUT, ¶m) < 0)
|
|
|
|
return -errno;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int autofs_send_ready(int dev_autofs_fd, int ioctl_fd, uint32_t token, int status) {
|
|
|
|
struct autofs_dev_ioctl param;
|
|
|
|
|
|
|
|
assert(dev_autofs_fd >= 0);
|
|
|
|
assert(ioctl_fd >= 0);
|
|
|
|
|
|
|
|
init_autofs_dev_ioctl(¶m);
|
|
|
|
param.ioctlfd = ioctl_fd;
|
|
|
|
|
2016-05-02 16:01:39 +02:00
|
|
|
if (status != 0) {
|
2010-04-16 23:24:39 +02:00
|
|
|
param.fail.token = token;
|
|
|
|
param.fail.status = status;
|
|
|
|
} else
|
|
|
|
param.ready.token = token;
|
|
|
|
|
|
|
|
if (ioctl(dev_autofs_fd, status ? AUTOFS_DEV_IOCTL_FAIL : AUTOFS_DEV_IOCTL_READY, ¶m) < 0)
|
|
|
|
return -errno;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
static int automount_send_ready(Automount *a, Set *tokens, int status) {
|
2014-03-18 19:22:43 +01:00
|
|
|
_cleanup_close_ int ioctl_fd = -1;
|
2010-04-16 23:24:39 +02:00
|
|
|
unsigned token;
|
2014-03-18 19:22:43 +01:00
|
|
|
int r;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
assert(a);
|
|
|
|
assert(status <= 0);
|
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
if (set_isempty(tokens))
|
2010-04-16 23:24:39 +02:00
|
|
|
return 0;
|
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id);
|
2014-03-18 19:22:43 +01:00
|
|
|
if (ioctl_fd < 0)
|
|
|
|
return ioctl_fd;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2016-05-02 16:01:39 +02:00
|
|
|
if (status != 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug_errno(UNIT(a), status, "Sending failure: %m");
|
2010-04-16 23:24:39 +02:00
|
|
|
else
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(UNIT(a), "Sending success.");
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2010-08-11 22:04:22 +02:00
|
|
|
r = 0;
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
/* Autofs thankfully does not hand out 0 as a token */
|
2015-04-14 22:01:48 +02:00
|
|
|
while ((token = PTR_TO_UINT(set_steal_first(tokens)))) {
|
2010-04-16 23:24:39 +02:00
|
|
|
int k;
|
|
|
|
|
2017-06-30 18:51:33 +02:00
|
|
|
/* Autofs fun fact:
|
2010-04-16 23:24:39 +02:00
|
|
|
*
|
2017-06-30 18:51:33 +02:00
|
|
|
* if you pass a positive status code here, kernels
|
|
|
|
* prior to 4.12 will freeze! Yay! */
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
k = autofs_send_ready(UNIT(a)->manager->dev_autofs_fd,
|
|
|
|
ioctl_fd,
|
|
|
|
token,
|
|
|
|
status);
|
|
|
|
if (k < 0)
|
2010-04-16 23:24:39 +02:00
|
|
|
r = k;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
static void automount_trigger_notify(Unit *u, Unit *other) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
2015-07-24 22:25:28 +02:00
|
|
|
int r;
|
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
assert(a);
|
2016-05-02 16:51:45 +02:00
|
|
|
assert(other);
|
|
|
|
|
|
|
|
/* Filter out invocations with bogus state */
|
|
|
|
if (other->load_state != UNIT_LOADED || other->type != UNIT_MOUNT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Don't propagate state changes from the mount if we are already down */
|
|
|
|
if (!IN_SET(a->state, AUTOMOUNT_WAITING, AUTOMOUNT_RUNNING))
|
|
|
|
return;
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
/* Propagate start limit hit state */
|
|
|
|
if (other->start_limit_hit) {
|
|
|
|
automount_enter_dead(a, AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT);
|
|
|
|
return;
|
|
|
|
}
|
2016-05-02 16:01:39 +02:00
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
/* Don't propagate anything if there's still a job queued */
|
|
|
|
if (other->job)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* The mount is successfully established */
|
|
|
|
if (IN_SET(MOUNT(other)->state, MOUNT_MOUNTED, MOUNT_REMOUNTING)) {
|
|
|
|
(void) automount_send_ready(a, a->tokens, 0);
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2015-07-24 22:25:28 +02:00
|
|
|
r = automount_start_expire(a);
|
|
|
|
if (r < 0)
|
|
|
|
log_unit_warning_errno(UNIT(a), r, "Failed to start expiration timer, ignoring: %m");
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
automount_set_state(a, AUTOMOUNT_RUNNING);
|
2015-04-14 22:01:48 +02:00
|
|
|
}
|
|
|
|
|
2016-06-05 17:25:14 +02:00
|
|
|
if (IN_SET(MOUNT(other)->state,
|
|
|
|
MOUNT_MOUNTING, MOUNT_MOUNTING_DONE,
|
|
|
|
MOUNT_MOUNTED, MOUNT_REMOUNTING,
|
|
|
|
MOUNT_REMOUNTING_SIGTERM, MOUNT_REMOUNTING_SIGKILL,
|
|
|
|
MOUNT_UNMOUNTING_SIGTERM, MOUNT_UNMOUNTING_SIGKILL,
|
|
|
|
MOUNT_FAILED)) {
|
|
|
|
|
|
|
|
(void) automount_send_ready(a, a->expire_tokens, -ENODEV);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MOUNT(other)->state == MOUNT_DEAD)
|
|
|
|
(void) automount_send_ready(a, a->expire_tokens, 0);
|
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
/* The mount is in some unhappy state now, let's unfreeze any waiting clients */
|
|
|
|
if (IN_SET(MOUNT(other)->state,
|
|
|
|
MOUNT_DEAD, MOUNT_UNMOUNTING,
|
|
|
|
MOUNT_REMOUNTING_SIGTERM, MOUNT_REMOUNTING_SIGKILL,
|
|
|
|
MOUNT_UNMOUNTING_SIGTERM, MOUNT_UNMOUNTING_SIGKILL,
|
|
|
|
MOUNT_FAILED)) {
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
(void) automount_send_ready(a, a->tokens, -ENODEV);
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
automount_set_state(a, AUTOMOUNT_WAITING);
|
|
|
|
}
|
2015-04-14 22:01:48 +02:00
|
|
|
}
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
static void automount_enter_waiting(Automount *a) {
|
2014-03-18 19:22:43 +01:00
|
|
|
_cleanup_close_ int ioctl_fd = -1;
|
2010-04-16 23:24:39 +02:00
|
|
|
int p[2] = { -1, -1 };
|
2017-12-14 19:02:29 +01:00
|
|
|
char name[STRLEN("systemd-") + DECIMAL_STR_MAX(pid_t) + 1];
|
|
|
|
char options[STRLEN("fd=,pgrp=,minproto=5,maxproto=5,direct")
|
2015-01-27 14:00:11 +01:00
|
|
|
+ DECIMAL_STR_MAX(int) + DECIMAL_STR_MAX(gid_t) + 1];
|
2010-04-16 23:24:39 +02:00
|
|
|
bool mounted = false;
|
2014-03-18 19:22:43 +01:00
|
|
|
int r, dev_autofs_fd;
|
2010-04-16 23:24:39 +02:00
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
assert(a->pipe_fd < 0);
|
|
|
|
assert(a->where);
|
|
|
|
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
set_clear(a->tokens);
|
|
|
|
|
2018-01-19 18:28:38 +01:00
|
|
|
r = unit_fail_if_noncanonical(UNIT(a), a->where);
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
if (r < 0)
|
|
|
|
goto fail;
|
|
|
|
|
2019-09-29 23:16:55 +02:00
|
|
|
(void) mkdir_p_label(a->where, a->directory_mode);
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
|
|
|
|
unit_warn_if_dir_nonempty(UNIT(a), a->where);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
dev_autofs_fd = open_dev_autofs(UNIT(a)->manager);
|
|
|
|
if (dev_autofs_fd < 0) {
|
2010-04-16 23:24:39 +02:00
|
|
|
r = dev_autofs_fd;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-02-07 23:44:06 +01:00
|
|
|
if (pipe2(p, O_CLOEXEC) < 0) {
|
2010-04-16 23:24:39 +02:00
|
|
|
r = -errno;
|
|
|
|
goto fail;
|
|
|
|
}
|
2019-02-07 23:44:06 +01:00
|
|
|
r = fd_nonblock(p[0], true);
|
|
|
|
if (r < 0)
|
|
|
|
goto fail;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2015-01-27 14:00:11 +01:00
|
|
|
xsprintf(options, "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct", p[1], getpgrp());
|
2017-07-20 16:19:18 +02:00
|
|
|
xsprintf(name, "systemd-"PID_FMT, getpid_cached());
|
2010-04-16 23:24:39 +02:00
|
|
|
if (mount(name, a->where, "autofs", 0, options) < 0) {
|
|
|
|
r = -errno;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
mounted = true;
|
|
|
|
|
2014-03-18 19:22:43 +01:00
|
|
|
p[1] = safe_close(p[1]);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
if (stat(a->where, &st) < 0) {
|
|
|
|
r = -errno;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
ioctl_fd = open_ioctl_fd(dev_autofs_fd, a->where, st.st_dev);
|
|
|
|
if (ioctl_fd < 0) {
|
2010-04-16 23:24:39 +02:00
|
|
|
r = ioctl_fd;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
r = autofs_protocol(dev_autofs_fd, ioctl_fd);
|
|
|
|
if (r < 0)
|
2010-04-16 23:24:39 +02:00
|
|
|
goto fail;
|
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
r = autofs_set_timeout(dev_autofs_fd, ioctl_fd, a->timeout_idle_usec);
|
2012-11-21 03:10:49 +01:00
|
|
|
if (r < 0)
|
2010-04-16 23:24:39 +02:00
|
|
|
goto fail;
|
|
|
|
|
2014-02-19 23:54:58 +01:00
|
|
|
r = sd_event_add_io(UNIT(a)->manager->event, &a->pipe_event_source, p[0], EPOLLIN, automount_dispatch_io, a);
|
2012-11-21 03:10:49 +01:00
|
|
|
if (r < 0)
|
2010-04-16 23:24:39 +02:00
|
|
|
goto fail;
|
|
|
|
|
2015-04-29 16:05:32 +02:00
|
|
|
(void) sd_event_source_set_description(a->pipe_event_source, "automount-io");
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
a->pipe_fd = p[0];
|
|
|
|
a->dev_id = st.st_dev;
|
|
|
|
|
|
|
|
automount_set_state(a, AUTOMOUNT_WAITING);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
fail:
|
2015-10-27 14:25:58 +01:00
|
|
|
log_unit_error_errno(UNIT(a), r, "Failed to initialize automounter: %m");
|
|
|
|
|
2014-03-24 03:22:44 +01:00
|
|
|
safe_close_pair(p);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2015-10-27 14:25:58 +01:00
|
|
|
if (mounted) {
|
|
|
|
r = repeat_unmount(a->where, MNT_DETACH);
|
|
|
|
if (r < 0)
|
|
|
|
log_error_errno(r, "Failed to unmount, ignoring: %m");
|
|
|
|
}
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2012-02-03 03:27:25 +01:00
|
|
|
automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
static void *expire_thread(void *p) {
|
|
|
|
struct autofs_dev_ioctl param;
|
|
|
|
_cleanup_(expire_data_freep) struct expire_data *data = (struct expire_data*)p;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(data->dev_autofs_fd >= 0);
|
|
|
|
assert(data->ioctl_fd >= 0);
|
|
|
|
|
|
|
|
init_autofs_dev_ioctl(¶m);
|
|
|
|
param.ioctlfd = data->ioctl_fd;
|
|
|
|
|
|
|
|
do {
|
|
|
|
r = ioctl(data->dev_autofs_fd, AUTOFS_DEV_IOCTL_EXPIRE, ¶m);
|
|
|
|
} while (r >= 0);
|
|
|
|
|
|
|
|
if (errno != EAGAIN)
|
|
|
|
log_warning_errno(errno, "Failed to expire automount, ignoring: %m");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int automount_dispatch_expire(sd_event_source *source, usec_t usec, void *userdata) {
|
|
|
|
Automount *a = AUTOMOUNT(userdata);
|
|
|
|
_cleanup_(expire_data_freep) struct expire_data *data = NULL;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
assert(source == a->expire_event_source);
|
|
|
|
|
|
|
|
data = new0(struct expire_data, 1);
|
|
|
|
if (!data)
|
|
|
|
return log_oom();
|
|
|
|
|
|
|
|
data->ioctl_fd = -1;
|
|
|
|
|
|
|
|
data->dev_autofs_fd = fcntl(UNIT(a)->manager->dev_autofs_fd, F_DUPFD_CLOEXEC, 3);
|
|
|
|
if (data->dev_autofs_fd < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
return log_unit_error_errno(UNIT(a), errno, "Failed to duplicate autofs fd: %m");
|
2015-04-14 22:01:48 +02:00
|
|
|
|
|
|
|
data->ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id);
|
|
|
|
if (data->ioctl_fd < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
return log_unit_error_errno(UNIT(a), data->ioctl_fd, "Couldn't open autofs ioctl fd: %m");
|
2015-04-14 22:01:48 +02:00
|
|
|
|
|
|
|
r = asynchronous_job(expire_thread, data);
|
|
|
|
if (r < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
return log_unit_error_errno(UNIT(a), r, "Failed to start expire job: %m");
|
2015-04-14 22:01:48 +02:00
|
|
|
|
|
|
|
data = NULL;
|
|
|
|
|
|
|
|
return automount_start_expire(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int automount_start_expire(Automount *a) {
|
|
|
|
usec_t timeout;
|
2020-07-28 11:18:26 +02:00
|
|
|
int r;
|
2015-04-14 22:01:48 +02:00
|
|
|
|
|
|
|
assert(a);
|
|
|
|
|
2015-07-24 17:40:55 +02:00
|
|
|
if (a->timeout_idle_usec == 0)
|
|
|
|
return 0;
|
|
|
|
|
2020-07-28 11:18:26 +02:00
|
|
|
timeout = MAX(a->timeout_idle_usec/3, USEC_PER_SEC);
|
2015-04-14 22:01:48 +02:00
|
|
|
|
|
|
|
if (a->expire_event_source) {
|
2020-07-28 11:18:26 +02:00
|
|
|
r = sd_event_source_set_time_relative(a->expire_event_source, timeout);
|
2015-04-14 22:01:48 +02:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
return sd_event_source_set_enabled(a->expire_event_source, SD_EVENT_ONESHOT);
|
|
|
|
}
|
|
|
|
|
2020-07-28 11:18:26 +02:00
|
|
|
r = sd_event_add_time_relative(
|
2015-04-14 22:01:48 +02:00
|
|
|
UNIT(a)->manager->event,
|
|
|
|
&a->expire_event_source,
|
|
|
|
CLOCK_MONOTONIC, timeout, 0,
|
|
|
|
automount_dispatch_expire, a);
|
2015-04-29 16:05:32 +02:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
(void) sd_event_source_set_description(a->expire_event_source, "automount-expire");
|
|
|
|
|
|
|
|
return 0;
|
2015-04-14 22:01:48 +02:00
|
|
|
}
|
|
|
|
|
2016-05-02 17:12:35 +02:00
|
|
|
static void automount_stop_expire(Automount *a) {
|
|
|
|
assert(a);
|
|
|
|
|
|
|
|
if (!a->expire_event_source)
|
|
|
|
return;
|
|
|
|
|
|
|
|
(void) sd_event_source_set_enabled(a->expire_event_source, SD_EVENT_OFF);
|
|
|
|
}
|
|
|
|
|
2017-05-10 13:23:58 +02:00
|
|
|
static void automount_enter_running(Automount *a) {
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.
With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.
The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).
This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.
Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:
#define _cleanup_(function) __attribute__((cleanup(function)))
Or similar, to make the gcc feature easier to use.
Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.
See #2008.
2015-11-27 19:13:45 +01:00
|
|
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
2017-05-10 13:23:58 +02:00
|
|
|
Unit *trigger;
|
2013-04-23 20:53:16 +02:00
|
|
|
struct stat st;
|
|
|
|
int r;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
assert(a);
|
|
|
|
|
2017-03-01 04:03:48 +01:00
|
|
|
/* If the user masked our unit in the meantime, fail */
|
|
|
|
if (UNIT(a)->load_state != UNIT_LOADED) {
|
|
|
|
log_unit_error(UNIT(a), "Suppressing automount event since unit is no longer loaded.");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2010-07-13 00:27:27 +02:00
|
|
|
/* We don't take mount requests anymore if we are supposed to
|
|
|
|
* shut down anyway */
|
2013-04-26 02:57:41 +02:00
|
|
|
if (unit_stop_pending(UNIT(a))) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(UNIT(a), "Suppressing automount request since unit stop is scheduled.");
|
2015-04-14 22:01:48 +02:00
|
|
|
automount_send_ready(a, a->tokens, -EHOSTDOWN);
|
|
|
|
automount_send_ready(a, a->expire_tokens, -EHOSTDOWN);
|
2010-07-13 00:27:27 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-27 11:33:50 +01:00
|
|
|
(void) mkdir_p_label(a->where, a->directory_mode);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2010-07-02 01:17:21 +02:00
|
|
|
/* Before we do anything, let's see if somebody is playing games with us? */
|
|
|
|
if (lstat(a->where, &st) < 0) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_warning_errno(UNIT(a), errno, "Failed to stat automount point: %m");
|
2010-04-16 23:24:39 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2017-05-10 13:23:58 +02:00
|
|
|
/* The mount unit may have been explicitly started before we got the
|
|
|
|
* autofs request. Ack it to unblock anything waiting on the mount point. */
|
|
|
|
if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_info(UNIT(a), "Automount point already active?");
|
2017-05-10 13:23:58 +02:00
|
|
|
automount_send_ready(a, a->tokens, 0);
|
|
|
|
return;
|
|
|
|
}
|
2016-02-10 23:39:31 +01:00
|
|
|
|
2017-05-10 13:23:58 +02:00
|
|
|
trigger = UNIT_TRIGGER(UNIT(a));
|
|
|
|
if (!trigger) {
|
|
|
|
log_unit_error(UNIT(a), "Unit to trigger vanished.");
|
|
|
|
goto fail;
|
|
|
|
}
|
2016-02-10 23:39:31 +01:00
|
|
|
|
2019-03-22 20:57:30 +01:00
|
|
|
r = manager_add_job(UNIT(a)->manager, JOB_START, trigger, JOB_REPLACE, NULL, &error, NULL);
|
2017-05-10 13:23:58 +02:00
|
|
|
if (r < 0) {
|
|
|
|
log_unit_warning(UNIT(a), "Failed to queue mount startup job: %s", bus_error_message(&error, r));
|
|
|
|
goto fail;
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
automount_set_state(a, AUTOMOUNT_RUNNING);
|
|
|
|
return;
|
|
|
|
|
|
|
|
fail:
|
2012-02-03 03:27:25 +01:00
|
|
|
automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int automount_start(Unit *u) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
core: move enforcement of the start limit into per-unit-type code again
Let's move the enforcement of the per-unit start limit from unit.c into the
type-specific files again. For unit types that know a concept of "result" codes
this allows us to hook up the start limit condition to it with an explicit
result code. Also, this makes sure that the state checks in clal like
service_start() may be done before the start limit is checked, as the start
limit really should be checked last, right before everything has been verified
to be in order.
The generic start limit logic is left in unit.c, but the invocation of it is
moved into the per-type files, in the various xyz_start() functions, so that
they may place the check at the right location.
Note that this change drops the enforcement entirely from device, slice, target
and scope units, since these unit types generally may not fail activation, or
may only be activated a single time. This is also documented now.
Note that restores the "start-limit-hit" result code that existed before
6bf0f408e4833152197fb38fb10a9989c89f3a59 already in the service code. However,
it's not introduced for all units that have a result code concept.
Fixes #3166.
2016-05-02 13:01:26 +02:00
|
|
|
int r;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
assert(a);
|
2017-09-29 00:37:23 +02:00
|
|
|
assert(IN_SET(a->state, AUTOMOUNT_DEAD, AUTOMOUNT_FAILED));
|
2010-05-24 05:25:33 +02:00
|
|
|
|
2016-11-18 21:35:21 +01:00
|
|
|
if (path_is_mount_point(a->where, NULL, 0) > 0) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error(u, "Path %s is already a mount point, refusing start.", a->where);
|
2010-04-16 23:24:39 +02:00
|
|
|
return -EEXIST;
|
|
|
|
}
|
|
|
|
|
2019-03-18 12:29:08 +01:00
|
|
|
r = unit_test_trigger_loaded(u);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2019-03-18 12:21:27 +01:00
|
|
|
r = unit_test_start_limit(u);
|
core: move enforcement of the start limit into per-unit-type code again
Let's move the enforcement of the per-unit start limit from unit.c into the
type-specific files again. For unit types that know a concept of "result" codes
this allows us to hook up the start limit condition to it with an explicit
result code. Also, this makes sure that the state checks in clal like
service_start() may be done before the start limit is checked, as the start
limit really should be checked last, right before everything has been verified
to be in order.
The generic start limit logic is left in unit.c, but the invocation of it is
moved into the per-type files, in the various xyz_start() functions, so that
they may place the check at the right location.
Note that this change drops the enforcement entirely from device, slice, target
and scope units, since these unit types generally may not fail activation, or
may only be activated a single time. This is also documented now.
Note that restores the "start-limit-hit" result code that existed before
6bf0f408e4833152197fb38fb10a9989c89f3a59 already in the service code. However,
it's not introduced for all units that have a result code concept.
Fixes #3166.
2016-05-02 13:01:26 +02:00
|
|
|
if (r < 0) {
|
|
|
|
automount_enter_dead(a, AUTOMOUNT_FAILURE_START_LIMIT_HIT);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2016-08-30 23:18:46 +02:00
|
|
|
r = unit_acquire_invocation_id(u);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2012-02-03 03:27:25 +01:00
|
|
|
a->result = AUTOMOUNT_SUCCESS;
|
2010-04-16 23:24:39 +02:00
|
|
|
automount_enter_waiting(a);
|
2015-01-28 15:07:13 +01:00
|
|
|
return 1;
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int automount_stop(Unit *u) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
|
|
|
|
|
|
|
assert(a);
|
2017-09-29 00:37:23 +02:00
|
|
|
assert(IN_SET(a->state, AUTOMOUNT_WAITING, AUTOMOUNT_RUNNING));
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2012-02-03 03:27:25 +01:00
|
|
|
automount_enter_dead(a, AUTOMOUNT_SUCCESS);
|
2015-01-28 15:07:13 +01:00
|
|
|
return 1;
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
2010-04-21 03:27:44 +02:00
|
|
|
static int automount_serialize(Unit *u, FILE *f, FDSet *fds) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
|
|
|
Iterator i;
|
2015-10-07 23:07:39 +02:00
|
|
|
void *p;
|
|
|
|
int r;
|
2010-04-21 03:27:44 +02:00
|
|
|
|
|
|
|
assert(a);
|
|
|
|
assert(f);
|
|
|
|
assert(fds);
|
|
|
|
|
2018-10-17 20:40:09 +02:00
|
|
|
(void) serialize_item(f, "state", automount_state_to_string(a->state));
|
|
|
|
(void) serialize_item(f, "result", automount_result_to_string(a->result));
|
|
|
|
(void) serialize_item_format(f, "dev-id", "%lu", (unsigned long) a->dev_id);
|
2010-04-21 03:27:44 +02:00
|
|
|
|
|
|
|
SET_FOREACH(p, a->tokens, i)
|
2018-10-17 20:40:09 +02:00
|
|
|
(void) serialize_item_format(f, "token", "%u", PTR_TO_UINT(p));
|
2015-04-14 22:01:48 +02:00
|
|
|
SET_FOREACH(p, a->expire_tokens, i)
|
2018-10-17 20:40:09 +02:00
|
|
|
(void) serialize_item_format(f, "expire-token", "%u", PTR_TO_UINT(p));
|
2010-04-21 03:27:44 +02:00
|
|
|
|
2018-10-17 20:40:09 +02:00
|
|
|
r = serialize_fd(f, fds, "pipe-fd", a->pipe_fd);
|
2015-10-07 23:07:39 +02:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2010-04-21 03:27:44 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int automount_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
|
|
|
|
Automount *a = AUTOMOUNT(u);
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
assert(fds);
|
|
|
|
|
|
|
|
if (streq(key, "state")) {
|
|
|
|
AutomountState state;
|
|
|
|
|
2012-11-21 03:10:49 +01:00
|
|
|
state = automount_state_from_string(value);
|
|
|
|
if (state < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(u, "Failed to parse state value: %s", value);
|
2010-04-21 03:27:44 +02:00
|
|
|
else
|
|
|
|
a->deserialized_state = state;
|
2012-02-03 03:27:25 +01:00
|
|
|
} else if (streq(key, "result")) {
|
|
|
|
AutomountResult f;
|
|
|
|
|
|
|
|
f = automount_result_from_string(value);
|
|
|
|
if (f < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(u, "Failed to parse result value: %s", value);
|
2012-02-03 03:27:25 +01:00
|
|
|
else if (f != AUTOMOUNT_SUCCESS)
|
|
|
|
a->result = f;
|
2010-04-21 03:27:44 +02:00
|
|
|
|
|
|
|
} else if (streq(key, "dev-id")) {
|
2018-10-17 20:15:26 +02:00
|
|
|
unsigned long d;
|
2010-04-21 03:27:44 +02:00
|
|
|
|
2018-10-17 20:15:26 +02:00
|
|
|
if (safe_atolu(value, &d) < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(u, "Failed to parse dev-id value: %s", value);
|
2010-04-21 03:27:44 +02:00
|
|
|
else
|
2018-10-17 20:15:26 +02:00
|
|
|
a->dev_id = (dev_t) d;
|
|
|
|
|
2010-04-21 03:27:44 +02:00
|
|
|
} else if (streq(key, "token")) {
|
|
|
|
unsigned token;
|
|
|
|
|
|
|
|
if (safe_atou(value, &token) < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(u, "Failed to parse token value: %s", value);
|
2010-04-21 03:27:44 +02:00
|
|
|
else {
|
2020-06-05 15:12:29 +02:00
|
|
|
r = set_ensure_put(&a->tokens, NULL, UINT_TO_PTR(token));
|
2012-11-21 03:10:49 +01:00
|
|
|
if (r < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error_errno(u, r, "Failed to add token to set: %m");
|
2010-04-21 03:27:44 +02:00
|
|
|
}
|
2015-04-14 22:01:48 +02:00
|
|
|
} else if (streq(key, "expire-token")) {
|
|
|
|
unsigned token;
|
|
|
|
|
|
|
|
if (safe_atou(value, &token) < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(u, "Failed to parse token value: %s", value);
|
2015-04-14 22:01:48 +02:00
|
|
|
else {
|
2020-06-05 15:12:29 +02:00
|
|
|
r = set_ensure_put(&a->expire_tokens, NULL, UINT_TO_PTR(token));
|
2015-04-14 22:01:48 +02:00
|
|
|
if (r < 0)
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error_errno(u, r, "Failed to add expire token to set: %m");
|
2015-04-14 22:01:48 +02:00
|
|
|
}
|
2010-04-21 03:27:44 +02:00
|
|
|
} else if (streq(key, "pipe-fd")) {
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(u, "Failed to parse pipe-fd value: %s", value);
|
2010-04-21 03:27:44 +02:00
|
|
|
else {
|
2014-03-18 19:22:43 +01:00
|
|
|
safe_close(a->pipe_fd);
|
2010-04-21 03:27:44 +02:00
|
|
|
a->pipe_fd = fdset_remove(fds, fd);
|
|
|
|
}
|
|
|
|
} else
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(u, "Unknown serialization key: %s", key);
|
2010-04-21 03:27:44 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-26 21:39:06 +01:00
|
|
|
static UnitActiveState automount_active_state(Unit *u) {
|
2010-04-21 03:27:44 +02:00
|
|
|
assert(u);
|
2010-01-26 21:39:06 +01:00
|
|
|
|
2010-04-10 17:53:17 +02:00
|
|
|
return state_translation_table[AUTOMOUNT(u)->state];
|
2010-01-23 01:52:57 +01:00
|
|
|
}
|
|
|
|
|
2010-04-13 20:59:01 +02:00
|
|
|
static const char *automount_sub_state_to_string(Unit *u) {
|
|
|
|
assert(u);
|
|
|
|
|
2010-04-21 03:27:44 +02:00
|
|
|
return automount_state_to_string(AUTOMOUNT(u)->state);
|
2010-04-13 20:59:01 +02:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:50:13 +01:00
|
|
|
static bool automount_may_gc(Unit *u) {
|
|
|
|
Unit *t;
|
|
|
|
|
2013-04-23 20:53:16 +02:00
|
|
|
assert(u);
|
2010-04-21 06:01:13 +02:00
|
|
|
|
2018-02-13 10:50:13 +01:00
|
|
|
t = UNIT_TRIGGER(u);
|
|
|
|
if (!t)
|
|
|
|
return true;
|
2010-09-06 01:04:59 +02:00
|
|
|
|
2018-02-13 10:50:13 +01:00
|
|
|
return UNIT_VTABLE(t)->may_gc(t);
|
2010-04-21 06:01:13 +02:00
|
|
|
}
|
|
|
|
|
2013-11-19 21:12:59 +01:00
|
|
|
static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, void *userdata) {
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.
With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.
The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).
This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.
Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:
#define _cleanup_(function) __attribute__((cleanup(function)))
Or similar, to make the gcc feature easier to use.
Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.
See #2008.
2015-11-27 19:13:45 +01:00
|
|
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
2010-04-16 23:24:39 +02:00
|
|
|
union autofs_v5_packet_union packet;
|
2013-11-19 21:12:59 +01:00
|
|
|
Automount *a = AUTOMOUNT(userdata);
|
2016-02-10 23:39:31 +01:00
|
|
|
Unit *trigger;
|
2010-04-16 23:24:39 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
assert(fd == a->pipe_fd);
|
|
|
|
|
|
|
|
if (events != EPOLLIN) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error(UNIT(a), "Got invalid poll event %"PRIu32" on pipe (fd=%d)", events, fd);
|
2010-04-16 23:24:39 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2015-03-10 02:23:53 +01:00
|
|
|
r = loop_read_exact(a->pipe_fd, &packet, sizeof(packet), true);
|
|
|
|
if (r < 0) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error_errno(UNIT(a), r, "Invalid read from pipe: %m");
|
2010-04-16 23:24:39 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (packet.hdr.type) {
|
|
|
|
|
|
|
|
case autofs_ptype_missing_direct:
|
2010-10-28 22:20:01 +02:00
|
|
|
|
|
|
|
if (packet.v5_packet.pid > 0) {
|
2012-11-22 00:40:45 +01:00
|
|
|
_cleanup_free_ char *p = NULL;
|
2010-10-28 22:20:01 +02:00
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
get_process_comm(packet.v5_packet.pid, &p);
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_info(UNIT(a), "Got automount request for %s, triggered by %"PRIu32" (%s)", a->where, packet.v5_packet.pid, strna(p));
|
2010-10-28 22:20:01 +02:00
|
|
|
} else
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(UNIT(a), "Got direct mount request on %s", a->where);
|
2010-04-16 23:24:39 +02:00
|
|
|
|
2020-06-05 15:12:29 +02:00
|
|
|
r = set_ensure_put(&a->tokens, NULL, UINT_TO_PTR(packet.v5_packet.wait_queue_token));
|
2012-11-21 03:10:49 +01:00
|
|
|
if (r < 0) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error_errno(UNIT(a), r, "Failed to remember token: %m");
|
2010-04-16 23:24:39 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2017-05-10 13:23:58 +02:00
|
|
|
automount_enter_running(a);
|
2010-04-16 23:24:39 +02:00
|
|
|
break;
|
|
|
|
|
2015-04-14 22:01:48 +02:00
|
|
|
case autofs_ptype_expire_direct:
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_debug(UNIT(a), "Got direct umount request on %s", a->where);
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2016-05-02 17:12:35 +02:00
|
|
|
automount_stop_expire(a);
|
2015-04-14 22:01:48 +02:00
|
|
|
|
2020-06-05 15:12:29 +02:00
|
|
|
r = set_ensure_put(&a->expire_tokens, NULL, UINT_TO_PTR(packet.v5_packet.wait_queue_token));
|
2015-04-14 22:01:48 +02:00
|
|
|
if (r < 0) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error_errno(UNIT(a), r, "Failed to remember token: %m");
|
2015-04-14 22:01:48 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
2015-07-24 22:21:59 +02:00
|
|
|
|
2016-02-10 23:39:31 +01:00
|
|
|
trigger = UNIT_TRIGGER(UNIT(a));
|
|
|
|
if (!trigger) {
|
|
|
|
log_unit_error(UNIT(a), "Unit to trigger vanished.");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2019-03-22 20:57:30 +01:00
|
|
|
r = manager_add_job(UNIT(a)->manager, JOB_STOP, trigger, JOB_REPLACE, NULL, &error, NULL);
|
2015-04-14 22:01:48 +02:00
|
|
|
if (r < 0) {
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_warning(UNIT(a), "Failed to queue umount startup job: %s", bus_error_message(&error, r));
|
2015-04-14 22:01:48 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
default:
|
core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.
Also contains a couple of other logging improvements:
- Drops a couple of strerror() invocations in favour of using %m.
- Not only .mount units now warn if a symlinks exist for the mount
point already, .automount units do that too, now.
- A few invocations of log_struct() that didn't actually pass any
additional structured data have been replaced by simpler invocations
of log_unit_info() and friends.
- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
that works like LOG_MESSAGE() but prefixes the message with the unit
name. Similar, there's now LOG_LINK_MESSAGE() and
LOG_NETDEV_MESSAGE().
- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
LOG_NETDEV_INTERFACE() macros have been added that generate the
necessary per object fields. The old log_unit_struct() call has been
removed in favour of these new macros used in raw log_struct()
invocations. In addition to removing one more function call this
allows generated structured log messages that contain two object
fields, as necessary for example for network interfaces that are
joined into another network interface, and whose messages shall be
indexed by both.
- The LOG_ERRNO() macro has been removed, in favour of
log_struct_errno(). The latter has the benefit of ensuring that %m in
format strings is properly resolved to the specified error number.
- A number of logging messages have been converted to use
log_unit_info() instead of log_info()
- The client code in sysv-generator no longer #includes core code from
src/core/.
- log_unit_full_errno() has been removed, log_unit_full() instead takes
an errno now, too.
- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
avoid double evaluation of their parameters
2015-05-11 20:38:21 +02:00
|
|
|
log_unit_error(UNIT(a), "Received unknown automount request %i", packet.hdr.type);
|
2010-04-16 23:24:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-19 21:12:59 +01:00
|
|
|
return 0;
|
2010-04-16 23:24:39 +02:00
|
|
|
|
|
|
|
fail:
|
2012-02-03 03:27:25 +01:00
|
|
|
automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
|
2013-11-19 21:12:59 +01:00
|
|
|
return 0;
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void automount_shutdown(Manager *m) {
|
|
|
|
assert(m);
|
|
|
|
|
2014-03-18 19:22:43 +01:00
|
|
|
m->dev_autofs_fd = safe_close(m->dev_autofs_fd);
|
2010-04-16 23:24:39 +02:00
|
|
|
}
|
|
|
|
|
2010-08-31 00:17:56 +02:00
|
|
|
static void automount_reset_failed(Unit *u) {
|
2010-07-18 04:58:01 +02:00
|
|
|
Automount *a = AUTOMOUNT(u);
|
|
|
|
|
|
|
|
assert(a);
|
|
|
|
|
2010-08-31 00:17:56 +02:00
|
|
|
if (a->state == AUTOMOUNT_FAILED)
|
2010-07-18 04:58:01 +02:00
|
|
|
automount_set_state(a, AUTOMOUNT_DEAD);
|
|
|
|
|
2012-02-03 03:27:25 +01:00
|
|
|
a->result = AUTOMOUNT_SUCCESS;
|
2010-07-18 04:58:01 +02:00
|
|
|
}
|
|
|
|
|
2015-04-30 01:29:00 +02:00
|
|
|
static bool automount_supported(void) {
|
2014-12-12 21:05:32 +01:00
|
|
|
static int supported = -1;
|
|
|
|
|
|
|
|
if (supported < 0)
|
|
|
|
supported = access("/dev/autofs", F_OK) >= 0;
|
|
|
|
|
|
|
|
return supported;
|
|
|
|
}
|
|
|
|
|
2012-02-03 03:27:25 +01:00
|
|
|
static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = {
|
|
|
|
[AUTOMOUNT_SUCCESS] = "success",
|
core: move enforcement of the start limit into per-unit-type code again
Let's move the enforcement of the per-unit start limit from unit.c into the
type-specific files again. For unit types that know a concept of "result" codes
this allows us to hook up the start limit condition to it with an explicit
result code. Also, this makes sure that the state checks in clal like
service_start() may be done before the start limit is checked, as the start
limit really should be checked last, right before everything has been verified
to be in order.
The generic start limit logic is left in unit.c, but the invocation of it is
moved into the per-type files, in the various xyz_start() functions, so that
they may place the check at the right location.
Note that this change drops the enforcement entirely from device, slice, target
and scope units, since these unit types generally may not fail activation, or
may only be activated a single time. This is also documented now.
Note that restores the "start-limit-hit" result code that existed before
6bf0f408e4833152197fb38fb10a9989c89f3a59 already in the service code. However,
it's not introduced for all units that have a result code concept.
Fixes #3166.
2016-05-02 13:01:26 +02:00
|
|
|
[AUTOMOUNT_FAILURE_RESOURCES] = "resources",
|
|
|
|
[AUTOMOUNT_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
|
2016-05-02 16:51:45 +02:00
|
|
|
[AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT] = "mount-start-limit-hit",
|
2012-02-03 03:27:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_STRING_TABLE_LOOKUP(automount_result, AutomountResult);
|
|
|
|
|
2010-01-26 21:39:06 +01:00
|
|
|
const UnitVTable automount_vtable = {
|
2012-01-15 10:53:49 +01:00
|
|
|
.object_size = sizeof(Automount),
|
2013-11-19 21:12:59 +01:00
|
|
|
|
2011-08-01 00:43:05 +02:00
|
|
|
.sections =
|
|
|
|
"Unit\0"
|
|
|
|
"Automount\0"
|
|
|
|
"Install\0",
|
2020-07-03 11:13:08 +02:00
|
|
|
.private_section = "Automount",
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2020-01-07 11:48:57 +01:00
|
|
|
.can_transient = true,
|
|
|
|
.can_fail = true,
|
|
|
|
.can_trigger = true,
|
|
|
|
|
2010-01-26 04:18:44 +01:00
|
|
|
.init = automount_init,
|
2010-04-10 17:53:17 +02:00
|
|
|
.load = automount_load,
|
2010-01-26 04:18:44 +01:00
|
|
|
.done = automount_done,
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2010-04-21 03:27:44 +02:00
|
|
|
.coldplug = automount_coldplug,
|
|
|
|
|
2010-01-26 04:18:44 +01:00
|
|
|
.dump = automount_dump,
|
2010-01-23 01:52:57 +01:00
|
|
|
|
2010-04-16 23:24:39 +02:00
|
|
|
.start = automount_start,
|
|
|
|
.stop = automount_stop,
|
|
|
|
|
2010-04-21 03:27:44 +02:00
|
|
|
.serialize = automount_serialize,
|
|
|
|
.deserialize_item = automount_deserialize_item,
|
|
|
|
|
2010-04-13 20:59:01 +02:00
|
|
|
.active_state = automount_active_state,
|
2010-04-16 23:24:39 +02:00
|
|
|
.sub_state_to_string = automount_sub_state_to_string,
|
|
|
|
|
2018-02-13 10:50:13 +01:00
|
|
|
.may_gc = automount_may_gc,
|
2010-04-21 06:01:13 +02:00
|
|
|
|
2016-05-02 16:51:45 +02:00
|
|
|
.trigger_notify = automount_trigger_notify,
|
|
|
|
|
2010-08-31 00:17:56 +02:00
|
|
|
.reset_failed = automount_reset_failed,
|
2010-07-18 04:58:01 +02:00
|
|
|
|
2015-12-09 15:46:46 +01:00
|
|
|
.bus_set_property = bus_automount_set_property,
|
|
|
|
|
2012-05-13 18:18:54 +02:00
|
|
|
.shutdown = automount_shutdown,
|
2014-12-12 21:05:32 +01:00
|
|
|
.supported = automount_supported,
|
2012-05-13 18:18:54 +02:00
|
|
|
|
|
|
|
.status_message_formats = {
|
|
|
|
.finished_start_job = {
|
|
|
|
[JOB_DONE] = "Set up automount %s.",
|
|
|
|
[JOB_FAILED] = "Failed to set up automount %s.",
|
|
|
|
},
|
|
|
|
.finished_stop_job = {
|
|
|
|
[JOB_DONE] = "Unset automount %s.",
|
|
|
|
[JOB_FAILED] = "Failed to unset automount %s.",
|
|
|
|
},
|
|
|
|
},
|
2010-01-23 01:52:57 +01:00
|
|
|
};
|