Re: EDD disksigs for disks other than 0x80

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 25, 2004 at 12:00:22PM -0400, Jeremy Katz wrote:
> Well, for anaconda to do it the best thing is actually to get parted
> doing so.

Patch below against parted-1.6.11 sets the mbr_signature if it is
already zero, any time msdos_write() gets called.  The value set is
the tv_usec field of the current time, of which three bytes are
quasi-unique, but the fourth (most significant byte) is always zero
for me.

The boot code struct is reduced by 6 bytes, but the code ever written
to it by parted is only like 50 bytes, and the EFI spec says that the
boot_code portion should only be 440 bytes anyhow.

Thoughts?

Thanks,
Matt

-- 
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

diff -urNp --exclude-from=/home/mdomsch/excludes --minimal parted-1.6.11.orig/libparted/disk_dos.c parted-1.6.11/libparted/disk_dos.c
--- parted-1.6.11.orig/libparted/disk_dos.c	Tue Mar  9 04:17:08 2004
+++ parted-1.6.11/libparted/disk_dos.c	Fri Jun 25 17:20:32 2004
@@ -19,6 +19,7 @@
 
 #include "config.h"
 
+#include <sys/time.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
 #include <parted/endian.h>
@@ -107,7 +108,9 @@ struct _DosRawPartition {
 } __attribute__((packed));
 
 struct _DosRawTable {
-	char			boot_code [446];
+	char			boot_code [440];
+	uint32_t                mbr_signature;
+	uint16_t                Unknown;
 	DosRawPartition		partitions [4];
 	uint16_t			magic;
 } __attribute__((packed));
@@ -769,6 +772,16 @@ write_extended_partitions (PedDisk* disk
 		return write_empty_table (disk, ext_part->geom.start);
 }
 
+static inline uint32_t set_mbr_signature(void)
+{
+	struct timeval tv;
+	int rc;
+	rc = gettimeofday(&tv, NULL);
+	if (rc == -1)
+		return 0;
+	return (uint32_t)(tv.tv_usec & 0xFFFFFFFFUL);
+}
+
 static int
 msdos_write (PedDisk* disk)
 {
@@ -786,6 +799,9 @@ msdos_write (PedDisk* disk)
 		memcpy (table.boot_code, MBR_BOOT_CODE,
 			sizeof (MBR_BOOT_CODE));
 	}
+
+	if (!table.mbr_signature)
+		table.mbr_signature = set_mbr_signature();
 
 	memset (table.partitions, 0, sizeof (DosRawPartition) * 4);
 	table.magic = PED_CPU_TO_LE16 (MSDOS_MAGIC);

Attachment: pgpPE95JssNz6.pgp
Description: PGP signature


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux