chiark / gitweb /
core: Set source for mountinfo .mount units
[elogind.git] / src / core / mount.c
index 5d2b0100138727dbc2c995df935bdba057a90efb..e5f5e4272ea02dce6c60e37e9d8ca8c5783f3233 100644 (file)
@@ -717,9 +717,9 @@ static void mount_set_state(Mount *m, MountState state) {
                  state == MOUNT_UNMOUNTING_SIGTERM ||
                  state == MOUNT_UNMOUNTING_SIGKILL ||
                  state == MOUNT_FAILED) {
-               if (state != old_state)
-                       mount_notify_automount(m, -ENODEV);
-       }
+                if (state != old_state)
+                        mount_notify_automount(m, -ENODEV);
+        }
 
         if (state != old_state)
                 log_debug_unit(UNIT(m)->id,
@@ -955,11 +955,11 @@ fail:
 void warn_if_dir_nonempty(const char *unit, const char* where) {
         if (dir_is_empty(where) > 0)
                 return;
-        log_struct(LOG_NOTICE,
+        log_struct_unit(LOG_NOTICE,
+                   unit,
                    "MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.",
                    unit, where,
                    "WHERE=%s", where,
-                   "_SYSTEMD_UNIT=%s", unit,
                    MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
                    NULL);
 }
@@ -1472,7 +1472,7 @@ static int mount_add_one(
         int r;
         Unit *u;
         bool delete;
-        char *e, *w = NULL, *o = NULL, *f = NULL;
+        char *e, *w = NULL, *o = NULL, *s = NULL, *f = NULL;
         MountParameters *p;
         bool load_extras = false;
 
@@ -1545,6 +1545,7 @@ static int mount_add_one(
 
         if (!(w = strdup(what)) ||
             !(o = strdup(options)) ||
+            !(s = strdup("/proc/self/mountinfo")) ||
             !(f = strdup(fstype))) {
                 r = -ENOMEM;
                 goto fail;
@@ -1558,6 +1559,8 @@ static int mount_add_one(
         }
 
         MOUNT(u)->from_proc_self_mountinfo = true;
+        free(u->source_path);
+        u->source_path = s;
 
         free(p->what);
         p->what = w;
@@ -1583,6 +1586,7 @@ static int mount_add_one(
 fail:
         free(w);
         free(o);
+        free(s);
         free(f);
 
         if (delete && u)
@@ -1888,13 +1892,15 @@ DEFINE_STRING_TABLE_LOOKUP(mount_result, MountResult);
 
 const UnitVTable mount_vtable = {
         .object_size = sizeof(Mount),
-        .exec_context_offset = offsetof(Mount, exec_context),
 
         .sections =
                 "Unit\0"
                 "Mount\0"
                 "Install\0",
 
+        .exec_context_offset = offsetof(Mount, exec_context),
+        .exec_section = "Mount",
+
         .no_alias = true,
         .no_instances = true,