* [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32
@ 2022-06-28 14:45 hexiaole
2022-06-28 14:48 ` Darrick J. Wong
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: hexiaole @ 2022-06-28 14:45 UTC (permalink / raw)
To: linux-xfs; +Cc: hexiaole
From: hexiaole <hexiaole@kylinos.cn>
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
---
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 35e926a3..6add28ed 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32
2022-06-28 14:45 [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32 hexiaole
@ 2022-06-28 14:48 ` Darrick J. Wong
2022-06-29 7:27 ` Christoph Hellwig
2022-07-14 1:57 ` Eric Sandeen
2 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2022-06-28 14:48 UTC (permalink / raw)
To: hexiaole; +Cc: linux-xfs, hexiaole
On Tue, Jun 28, 2022 at 10:45:42PM +0800, hexiaole wrote:
> From: hexiaole <hexiaole@kylinos.cn>
>
> 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
> ---
> 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 35e926a3..6add28ed 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"),
*Half* decimal? LOL, I'd forgotten that even exists.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32
2022-06-28 14:45 [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32 hexiaole
2022-06-28 14:48 ` Darrick J. Wong
@ 2022-06-29 7:27 ` Christoph Hellwig
2022-07-14 1:57 ` Eric Sandeen
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-06-29 7:27 UTC (permalink / raw)
To: hexiaole; +Cc: linux-xfs, hexiaole
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32
2022-06-28 14:45 [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32 hexiaole
2022-06-28 14:48 ` Darrick J. Wong
2022-06-29 7:27 ` Christoph Hellwig
@ 2022-07-14 1:57 ` Eric Sandeen
2022-07-14 2:07 ` Darrick J. Wong
2 siblings, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2022-07-14 1:57 UTC (permalink / raw)
To: hexiaole, linux-xfs; +Cc: hexiaole
On 6/28/22 9:45 AM, hexiaole wrote:
> From: hexiaole <hexiaole@kylinos.cn>
>
> 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
I'm being pedantic for such a small change, but technically this needs to be sent
with a Signed-off-by: from you please?
It's probably enough for you to just reply to this thread with "yes, please
add my Signed-off-by"
Thanks,
-Eric
> ---
> 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 35e926a3..6add28ed 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),
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32
2022-07-14 1:57 ` Eric Sandeen
@ 2022-07-14 2:07 ` Darrick J. Wong
0 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2022-07-14 2:07 UTC (permalink / raw)
To: Eric Sandeen; +Cc: hexiaole, linux-xfs, hexiaole
On Wed, Jul 13, 2022 at 08:57:52PM -0500, Eric Sandeen wrote:
> On 6/28/22 9:45 AM, hexiaole wrote:
> > From: hexiaole <hexiaole@kylinos.cn>
> >
> > 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
>
> I'm being pedantic for such a small change, but technically this needs to be sent
> with a Signed-off-by: from you please?
It's not pedantry, it's a assertion that the author has the right to
submit the change under the GPL2, which is mandatory.
--D
> It's probably enough for you to just reply to this thread with "yes, please
> add my Signed-off-by"
>
> Thanks,
> -Eric
>
> > ---
> > 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 35e926a3..6add28ed 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),
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-14 2:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 14:45 [PATCH v1] xfs: correct nlink printf specifier from hd to PRIu32 hexiaole
2022-06-28 14:48 ` Darrick J. Wong
2022-06-29 7:27 ` Christoph Hellwig
2022-07-14 1:57 ` Eric Sandeen
2022-07-14 2:07 ` Darrick J. Wong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.