Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SSOMU-00065T-BU for mharc-grub-devel@gnu.org; Thu, 10 May 2012 04:04:34 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSOMM-00064h-Im for grub-devel@gnu.org; Thu, 10 May 2012 04:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSOMG-00021L-45 for grub-devel@gnu.org; Thu, 10 May 2012 04:04:26 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:41989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSOMF-0001yL-Qs for grub-devel@gnu.org; Thu, 10 May 2012 04:04:20 -0400 Received: by eekb47 with SMTP id b47so427914eek.0 for ; Thu, 10 May 2012 01:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; bh=1zuTrsO3nu7IGQmtE8kO11TppQ3yGSdnAeVe42K1ZoA=; b=vGunHB4p4LMU5PT6oYXD9nw1H0nuiKQjL+PRxDCE7iStv/Zj48EXXc2dtLCR0bD8FQ G08ytTTVuSyFrexxihLYQmD+wqncKc4Rf4e+mntIFQAfngXb+oMxwilRjmSqbycirZ/A rfqzwNZ0Hq1PK7cyVyH6euebHXMXGoSy3HWlfn2zJ900EkbwaI0PCogdU5kGUnF6fDPd s4vVAb6Ub9aIMTdoDkVCGXpmIpbvgMgAO9B3tLgjxGVu6UN/wZCWZzoDa5n97l6kLM/K ev7mWQJg47PMLoiiowBaLKF5eZvF3D3/o6t/oujh5gqPONs79UdhStVx27HhQqQSr24u 4ktg== Received: by 10.14.119.9 with SMTP id m9mr607062eeh.93.1336637057851; Thu, 10 May 2012 01:04:17 -0700 (PDT) Received: from debian.x201.phnet (109-232.197-178.cust.bluewin.ch. [178.197.232.109]) by mx.google.com with ESMTPS id f16sm25127276eec.2.2012.05.10.01.04.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 May 2012 01:04:17 -0700 (PDT) Message-ID: <4FAB767F.80700@gmail.com> Date: Thu, 10 May 2012 10:04:15 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120329 Icedove/10.0.3 MIME-Version: 1.0 To: The development of GRUB 2 , pfsmorigo@br.ibm.com Subject: [PATCH] PreP zero compare X-Enigmail-Version: 1.4.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig79D99F74DC093E9060BB90AC" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.83.41 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2012 08:04:32 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig79D99F74DC093E9060BB90AC Content-Type: multipart/mixed; boundary="------------010505060206080502030305" This is a multi-part message in MIME format. --------------010505060206080502030305 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Please test attached patch --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------010505060206080502030305 Content-Type: text/x-diff; name="prep.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="prep.diff" =3D=3D=3D 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 =20 - if [ "$(file -s "${install_device}" -b | awk '{ print $1 }')= " =3D ELF ] || [ $(cmp /dev/zero "${install_device}" &>/dev/null) ]; then= + if [ "$(file -s "${install_device}" -b | awk '{ print $1 }')= " =3D ELF ] || [ x$("${grub_probe}" -m "${device_map}" -d "${install_devi= ce}" -t zero_check) =3D xtrue ]; then # Change boot device to the harddisk root boot_device=3D"$ofpath" dd if=3D"${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/= core.${imgext}" of=3D"${install_device}" status=3Dnoxfer || { =3D=3D=3D 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 }; =20 @@ -392,6 +393,45 @@ probe (const char *path, char **device_n goto end; } =20 + if (print =3D=3D PRINT_ZERO_CHECK) + { + for (curdev =3D device_names; *curdev; curdev++) + { + grub_device_t dev =3D NULL; + grub_uint32_t buffer[32768]; + grub_disk_addr_t addr; + grub_disk_addr_t dsize; + + grub_util_info ("opening %s", *curdev); + dev =3D grub_device_open (*curdev); + if (! dev || !dev->disk) + grub_util_error ("%s", grub_errmsg); + + dsize =3D grub_disk_get_size (dev->disk); + for (addr =3D 0; addr < dsize; + addr +=3D sizeof (buffer) / GRUB_DISK_SECTOR_SIZE) + { + grub_size_t sz =3D sizeof (buffer); + grub_uint32_t *ptr; + + if (sizeof (buffer) / GRUB_DISK_SECTOR_SIZE < dsize - addr) + sz =3D (dsize - addr) * GRUB_DISK_SECTOR_SIZE; + grub_disk_read (dev->disk, addr, 0, sz, buffer); + + for (ptr =3D 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 =3D=3D PRINT_FS || print =3D=3D PRINT_FS_UUID || print =3D=3D PRINT_FS_LABEL) { @@ -770,6 +810,8 @@ argp_parser (int key, char *arg, struct print =3D PRINT_ARC_HINT; else if (!strcmp (arg, "compatibility_hint")) print =3D PRINT_COMPATIBILITY_HINT; + else if (strcmp (arg, "zero_check") =3D=3D 0) + print =3D PRINT_ZERO_CHECK; else if (!strcmp (arg, "disk")) print =3D PRINT_DISK; else --------------010505060206080502030305-- --------------enig79D99F74DC093E9060BB90AC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAk+rdn8ACgkQNak7dOguQgkHQQD/c104wiSDV6gmhggtveaAStPK wAEaz/+ftYsjABt6HRoA/18CHXgT9Lpa60OKopSQ3JxLHbdOu+N322gHaM6zZcgG =na1k -----END PGP SIGNATURE----- --------------enig79D99F74DC093E9060BB90AC--