diff --git a/0001-xfs-correct-nlink-printf-specifier-from-hd-to-PRIu32.patch b/0001-xfs-correct-nlink-printf-specifier-from-hd-to-PRIu32.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f3b65c4ce7fcce7d55da6359d7f7bc656aafbfc --- /dev/null +++ b/0001-xfs-correct-nlink-printf-specifier-from-hd-to-PRIu32.patch @@ -0,0 +1,69 @@ +From 8f9d8d38f2c4cea10d82d62286e6caa837d1bfd6 Mon Sep 17 00:00:00 2001 +From: hexiaole +Date: Wed, 13 Jul 2022 20:58:24 -0500 +Subject: [PATCH] xfs: correct nlink printf specifier from hd to PRIu32 + +1. Description +libxfs/xfs_log_format.h declare 'di_nlink' as unsigned 32-bit integer: + +typedef struct xfs_icdinode { + ... + __uint32_t di_nlink; /* number of links to file */ + ... +} xfs_icdinode_t; + +But logprint/log_misc.c use '%hd' to print 'di_nlink': + +void +xlog_print_trans_inode_core(xfs_icdinode_t *ip) +{ + ... + printf(_("nlink %hd uid %d gid %d\n"), + ip->di_nlink, ip->di_uid, ip->di_gid); + ... +} + +'%hd' can be 16-bit on many architectures, on these architectures, the 'printf' only print the low 16-bit of 'di_nlink'. + +2. Reproducer +2.1. Commands +[root@localhost ~]# cd +[root@localhost ~]# xfs_mkfile 128m 128m.xfs +[root@localhost ~]# mkfs.xfs 128m.xfs +[root@localhost ~]# mount 128m.xfs /mnt/ +[root@localhost ~]# cd /mnt/ +[root@localhost mnt]# seq 1 65534|xargs mkdir -p +[root@localhost mnt]# cd +[root@localhost ~]# umount /mnt/ +[root@localhost ~]# xfs_logprint 128m.xfs|grep nlink|tail -1 + +2.2. Expect result +nlink 65536 + +2.3. Actual result +nlink 0 + +Signed-off-by: hexiaole +Reviewed-by: Darrick J. Wong +Reviewed-by: Christoph Hellwig +Signed-off-by: Eric Sandeen +--- + logprint/log_misc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/logprint/log_misc.c b/logprint/log_misc.c +index 35e926a..6add28e 100644 +--- a/logprint/log_misc.c ++++ b/logprint/log_misc.c +@@ -444,7 +444,7 @@ xlog_print_trans_inode_core( + printf(_("magic 0x%hx mode 0%ho version %d format %d\n"), + ip->di_magic, ip->di_mode, (int)ip->di_version, + (int)ip->di_format); +- printf(_("nlink %hd uid %d gid %d\n"), ++ printf(_("nlink %" PRIu32 " uid %d gid %d\n"), + ip->di_nlink, ip->di_uid, ip->di_gid); + printf(_("atime 0x%llx mtime 0x%llx ctime 0x%llx\n"), + xlog_extract_dinode_ts(ip->di_atime), +-- +2.27.0 + diff --git a/xfsprogs.spec b/xfsprogs.spec index d2eef705b3d217ff669bd7dbaa47e8a5a997bdb1..32ffd5a525ddb487c902089346241689b64ae19d 100644 --- a/xfsprogs.spec +++ b/xfsprogs.spec @@ -1,6 +1,6 @@ Name: xfsprogs Version: 5.14.1 -Release: 2 +Release: 3 Summary: Administration and debugging tools for the XFS file system License: GPL+ and LGPLv2+ URL: https://xfs.wiki.kernel.org @@ -18,6 +18,7 @@ Obsoletes: xfsprogs-qa-devel <= %{version} Conflicts: xfsdump < 3.0.1 Patch0: xfsprogs-5.12.0-default-bigtime-inobtcnt-on.patch +Patch1: 0001-xfs-correct-nlink-printf-specifier-from-hd-to-PRIu32.patch %description xfsprogs are the userspace utilities that manage XFS filesystems. @@ -101,6 +102,9 @@ rm -rf %{buildroot}%{_datadir}/doc/xfsprogs/ %changelog +* Mon Jul 18 2022 Xiaole He - 5.14.1-3 +- add Patch1: correct nlink printf specifier from hd to PRIu32 + * Fri Jun 10 2022 xiongyu - 5.14.1-2 - turn bigtime & inobtcnt on as default