aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2020-05-04 11:27:51 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2020-05-04 11:27:51 +0100
commit10a91c849a80429d91dcfa94f358cbf9ffa5890a (patch)
tree0a7fc377359215ee4259fd2f53a895728b0b7f01 /lib
parent987987df5f22469c01ce92bd172688f7b190a5eb (diff)
downloadperl-Hal-Cdroms-10a91c849a80429d91dcfa94f358cbf9ffa5890a.tar
perl-Hal-Cdroms-10a91c849a80429d91dcfa94f358cbf9ffa5890a.tar.gz
perl-Hal-Cdroms-10a91c849a80429d91dcfa94f358cbf9ffa5890a.tar.bz2
perl-Hal-Cdroms-10a91c849a80429d91dcfa94f358cbf9ffa5890a.tar.xz
perl-Hal-Cdroms-10a91c849a80429d91dcfa94f358cbf9ffa5890a.zip
Remove redundant fallback to system mount/umount.
udisks2 correctly handles devices listed in /etc/fstab.
Diffstat (limited to 'lib')
-rw-r--r--lib/Hal/Cdroms.pm56
1 files changed, 3 insertions, 53 deletions
diff --git a/lib/Hal/Cdroms.pm b/lib/Hal/Cdroms.pm
index 0d4b235..d8e6d8f 100644
--- a/lib/Hal/Cdroms.pm
+++ b/lib/Hal/Cdroms.pm
@@ -154,15 +154,14 @@ sub ensure_mounted {
}
-=head2 $cdroms->mount_through_hal($udisks_path)
+=head2 $cdroms->mount($udisks_path)
Mount the C<udisks_path> through HAL
Return the mount point associated to the C<udisks_path>, or undef it cannot be mounted successfully (see $cdroms->{error}).
-If the cdrom is listed in fstab, HAL will refuse to mount it.
=cut
-sub mount_hal {
+sub mount {
my ($o, $udisks_path) = @_;
my $device = _get_device($o, $udisks_path, "$dn.Filesystem");
@@ -172,68 +171,19 @@ sub mount_hal {
$mountpoint;
}
-=head2 $cdroms->mount($udisks_path)
-
-Mount the C<udisks_path> through HAL or fallback to plain mount(8).
-Return the mount point associated to the C<udisks_path>, or undef it cannot be mounted successfully (see $cdroms->{error})
-
-=cut
-
-sub mount {
- my ($o, $udisks_path) = @_;
-
- my $mntpoint = mount_hal($o, $udisks_path);
- if (!$mntpoint) {
- # this usually means HAL refused to mount a cdrom listed in fstab
- my $device = _get_device($o, $udisks_path);
- my $dev = _int_array_to_string(_get_property($device, 'Block', 'Device'));
- if (my $wanted = $dev && _rdev($dev)) {
- my ($fstab_dev) = grep { $wanted == _rdev($_) } _fstab_devices();
- system("mount", $fstab_dev) == 0
- and $mntpoint = get_mount_point($o, $udisks_path);
- }
- }
- $mntpoint;
-}
-
-sub _rdev {
- my ($dev) = @_;
- (stat($dev))[6];
-}
-sub _fstab_devices() {
- open(my $F, '<', '/etc/fstab') or return;
- map { /(\S+)/ } <$F>;
-}
-
=head2 $cdroms->unmount($udisks_path)
Unmount the C<udisks_path>. Return true on success (see $cdroms->{error} on failure)
-If the cdrom is listed in not mounted by HAL, HAL will refuse to unmount it.
=cut
-sub unmount_hal {
+sub unmount {
my ($o, $udisks_path) = @_;
my $device = _get_device($o, $udisks_path, "$dn.Filesystem");
_try($o, sub { $device->Unmount(undef) });
}
-=head2 $cdroms->unmount($udisks_path)
-
-Unmount the C<udisks_path> through HAL or fallback on umount(8).
-Return true on success (see $cdroms->{error} on failure)
-
-=cut
-
-sub unmount {
- my ($o, $udisks_path) = @_;
-
- unmount_hal($o, $udisks_path) and return 1;
-
- system('umount', get_mount_point($o, $udisks_path)) == 0;
-}
-
=head2 $cdroms->eject($udisks_path)
Ejects the C<udisks_path>. Return true on success (see $cdroms->{error} on failure)