From: FabF <fabian.frederick@skynet.be>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH 2.6.7-mm1] MBR centralization
Date: Wed, 23 Jun 2004 23:15:49 +0200 [thread overview]
Message-ID: <1088025348.2213.32.camel@localhost.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 538 bytes --]
Andrew,
Here's a patch for partition management:
-Centralize msdos mbr detection.(magic detection was made twice : in
efi and msdos)
-mbr definition moved from efi to genhd
-msdos partition code mbr magics removed to use the one above
-adding genhd explicit macro used by both
-DOS_EXTENDED_PARTITION washing#2
(we don't want magic numbers, do we ?)
-Remove use of <= 4 to < DOS_EXTENDED_PARTITION where needed
-Trivial doc (so trivial indeed).
-Some code washing
PS: It runs under !EFI (for the least)
Regards,
FabF
[-- Attachment #2: partitions2.diff --]
[-- Type: text/x-patch, Size: 4423 bytes --]
diff -Naur orig/fs/partitions/efi.c edited/fs/partitions/efi.c
--- orig/fs/partitions/efi.c 2004-06-16 07:19:23.000000000 +0200
+++ edited/fs/partitions/efi.c 2004-06-24 01:43:45.000000000 +0200
@@ -145,7 +145,7 @@
int i, found = 0, signature = 0;
if (!mbr)
return 0;
- signature = (le16_to_cpu(mbr->signature) == MSDOS_MBR_SIGNATURE);
+ signature = MSDOS_MBR(&mbr->signature);
for (i = 0; signature && i < 4; i++) {
if (mbr->partition_record[i].sys_ind ==
EFI_PMBR_OSTYPE_EFI_GPT) {
diff -Naur orig/fs/partitions/efi.h edited/fs/partitions/efi.h
--- orig/fs/partitions/efi.h 2004-06-16 07:19:43.000000000 +0200
+++ edited/fs/partitions/efi.h 2004-06-24 01:20:46.000000000 +0200
@@ -34,7 +34,6 @@
#include <linux/string.h>
#include <linux/efi.h>
-#define MSDOS_MBR_SIGNATURE 0xaa55
#define EFI_PMBR_OSTYPE_EFI 0xEF
#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
diff -Naur orig/fs/partitions/msdos.c edited/fs/partitions/msdos.c
--- orig/fs/partitions/msdos.c 2004-06-16 07:19:37.000000000 +0200
+++ edited/fs/partitions/msdos.c 2004-06-23 22:36:46.496786675 +0200
@@ -50,15 +50,6 @@
SYS_IND(p) == LINUX_EXTENDED_PARTITION);
}
-#define MSDOS_LABEL_MAGIC1 0x55
-#define MSDOS_LABEL_MAGIC2 0xAA
-
-static inline int
-msdos_magic_present(unsigned char *p)
-{
- return (p[0] == MSDOS_LABEL_MAGIC1 && p[1] == MSDOS_LABEL_MAGIC2);
-}
-
/*
* Create devices for each logical partition in an extended partition.
* The logical partitions form a linked list, with each entry being
@@ -87,6 +78,7 @@
this_size = first_size;
while (1) {
+ /*FIXME : Some definition for 100*/
if (++loopct > 100)
return;
if (state->next == state->limit)
@@ -95,7 +87,7 @@
if (!data)
return;
- if (!msdos_magic_present(data + 510))
+ if (!MSDOS_MBR (data + 510))
goto done;
p = (struct partition *) (data + 0x1be);
@@ -112,7 +104,7 @@
/*
* First process the data partition(s)
*/
- for (i=0; i<4; i++, p++) {
+ for (i = 0; i < 4; i++, p++) {
u32 offs, size, next;
if (!NR_SECTS(p) || is_extended_partition(p))
continue;
@@ -146,7 +138,7 @@
* It should be a link to the next logical partition.
*/
p -= 4;
- for (i=0; i<4; i++, p++)
+ for (i = 0; i < 4; i++, p++)
if (NR_SECTS(p) && is_extended_partition(p))
break;
if (i == 4)
@@ -342,7 +334,7 @@
/* The first sector of a Minix partition can have either
* a secondary MBR describing its subpartitions, or
* the normal boot sector. */
- if (msdos_magic_present (data + 510) &&
+ if (MSDOS_MBR(data + 510) &&
SYS_IND(p) == MINIX_PARTITION) { /* subpartition table present */
printk(" %s%d: <minix:", state->name, origin);
@@ -385,7 +377,7 @@
data = read_dev_sector(bdev, 0, §);
if (!data)
return -1;
- if (!msdos_magic_present(data + 510)) {
+ if (!MSDOS_MBR(data + 510)) {
put_dev_sector(sect);
return 0;
}
@@ -397,16 +389,16 @@
* is not 0 or 0x80.
*/
p = (struct partition *) (data + 0x1be);
- for (slot = 1; slot <= 4; slot++, p++) {
+ for (slot = 1; slot < DOS_EXTENDED_PARTITION; slot++, p++) {
if (p->boot_ind != 0 && p->boot_ind != 0x80) {
put_dev_sector(sect);
return 0;
}
}
-
+ /*EFI : Extensible Firmware Initiative partitions ?*/
#ifdef CONFIG_EFI_PARTITION
p = (struct partition *) (data + 0x1be);
- for (slot = 1 ; slot <= 4 ; slot++, p++) {
+ for (slot = 1 ; slot < DOS_EXTENDED_PARTITION; slot++, p++) {
/* If this is an EFI GPT disk, msdos should ignore it. */
if (SYS_IND(p) == EFI_PMBR_OSTYPE_EFI_GPT) {
put_dev_sector(sect);
@@ -433,6 +425,7 @@
extended partition, but leave room for LILO */
put_partition(state, slot, start, size == 1 ? 1 : 2);
printk(" <");
+ /*parsing extended for logical partitions*/
parse_extended(state, bdev, start, size);
printk(" >");
continue;
diff -Naur orig/include/linux/genhd.h edited/include/linux/genhd.h
--- orig/include/linux/genhd.h 2004-06-16 07:18:59.000000000 +0200
+++ edited/include/linux/genhd.h 2004-06-24 02:00:09.000000000 +0200
@@ -17,6 +17,10 @@
#include <linux/string.h>
#include <linux/fs.h>
+/*Master boot record magic numbers*/
+#define MSDOS_MBR_SIGNATURE 0xaa55
+#define MSDOS_MBR(p) le16_to_cpu((u16)*p) == MSDOS_MBR_SIGNATURE
+
enum {
/* These three have identical behaviour; use the second one if DOS FDISK gets
confused about extended/logical partitions starting past cylinder 1023. */
next reply other threads:[~2004-06-23 20:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-23 21:15 FabF [this message]
2004-06-23 21:06 ` [PATCH 2.6.7-mm1] MBR centralization Andrew Morton
2004-06-23 22:04 ` FabF
2004-06-23 21:36 ` Andries Brouwer
2004-06-24 6:07 ` FabF
2004-06-24 12:57 ` Andries Brouwer
[not found] ` <Pine.LNX.4.60.0406240809280.29245@hermes-1.csi.cam.ac.uk>
[not found] ` <Pine.LNX.4.60.0406240829550.29245@hermes-1.csi.cam.ac.uk>
2004-06-24 13:06 ` Andries Brouwer
[not found] ` <1088152223.16286.9.camel@imp.csi.cam.ac.uk>
2004-06-25 9:39 ` Andries Brouwer
2004-06-24 15:10 ` FabF
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=1088025348.2213.32.camel@localhost.localdomain \
--to=fabian.frederick@skynet.be \
--cc=akpm@osdl.org \
--cc=linux-kernel@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 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.