* [PATCH] PreP zero compare
@ 2012-05-10 8:04 Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; only message in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-05-10 8:04 UTC (permalink / raw)
To: The development of GRUB 2, pfsmorigo
[-- Attachment #1.1: Type: text/plain, Size: 86 bytes --]
Please test attached patch
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: prep.diff --]
[-- Type: text/x-diff; name="prep.diff", Size: 2655 bytes --]
=== modified file 'util/grub-install.in'
--- util/grub-install.in 2012-05-08 21:11:47 +0000
+++ util/grub-install.in 2012-05-10 08:01:38 +0000
@@ -776,7 +776,7 @@ elif [ "${grub_modinfo_target_cpu}-${gru
exit 1
fi
- if [ "$(file -s "${install_device}" -b | awk '{ print $1 }')" = ELF ] || [ $(cmp /dev/zero "${install_device}" &>/dev/null) ]; then
+ if [ "$(file -s "${install_device}" -b | awk '{ print $1 }')" = ELF ] || [ x$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t zero_check) = xtrue ]; then
# Change boot device to the harddisk root
boot_device="$ofpath"
dd if="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" of="${install_device}" status=noxfer || {
=== modified file 'util/grub-probe.c'
--- util/grub-probe.c 2012-02-26 16:28:05 +0000
+++ util/grub-probe.c 2012-05-10 08:00:23 +0000
@@ -67,6 +67,7 @@ enum {
PRINT_ARC_HINT,
PRINT_COMPATIBILITY_HINT,
PRINT_MSDOS_PARTTYPE,
+ PRINT_ZERO_CHECK,
PRINT_DISK
};
@@ -392,6 +393,45 @@ probe (const char *path, char **device_n
goto end;
}
+ if (print == PRINT_ZERO_CHECK)
+ {
+ for (curdev = device_names; *curdev; curdev++)
+ {
+ grub_device_t dev = NULL;
+ grub_uint32_t buffer[32768];
+ grub_disk_addr_t addr;
+ grub_disk_addr_t dsize;
+
+ grub_util_info ("opening %s", *curdev);
+ dev = grub_device_open (*curdev);
+ if (! dev || !dev->disk)
+ grub_util_error ("%s", grub_errmsg);
+
+ dsize = grub_disk_get_size (dev->disk);
+ for (addr = 0; addr < dsize;
+ addr += sizeof (buffer) / GRUB_DISK_SECTOR_SIZE)
+ {
+ grub_size_t sz = sizeof (buffer);
+ grub_uint32_t *ptr;
+
+ if (sizeof (buffer) / GRUB_DISK_SECTOR_SIZE < dsize - addr)
+ sz = (dsize - addr) * GRUB_DISK_SECTOR_SIZE;
+ grub_disk_read (dev->disk, addr, 0, sz, buffer);
+
+ for (ptr = buffer; ptr < buffer + sz / sizeof (*buffer); ptr++)
+ if (*ptr)
+ {
+ grub_printf ("false\n");
+ grub_device_close (dev);
+ goto end;
+ }
+ }
+
+ grub_device_close (dev);
+ }
+ grub_printf ("true\n");
+ }
+
if (print == PRINT_FS || print == PRINT_FS_UUID
|| print == PRINT_FS_LABEL)
{
@@ -770,6 +810,8 @@ argp_parser (int key, char *arg, struct
print = PRINT_ARC_HINT;
else if (!strcmp (arg, "compatibility_hint"))
print = PRINT_COMPATIBILITY_HINT;
+ else if (strcmp (arg, "zero_check") == 0)
+ print = PRINT_ZERO_CHECK;
else if (!strcmp (arg, "disk"))
print = PRINT_DISK;
else
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-05-10 8:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-10 8:04 [PATCH] PreP zero compare Vladimir 'φ-coder/phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.