summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-10-25 21:29:24 +0200
committerLennart Poettering <lennart@poettering.net>2017-11-10 19:45:29 +0100
commit40b1a32ca854b5ce29029d358c924e1b18f4a1d0 (patch)
treef0deb2c0a4a8eed4ec442df94890088cb018e1d5 /src
parenteef85c4a3f8054d29383a176f6cebd1ef3a15b9a (diff)
downloadsystemd-40b1a32ca854b5ce29029d358c924e1b18f4a1d0.tar.gz
device: rework device_is_bound_by_mounts() a bit
Let's log when we can't parse the udev property, and always use the most precise, correct types.
Diffstat (limited to 'src')
-rw-r--r--src/core/device.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/core/device.c b/src/core/device.c
index 63933baf85..ad101a4197 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -285,19 +285,24 @@ static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
}
}
-static bool device_is_bound_by_mounts(Unit *d, struct udev_device *dev) {
+static bool device_is_bound_by_mounts(Device *d, struct udev_device *dev) {
const char *bound_by;
- int r = false;
+ int r;
assert(d);
assert(dev);
bound_by = udev_device_get_property_value(dev, "SYSTEMD_MOUNT_DEVICE_BOUND");
- if (bound_by)
- r = parse_boolean(bound_by) > 0;
+ if (bound_by) {
+ r = parse_boolean(bound_by);
+ if (r < 0)
+ log_warning_errno(r, "Failed to parse SYSTEMD_MOUNT_DEVICE_BOUND='%s' udev property of %s, ignoring: %m", bound_by, strna(d->sysfs));
- DEVICE(d)->bind_mounts = r;
- return r;
+ d->bind_mounts = r > 0;
+ } else
+ d->bind_mounts = false;
+
+ return d->bind_mounts;
}
static int device_upgrade_mount_deps(Unit *u) {
@@ -386,7 +391,7 @@ static int device_setup_unit(Manager *m, struct udev_device *dev, const char *pa
/* So the user wants the mount units to be bound to the device but a mount unit might has been seen by systemd
* before the device appears on its radar. In this case the device unit is partially initialized and includes
* the deps on the mount unit but at that time the "bind mounts" flag wasn't not present. Fix this up now. */
- if (dev && device_is_bound_by_mounts(u, dev))
+ if (dev && device_is_bound_by_mounts(DEVICE(u), dev))
device_upgrade_mount_deps(u);
/* Note that this won't dispatch the load queue, the caller