Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Wang Yugui <wangyugui@e16-tech.com>
To: dsterba@suse.cz, Wang Yugui <wangyugui@e16-tech.com>,
	linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
	dhowells@redhat.com
Subject: Re: the major/minor value of statx(kernel samples/vfs/test-statx.c) does not match /usr/bin/stat
Date: Thu, 24 Jun 2021 06:19:18 +0800	[thread overview]
Message-ID: <20210624061917.A9CD.409509F4@e16-tech.com> (raw)
In-Reply-To: <20210623204910.GO28158@twin.jikos.cz>

Hi,

> On Thu, Jun 17, 2021 at 06:12:56PM +0800, Wang Yugui wrote:
> > the major/minor value of statx(kernel samples/vfs/test-statx.c) does not
> > match /usr/bin/stat. 
> > 
> > major/minor of statx result seems be truncated by something like
> > old_decode_dev()?
> 
> I've checked the code first, both stat/statx seem to be doing the same
> thing.
> 
> > [root@T640 vfs]# ./test-statx /ssd/
> > statx(/ssd/) = 0
> > results=1fff
> >   Size: 200             Blocks: 0          IO Block: 4096    directory
> > Device: 00:31           Inode: 256         Links: 1
> 
> So Device is 00:31, printed as two fields in hex.
> 
> > Access: (0755/drwxr-xr-x)  Uid:     0   Gid:     0
> > Access: 2021-06-16 19:16:56.644344956+0800
> > Modify: 2021-05-06 16:14:33.676248229+0800
> > Change: 2021-05-06 16:14:33.676248229+0800
> >  Birth: 2020-11-18 14:03:35.324915316+0800
> > Attributes: 0000000000002000 (........ ........ ........ ........ ........ ..-..... ..?-.... .---.-..)
> > [root@T640 vfs]# stat /ssd/
> >   File: ‘/ssd/’
> >   Size: 200             Blocks: 0          IO Block: 4096   directory
> > Device: 31h/49d Inode: 256         Links: 1
> 
> And here it's also 31, the 'h' suffix means it's hexadecimal and "49d"
> si the same value in decimal.
> 
> > Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
> > Access: 2021-06-16 19:16:56.644344956 +0800
> > Modify: 2021-05-06 16:14:33.676248229 +0800
> > Change: 2021-05-06 16:14:33.676248229 +0800
> >  Birth: -
> > 
> > vfat output sample:
> > [root@T640 vfs]# ./test-statx /boot/efi/
> > statx(/boot/efi/) = 0
> > results=17ff
> >   Size: 4096            Blocks: 8          IO Block: 4096    directory
> > Device: 08:01           Inode: 1           Links: 3
> 
> 08:01
> 
> > Access: (0700/drwx------)  Uid:     0   Gid:     0
> > Access: 1970-01-01 08:00:00.000000000+0800
> > Modify: 1970-01-01 08:00:00.000000000+0800
> > Change: 1970-01-01 08:00:00.000000000+0800
> > Attributes: 0000000000002000 (........ ........ ........ ........ ........ ..-..... ..?-.... ........)
> > [root@T640 vfs]# stat /boot/efi/
> >   File: ‘/boot/efi/’
> >   Size: 4096            Blocks: 8          IO Block: 4096   directory
> > Device: 801h/2049d      Inode: 1           Links: 3
> 
> 801h == 0801h the same value, so it's just a matter of formatting the
> output and the values are indeed the same.
> 
> If you change the format in test-statx.c to  "%2xh/%2dd" and the value
> to "(stx->stx_dev_major << 8) + stx->stx_dev_minor", the output is
> exactly the same.


'/bin/stat' output (struct stat).st_dev in both hex and decimal.

coreutils-8.32/src/stat.c
    case 'd':
      out_uint (pformat, prefix_len, statbuf->st_dev);
      break;
    case 'D':
      out_uint_x (pformat, prefix_len, statbuf->st_dev);
      break;

But I thought it output the major and minor of  (struct stat).st_dev.

That is my bad.  Thanks a lot.

Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2021/06/24



      reply	other threads:[~2021-06-23 22:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 10:12 the major/minor value of statx(kernel samples/vfs/test-statx.c) does not match /usr/bin/stat Wang Yugui
2021-06-23 20:49 ` David Sterba
2021-06-23 22:19   ` Wang Yugui [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210624061917.A9CD.409509F4@e16-tech.com \
    --to=wangyugui@e16-tech.com \
    --cc=dhowells@redhat.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox