From c9a6d055d51a0ebe83b845de0bf1498e28b54988 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Sat, 26 Feb 2011 17:02:19 +0100
Subject: [PATCH] If partition file is not present, use whole disk
In that case, we don't need to worry about cache coherence between whole
volume and partition anyway.
---
lib/device.c | 4 ++++
stage2/disk_io.c | 28 ++++++++++++++--------------
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/lib/device.c b/lib/device.c
index 45e4001..50540bc 100644
--- a/lib/device.c
+++ b/lib/device.c
@@ -1119,6 +1119,10 @@ write_to_partition (char **map, int drive, int partition,
fd = open (dev, O_RDWR);
if (fd < 0)
{
+ /* No partition file, pass thru and not worry about
+ * cache inconsistency. */
+ if (errno == ENOENT)
+ return -1;
errnum = ERR_NO_PART;
return 0;
}
diff --git a/stage2/disk_io.c b/stage2/disk_io.c
index 308b291..09a0b75 100644
--- a/stage2/disk_io.c
+++ b/stage2/disk_io.c
@@ -381,23 +381,23 @@ devwrite (int sector, int sector_count, char *buf)
embed a Stage 1.5 into a partition instead of a MBR, use system
calls directly instead of biosdisk, because of the bug in
Linux. *sigh* */
- return write_to_partition (device_map, current_drive, current_partition,
- sector, sector_count, buf);
+ int ret;
+ ret = write_to_partition (device_map, current_drive, current_partition,
+ sector, sector_count, buf);
+ if (ret != -1)
+ return ret;
}
- else
#endif /* GRUB_UTIL && __linux__ */
- {
- int i;
-
- for (i = 0; i < sector_count; i++)
- {
- if (! rawwrite (current_drive, part_start + sector + i,
- buf + (i << get_sector_bits(current_drive))))
- return 0;
+ int i;
- }
- return 1;
- }
+ for (i = 0; i < sector_count; i++)
+ {
+ if (! rawwrite (current_drive, part_start + sector + i,
+ buf + (i << get_sector_bits(current_drive))))
+ return 0;
+
+ }
+ return 1;
}
static int
--
1.7.1