diff --git a/include/BCache_Info.h b/include/BCache_Info.h
new file mode 100644
index 00000000..5265a547
--- /dev/null
+++ b/include/BCache_Info.h
@@ -0,0 +1,44 @@
+/* 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 .
+ */
+
+
+/* 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
+
+
+namespace GParted
+{
+
+
+class BCache_Info
+{
+public:
+ static bool is_active(const Glib::ustring& device_path, const Glib::ustring& partition_path);
+};
+
+
+} //GParted
+
+#endif /* GPARTED_BCACHE_INFO_H */
diff --git a/include/Makefile.am b/include/Makefile.am
index 423e2f7f..4a2d0dfc 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,6 +1,7 @@
gparted_includedir = $(pkgincludedir)
EXTRA_DIST = \
+ BCache_Info.h \
BlockSpecial.h \
CopyBlocks.h \
DMRaid.h \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d2392c25..c6fe9a1b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ gparted.appdata.xml.in
gparted.desktop.in.in
org.gnome.gparted.policy.in.in
include/Utils.h
+src/BCache_Info.cc
src/BlockSpecial.cc
src/CopyBlocks.cc
src/DialogPasswordEntry.cc
diff --git a/src/BCache_Info.cc b/src/BCache_Info.cc
new file mode 100644
index 00000000..ff9bd105
--- /dev/null
+++ b/src/BCache_Info.cc
@@ -0,0 +1,51 @@
+/* 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 .
+ */
+
+
+#include "BCache_Info.h"
+
+#include
+#include
+
+
+namespace GParted
+{
+
+
+// Return true if this device or partition contains an active bcache component, false
+// otherwise. Equivalent to does the directory /sys/block/DEV[/PTN]/bcache exist?
+bool BCache_Info::is_active(const Glib::ustring& device_path, const Glib::ustring& partition_path)
+{
+ Glib::ustring bcache_path;
+ Glib::ustring dev_name = device_path.substr(5); // Remove leading "/dev/".
+
+ if (device_path == partition_path)
+ {
+ // Whole drive
+ bcache_path = "/sys/block/" + dev_name + "/bcache";
+ }
+ else
+ {
+ // Partition on drive
+ Glib::ustring ptn_name = partition_path.substr(5); // Remove leading "/dev/".
+ bcache_path = "/sys/block/" + dev_name + "/" + ptn_name + "/bcache";
+ }
+
+ return file_test(bcache_path, Glib::FILE_TEST_IS_DIR);
+}
+
+
+} //GParted
diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc
index 0cbb5390..b98ef102 100644
--- a/src/Dialog_Partition_Info.cc
+++ b/src/Dialog_Partition_Info.cc
@@ -340,7 +340,8 @@ void Dialog_Partition_Info::Display_Info()
else if (filesystem_ptn.fstype == FS_LINUX_SWAP ||
filesystem_ptn.fstype == FS_LINUX_SWRAID ||
filesystem_ptn.fstype == FS_ATARAID ||
- filesystem_ptn.fstype == FS_LVM2_PV )
+ filesystem_ptn.fstype == FS_LVM2_PV ||
+ filesystem_ptn.fstype == FS_BCACHE )
{
/* TO TRANSLATORS: Active
* means that this linux swap, linux software raid partition, or
@@ -374,7 +375,8 @@ void Dialog_Partition_Info::Display_Info()
}
else if (filesystem_ptn.fstype == FS_LINUX_SWAP ||
filesystem_ptn.fstype == FS_LINUX_SWRAID ||
- filesystem_ptn.fstype == FS_ATARAID )
+ filesystem_ptn.fstype == FS_ATARAID ||
+ filesystem_ptn.fstype == FS_BCACHE )
{
/* TO TRANSLATORS: Not active
* means that this linux swap or linux software raid partition
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index c881f062..7dae661d 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -15,9 +15,11 @@
* along with this program; if not, see .
*/
+
#include "GParted_Core.h"
-#include "CopyBlocks.h"
+#include "BCache_Info.h"
#include "BlockSpecial.h"
+#include "CopyBlocks.h"
#include "Device.h"
#include "DMRaid.h"
#include "FileSystem.h"
@@ -1595,6 +1597,7 @@ bool GParted_Core::is_busy(const Glib::ustring& device_path, FSType fstype, cons
busy |= (fstype == FS_LINUX_SWRAID && SWRaid_Info::is_member_active(partition_path));
busy |= (fstype == FS_ATARAID && (SWRaid_Info::is_member_active(partition_path) ||
dmraid.is_member_active(partition_path) ));
+ busy |= (fstype == FS_BCACHE && BCache_Info::is_active(device_path, partition_path));
}
return busy ;
diff --git a/src/Makefile.am b/src/Makefile.am
index 1234a4a4..cb359e89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ AM_CXXFLAGS = -Wall
libexec_PROGRAMS = gpartedbin
gpartedbin_SOURCES = \
+ BCache_Info.cc \
BlockSpecial.cc \
CopyBlocks.cc \
DMRaid.cc \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bbd0ba8e..931c1aef 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,6 +24,7 @@ test_dummy_SOURCES = test_dummy.cc
test_SupportedFileSystems_SOURCES = test_SupportedFileSystems.cc
test_SupportedFileSystems_LDADD = \
+ $(top_builddir)/src/BCache_Info.$(OBJEXT) \
$(top_builddir)/src/BlockSpecial.$(OBJEXT) \
$(top_builddir)/src/CopyBlocks.$(OBJEXT) \
$(top_builddir)/src/DMRaid.$(OBJEXT) \