gen_init_cpio: remove leading `/' from file names
PATCH 1/1 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.
--- usr/gen_init_cpio.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
usr/gen_init_cpio.c +8 -0
@@ -104,6 +104,8 @@ static int cpio_mkslink(const char *name, const char *target,char s[256 ];time_t mtime =time (NULL ); +if (name[0 ] =='/' ) + name++; sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" "%08X%08X%08X%08X%08X%08X%08X", "070701", /* magic */
@@ -152,6 +154,8 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,char s[256 ];time_t mtime =time (NULL ); +if (name[0 ] =='/' ) + name++; sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" "%08X%08X%08X%08X%08X%08X%08X", "070701", /* magic */
@@ -245,6 +249,8 @@ static int cpio_mknod(const char *name, unsigned int mode,else mode |=S_IFCHR ; +if (name[0 ] =='/' ) + name++; sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" "%08X%08X%08X%08X%08X%08X%08X", "070701", /* magic */
@@ -332,6 +338,8 @@ static int cpio_mkfile(const char *name, const char *location,/* data goes on last link */ if (i == nlinks) size = buf.st_size; +if (name[0 ] =='/' ) + name++; namesize =strlen (name) +1 ; sprintf(s,"%s%08X%08X%08lX%08lX%08X%08lX" "%08lX%08X%08X%08X%08X%08X%08X",
Signature · 1 line
1.7.1.86.g0e460
Quoted 10 lines · Thomas Chou
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
Quoted 2 lines
It is worse with the latest "cpio" or "pax", which tries to overwrite the host file system with the leading '/'.
seems to work as intended on Blackfin systems, and i cant see any reason to require the leading slash, so:
-mike
Hi Andrew and Michal,
Quoted 11 lines · Mike Frysinger
Quoted 10 lines · Thomas Chou
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
Quoted 9 lines
Quoted 2 lines
It is worse with the latest "cpio" or "pax", which tries to overwrite the host file system with the leading '/'.
seems to work as intended on Blackfin systems, and i cant see any reason to require the leading slash, so:
Acked-by Mike Frysinger<[email protected]>-mike
Would you please review this patch? It is not clear as who should handle this with the MAINTAINERS.
Best regards,
Thomas
Quoted 24 lines · Thomas Chou
Hi Andrew and Michal,
Quoted 11 lines · Mike Frysinger
Quoted 10 lines · Thomas Chou
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/miscQuoted 9 lines
Quoted 2 lines
It is worse with the latest "cpio" or "pax", which tries to overwrite the host file system with the leading '/'.
seems to work as intended on Blackfin systems, and i cant see any reason to require the leading slash, so:
Acked-by Mike Frysinger<[email protected]>-mike
Quoted 2 lines
Would you please review this patch? It is not clear as who should handle this with the
MAINTAINERS.
Applied to kbuild-2.6.git#kbuild, thanks a lot.
Michal