From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Domsch Date: Tue, 06 Sep 2005 03:23:53 +0000 Subject: Re: Udev support for EDD Message-Id: <20050906032353.GB8320@lists.us.dell.com> List-Id: References: <3177C9E428AFD2468DC6CF7F7DA63E74304AA8@ausx3mps314.aus.amer.dell.com> In-Reply-To: <3177C9E428AFD2468DC6CF7F7DA63E74304AA8@ausx3mps314.aus.amer.dell.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org 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 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