diff options
Diffstat (limited to 'lib/Hal/Cdroms.pm')
-rw-r--r-- | lib/Hal/Cdroms.pm | 56 |
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) |