From 10a91c849a80429d91dcfa94f358cbf9ffa5890a Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Mon, 4 May 2020 11:27:51 +0100 Subject: Remove redundant fallback to system mount/umount. udisks2 correctly handles devices listed in /etc/fstab. --- lib/Hal/Cdroms.pm | 56 +++---------------------------------------------------- 1 file 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 through HAL Return the mount point associated to the C, 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 through HAL or fallback to plain mount(8). -Return the mount point associated to the C, 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. 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 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. Return true on success (see $cdroms->{error} on failure) -- cgit v1.2.1