Skip to content

Commit

Permalink
init: separate 'mount --rbind -o rslave ...' into 'mount --rbind ...'…
Browse files Browse the repository at this point in the history
… and 'mount --make-rslave ...'

On some legacy distros like Ubuntu 18.04.6, the mount executable does not support '-o rslave'. So we use '--make-rslave' instead.
  • Loading branch information
timwa0669 committed Oct 10, 2024
1 parent c05b6a4 commit 2e669d8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,18 @@ mount_bind()
fi

# Add mountflags if needed, if no are specified, use rslave as default.
if [ "${mount_flags}" = "" ]; then
mount_flags="rslave"
fi
# bind mount source_dir to target_dir, return error if not successful
if ! mount --rbind -o "${mount_flags}" "${source_dir}" "${target_dir}"; then
printf "Warning: failed to bind mount %s to %s\n" "${source_dir}" "${target_dir}"
if [ "${mount_flags}" = "" ]; then
if ! mount --rbind "${source_dir}" "${target_dir}"; then
printf "Warning: failed to bind mount %s to %s\n" "${source_dir}" "${target_dir}"
return 1
fi
if ! mount --make-rslave "${target_dir}"; then
printf "Warning: failed to make rslave to %s\n" "${target_dir}"
return 1
fi
elif ! mount --rbind -o "${mount_flags}" "${source_dir}" "${target_dir}"; then
printf "Warning: failed to bind mount %s to %s using option %s\n" "${source_dir}" "${target_dir}" "${mount_flags}"
return 1
fi

Expand Down

0 comments on commit 2e669d8

Please sign in to comment.