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 From 281f30dde58cc16229690a522a0db5b61802220f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 13 Jul 2021 14:37:22 -0500 Subject: Guo Chuang pointed out that lsattr won't build with headers still within our 7 year time horizon. Clean up the existing portability attempts while we're there, and add timeout dates. --- toys/other/lsattr.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/toys/other/lsattr.c b/toys/other/lsattr.c index 547012ef..c5536281 100644 --- a/toys/other/lsattr.c +++ b/toys/other/lsattr.c @@ -71,12 +71,23 @@ GLOBALS( int have_set; ) -#define FS_PROJINHERT_FL 0x20000000 // Linux 4.5 -#define FS_CASEFOLD_FL 0x40000000 // Linux 5.4 -#define FS_VERITY_FL 0x00100000 // Linux 5.4 - -// Linux 4.5 -struct fsxattr_4_5 { +// Added more recently than the 7 year support horizon. TODO: remove +#ifndef FS_INLINE_DATA_FL +#define FS_INLINE_DATA_FL 0x10000000 // commit 68ce7bfcd995a 2016-01-08 +#endif +#ifndef FS_PROJINHERIT_FL +#define FS_PROJINHERIT_FL 0x20000000 // commit 8b4953e13f4c5 2015-10-17 +#endif +#ifndef FS_CASEFOLD_FL +#define FS_CASEFOLD_FL 0x40000000 // commit 71e90b4654a92 2019-07-23 +#endif +#ifndef FS_VERITY_FL +#define FS_VERITY_FL 0x00100000 // commit fe9918d3b228b 2019-07-22 +#endif + +#ifndef FS_IOC_FSGETXATTR +// commit 334e580a6f97e 2016-01-04 +struct fsxattr { unsigned fsx_xflags; unsigned fsx_extsize; unsigned fsx_nextents; @@ -84,8 +95,9 @@ struct fsxattr_4_5 { unsigned fsx_cowextsize; char fsx_pad[8]; }; -#define FS_IOC_FSGETXATTR_4_5 _IOR('X', 31, struct fsxattr_4_5) -#define FS_IOC_FSSETXATTR_4_5 _IOW('X', 32, struct fsxattr_4_5) +#define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr) +#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr) +#endif static struct ext2_attr { char *name; @@ -152,9 +164,9 @@ static void print_file_attr(char *path) if (-1 == (fd=open(path, O_RDONLY | O_NONBLOCK))) goto LABEL1; if (FLAG(p)) { - struct fsxattr_4_5 fsx; + struct fsxattr fsx; - if (ioctl(fd, FS_IOC_FSGETXATTR_4_5, &fsx)) goto LABEL2; + if (ioctl(fd, FS_IOC_FSGETXATTR, &fsx)) goto LABEL2; xprintf("%5u ", fsx.fsx_projid); } if (FLAG(v)) { @@ -330,11 +342,11 @@ static int update_attr(struct dirtree *root) perror_msg("%s: setting version to %d failed", fpath, v); if (FLAG(p)) { - struct fsxattr_4_5 fsx; - int fail = ioctl(fd, FS_IOC_FSGETXATTR_4_5, &fsx); + struct fsxattr fsx; + int fail = ioctl(fd, FS_IOC_FSGETXATTR, &fsx); fsx.fsx_projid = TT.p; - if (fail || ioctl(fd, FS_IOC_FSSETXATTR_4_5, &fsx)) + if (fail || ioctl(fd, FS_IOC_FSSETXATTR, &fsx)) perror_msg("%s: setting projid to %u failed", fpath, fsx.fsx_projid); } -- cgit v1.2.3