git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git-am: "Patch fragment without a header"
@ 2006-02-07  2:59 H. Peter Anvin
  2006-02-07  3:20 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: H. Peter Anvin @ 2006-02-07  2:59 UTC (permalink / raw)
  To: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 896 bytes --]

git-am from git-1.1.6 refuses to apply the following two patches, 
whereas patch(1) sees nothing wrong with them...

The error messages look like:

: smyrno 46 ; git-am /tmp/\[klibc]\ Add\ swap\ support\ to\ fstype,\ 
second\ version.eml

Applying 'Add swap support to fstype, second version'

error: patch fragment without header at line 4: @@ -7,7 +7,7 @@
error: patch fragment without header at line 13: @@ -20,6 +20,7 @@
error: patch fragment without header at line 21: @@ -49,6 +50,9 @@
error: patch fragment without header at line 31: @@ -182,6 +186,19 @@
error: patch fragment without header at line 50: @@ -189,17 +206,18 @@
error: patch fragment without header at line 83: @@ -0,0 +1,18 @@
fatal: No changes
Patch failed at 0001.

The patches are meant to be apply to the top of:

git://git.kernel.org/pub/scm/libs/klibc/klibc.git

HEAD = ea6af2b08cb18ba60e55c5e8f0f65ddac1672ca0

	-hpa

