Index: klibc/usr/kinit/fstype/fstype.c =================================================================== --- klibc.orig/usr/kinit/fstype/fstype.c 2006-02-05 10:53:51.000000000 +0100 +++ klibc/usr/kinit/fstype/fstype.c 2006-02-05 11:09:31.000000000 +0100 @@ -7,7 +7,7 @@ * FSSIZE - filesystem size (if known) * * We currently detect (in order): - * gzip, cramfs, romfs, xfs, minix, ext3, ext2, reiserfs, jfs + * gzip, cramfs, romfs, xfs, luks, minix, ext3, ext2, reiserfs, jfs * * MINIX, ext3 and Reiserfs bits are currently untested. */ @@ -29,6 +29,7 @@ #include "ext2_fs.h" #include "ext3_fs.h" #include "xfs_sb.h" +#include "luks_fs.h" /* * Slightly cleaned up version of jfs_superblock to @@ -168,6 +169,19 @@ return 0; } +static int luks_image(const unsigned char *buf, unsigned long long *blocks) +{ + const struct luks_partition_header *lph = + (const struct luks_partition_header *)buf; + + if (!memcmp(lph->magic, LUKS_MAGIC, LUKS_MAGIC_L)) { + /* FSSIZE is dictated by the underlying fs, not by LUKS */ + *blocks = 0; + return 1; + } + return 0; +} + struct imagetype { off_t block; const char name[12]; @@ -179,6 +193,7 @@ { 0, "cramfs", cramfs_image }, { 0, "romfs", romfs_image }, { 0, "xfs", xfs_image }, + { 0, "luks", luks_image }, { 1, "minix", minix_image }, { 1, "ext3", ext3_image }, { 1, "ext2", ext2_image }, Index: klibc/usr/kinit/fstype/luks_fs.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ klibc/usr/kinit/fstype/luks_fs.h 2006-02-05 10:57:52.000000000 +0100 @@ -0,0 +1,45 @@ +#ifndef __LINUX_LUKS_FS_H +#define __LINUX_LUKS_FS_H + +/* The basic structures of the luks partition header */ +#define LUKS_MAGIC_L 6 +#define LUKS_CIPHERNAME_L 32 +#define LUKS_CIPHERMODE_L 32 +#define LUKS_HASHSPEC_L 32 +#define LUKS_UUID_STRING_L 40 + +#define LUKS_MAGIC "LUKS\xBA\xBE" +#define LUKS_DIGESTSIZE 20 +#define LUKS_SALTSIZE 32 +#define LUKS_NUMKEYS 8 +#define LUKS_MKD_ITER 10 +#define LUKS_KEY_DISABLED 0x0000DEAD +#define LUKS_KEY_ENABLED 0x00AC71F3 +#define LUKS_STRIPES 4000 + + +/* On-disk "super block" */ +struct luks_partition_header { + char magic[LUKS_MAGIC_L]; + __be16 version; + char cipherName[LUKS_CIPHERNAME_L]; + char cipherMode[LUKS_CIPHERMODE_L]; + char hashSpec[LUKS_HASHSPEC_L]; + __be32 payloadOffset; + __be32 keyBytes; + char mkDigest[LUKS_DIGESTSIZE]; + char mkDigestSalt[LUKS_SALTSIZE]; + __be32 mkDigestIterations; + char uuid[LUKS_UUID_STRING_L]; + + struct { + __be32 active; + /* Parameters for PBKDF2 processing */ + __be32 passwordIterations; + char passwordSalt[LUKS_SALTSIZE]; + __be32 keyMaterialOffset; + __be32 stripes; + } keyblock[LUKS_NUMKEYS]; +}; + +#endif