[gparted] Enable GParted to present bcache devices (#183)



commit 99d683221d3948753eda857312a704579cf58893
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu Jan 6 17:12:58 2022 +0000

    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

 src/Proc_Partitions_Info.cc | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/src/Proc_Partitions_Info.cc b/src/Proc_Partitions_Info.cc
index d194d943..74793c8c 100644
--- a/src/Proc_Partitions_Info.cc
+++ b/src/Proc_Partitions_Info.cc
@@ -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;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]