Skip to contentSkip to conversation

ident of whole-disk ext2 fs

PATCH In review Paul Gortmaker 3 participants 4 messages Dec 19, 2000 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ident of whole-disk ext2 fs

I always disliked the unknown partition table messages you get when you mke2fs a whole disk and don't bother with a table at all, so I fixed it. Output before/after shown below:

Partition check:
hda: hda1 hda2
- hdd: unknown partition table
+ hdd: whole disk EXT2-fs, revision 1.0, 1k blocks, status: clean.
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 32k freed

Note that I placed the check right before we give up and print the unknown message, so all the other identification schemes get their chance to prod at the disk first. Patch against 2.2.18 follows -- not necessarily advocating it for 2.2 - just happened to be what I patched... :)

Paul.

drivers/block/genhd.c renamed from drivers/block/genhd.c~ +37 -0
@@ -232,6 +232,39 @@
 	return ret;
 }
 
+/*
+ * Lots of people put ext2 fs directly onto a whole disk, without a 
+ * partition table.  Looks kind of silly if we call a disk with our
+ * own filesystem "unknown". - Paul G.
+ */
+
+#ifdef CONFIG_EXT2_FS
+#include <linux/ext2_fs.h>
+
+static int ext2_partition(struct gendisk *hd, unsigned int dev, unsigned long first_sector)
+{
+	struct buffer_head *bh;
+	struct ext2_super_block *es;
+
+	if (!(bh = bread(dev, 1, get_ptable_blocksize(dev)))) {
+		printk("unable to read block one.\n");
+		return -1;
+	}
+	es = (struct ext2_super_block *) bh->b_data;
+	if (le16_to_cpu(es->s_magic) != EXT2_SUPER_MAGIC) {
+		brelse(bh);
+		return 0;
+	}
+	printk(" whole disk EXT2-fs, revision %d.%d, %dk blocks, status: %sclean.\n",
+		le32_to_cpu(es->s_rev_level),
+		le16_to_cpu(es->s_minor_rev_level),
+		1<<le32_to_cpu(es->s_log_block_size),
+		le16_to_cpu(es->s_state) == EXT2_VALID_FS ? "" : "un");
+	brelse(bh);
+	return 1;
+}
+#endif
+
 #ifdef CONFIG_MSDOS_PARTITION
 /*
  * Create devices for each logical partition in an extended partition.
@@ -1608,6 +1641,10 @@
 #endif
 #ifdef CONFIG_ARCH_S390
 	if (ibm_partition (hd, dev, first_sector))
+		return;
+#endif
+#ifdef CONFIG_EXT2_FS
+	if (ext2_partition(hd, dev, first_sector))
 		return;
 #endif
 	printk(" unknown partition table\n");

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 8 lines · Paul Gortmaker

I always disliked the unknown partition table messages you get when you mke2fs a whole disk and don't bother with a table at all, so I fixed it. Output before/after shown below:

Partition check:
hda: hda1 hda2
- hdd: unknown partition table
+ hdd: whole disk EXT2-fs, revision 1.0, 1k blocks, status: clean.

A nice boot message.

But what if you just replace the "unknown partition table" by the more correct "no recognized partition table"?

Quoted 1 line

+static int ext2_partition(struct gendisk *hd, ...

I don't like the patch very much. It is too ad hoc. Why ext2? Not ext3? reiser? ufs?

At boot time, the kernel needs 6 pieces of information:
- the rootdevice
- the partitiontype of the rootdevice
- the rootpartition
- the filesystemtype of the root filesystem
- the remaining mount options for the root filesystem
- the first program to start

We can make the kernel guess, or we can specify.
The usual situation is that we specify rootdevice and rootpartition and mount options like ro/rw or nfsaddr and perhaps the init program, but make the kernel guess partitiontype and rootfstype.

It would be good to at least have the possibility to specify partitiontype and rootfstype. In the course of time several people have submitted patches adding a "rootfstype=" boot option. Today or so Tigran did this again - maybe Linus accepts it this time.

Remains the partitiontype. You remind us of the fact that a good partitiontype is "none". And then there are "dos", "bsd", "atari", ... And recursive ones: a dos-type partition further sliced up into bsd-type partitions, etc.
So, I can imagine two useful boot options here:
(i) "root_partition_type=", and
(ii) "do_not_parse_partition_tables"
(you may invent shorter forms if you prefer).
Since it is possible to parse partition tables from user space and tell the kernel which disk regions should be considered partitions, there is no need for the kernel to do this parsing, except for the rootdevice, just like there is no need for the kernel to do any mounting except for the root filesystem. (And one could have /etc/pttab as analogue of /etc/fstab.) The second option would tell the kernel to leave the disks alone, except for the rootdevice; the first option would tell the kernel what partition table type to expect there.

There is no hurry, but sooner or later it would be good to get rid of all partition table parsing in the kernel.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to Paul Gortmaker

Dnia Wto 19. Grudzie? 2000 18:45, Andries Brouwer napisa?:

Quoted 5 lines · Paul Gortmaker
Quoted 4 lines

I always disliked the unknown partition table messages you get when you mke2fs a whole disk and don't bother with a table at all, so I fixed it. Output before/after shown below:

Quoted 8 lines
Quoted 4 lines

Partition check:
hda: hda1 hda2
- hdd: unknown partition table
+ hdd: whole disk EXT2-fs, revision 1.0, 1k blocks, status: clean.

A nice boot message.

But what if you just replace the "unknown partition table"

What about the more correct.
hdd: no partition table

There is no presumed "unknown" partition table at all when we can't recognize it.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
In reply to Paul Gortmaker
Quoted 9 lines · Martin Dalecki

Dnia Wto 19. Grudzie? 2000 18:45, Andries Brouwer napisa?:

Quoted 2 lines

But what if you just replace the "unknown partition table" by "no recognized partition table"

What about the more correct.
hdd: no partition table

There is no presumed "unknown" partition table at all when we can't recognize it.

That is more confusing. The user tends to believe such messages and will start reformatting / fdisking etc, while in reality the problem may be that she forgot to enable CONFIG_OSF_PARTITION or so. (And there are also partition types, like AIX partition, that the kernel currently has no support for.)

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/