gparted/include/BCache_Info.h

50 lines
1.4 KiB
C
Raw Normal View History

/* Copyright (C) 2022 Mike Fleetwood
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/* BCache_Info
*
* Simple module to query very basic information about bcache devices
* (components). No caching is performed by this module.
*/
#ifndef GPARTED_BCACHE_INFO_H
#define GPARTED_BCACHE_INFO_H
#include <glibmm/ustring.h>
namespace GParted
{
class BCache_Info
{
public:
static bool is_active(const Glib::ustring& device_path, const Glib::ustring& partition_path);
Show bcache device as mount point of registered backing device (#183) A bcache device provides accelerated access to a backing device in a one to one relationship. Multiple bcache backing devices can be attached to and accelerated by the same cache device. Extending the setup from the previous commit, create an additional backing device and attach it to the same cache. # bcache make -B /dev/sdb2 # bcache attach /dev/sdc1 /dev/sdb2 # bcache show Name Type State Bname AttachToDev /dev/sdb2 1 (data) clean(running) bcache1 /dev/sdc1 /dev/sdb1 1 (data) clean(running) bcache0 /dev/sdc1 /dev/sdc1 3 (cache) active N/A N/A List a couple of bcache specific sysfs files which identify registered (active) bcache devices (components). # ls -l /sys/block/sd?/sd??/bcache/{dev,set} lrwxrwxrwx. 1 root root 0 Jan 7 10:08 /sys/block/sdb/sdb1/bcache/dev -> ../../../../../../../../../../virtual/block/bcache0 lrwxrwxrwx. 1 root root 0 Jan 7 11:53 /sys/block/sdb/sdb2/bcache/dev -> ../../../../../../../../../../virtual/block/bcache1 lrwxrwxrwx. 1 root root 0 Jan 7 11:53 /sys/block/sdc/sdc1/bcache/set -> ../../../../../../../../../../../fs/bcache/9945e165-0604-4f29-94bd-b155d01080ad As was done with previous software block devices [1][2][3][4] show the bcache (access) device as the mount point of a backing device (component). Use the /sys/block/DEV[/PTN]/bcache/dev sysfs symlinks to provide the bcache device names. Bcache cache devices (components) don't get mount points because they aren't accessible. [1] commit 8083f11d84dbd4f186271a3cdbf5170db259f8b8 Display LVM2 VGNAME as the PV's mount point (#160787) [2] commit f6c2f00df7858a7f4b97e699b9bcf1023bba850a Populate member mount point with SWRaid array device (#756829) [3] commit 538c866d099bc1f2bab3a41dc13a00b3d4336bbf Display array device as mount point of mdadm started ATARAID members (#75) [4] commit 538c866d099bc1f2bab3a41dc13a00b3d4336bbf Display array device as mount point of mdadm started ATARAID members (#75) Closes #183 - Basic support for bcache
2022-01-07 10:34:49 -07:00
static Glib::ustring get_bcache_device(const Glib::ustring& device_path, const Glib::ustring& partition_path);
private:
static Glib::ustring get_sysfs_bcache_path(const Glib::ustring& device_path,
const Glib::ustring& partition_path);
};
} //GParted
#endif /* GPARTED_BCACHE_INFO_H */