mirror of https://github.com/digint/btrbk
btrbk: fix mountinfo parsing (octal encoded chars)
Making sure this is done after splitting, as encoded value could be a comma. After some testing it shows that the kernel [1] produces ambigous output in "super options" if a subvolume containing a comma is mounted using "-o subvolid=" (tried hard to mount with "-o subvol=", seems not possible via shell): # btrfs sub create /tmp/btrbk_unittest/mnt_source/svol\,comma # mount /dev/loop0 -o subvolid=282 '/tmp/btrbk_unittest/mount,comma' # cat /proc/self/mountinfo [...] 48 40 0:319 /svol,comma /tmp/btrbk_unittest/mount,comma rw,relatime - btrfs /dev/loop0 rw,ssd,noacl,space_cache,subvolid=282,subvol=/svol,comma ^^^^^^^^^^^^^^^^^^ [1] sys-kernel/gentoo-sources-5.10.45pull/409/head
parent
eac9ef9828
commit
6c13a64459
17
btrbk
17
btrbk
|
@ -1975,15 +1975,24 @@ sub system_list_mountinfo($)
|
|||
return undef;
|
||||
}
|
||||
my %line = %+;
|
||||
|
||||
# merge super_options and mount_options to MNTOPS.
|
||||
foreach (split(',', $line{super_options}), split(',', $line{mount_options})) {
|
||||
my %mntops;
|
||||
foreach (split(',', delete($line{super_options})),
|
||||
split(',', delete($line{mount_options})))
|
||||
{
|
||||
if(/^(.+?)=(.+)$/) {
|
||||
$line{MNTOPS}->{$1} = $2;
|
||||
$mntops{$1} = $2;
|
||||
} else {
|
||||
$line{MNTOPS}->{$_} = 1;
|
||||
$mntops{$_} = 1;
|
||||
}
|
||||
}
|
||||
$line{MNTOPS}->{rw} = 0 if($line{MNTOPS}->{ro}); # e.g. mount_options="ro", super_options="rw"
|
||||
$mntops{rw} = 0 if($mntops{ro}); # e.g. mount_options="ro", super_options="rw"
|
||||
|
||||
# decode values (octal, e.g. "\040" = whitespace)
|
||||
s/\\([0-7]{3})/chr(oct($1))/eg foreach(values %line, values %mntops);
|
||||
|
||||
$line{MNTOPS} = \%mntops;
|
||||
push @mountinfo, \%line;
|
||||
}
|
||||
# TRACE(Data::Dumper->Dump([\@mountinfo], ["mountinfo"])) if($do_trace && $do_dumper);
|
||||
|
|
Loading…
Reference in New Issue