Skip to content

Commit 8b368c6

Browse files
committed
ccon: Only create target files for non-dir bind mounts
For example, if you're mounting /dev/sda1 (a block device, so not a directory), you'll still want a target directory.
1 parent 161fa7a commit 8b368c6

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,10 @@ interpreted as paths relative to ccon's [current working
352352
directory][getcwd.3].
353353

354354
If **`target`** does not exist, ccon will attempt to create it by
355-
calling [`mkdir`][mkdir.3p], making multiple calls if necessary. If
356-
**`source`** is set to a non-directory and **`target`** does not exit,
357-
ccon will create an empty file at **`target`** to mount over.
355+
calling [`mkdir`][mkdir.3p], making multiple calls if necessary. For
356+
bind mounts where **`source`** is set to a non-directory and
357+
**`target`** does not exit, ccon will create an empty file at
358+
**`target`** to mount over.
358359

359360
In addition to the usual types supported by [`mount`][mount.2], ccon
360361
supports a `pivot-root` **`type`** that invokes the

ccon.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2386,7 +2386,9 @@ static int handle_mounts(json_t * config)
23862386
PERROR("stat");
23872387
return 1;
23882388
}
2389-
mkdir = S_ISDIR(buf.st_mode);
2389+
if (flags | MS_BIND && !S_ISDIR(buf.st_mode)) {
2390+
mkdir = 0;
2391+
}
23902392
}
23912393
if (mkdir) {
23922394
if (mkdir_all(target, 0777) == -1) {

0 commit comments

Comments
 (0)