mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pragnesh Sampat <pragnesh.sampat@timesys.com>
To: bos@serpentine.com
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: [PATCH] sprintf modifiers in usr/gen_init_cpio.c
Date: Tue, 17 Feb 2004 19:26:20 -0500	[thread overview]
Message-ID: <1077063980.9721.22.camel@dagoban.timesys> (raw)

The file initramfs_data.cpio is slightly different when generated on
cygwin, compared to linux, which causes the kernel to panic with the
message "no cpio magic" (See Documentation/early-userspace/README).

The problem in cpio generation is due to the difference in sprintf
modifiers on cygwin.  The code uses "%08ZX" for strlen of a device
node.  printf man pages discourages "Z" and has 'z' instead.
Both of these are not available on cygwin sprintf (at least some
versions of cygwin).  The net result of all of this is that the
generated file literally contains "ZX" and then the strlen after that
and messes up that 110 offset etc.  The file is 516 bytes long on the
system that I tested and on linux it is 512 bytes.

The fix below just uses "%08X" for that field.  Any basic portable
modifier should be ok, I think.

-Pragnesh
	
--- usr/gen_init_cpio.c-orig
+++ usr/gen_init_cpio.c

@@ -56,7 +56,7 @@
 	const char name[] = "TRAILER!!!";
 
 	sprintf(s, "%s%08X%08X%08lX%08lX%08X%08lX"
-	       "%08X%08X%08X%08X%08X%08ZX%08X",
+	       "%08X%08X%08X%08X%08X%08X%08X",
 		"070701",		/* magic */
 		0,			/* ino */
 		0,			/* mode */
@@ -87,7 +87,7 @@
 	time_t mtime = time(NULL);
 
 	sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
-	       "%08X%08X%08X%08X%08X%08ZX%08X",
+	       "%08X%08X%08X%08X%08X%08X%08X",
 		"070701",		/* magic */
 		ino++,			/* ino */
 		S_IFDIR | mode,		/* mode */
@@ -119,7 +119,7 @@
 		mode |= S_IFCHR;
 
 	sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
-	       "%08X%08X%08X%08X%08X%08ZX%08X",
+	       "%08X%08X%08X%08X%08X%08X%08X",
 		"070701",		/* magic */
 		ino++,			/* ino */
 		mode,			/* mode */
@@ -176,7 +176,7 @@
 	}
 
 	sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX"
-	       "%08X%08X%08X%08X%08X%08ZX%08X",
+	       "%08X%08X%08X%08X%08X%08X%08X",
 		"070701",		/* magic */
 		ino++,			/* ino */
 		mode,			/* mode */



             reply	other threads:[~2004-02-18  0:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-18  0:26 Pragnesh Sampat [this message]
2004-02-18  0:44 ` Andrew Morton
2004-02-18  4:05   ` Pragnesh Sampat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1077063980.9721.22.camel@dagoban.timesys \
    --to=pragnesh.sampat@timesys.com \
    --cc=akpm@osdl.org \
    --cc=bos@serpentine.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®