Skip to content

Commit 9e5a453

Browse files
mount: Remove files in place of mount points
If a mount point is not a directory, systemd will remove() it and then mkdir_p() the full path. Signed-off-by: rajmohan r <rajmohan.r@kpit.com>
1 parent 606472d commit 9e5a453

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/core/mount.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ static int mount_set_mount_command(Mount *m, ExecCommand *c, const MountParamete
11081108

11091109
static void mount_enter_mounting(Mount *m) {
11101110
MountParameters *p;
1111+
DIR* dp;
11111112
bool source_is_dir = true;
11121113
int r;
11131114

@@ -1168,6 +1169,16 @@ static void mount_enter_mounting(Mount *m) {
11681169
m->control_command_id = MOUNT_EXEC_MOUNT;
11691170
m->control_command = m->exec_command + MOUNT_EXEC_MOUNT;
11701171

1172+
dp = opendir(m->where);
1173+
if (!dp) {
1174+
//this is not a directory but rather file or link
1175+
remove(m->where);
1176+
mkdir_p(m->where, m->directory_mode);
1177+
}
1178+
else {
1179+
closedir(dp);
1180+
}
1181+
11711182
/* Create the source directory for bind-mounts if needed */
11721183
if (p && mount_is_bind(p)) {
11731184
r = mkdir_p_label(p->what, m->directory_mode);

0 commit comments

Comments
 (0)