Subject: stat --printf %t, %T flags (major and minor device types) don't work on mount points
From: Tyler Hobbs <[email-masked]>
To: [email-masked]
Date: Mon, 11 Mar 2013 15:39:51 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

If I run stat --printf='%D', the result is "10ca70", which is correct.
However, if I run stat --printf='%t %T' /mountpoint, the result is
erroneously "0 0".  If I instead run stat against the device directly (stat
--printf='%t %T' /dev/xvdx), I get the correct result of "ca 170".

I believe the proper fix is to replace (in stat.c):

  out_uint_x (pformat, prefix_len, major (statbuf->st_rdev));

with:

  out_uint_x (pformat, prefix_len, major (statbuf->st_dev));

That is, use statbuf->st_dev instead of st_rdev, which is what the %d and
%D directives use.

I'm using coreutils 8.9, compiled from source, and this is the output of
uname -a:

Linux ip-10-39-122-238 2.6.32-276.el6.x86_64 #1 SMP Tue May 29 17:38:19 EDT
2012 x86_64 x86_64 x86_64 GNU/Linux

Thanks for your time.
- Tyler