diff options
author | Thomas Chou <thomas@wytron.com.tw> | 2010-10-06 03:13:53 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-12-02 08:28:50 -0500 |
commit | 43f901fbc8ba94bfa8d58155ba9378d7a13af636 (patch) | |
tree | 76e695aef20df9fbb6007c3f2467c6019fe8c428 /usr/gen_init_cpio.c | |
parent | 01660dfc37933c92dbb7c5718aea61f88025d71f (diff) |
gen_init_cpio: remove leading `/' from file names
When we extracted the generated cpio archive using "cpio -id" command,
it complained,
cpio: Removing leading `/' from member names
var/run
cpio: Removing leading `/' from member names
var/lib
cpio: Removing leading `/' from member names
var/lib/misc
It is worse with the latest "cpio" or "pax", which tries to overwrite
the host file system with the leading '/'.
So the leading '/' of file names should be removed. This is consistent
with the initramfs come with major distributions such as Fedora or
Debian, etc.
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Mike Frysinger<vapier@gentoo.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'usr/gen_init_cpio.c')
-rw-r--r-- | usr/gen_init_cpio.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c index b2b3c2d1cf8b..59df70d9d1dc 100644 --- a/usr/gen_init_cpio.c +++ b/usr/gen_init_cpio.c | |||
@@ -104,6 +104,8 @@ static int cpio_mkslink(const char *name, const char *target, | |||
104 | char s[256]; | 104 | char s[256]; |
105 | time_t mtime = time(NULL); | 105 | time_t mtime = time(NULL); |
106 | 106 | ||
107 | if (name[0] == '/') | ||
108 | name++; | ||
107 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 109 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
108 | "%08X%08X%08X%08X%08X%08X%08X", | 110 | "%08X%08X%08X%08X%08X%08X%08X", |
109 | "070701", /* magic */ | 111 | "070701", /* magic */ |
@@ -152,6 +154,8 @@ static int cpio_mkgeneric(const char *name, unsigned int mode, | |||
152 | char s[256]; | 154 | char s[256]; |
153 | time_t mtime = time(NULL); | 155 | time_t mtime = time(NULL); |
154 | 156 | ||
157 | if (name[0] == '/') | ||
158 | name++; | ||
155 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 159 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
156 | "%08X%08X%08X%08X%08X%08X%08X", | 160 | "%08X%08X%08X%08X%08X%08X%08X", |
157 | "070701", /* magic */ | 161 | "070701", /* magic */ |
@@ -245,6 +249,8 @@ static int cpio_mknod(const char *name, unsigned int mode, | |||
245 | else | 249 | else |
246 | mode |= S_IFCHR; | 250 | mode |= S_IFCHR; |
247 | 251 | ||
252 | if (name[0] == '/') | ||
253 | name++; | ||
248 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 254 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
249 | "%08X%08X%08X%08X%08X%08X%08X", | 255 | "%08X%08X%08X%08X%08X%08X%08X", |
250 | "070701", /* magic */ | 256 | "070701", /* magic */ |
@@ -332,6 +338,8 @@ static int cpio_mkfile(const char *name, const char *location, | |||
332 | /* data goes on last link */ | 338 | /* data goes on last link */ |
333 | if (i == nlinks) size = buf.st_size; | 339 | if (i == nlinks) size = buf.st_size; |
334 | 340 | ||
341 | if (name[0] == '/') | ||
342 | name++; | ||
335 | namesize = strlen(name) + 1; | 343 | namesize = strlen(name) + 1; |
336 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" | 344 | sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" |
337 | "%08lX%08X%08X%08X%08X%08X%08X", | 345 | "%08lX%08X%08X%08X%08X%08X%08X", |