[gnome-multi-writer/wip/hadess/more-random: 2/2] Fix gmw-probe only testing the first 15% of the disks
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-multi-writer/wip/hadess/more-random: 2/2] Fix gmw-probe only testing the first 15% of the disks
- Date: Mon, 18 Nov 2019 17:46:15 +0000 (UTC)
commit f2466c74f2b0f0506ba01d74e06c045f08662b79
Author: Bastien Nocera <hadess hadess net>
Date: Mon Nov 18 18:41:46 2019 +0100
Fix gmw-probe only testing the first 15% of the disks
The code was breaking up the disk in 256 chunks, to put about a block's
worth of data around those sections, but was only saving random data for
the 40 first ones.
Fix that by making the number of chunks a constant.
Fixes: 2768316
src/gmw-probe.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/gmw-probe.c b/src/gmw-probe.c
index 2571fba..2417443 100644
--- a/src/gmw-probe.c
+++ b/src/gmw-probe.c
@@ -66,6 +66,10 @@ static guint32 seed = 0;
#define GMW_ERROR_FAILED 0
#define GMW_ERROR_IS_FAKE 1
+/* The number of chunks of data to read and write to
+ * verify integrity */
+#define NUM_CHUNKS 256
+
static guint8 *
gmw_probe_get_random_data (guint len)
{
@@ -176,10 +180,10 @@ gmw_probe_device_data_save (GmwProbeDevice *dev,
GError **error)
{
/* aim for roughtly the same number of chunks for all device sizes */
- guint64 chunk_size = dev->disk_size / 256;
+ guint64 chunk_size = dev->disk_size / NUM_CHUNKS;
g_debug ("using chunk size of %" G_GUINT64_FORMAT "MB",
chunk_size / ONE_MB);
- for (guint i = 1; i < 40; i++) {
+ for (guint i = 1; i < NUM_CHUNKS; i++) {
GmwProbeBlock *item = g_new0 (GmwProbeBlock, 1);
item->valid = TRUE;
item->offset = g_random_int_range (1, 0xff);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]