xfs: correct nlink printf specifier from hd to PRIu32
Backport from kernel xfsprogs git: This correction has already been merged into kernel xfsprogs git: Link: https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/commit/?h=for-next&id=03bc653907cc4e89cbb45524063439800a722d9b and the original discussion for this patch can be found: Link: https://marc.info/?l=linux-xfs&m=165642746415368&w=2 Signed-off-by: Xiaole He <hexiaole@kylinos.cn> (cherry picked from commit 7753047ce8d12b091577cca9af9b8fd3e40a3a4d)
This commit is contained in:
parent
48dd2baef2
commit
7f303d139b
@ -0,0 +1,69 @@
|
||||
From c575462896c86e8ca16390bb5aea405c96403251 Mon Sep 17 00:00:00 2001
|
||||
From: Xiaole He <hexiaole@kylinos.cn>
|
||||
Date: Tue, 19 Jul 2022 11:34:16 +0800
|
||||
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 <hexiaole@kylinos.cn>
|
||||
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
|
||||
Reviewed-by: Christoph Hellwig <hch@lst.de>
|
||||
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
|
||||
---
|
||||
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 45f697f..699e169 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%x mtime 0x%x ctime 0x%x\n"),
|
||||
ip->di_atime.t_sec, ip->di_mtime.t_sec, ip->di_ctime.t_sec);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: xfsprogs
|
||||
Version: 5.6.0
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: Administration and debugging tools for the XFS file system
|
||||
License: GPL+ and LGPLv2+
|
||||
URL: https://xfs.wiki.kernel.org
|
||||
@ -18,8 +18,9 @@ Patch8: 0008-xfs-fix-inode-allocation-block-res-calculation-prece.patch
|
||||
Patch9: 0009-xfs-fix-off-by-one-in-inode-alloc-block-reservation-.patch
|
||||
Patch10: 0010-xfs-fix-boundary-test-in-xfs_attr_shortform_verify.patch
|
||||
Patch11: 0011-xfs-set-xefi_discard-when-creating-a-deferred-agfl-f.patch
|
||||
Patch12: 0012-xfs-correct-nlink-printf-specifier-from-hd-to-PRIu32.patch
|
||||
|
||||
BuildRequires: libtool libattr-devel libuuid-devel gcc git
|
||||
BuildRequires: libtool libattr-devel libuuid-devel gcc git gettext
|
||||
BuildRequires: readline-devel libblkid-devel >= 2.30 lvm2-devel libicu-devel >= 62.0
|
||||
|
||||
Recommends: %{name}-xfs_scrub
|
||||
@ -110,6 +111,9 @@ rm -rf %{buildroot}%{_datadir}/doc/xfsprogs/
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Jul 19 2022 Xiaole He <hexiaole@kylinos.cn> - 5.6.0-5
|
||||
- add Patch12: correct nlink printf specifier from hd to PRIu32
|
||||
|
||||
* Mon Mar 14 2022 wuguanghao <wuguanghao3@huawei.com> - 5.6.0-4
|
||||
- backport bugfix patches from community
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user