Subject: | dev_to_mount_point does not deal with symbolic links and aliases for common device names |
dev_to_mount_point does not deal with symbolic links, as may occur with
some linux distributions that mount root by UUID. As observed on a
Ubuntu 9.10 installation, running the 2.6.31-20-generic kernel, if my
root filesystem is on /dev/sda3, but it was mounted during boot using
the /dev/disk/by-uuid/17120cd6-9df6-8825-0917-7a7f36b155a2 symbolic link
created by udev, trying to do something like:
dev_to_mount_point("/dev/sda3")
returns undef, whereas one would expect it to return "/". Using device
numbers to perform the comparison may fix the problem. Such a patch is
provided, however, it will likely not work on non-unix systems such as
Windows, so further work may be required for portability.
Subject: | Sys-Filesystem-MountPoint-fix-device.patch |
diff -r -c Sys-Filesystem-MountPoint-1.02/lib/Sys/Filesystem/MountPoint.pm Sys-Filesystem-MountPoint-mod/lib/Sys/Filesystem/MountPoint.pm
*** Sys-Filesystem-MountPoint-1.02/lib/Sys/Filesystem/MountPoint.pm 2009-01-27 22:15:22.000000000 -0500
--- Sys-Filesystem-MountPoint-mod/lib/Sys/Filesystem/MountPoint.pm 2010-04-12 02:11:33.919585163 -0400
***************
*** 54,60 ****
my $arg = $_[0] or confess("missing arg");
for my $mnt ( _f->filesystems ){
! (_f->device($mnt) eq $arg) and return $mnt;
}
$errstr="Can't find mount point for $arg";
return;
--- 54,63 ----
my $arg = $_[0] or confess("missing arg");
for my $mnt ( _f->filesystems ){
! my @arg_stat = stat $arg;
! my @fs_stat = stat _f->device($mnt);
!
! return $mnt if $fs_stat[6] == $arg_stat[6];
}
$errstr="Can't find mount point for $arg";
return;