Enable GParted to present bcache devices (#183)

Add pattern to recognise block cache devices as valid devices for
GParted to work with.  Devices are named by the Linux kernel device
driver like /dev/bcache0 [1] with partitions named like /dev/bcache0p1
[2].

Note bcache devices can be partitioned but all the documents I have seen
guide users to create file systems directly in a bcache device and not
partition it [3][4] (plus all other Internet search results I looked
at).  This might be because bcache is a specialist use case and the
bcache backing device can be a partition itself.

[1] linux 5.15 drivers/md/bcache/super.c bcache_device_init()
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/md/bcache/super.c?h=v5.15#n945
[2] Contents of /proc/partitions for a bcache partitioned backing device
    $ grep bcache /proc/partitions
     251        0  524280 bcache0
     251        1  523256 bcache0p1
[3] Linux kernel document: A block layer cache (bcache)
    https://www.kernel.org/doc/Documentation/bcache.txt
[4] The Linux kernel user's and administrator's guide > A block layer
    cache (bcache)
    https://www.kernel.org/doc/html/latest/admin-guide/bcache.html

Closes #183 - Basic support for bcache
This commit is contained in:
Mike Fleetwood 2022-01-06 17:12:58 +00:00 committed by Curtis Gedak
parent e5041954cf
commit 99d683221d
1 changed files with 5 additions and 0 deletions

View File

@ -155,6 +155,11 @@ bool Proc_Partitions_Info::is_whole_disk_device_name(const Glib::ustring& name)
if (Utils::regexp_label(name, "^([a-z]+/c[0-9]+d[0-9]+)$") != "")
return true;
// Match block layer cache (bcache) device names.
// E.g.: device = bcache0 (partition = bcache0p1)
if (Utils::regexp_label(name, "^(bcache[0-9]+)$") != "")
return true;
return false;
}