Skip to content

Commit 9dc3498

Browse files
committed
WSL: Disable read-only bind mount
When re-mounting a bind mount read-only WSL fails with EBUSY if there are any outstanding writable file-descriptors anywhere on the filesystem (even outside the bind-mount). This makes read-only bindmounts fail most of the time (for example in flatpak due to writable /var/tmp files). For now we just disable read-only.
1 parent e62e956 commit 9dc3498

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bind-mount.c

+5
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,11 @@ bind_mount (int proc_fd,
408408

409409
assert (path_equal (mount_tab[0].mountpoint, resolved_dest));
410410
current_flags = mount_tab[0].options;
411+
412+
/* WSL: Any writable fd open on the same fs that the bindmount is on will block the readonly
413+
bind mount with EBUSY, so we ignore it for now. */
414+
readonly = FALSE;
415+
411416
new_flags = current_flags | (devices ? 0 : MS_NODEV) | MS_NOSUID | (readonly ? MS_RDONLY : 0);
412417
if (new_flags != current_flags &&
413418
mount ("none", resolved_dest,

0 commit comments

Comments
 (0)