diff --git a/btrbk b/btrbk index 3eb9001..dbae4b3 100755 --- a/btrbk +++ b/btrbk @@ -1760,6 +1760,53 @@ sub btrfs_send_to_file($$$;$$) } +sub system_list_mountinfo($) +{ + my $vol = shift // die; + my $file = '/proc/self/mountinfo'; + my $ret = run_cmd(cmd => [ qw(cat), $file ], + rsh => vinfo_rsh($vol), + non_destructive => 1, + catch_stderr => 1, # hack for shell-based run_cmd() + ); + return undef unless(defined($ret)); + + my @mountinfo; + foreach (split(/\n/, $ret)) + { + # https://www.kernel.org/doc/Documentation/filesystems/proc.txt + unless(/^(?[0-9]+) # mount ID: unique identifier of the mount (may be reused after umount) + \s(?[0-9]+) # parent ID: ID of parent (or of self for the top of the mount tree) + \s(?[0-9]+:[0-9]+) # major:minor: value of st_dev for files on filesystem + \s(?\S+) # root: root of the mount within the filesystem + \s(?\S+) # mount point: mount point relative to the process's root + \s(?\S+) # mount options: per mount options + (\s\S+)* # optional fields: zero or more fields of the form "tag[:value]" + \s- # separator: marks the end of the optional fields + \s(?\S+) # filesystem type: name of filesystem of the form "type[.subtype]" + \s(?\S+) # mount source: filesystem specific information or "none" + \s(?\S+)$ # super options: per super block options + /x) + { + ERROR "Failed to parse \"$file\" on " . ($vol->{HOST} || "localhost"); + DEBUG "Offending line: $_"; + return undef; + } + my %line = %+; + foreach (split(',', $line{super_options})) { + if(/^(.+?)=(.+)$/) { + $line{MNTOPS}->{$1} = $2; + } else { + $line{MNTOPS}->{$_} = 1; + } + } + push @mountinfo, \%line; + } + # TRACE(Data::Dumper->Dump([\@mountinfo], ["mountinfo"])) if($do_dumper); + return \@mountinfo; +} + + sub system_list_mounts($) { my $vol = shift // die;