only unmount device nodes and directories with --no-mtab in unshare mode

This commit is contained in:
Johannes 'josch' Schauer 2018-10-08 11:25:39 +02:00
parent 594a37d093
commit ac8084cb42
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -1115,11 +1115,19 @@ sub setup {
unlink "$options->{root}/$fname" or die "cannot unlink $fname: $!"; unlink "$options->{root}/$fname" or die "cannot unlink $fname: $!";
} elsif ($type == 3 or $type == 4) { # character/block special } elsif ($type == 3 or $type == 4) { # character/block special
if (!$options->{havemknod}) { if (!$options->{havemknod}) {
0 == system('umount', '--no-mtab', "$options->{root}/$fname") or die "umount failed: $?"; if ($options->{mode} eq 'unshare') {
0 == system('umount', '--no-mtab', "$options->{root}/$fname") or die "umount failed: $?";
} else {
0 == system('umount', "$options->{root}/$fname") or die "umount failed: $?";
}
unlink "$options->{root}/$fname"; unlink "$options->{root}/$fname";
} }
} elsif ($type == 5) { # directory } elsif ($type == 5) { # directory
0 == system('umount', '--no-mtab', "$options->{root}/$fname") or die "umount failed: $?"; if ($options->{mode} eq 'unshare') {
0 == system('umount', '--no-mtab', "$options->{root}/$fname") or die "umount failed: $?";
} else {
0 == system('umount', "$options->{root}/$fname") or die "umount failed: $?";
}
if (!$options->{havemknod}) { if (!$options->{havemknod}) {
rmdir "$options->{root}/$fname" or die "cannot rmdir $fname: $!"; rmdir "$options->{root}/$fname" or die "cannot rmdir $fname: $!";
} }