Skip to content

Commit

Permalink
Bind mounting does not allow to change options. We need to remount.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbernat committed Sep 6, 2011
1 parent 64822da commit dce746b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jchroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,12 @@ static int step2(void *arg) {
free(mntdata);
return EXIT_FAILURE;
}
if (mount(mntent->mnt_fsname, path, mntent->mnt_type,
mntflags, mntdata)) {
if ((mount(mntent->mnt_fsname, path, mntent->mnt_type,
mntflags & ~MS_REMOUNT, mntdata)) ||
/* With MS_BIND, we need to remount to enable some options like "ro" */
(((mntflags & MS_REMOUNT) || (mntflags & MS_BIND)) &&
(mount(mntent->mnt_fsname, path, mntent->mnt_type,
mntflags | MS_REMOUNT, mntdata)))) {
fprintf(stderr, "unable to mount '%s' on '%s': %m\n",
mntent->mnt_fsname, mntent->mnt_dir);
free(mntdata);
Expand Down

0 comments on commit dce746b

Please sign in to comment.