Changeset 3742


Ignore:
Timestamp:
Nov 18, 2019, 12:02:21 PM (3 months ago)
Author:
Bruno Cornec
Message:

Fix non working mr-device-mounted

Location:
branches/3.3/MondoRescue
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/MondoRescue/bin/mr-device-mounted

    r3650 r3742  
    6262}
    6363
    64 my $txt = "";
    65 my $txt2 = "";
    6664my $ans = "";
    6765
    6866if (defined $ARGV[0]) {
    6967    foreach my $i (@ARGV) {
     68        my $txt = "";
     69        my $txt2 = "";
    7070        $ans = mr_device_mounted($i);
    7171        $txt = " not" if (not defined $ans);
  • branches/3.3/MondoRescue/lib/MondoRescue/Disk.pm

    r3553 r3742  
    105105my $device = shift;
    106106
    107 return(1) if ((not defined $device) || ($device =~ "^/sys|^/proc"));
     107return("") if ((not defined $device) || ($device =~ "^/sys|^/proc"));
    108108
     109# Beware of how hashes are handled in these functions
    109110my $h = mr_file_read_all_link($device);
    110111# Preserve that hash locally before earsing it to reuse another one
     
    114115    pb_log(2,"Working on device $f\n");
    115116    # TODO: get them from a conf file - FreeBSD needs swapinfo for swap request
    116     foreach my $dev ("mount","cat /proc/swaps") {
     117    foreach my $dev ("mount","grep -Ev '^Filename' /proc/swaps") {
    117118        # Look for the device in the command result
    118119        open(MOUNT,"$dev|") || die "Unable to execute the $dev command";
    119120        while (<MOUNT>) {
    120             my ($mntp,$void) = split('\s',$_,2);
     121            my ($mntp,$v1,$dir,$v3) = split('\s',$_,4);
    121122            $h = mr_file_read_all_link($mntp);
    122123            foreach my $m (keys %$h) {
     
    124125                if ($m eq $f) {
    125126                    # Find the mountpoint and return it
    126                     my ($void1,$mountpoint,$void2) = split('\s',$void);
    127                     pb_log(2,"*** Found $m on $mountpoint\n") if (defined $mountpoint);
    128                     return($mountpoint);
     127                    pb_log(2,"*** Found $m on $dir\n") if (defined $dir);
     128                    # Clean before returning
     129                    mr_file_erase_hash($h);
     130                    mr_file_erase_hash($h2);
     131                    return($dir);
    129132                }
    130133            }
    131             my $h3 = mr_file_copy_and_erase_hash($h);
     134            mr_file_erase_hash($h);
    132135        }
    133136        close(MOUNT);
  • branches/3.3/MondoRescue/lib/MondoRescue/File.pm

    r3447 r3742  
    2626
    2727our @ISA = qw(Exporter);
    28 our @EXPORT = qw(mr_file_read_all_link mr_file_process_ldd mr_file_normalize mr_file_copy_and_erase_hash);
     28our @EXPORT = qw(mr_file_read_all_link mr_file_process_ldd mr_file_normalize mr_file_erase_hash mr_file_copy_and_erase_hash);
    2929
    3030=pod
     
    8686
    8787=item B<mr_file_erase_hash>
     88
     89This function erases all elements in the hash passed in parameter (such as the one created in mr_file_read_all_link)
     90
     91=cut
     92
     93sub mr_file_erase_hash {
     94
     95my $files = shift;
     96
     97foreach my $i (keys %$files) {
     98    delete $files->{$i};
     99}
     100return();
     101}
     102
     103
     104=over 4
     105
     106=item B<mr_file_copy_and_erase_hash>
    88107
    89108This function erases all elements in the hash passed in parameter (such as the one created in mr_file_read_all_link)
Note: See TracChangeset for help on using the changeset viewer.