This should make the error much clearer when partition exceeds 2 TiB on a PC
partition map (currently, all user gets is a "out of partition" error which
is hard to figure out if you're unaware of the 2 TiB limit).
Comments?
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
* include/grub/types.h (ULONG_MAX32): New macro.
(ULONG_MAX64): Likewise.
(ULONG_MAX): Use ULONG_MAX32 / ULONG_MAX64 to define it.
* util/misc.c (grub_util_warn): New function.
* util/biosdisk.c (grub_util_biosdisk_get_grub_dev): Issue a warning
when `disk->total_sectors' exceeds ULONG_MAX32 on `pc' partmap.
diff -ur grub2/include/grub/types.h grub2.bigdisk/include/grub/types.h
--- grub2/include/grub/types.h 2007-10-27 13:56:58.000000000 +0200
+++ grub2.bigdisk/include/grub/types.h 2007-11-05 16:07:57.000000000 +0100
@@ -92,10 +92,13 @@
typedef grub_int32_t grub_ssize_t;
#endif
+#define ULONG_MAX32 4294967295UL
+#define ULONG_MAX64 18446744073709551615UL
+
#if GRUB_CPU_SIZEOF_VOID_P == 8
-# define ULONG_MAX 18446744073709551615UL
+# define ULONG_MAX ULONG_MAX64
#else
-# define ULONG_MAX 4294967295UL
+# define ULONG_MAX ULONG_MAX32
#endif
/* The type for representing a file offset. */
diff -ur grub2/util/biosdisk.c grub2.bigdisk/util/biosdisk.c
--- grub2/util/biosdisk.c 2007-07-22 01:32:31.000000000 +0200
+++ grub2.bigdisk/util/biosdisk.c 2007-11-05 16:10:03.000000000 +0100
@@ -738,6 +738,9 @@
if (pcdata)
{
+ if (disk->total_sectors > ULONG_MAX32)
+ grub_util_warn ("Size of disk exceeds maximum permitted by partition map");
+
if (pcdata->bsd_part < 0)
grub_util_info ("DOS partition %d starts from %lu",
pcdata->dos_part, partition->start);
diff -ur grub2/util/misc.c grub2.bigdisk/util/misc.c
--- grub2/util/misc.c 2007-10-21 14:29:33.000000000 +0200
+++ grub2.bigdisk/util/misc.c 2007-11-05 16:06:37.000000000 +0100
@@ -58,6 +58,19 @@
}
void
+grub_util_warn (const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf (stderr, "%s: warning: ", progname);
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+ fputc ('\n', stderr);
+ fflush (stderr);
+}
+
+void
grub_util_error (const char *fmt, ...)
{
va_list ap;
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel