@@ -1029,6 +1029,34 @@ static int blockd_notify(char *device, struct mount *m, struct probe_info *pr)
return err;
}
+/**
+ * find_parent_device - find "parent" device for a given target path
+ *
+ * Some devices may have target path set to directory that is used as another
+ * device mount point. This function allows finding such devices so they can be
+ * mounted first.
+ */
+static struct probe_info *find_parent_device(struct probe_info *pr, const char *target)
+{
+ struct probe_info *e;
+
+ list_for_each_entry(e, &devices, list) {
+ struct mount *mp;
+
+ if (e == pr)
+ continue;
+
+ mp = find_block(e->uuid, e->label, basename(e->dev), NULL);
+ if (mp && mp->target) {
+ if (strlen(mp->target) < strlen(target) &&
+ !strncmp(mp->target, target, strlen(mp->target)))
+ return e;
+ }
+ }
+
+ return NULL;
+}
+
static int mount_device(struct probe_info *pr, int type)
{
struct mount *m;
@@ -1069,6 +1097,14 @@ static int mount_device(struct probe_info *pr, int type)
return err;
}
+ /* Check if there is device for parent dir */
+ if (m && m->target) {
+ struct probe_info *parent = find_parent_device(pr, m->target);
+
+ if (parent)
+ ULOG_WARN("Device %s should be mounted first!\n", parent->dev);
+ }
+
if (type == TYPE_HOTPLUG)
blockd_notify(device, m, pr);