aboutsummaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-02-18 04:59:24 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-02-18 04:59:24 -0800
commit499104b6a0075edf7e1fe2ba5b6123f335f26897 (patch)
tree1a284e7b45cb1f6caa6f8f4eedf7baec179ce3b5 /usr
parentaa81900ec1ee8cc5f3ae56db52ad9b59a90cfe4a (diff)
downloadhistory-499104b6a0075edf7e1fe2ba5b6123f335f26897.tar.gz
[PATCH] Fix sprintf modifiers in usr/gen_init_cpio.c for cygwin
From: Pragnesh Sampat <pragnesh.sampat@timesys.com> 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.
Diffstat (limited to 'usr')
-rw-r--r--usr/gen_init_cpio.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index e1ccfaa84caac8..bf2d1fdd53a276 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -56,7 +56,7 @@ static void cpio_trailer(void)
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 */
@@ -69,7 +69,7 @@ static void cpio_trailer(void)
0, /* minor */
0, /* rmajor */
0, /* rminor */
- strlen(name) + 1, /* namesize */
+ (unsigned)strlen(name) + 1, /* namesize */
0); /* chksum */
push_hdr(s);
push_rest(name);
@@ -87,7 +87,7 @@ static void cpio_mkdir(const char *name, unsigned int mode,
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 */
@@ -100,7 +100,7 @@ static void cpio_mkdir(const char *name, unsigned int mode,
1, /* minor */
0, /* rmajor */
0, /* rminor */
- strlen(name) + 1, /* namesize */
+ (unsigned)strlen(name) + 1,/* namesize */
0); /* chksum */
push_hdr(s);
push_rest(name);
@@ -119,7 +119,7 @@ static void cpio_mknod(const char *name, unsigned int mode,
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 */
@@ -132,7 +132,7 @@ static void cpio_mknod(const char *name, unsigned int mode,
1, /* minor */
maj, /* rmajor */
min, /* rminor */
- strlen(name) + 1, /* namesize */
+ (unsigned)strlen(name) + 1,/* namesize */
0); /* chksum */
push_hdr(s);
push_rest(name);
@@ -176,7 +176,7 @@ void cpio_mkfile(const char *filename, const char *location,
}
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 */
@@ -189,7 +189,7 @@ void cpio_mkfile(const char *filename, const char *location,
1, /* minor */
0, /* rmajor */
0, /* rminor */
- strlen(location) + 1, /* namesize */
+ (unsigned)strlen(location) + 1,/* namesize */
0); /* chksum */
push_hdr(s);
push_string(location);