Mount canonicalizes paths unless the -c option is used. This
is mostly fine but for device-mapper nodes (/dev/dm-*) it'll
fetch the /dev/mapper/* path and pass that to the mount
system call resulting in /proc/mounts showing the
/dev/mapper path. This is neither the one we provided (since
we use /dev/$vg/$lv), nor the one userspace tools will find
in /dev currently.
Since the dm-* paths are rather inconvenient to look at we
decided to keep mount's behavior and compensate by providing
the /dev/mapper symlinks for devices via the autodev hook.
}
return wantarray ? ($path, 0, undef) : $path;
} elsif ($format eq 'raw' || $format eq 'iso') {
+ # NOTE: 'mount' performs canonicalization without the '-c' switch, which for
+ # device-mapper devices is special-cased to use the /dev/mapper symlinks.
+ # Our autodev hook expects the /dev/dm-* device currently
+ # and will create the /dev/mapper symlink accordingly
+ ($path) = (Cwd::realpath($path) =~ /^(.*)$/s); # realpath() taints
my $domount = sub {
my ($path) = @_;
if ($mount_path) {
PVE::Tools::run_command(['mknod', '-m', '666', "$root/dev/$dev",
$type, $major, $minor]);
+
+ if ($dev =~ /^dm-\d+$/) {
+ File::Path::mkpath("$root/dev/mapper");
+ my $mapped_name = PVE::Tools::file_get_contents("/sys/block/$dev/dm/name");
+ chomp $mapped_name;
+ symlink("/dev/$dev", "$root/dev/mapper/$mapped_name");
+ }
}
close $fd;