[-- Attachment #2: [klibc] Add LUKS support to fstype, second version.eml --]
[-- Type: message/rfc822, Size: 6160 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 526 bytes --]

The attached patch adds support for detecting LUKS partitions (Linux 
Unified Key Setup - http://luks.endorphin.org/) to fstype. This makes it 
easier to automatically detect and activate encrypted (root) partitions 
from an initramfs image.

The patch is now against klibc's git tree instead of klibc-1.2.

Signed-off-by: David Härdeman <david@2gen.com>

--

 fstype.c  |   17 ++++++++++++++++-
 luks_fs.h |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)


[-- Attachment #2.1.2: klibc-add-luks-to-fstype-v2 --]
[-- Type: text/plain, Size: 2769 bytes --]

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

[-- Attachment #2.1.3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
klibc mailing list
klibc@zytor.com
http://www.zytor.com/mailman/listinfo/klibc

[-- Attachment #3: [klibc] Add swap support to fstype, second version.eml --]
[-- Type: message/rfc822, Size: 6293 bytes --]

[-- Attachment #3.1.1: Type: text/plain, Size: 388 bytes --]

This patch adds support for swap detection to fstype (to be applied on 
top of the previous luks patch).

The patch is now against klibc's git tree instead of klibc-1.2.

Signed-off-by: David Härdeman <david@2gen.com>

-- 

 fstype.c  |   42 ++++++++++++++++++++++++++++++------------
 swap_fs.h |   18 ++++++++++++++++++
 2 files changed, 48 insertions(+), 12 deletions(-)


[-- Attachment #3.1.2: klibc-add-swap-to-fstype-v2 --]
[-- Type: text/plain, Size: 3040 bytes --]

Index: klibc/usr/kinit/fstype/fstype.c
===================================================================
--- klibc.orig/usr/kinit/fstype/fstype.c	2006-02-05 11:09:31.000000000 +0100
+++ klibc/usr/kinit/fstype/fstype.c	2006-02-05 11:11:15.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
+ *  gzip, cramfs, romfs, xfs, luks, minix, ext3, ext2, reiserfs, jfs, swap
  *
  * MINIX, ext3 and Reiserfs bits are currently untested.
  */
@@ -20,6 +20,7 @@
 #include <endian.h>
 #include <netinet/in.h>
 #include <sys/vfs.h>
+#include <asm/page.h>
 
 #define cpu_to_be32(x) __cpu_to_be32(x)	/* Needed by romfs_fs.h */
 
@@ -49,6 +50,9 @@
 
 #define BLOCK_SIZE 1024
 
+/* Swap needs the definition of block size */
+#include "swap_fs.h"
+
 static int gzip_image(const unsigned char *buf, unsigned long long *bytes)
 {
 	if (buf[0] == 037 && (buf[1] == 0213 || buf[1] == 0236)) {
@@ -182,6 +186,19 @@
 	return 0;
 }
 
+static int swap_image(const unsigned char *buf, unsigned long long *blocks)
+{
+	const struct swap_super_block *ssb =
+		(const struct swap_super_block *)buf;
+
+	if (!memcmp(ssb->magic, SWAP_MAGIC_1, SWAP_MAGIC_L) ||
+	    !memcmp(ssb->magic, SWAP_MAGIC_2, SWAP_MAGIC_L)) {
+		*blocks = 0;
+		return 1;
+	}
+	return 0;
+}
+
 struct imagetype {
 	off_t		block;
 	const char	name[12];
@@ -189,17 +206,18 @@
 };
 
 static struct imagetype images[] = {
-	{ 0,	"gzip",		gzip_image	},
-	{ 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	},
-	{ 8,	"reiserfs",	reiserfs_image	},
-	{ 64,	"reiserfs",	reiserfs_image	},
-	{ 32,	"jfs",		jfs_image	}
+	{ 0,		"gzip",		gzip_image	},
+	{ 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	},
+	{ 8,		"reiserfs",	reiserfs_image	},
+	{ 64,		"reiserfs",	reiserfs_image	},
+	{ 32,		"jfs",		jfs_image	},
+	{ SWAP_OFFSET,	"swap",		swap_image	}
 };
 
 int identify_fs(int fd, const char **fstype,
Index: klibc/usr/kinit/fstype/swap_fs.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ klibc/usr/kinit/fstype/swap_fs.h	2006-02-05 11:10:01.000000000 +0100
@@ -0,0 +1,18 @@
+#ifndef __LINUX_SWAP_FS_H
+#define __LINUX_SWAP_FS_H
+
+/* The basic structures of the swap super block */
+#define SWAP_RESERVED_L		BLOCK_SIZE - 10
+#define SWAP_MAGIC_L		10
+#define SWAP_MAGIC_1		"SWAP-SPACE"
+#define SWAP_MAGIC_2		"SWAPSPACE2"
+/* The super block is the last block in the first page */
+#define SWAP_OFFSET		((PAGE_SIZE - BLOCK_SIZE) / BLOCK_SIZE)
+
+/* On-disk "super block" */
+struct swap_super_block {
+	char reserved[SWAP_RESERVED_L];
+	char magic[SWAP_MAGIC_L];
+};
+
+#endif

[-- Attachment #3.1.3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
klibc mailing list
klibc@zytor.com
http://www.zytor.com/mailman/listinfo/klibc

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-am: "Patch fragment without a header"
  2006-02-07  2:59 git-am: "Patch fragment without a header" H. Peter Anvin
@ 2006-02-07  3:20 ` Junio C Hamano
  2006-02-07  3:32   ` H. Peter Anvin
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-02-07  3:20 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: git

"H. Peter Anvin" <hpa@zytor.com> writes:

> git-am from git-1.1.6 refuses to apply the following two patches,
> whereas patch(1) sees nothing wrong with them...

Linus would have said "Say No to MIME".  I am a bit too busy
right now so if you are inclined to take a look, the problem is
in mailinfo.

It tries to do a limited form of MIME and fails.  The problem is
that it does not handle different content transfer encodings
used in the same message.  The first part of the multipart (log
message) does this:

    Content-Type: text/plain; charset=iso-8859-1; format=flowed
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

and it then switches to:

    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: inline; filename=klibc-add-luks-to-fstype-v2

    Index: klibc/usr/kinit/fstype/fstype.c
    ===================================================================
    --- .....

in the second part.  The mailinfo splits them alright but it
still thinks it needs to help with quoted printable, and ends up
eating these ===== marks and spitting out garbage.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-am: "Patch fragment without a header"
  2006-02-07  3:20 ` Junio C Hamano
@ 2006-02-07  3:32   ` H. Peter Anvin
  2006-02-07  5:35     ` Junio C Hamano
  2006-02-07 15:46     ` Linus Torvalds
  0 siblings, 2 replies; 5+ messages in thread
From: H. Peter Anvin @ 2006-02-07  3:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:
> 
> Linus would have said "Say No to MIME".  I am a bit too busy
> right now so if you are inclined to take a look, the problem is
> in mailinfo.
> 

Unfortunately git-mailinfo is in C, otherwise I'd have suggested using 
the Perl MIME-tools, which seems to have all this stuff in it.

It might just be easier to try to rewrite git-mailinfo in Perl...

	-hpa

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-am: "Patch fragment without a header"
  2006-02-07  3:32   ` H. Peter Anvin
@ 2006-02-07  5:35     ` Junio C Hamano
  2006-02-07 15:46     ` Linus Torvalds
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2006-02-07  5:35 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: git

"H. Peter Anvin" <hpa@zytor.com> writes:

> Unfortunately git-mailinfo is in C, otherwise I'd have suggested using
> the Perl MIME-tools, which seems to have all this stuff in it.

Heh, spawn Perl for every message?  I'd be ****ed by Linus if I
did so ;-).

This should fix it and I'd appreciate if you try it on other
messages.

I tried it on the message you quoted with:

    git-mailinfo -u /var/tmp/msg /var/tmp/patch <./+hpa.eml >/var/tmp/info

The resulting 'msg' and 'info' looks reasonable utf8 and patch
was not corrupt.

-- >8 --
[PATCH] mailinfo: reset CTE after each multipart

If the first part uses quoted-printable to protect iso8859-1
name in the commit log, and the second part was plain ascii text
patchfile without even Content-Transfer-Encoding subheader, we
incorrectly tried to decode the patch as quoted printable.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/mailinfo.c b/mailinfo.c
index 0265a29..ff2d4d4 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -707,6 +707,9 @@ static void handle_multipart_body(void)
 		if (!len) {
 			if (handle_multipart_one_part() < 0)
 				return;
+			/* Reset per part headers */
+			transfer_encoding = TE_DONTCARE;
+			charset[0] = 0;
 		}
 		else
 			check_subheader_line(line, len);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: git-am: "Patch fragment without a header"
  2006-02-07  3:32   ` H. Peter Anvin
  2006-02-07  5:35     ` Junio C Hamano
@ 2006-02-07 15:46     ` Linus Torvalds
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Torvalds @ 2006-02-07 15:46 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Junio C Hamano, git



On Mon, 6 Feb 2006, H. Peter Anvin wrote:
> 
> Unfortunately git-mailinfo is in C, otherwise I'd have suggested using the
> Perl MIME-tools, which seems to have all this stuff in it.
> 
> It might just be easier to try to rewrite git-mailinfo in Perl...

It might just be easier to make the mime checking go the hell away.

I do _not_ want to see some random perl code for the stuff I use (hundreds 
of times) a day. I can apply 5 patches a second right now, and more 
importantly, I know what it does.

Partly because I always edit out the stupid MIME stuff. I think it was a 
mistake to accept MIME patches in the first place.

		Linus

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-02-07 15:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-07  2:59 git-am: "Patch fragment without a header" H. Peter Anvin
2006-02-07  3:20 ` Junio C Hamano
2006-02-07  3:32   ` H. Peter Anvin
2006-02-07  5:35     ` Junio C Hamano
2006-02-07 15:46     ` Linus Torvalds

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).