summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2020-12-19 22:40:47 +0100
committerLennart Poettering <lennart@poettering.net>2020-12-21 21:48:13 +0100
commit8bab8029105e44ce78c5e11bffa203a1135fe201 (patch)
tree4f59489231f4d0be6b3688836747f6dbed4a620c /src/core
parentudev: fix memleak (diff)
downloadsystemd-8bab8029105e44ce78c5e11bffa203a1135fe201.tar.xz
systemd-8bab8029105e44ce78c5e11bffa203a1135fe201.zip
basic: add make_mount_point_inode helper
Creates a file or a directory depending on the source path, useful for creating mount points.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/namespace.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 767439b7f6..e32336a7ff 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -1184,29 +1184,19 @@ static int apply_mount(
bool try_again = false;
if (r == -ENOENT && make) {
- struct stat st;
+ int q;
/* Hmm, either the source or the destination are missing. Let's see if we can create
the destination, then try again. */
- if (stat(what, &st) < 0)
- log_error_errno(errno, "Mount point source '%s' is not accessible: %m", what);
- else {
- int q;
+ (void) mkdir_parents(mount_entry_path(m), 0755);
- (void) mkdir_parents(mount_entry_path(m), 0755);
-
- if (S_ISDIR(st.st_mode))
- q = mkdir(mount_entry_path(m), 0755) < 0 ? -errno : 0;
- else
- q = touch(mount_entry_path(m));
-
- if (q < 0)
- log_error_errno(q, "Failed to create destination mount point node '%s': %m",
- mount_entry_path(m));
- else
- try_again = true;
- }
+ q = make_mount_point_inode_from_path(what, mount_entry_path(m), 0755);
+ if (q < 0)
+ log_error_errno(q, "Failed to create destination mount point node '%s': %m",
+ mount_entry_path(m));
+ else
+ try_again = true;
}
if (try_again)