{"thread":{"id":"3253","subject":"git-am: \"Patch fragment without a header\"","startedAt":"2006-02-07T02:59:47Z","lastAt":"2006-02-07T15:46:04Z","messageCount":5,"participants":["H. Peter Anvin","Junio C Hamano","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15655","messageId":"43E80D23.4070007@zytor.com","threadId":"3253","inReplyTo":null,"subject":"git-am: \"Patch fragment without a header\"","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2006-02-07T02:59:47Z","receivedAt":"2006-02-07T02:59:47Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"git-am from git-1.1.6 refuses to apply the following two patches, \nwhereas patch(1) sees nothing wrong with them...\n\nThe error messages look like:\n\n: smyrno 46 ; git-am /tmp/\\[klibc]\\ Add\\ swap\\ support\\ to\\ fstype,\\ \nsecond\\ version.eml\n\nApplying 'Add swap support to fstype, second version'\n\nerror: patch fragment without header at line 4: @@ -7,7 +7,7 @@\nerror: patch fragment without header at line 13: @@ -20,6 +20,7 @@\nerror: patch fragment without header at line 21: @@ -49,6 +50,9 @@\nerror: patch fragment without header at line 31: @@ -182,6 +186,19 @@\nerror: patch fragment without header at line 50: @@ -189,17 +206,18 @@\nerror: patch fragment without header at line 83: @@ -0,0 +1,18 @@\nfatal: No changes\nPatch failed at 0001.\n\nThe patches are meant to be apply to the top of:\n\ngit://git.kernel.org/pub/scm/libs/klibc/klibc.git\n\nHEAD = ea6af2b08cb18ba60e55c5e8f0f65ddac1672ca0\n\n\t-hpa\n\n\nThe attached patch adds support for detecting LUKS partitions (Linux \nUnified Key Setup - http://luks.endorphin.org/) to fstype. This makes it \neasier to automatically detect and activate encrypted (root) partitions \nfrom an initramfs image.\n\nThe patch is now against klibc's git tree instead of klibc-1.2.\n\nSigned-off-by: David Härdeman <david@2gen.com>\n\n--\n\n fstype.c  |   17 ++++++++++++++++-\n luks_fs.h |   45 +++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 61 insertions(+), 1 deletion(-)\n\n\n\nIndex: klibc/usr/kinit/fstype/fstype.c\n===================================================================\n--- klibc.orig/usr/kinit/fstype/fstype.c\t2006-02-05 10:53:51.000000000 +0100\n+++ klibc/usr/kinit/fstype/fstype.c\t2006-02-05 11:09:31.000000000 +0100\n@@ -7,7 +7,7 @@\n  *  FSSIZE - filesystem size (if known)\n  *\n  * We currently detect (in order):\n- *  gzip, cramfs, romfs, xfs, minix, ext3, ext2, reiserfs, jfs\n+ *  gzip, cramfs, romfs, xfs, luks, minix, ext3, ext2, reiserfs, jfs\n  *\n  * MINIX, ext3 and Reiserfs bits are currently untested.\n  */\n@@ -29,6 +29,7 @@\n #include \"ext2_fs.h\"\n #include \"ext3_fs.h\"\n #include \"xfs_sb.h\"\n+#include \"luks_fs.h\"\n \n /*\n  * Slightly cleaned up version of jfs_superblock to\n@@ -168,6 +169,19 @@\n \treturn 0;\n }\n \n+static int luks_image(const unsigned char *buf, unsigned long long *blocks)\n+{\n+\tconst struct luks_partition_header *lph =\n+\t\t(const struct luks_partition_header *)buf;\n+\n+\tif (!memcmp(lph->magic, LUKS_MAGIC, LUKS_MAGIC_L)) {\n+\t\t/* FSSIZE is dictated by the underlying fs, not by LUKS */\n+\t\t*blocks = 0;\n+\t\treturn 1;\n+\t}\n+\treturn 0;\n+}\n+\n struct imagetype {\n \toff_t\t\tblock;\n \tconst char\tname[12];\n@@ -179,6 +193,7 @@\n \t{ 0,\t\"cramfs\",\tcramfs_image\t},\n \t{ 0,\t\"romfs\",\tromfs_image\t},\n \t{ 0,\t\"xfs\",\t\txfs_image\t},\n+\t{ 0,\t\"luks\",\t\tluks_image\t},\n \t{ 1,\t\"minix\",\tminix_image\t},\n \t{ 1,\t\"ext3\",\t\text3_image\t},\n \t{ 1,\t\"ext2\",\t\text2_image\t},\nIndex: klibc/usr/kinit/fstype/luks_fs.h\n===================================================================\n--- /dev/null\t1970-01-01 00:00:00.000000000 +0000\n+++ klibc/usr/kinit/fstype/luks_fs.h\t2006-02-05 10:57:52.000000000 +0100\n@@ -0,0 +1,45 @@\n+#ifndef __LINUX_LUKS_FS_H\n+#define __LINUX_LUKS_FS_H\n+\n+/* The basic structures of the luks partition header */\n+#define LUKS_MAGIC_L\t\t6\n+#define LUKS_CIPHERNAME_L\t32\n+#define LUKS_CIPHERMODE_L\t32\n+#define LUKS_HASHSPEC_L\t\t32\n+#define LUKS_UUID_STRING_L\t40\n+\n+#define LUKS_MAGIC\t\t\"LUKS\\xBA\\xBE\"\n+#define LUKS_DIGESTSIZE\t\t20\n+#define LUKS_SALTSIZE\t\t32\n+#define LUKS_NUMKEYS\t\t8\n+#define LUKS_MKD_ITER\t\t10\n+#define LUKS_KEY_DISABLED\t0x0000DEAD\n+#define LUKS_KEY_ENABLED\t0x00AC71F3\n+#define LUKS_STRIPES\t\t4000\n+\n+\n+/* On-disk \"super block\" */\n+struct luks_partition_header {\n+\tchar\tmagic[LUKS_MAGIC_L];\n+\t__be16\tversion;\n+\tchar\tcipherName[LUKS_CIPHERNAME_L];\n+\tchar\tcipherMode[LUKS_CIPHERMODE_L];\n+\tchar\thashSpec[LUKS_HASHSPEC_L];\n+\t__be32\tpayloadOffset;\n+\t__be32  keyBytes;\n+\tchar\tmkDigest[LUKS_DIGESTSIZE];\n+\tchar\tmkDigestSalt[LUKS_SALTSIZE];\n+\t__be32\tmkDigestIterations;\n+\tchar\tuuid[LUKS_UUID_STRING_L];\n+\n+\tstruct {\n+\t\t__be32\tactive;\n+\t\t/* Parameters for PBKDF2 processing */\n+\t\t__be32\tpasswordIterations;\n+\t\tchar\tpasswordSalt[LUKS_SALTSIZE];\n+\t\t__be32\tkeyMaterialOffset;\n+\t\t__be32\tstripes;\n+\t} keyblock[LUKS_NUMKEYS];\n+};\n+\n+#endif\n\n\n_______________________________________________\nklibc mailing list\nklibc@zytor.com\nhttp://www.zytor.com/mailman/listinfo/klibc\n\n\nThis patch adds support for swap detection to fstype (to be applied on \ntop of the previous luks patch).\n\nThe patch is now against klibc's git tree instead of klibc-1.2.\n\nSigned-off-by: David Härdeman <david@2gen.com>\n\n-- \n\n fstype.c  |   42 ++++++++++++++++++++++++++++++------------\n swap_fs.h |   18 ++++++++++++++++++\n 2 files changed, 48 insertions(+), 12 deletions(-)\n\n\n\nIndex: klibc/usr/kinit/fstype/fstype.c\n===================================================================\n--- klibc.orig/usr/kinit/fstype/fstype.c\t2006-02-05 11:09:31.000000000 +0100\n+++ klibc/usr/kinit/fstype/fstype.c\t2006-02-05 11:11:15.000000000 +0100\n@@ -7,7 +7,7 @@\n  *  FSSIZE - filesystem size (if known)\n  *\n  * We currently detect (in order):\n- *  gzip, cramfs, romfs, xfs, luks, minix, ext3, ext2, reiserfs, jfs\n+ *  gzip, cramfs, romfs, xfs, luks, minix, ext3, ext2, reiserfs, jfs, swap\n  *\n  * MINIX, ext3 and Reiserfs bits are currently untested.\n  */\n@@ -20,6 +20,7 @@\n #include <endian.h>\n #include <netinet/in.h>\n #include <sys/vfs.h>\n+#include <asm/page.h>\n \n #define cpu_to_be32(x) __cpu_to_be32(x)\t/* Needed by romfs_fs.h */\n \n@@ -49,6 +50,9 @@\n \n #define BLOCK_SIZE 1024\n \n+/* Swap needs the definition of block size */\n+#include \"swap_fs.h\"\n+\n static int gzip_image(const unsigned char *buf, unsigned long long *bytes)\n {\n \tif (buf[0] == 037 && (buf[1] == 0213 || buf[1] == 0236)) {\n@@ -182,6 +186,19 @@\n \treturn 0;\n }\n \n+static int swap_image(const unsigned char *buf, unsigned long long *blocks)\n+{\n+\tconst struct swap_super_block *ssb =\n+\t\t(const struct swap_super_block *)buf;\n+\n+\tif (!memcmp(ssb->magic, SWAP_MAGIC_1, SWAP_MAGIC_L) ||\n+\t    !memcmp(ssb->magic, SWAP_MAGIC_2, SWAP_MAGIC_L)) {\n+\t\t*blocks = 0;\n+\t\treturn 1;\n+\t}\n+\treturn 0;\n+}\n+\n struct imagetype {\n \toff_t\t\tblock;\n \tconst char\tname[12];\n@@ -189,17 +206,18 @@\n };\n \n static struct imagetype images[] = {\n-\t{ 0,\t\"gzip\",\t\tgzip_image\t},\n-\t{ 0,\t\"cramfs\",\tcramfs_image\t},\n-\t{ 0,\t\"romfs\",\tromfs_image\t},\n-\t{ 0,\t\"xfs\",\t\txfs_image\t},\n-\t{ 0,\t\"luks\",\t\tluks_image\t},\n-\t{ 1,\t\"minix\",\tminix_image\t},\n-\t{ 1,\t\"ext3\",\t\text3_image\t},\n-\t{ 1,\t\"ext2\",\t\text2_image\t},\n-\t{ 8,\t\"reiserfs\",\treiserfs_image\t},\n-\t{ 64,\t\"reiserfs\",\treiserfs_image\t},\n-\t{ 32,\t\"jfs\",\t\tjfs_image\t}\n+\t{ 0,\t\t\"gzip\",\t\tgzip_image\t},\n+\t{ 0,\t\t\"cramfs\",\tcramfs_image\t},\n+\t{ 0,\t\t\"romfs\",\tromfs_image\t},\n+\t{ 0,\t\t\"xfs\",\t\txfs_image\t},\n+\t{ 0,\t\t\"luks\",\t\tluks_image\t},\n+\t{ 1,\t\t\"minix\",\tminix_image\t},\n+\t{ 1,\t\t\"ext3\",\t\text3_image\t},\n+\t{ 1,\t\t\"ext2\",\t\text2_image\t},\n+\t{ 8,\t\t\"reiserfs\",\treiserfs_image\t},\n+\t{ 64,\t\t\"reiserfs\",\treiserfs_image\t},\n+\t{ 32,\t\t\"jfs\",\t\tjfs_image\t},\n+\t{ SWAP_OFFSET,\t\"swap\",\t\tswap_image\t}\n };\n \n int identify_fs(int fd, const char **fstype,\nIndex: klibc/usr/kinit/fstype/swap_fs.h\n===================================================================\n--- /dev/null\t1970-01-01 00:00:00.000000000 +0000\n+++ klibc/usr/kinit/fstype/swap_fs.h\t2006-02-05 11:10:01.000000000 +0100\n@@ -0,0 +1,18 @@\n+#ifndef __LINUX_SWAP_FS_H\n+#define __LINUX_SWAP_FS_H\n+\n+/* The basic structures of the swap super block */\n+#define SWAP_RESERVED_L\t\tBLOCK_SIZE - 10\n+#define SWAP_MAGIC_L\t\t10\n+#define SWAP_MAGIC_1\t\t\"SWAP-SPACE\"\n+#define SWAP_MAGIC_2\t\t\"SWAPSPACE2\"\n+/* The super block is the last block in the first page */\n+#define SWAP_OFFSET\t\t((PAGE_SIZE - BLOCK_SIZE) / BLOCK_SIZE)\n+\n+/* On-disk \"super block\" */\n+struct swap_super_block {\n+\tchar reserved[SWAP_RESERVED_L];\n+\tchar magic[SWAP_MAGIC_L];\n+};\n+\n+#endif\n\n\n_______________________________________________\nklibc mailing list\nklibc@zytor.com\nhttp://www.zytor.com/mailman/listinfo/klibc\n"},{"id":"15657","messageId":"7vwtg73ld7.fsf@assigned-by-dhcp.cox.net","threadId":"3253","inReplyTo":"43E80D23.4070007@zytor.com","subject":"Re: git-am: \"Patch fragment without a header\"","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-07T03:20:52Z","receivedAt":"2006-02-07T03:20:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> git-am from git-1.1.6 refuses to apply the following two patches,\n> whereas patch(1) sees nothing wrong with them...\n\nLinus would have said \"Say No to MIME\".  I am a bit too busy\nright now so if you are inclined to take a look, the problem is\nin mailinfo.\n\nIt tries to do a limited form of MIME and fails.  The problem is\nthat it does not handle different content transfer encodings\nused in the same message.  The first part of the multipart (log\nmessage) does this:\n\n    Content-Type: text/plain; charset=iso-8859-1; format=flowed\n    Content-Disposition: inline\n    Content-Transfer-Encoding: quoted-printable\n\nand it then switches to:\n\n    Content-Type: text/plain; charset=us-ascii\n    Content-Disposition: inline; filename=klibc-add-luks-to-fstype-v2\n\n    Index: klibc/usr/kinit/fstype/fstype.c\n    ===================================================================\n    --- .....\n\nin the second part.  The mailinfo splits them alright but it\nstill thinks it needs to help with quoted printable, and ends up\neating these ===== marks and spitting out garbage.\n"},{"id":"15661","messageId":"43E814C2.6090104@zytor.com","threadId":"3253","inReplyTo":"7vwtg73ld7.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-am: \"Patch fragment without a header\"","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2006-02-07T03:32:18Z","receivedAt":"2006-02-07T03:32:18Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Junio C Hamano wrote:\n> \n> Linus would have said \"Say No to MIME\".  I am a bit too busy\n> right now so if you are inclined to take a look, the problem is\n> in mailinfo.\n> \n\nUnfortunately git-mailinfo is in C, otherwise I'd have suggested using \nthe Perl MIME-tools, which seems to have all this stuff in it.\n\nIt might just be easier to try to rewrite git-mailinfo in Perl...\n\n\t-hpa\n"},{"id":"15663","messageId":"7vfymv3f4y.fsf@assigned-by-dhcp.cox.net","threadId":"3253","inReplyTo":"43E814C2.6090104@zytor.com","subject":"Re: git-am: \"Patch fragment without a header\"","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-07T05:35:25Z","receivedAt":"2006-02-07T05:35:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> Unfortunately git-mailinfo is in C, otherwise I'd have suggested using\n> the Perl MIME-tools, which seems to have all this stuff in it.\n\nHeh, spawn Perl for every message?  I'd be ****ed by Linus if I\ndid so ;-).\n\nThis should fix it and I'd appreciate if you try it on other\nmessages.\n\nI tried it on the message you quoted with:\n\n    git-mailinfo -u /var/tmp/msg /var/tmp/patch <./+hpa.eml >/var/tmp/info\n\nThe resulting 'msg' and 'info' looks reasonable utf8 and patch\nwas not corrupt.\n\n-- >8 --\n[PATCH] mailinfo: reset CTE after each multipart\n\nIf the first part uses quoted-printable to protect iso8859-1\nname in the commit log, and the second part was plain ascii text\npatchfile without even Content-Transfer-Encoding subheader, we\nincorrectly tried to decode the patch as quoted printable.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/mailinfo.c b/mailinfo.c\nindex 0265a29..ff2d4d4 100644\n--- a/mailinfo.c\n+++ b/mailinfo.c\n@@ -707,6 +707,9 @@ static void handle_multipart_body(void)\n \t\tif (!len) {\n \t\t\tif (handle_multipart_one_part() < 0)\n \t\t\t\treturn;\n+\t\t\t/* Reset per part headers */\n+\t\t\ttransfer_encoding = TE_DONTCARE;\n+\t\t\tcharset[0] = 0;\n \t\t}\n \t\telse\n \t\t\tcheck_subheader_line(line, len);\n"},{"id":"15673","messageId":"Pine.LNX.4.64.0602070744250.3854@g5.osdl.org","threadId":"3253","inReplyTo":"43E814C2.6090104@zytor.com","subject":"Re: git-am: \"Patch fragment without a header\"","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-02-07T15:46:04Z","receivedAt":"2006-02-07T15:46:04Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 6 Feb 2006, H. Peter Anvin wrote:\n> \n> Unfortunately git-mailinfo is in C, otherwise I'd have suggested using the\n> Perl MIME-tools, which seems to have all this stuff in it.\n> \n> It might just be easier to try to rewrite git-mailinfo in Perl...\n\nIt might just be easier to make the mime checking go the hell away.\n\nI do _not_ want to see some random perl code for the stuff I use (hundreds \nof times) a day. I can apply 5 patches a second right now, and more \nimportantly, I know what it does.\n\nPartly because I always edit out the stupid MIME stuff. I think it was a \nmistake to accept MIME patches in the first place.\n\n\t\tLinus\n"}]}