]> err.no Git - systemd/commitdiff
mount: automatically create non-existing mount point dirs prior to mounting
authorLennart Poettering <lennart@poettering.net>
Thu, 1 Jul 2010 22:28:44 +0000 (00:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Jul 2010 22:28:44 +0000 (00:28 +0200)
src/load-fragment.c
src/mount.c
src/mount.h

index ce468734a2329765accf879b758113046a8158d9..43a4027c32839560ea9850d70c4c141a928f9c49 100644 (file)
@@ -1562,6 +1562,7 @@ static int load_from_path(Unit *u, const char *path) {
                 { "Type",                   config_parse_string,          &u->mount.parameters_fragment.fstype,            "Mount"   },
                 { "TimeoutSec",             config_parse_usec,            &u->mount.timeout_usec,                          "Mount"   },
                 { "KillMode",               config_parse_kill_mode,       &u->mount.kill_mode,                             "Mount"   },
+                { "DirectoryMode",          config_parse_mode,            &u->mount.directory_mode,                        "Mount"   },
                 EXEC_CONTEXT_CONFIG_ITEMS(u->mount.exec_context, "Mount"),
 
                 { "Where",                  config_parse_path,            &u->automount.where,                             "Automount" },
index 86c5b0a8cf1b2e474f92d401b35db9ca28703a70..db8551e854b2902e6a28ccb2d1310ebdadc5f41f 100644 (file)
@@ -62,6 +62,8 @@ static void mount_init(Unit *u) {
         m->timeout_usec = DEFAULT_TIMEOUT_USEC;
         exec_context_init(&m->exec_context);
 
+        m->directory_mode = 0755;
+
         /* We need to make sure that /bin/mount is always called in
          * the same process group as us, so that the autofs kernel
          * side doesn't send us another mount request while we are
@@ -497,7 +499,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
                 "%sFrom /etc/fstab: %s\n"
                 "%sFrom /proc/self/mountinfo: %s\n"
                 "%sFrom fragment: %s\n"
-                "%sKillMode: %s\n",
+                "%sKillMode: %s\n"
+                "%sDirectoryMode: %04o\n",
                 prefix, mount_state_to_string(m->state),
                 prefix, m->where,
                 prefix, strna(p->what),
@@ -506,7 +509,8 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
                 prefix, yes_no(m->from_etc_fstab),
                 prefix, yes_no(m->from_proc_self_mountinfo),
                 prefix, yes_no(m->from_fragment),
-                prefix, kill_mode_to_string(m->kill_mode));
+                prefix, kill_mode_to_string(m->kill_mode),
+                prefix, m->directory_mode);
 
         if (m->control_pid > 0)
                 fprintf(f,
@@ -662,6 +666,8 @@ static void mount_enter_mounting(Mount *m) {
         m->control_command_id = MOUNT_EXEC_MOUNT;
         m->control_command = m->exec_command + MOUNT_EXEC_MOUNT;
 
+        mkdir_p(m->where, m->directory_mode);
+
         if (m->from_fragment)
                 r = exec_command_set(
                                 m->control_command,
index 30da1368ffedaba9d4735ed0c8cf12ee273510d3..4732902ef3c91b2a895d23eb67d20066d2db5e0d 100644 (file)
@@ -81,6 +81,8 @@ struct Mount {
 
         usec_t timeout_usec;
 
+        mode_t directory_mode;
+
         ExecCommand exec_command[_MOUNT_EXEC_COMMAND_MAX];
         ExecContext exec_context;