The attached patch adds the ability to fstype to detect lvm2 physical volumes (PV's). Signed-off-by: David H?rdeman <david@2gen.com> -------------- next part -------------- diff -Nur klibc-orig/usr/kinit/fstype/fstype.c klibc/usr/kinit/fstype/fstype.c --- klibc-orig/usr/kinit/fstype/fstype.c 2006-03-22 21:28:31.000000000 +0100 +++ klibc/usr/kinit/fstype/fstype.c 2006-03-23 00:54:57.000000000 +0100 @@ -7,7 +7,7 @@ * FSSIZE - filesystem size (if known) * * We currently detect (in order): - * gzip, cramfs, romfs, xfs, luks, minix, ext3, ext2, reiserfs, jfs, swap + * gzip, cramfs, romfs, xfs, luks, lvm2, minix, ext3, ext2, reiserfs, jfs, swap * * MINIX, ext3 and Reiserfs bits are currently untested. */ @@ -30,6 +30,7 @@ #include "ext3_fs.h" #include "xfs_sb.h" #include "luks_fs.h" +#include "lvm2_sb.h" /* * Slightly cleaned up version of jfs_superblock to @@ -202,6 +203,26 @@ return 0; } +static int lvm2_image(const void *buf, unsigned long long *blocks) +{ + const struct lvm2_super_block *lsb; + int i; + + /* We must check every 512 byte sector */ + for (i = 0; i < BLOCK_SIZE; i += 0x200) { + lsb = (const struct lvm2_super_block *)(buf + i); + + if (!memcmp(lsb->magic, LVM2_MAGIC, LVM2_MAGIC_L) && + !memcmp(lsb->type, LVM2_TYPE, LVM2_TYPE_L)) { + /* This is just one of possibly many PV's */ + *blocks = 0; + return 1; + } + } + + return 0; +} + struct imagetype { off_t block; const char name[12]; @@ -214,6 +235,8 @@ { 0, "romfs", romfs_image }, { 0, "xfs", xfs_image }, { 0, "luks", luks_image }, + { 0, "lvm2", lvm2_image }, + { 1, "lvm2", lvm2_image }, { 1, "minix", minix_image }, { 1, "ext3", ext3_image }, { 1, "ext2", ext2_image }, diff -Nur klibc-orig/usr/kinit/fstype/lvm2_sb.h klibc/usr/kinit/fstype/lvm2_sb.h --- klibc-orig/usr/kinit/fstype/lvm2_sb.h 1970-01-01 01:00:00.000000000 +0100 +++ klibc/usr/kinit/fstype/lvm2_sb.h 2006-03-23 00:46:21.000000000 +0100 @@ -0,0 +1,18 @@ +#ifndef __LVM2_SB_H +#define __LVM2_SB_H + +/* LVM2 super block definitions */ +#define LVM2_MAGIC_L 8 +#define LVM2_MAGIC "LABELONE" +#define LVM2_TYPE_L 8 +#define LVM2_TYPE "LVM2 001" + +struct lvm2_super_block { + char magic[LVM2_MAGIC_L]; + __be64 sector; + __be32 crc; + __be32 offset; + char type[LVM2_TYPE_L]; +}; + +#endif