linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Domsch <Matt_Domsch@Dell.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Udev support for EDD
Date: Tue, 06 Sep 2005 03:23:53 +0000	[thread overview]
Message-ID: <20050906032353.GB8320@lists.us.dell.com> (raw)
In-Reply-To: <3177C9E428AFD2468DC6CF7F7DA63E74304AA8@ausx3mps314.aus.amer.dell.com>

On Fri, Sep 02, 2005 at 02:57:33AM +0200, Kay Sievers wrote:
> I did a quick conversion to C. :) So we can use in in initramfs without
> all the tools needed by the shell script. Please have a look at it...

Thanks, this is a great start.

One missing item is the test of the last 2 bytes of the MBR for the 2
bytes (0xAA55 stored on disk as little endian) which indicates that
this is an MBR, so the 4-bytes it then reads and treats as the
signature field has the expected meaning.  Something like this
(untested) patch.

Signed-off-by: Matt Domsch <Matt_Domsch@dell.com>

Thanks,
Matt

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

--- edd_id.c.orig	2005-09-05 22:11:15.000000000 -0500
+++ edd_id.c	2005-09-05 22:19:00.000000000 -0500
@@ -57,6 +57,7 @@
 	int i;
 	int export = 0;
 	uint32_t disk_id;
+	uint16_t mbr_valid;
 	struct dirent *dent;
 	int disk_fd;
 	int sysfs_fd;
@@ -95,6 +96,24 @@
 		goto closedir;
 	}
 
+	if (lseek(disk_fd, 510, SEEK_SET) < 0) {
+		info("'%s' seek to MBR validity failed", node);
+		rc = 4;
+		goto close;
+	}
+
+	if (read(disk_fd, &mbr_valid, sizeof(mbr_valid)) != sizeof(mbr_valid)) {
+		info("'%s' read MBR validity failed", node);
+		rc = 5;
+		goto close;
+	}
+
+	if (mbr_valid != 0xAA55) {
+		info("'%s' this is not an MBR", node);
+		rc=5;
+		goto close;
+	}
+
 	if (lseek(disk_fd, 440, SEEK_SET) < 0) {
 		info("'%s' seek to signature failed", node);
 		rc = 4;


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

  parent reply	other threads:[~2005-09-06  3:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-01 20:15 Udev support for EDD John_Hull
2005-09-02  0:57 ` Kay Sievers
2005-09-02 15:13 ` John_Hull
2005-09-02 18:30 ` John_Hull
2005-09-06  3:10 ` Matt Domsch
2005-09-06  3:23 ` Matt Domsch [this message]
2005-09-06 10:24 ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050906032353.GB8320@lists.us.dell.com \
    --to=matt_domsch@dell.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).