aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2021-07-17 15:26:55 +0300
committerCem Keylan <cem@ckyln.com>2021-07-17 15:26:55 +0300
commit677e9bd281cd67b845c80e0e166fc767c4aecf7d (patch)
treebb21596339e0a784894c6857654b1ddf5e55366a
parentd21b9d3c3147eb12f115b1fd361da913a1177fba (diff)
parent281f30dde58cc16229690a522a0db5b61802220f (diff)
downloadtoybox-677e9bd281cd67b845c80e0e166fc767c4aecf7d.tar.gz
merge upstreamHEADmaster
-rw-r--r--toys/other/lsattr.c38
-rw-r--r--toys/posix/cpio.c5
2 files changed, 29 insertions, 14 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);
}
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,