]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
prevent systemd-nspawn from trying to create target 2939/head
authorBjørnar Ness <bjornar.ness@gmail.com>
Fri, 1 Apr 2016 15:31:55 +0000 (17:31 +0200)
committerBjørnar Ness <bjornar.ness@gmail.com>
Fri, 1 Apr 2016 15:31:55 +0000 (17:31 +0200)
for bind-mounts when they already exist. This allows
bind-mounting over read-only files.

src/nspawn/nspawn-mount.c

index 64cb6b3ce3064bbb9ea3ea9918621057c038327b..8e2d2d543ce075507a4e89755963ef0966c91330 100644 (file)
@@ -438,21 +438,22 @@ static int mount_bind(const char *dest, CustomMount *m) {
                 r = mkdir_parents_label(where, 0755);
                 if (r < 0)
                         return log_error_errno(r, "Failed to make parents of %s: %m", where);
+
+                /* Create the mount point. Any non-directory file can be
+                * mounted on any non-directory file (regular, fifo, socket,
+                * char, block).
+                */
+                if (S_ISDIR(source_st.st_mode))
+                        r = mkdir_label(where, 0755);
+                else
+                        r = touch(where);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to create mount point %s: %m", where);
+
         } else {
                 return log_error_errno(errno, "Failed to stat %s: %m", where);
         }
 
-        /* Create the mount point. Any non-directory file can be
-         * mounted on any non-directory file (regular, fifo, socket,
-         * char, block).
-         */
-        if (S_ISDIR(source_st.st_mode))
-                r = mkdir_label(where, 0755);
-        else
-                r = touch(where);
-        if (r < 0 && r != -EEXIST)
-                return log_error_errno(r, "Failed to create mount point %s: %m", where);
-
         if (mount(m->source, where, NULL, mount_flags, mount_opts) < 0)
                 return log_error_errno(errno, "mount(%s) failed: %m", where);