From b1c071ee037b79e7058ebc03f6ca8536e52dc843 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 11 Jul 2021 05:02:32 -0500 Subject: Add options for reproducibility tests. --- toys/posix/cpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c index 35b74b3b..5ecd56df 100644 --- a/toys/posix/cpio.c +++ b/toys/posix/cpio.c @@ -16,7 +16,7 @@ * * todo: export/import linux file list text format ala gen_initramfs_list.sh -USE_CPIO(NEWTOY(cpio, "(quiet)(no-preserve-owner)md(make-directories)uH:p|i|t|F:v(verbose)o|[!pio][!pot][!pF]", TOYFLAG_BIN)) +USE_CPIO(NEWTOY(cpio, "(ignore-devno)(renumber-inodes)(quiet)(no-preserve-owner)md(make-directories)uH:p|i|t|F:v(verbose)o|[!pio][!pot][!pF]", TOYFLAG_BIN)) config CPIO bool "cpio" @@ -243,6 +243,7 @@ void cpio_main(void) } else { char *name = 0; size_t size = 0; + unsigned inode = 0; for (;;) { struct stat st; @@ -269,6 +270,8 @@ void cpio_main(void) if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode)) st.st_size = 0; if (st.st_size >> 32) perror_msg("skipping >2G file '%s'", name); else { + if (FLAG(renumber_inodes)) st.st_ino = ++inode; + if (FLAG(ignore_devno)) st.st_rdev = 0; llen = sprintf(toybuf, "070701%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X%08X", (int)st.st_ino, st.st_mode, st.st_uid, st.st_gid, (int)st.st_nlink, -- cgit v1.2.3