GNU bug report logs -
#64588
BUG: stat -f incorrectly reports a BTRFS device as a tmpfs
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 64588 in the body.
You can then email your comments to 64588 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#64588
; Package
coreutils
.
(Thu, 13 Jul 2023 03:28:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"debug <at> roosoft.ltd.uk" <debug <at> roosoft.ltd.uk>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Thu, 13 Jul 2023 03:28:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
coreutils version 9.1-1 on Debian testing, but also exists in previous
versions.
Example:
stat -f /dev/sdb
File: "/dev/sdb"
ID: eb91af7d7bda02dd Namelen: 255 Type: tmpfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 2012292 Free: 2012292 Available: 2012292
Inodes: Total: 2012292 Free: 2011839
stat -f /dev/disk/by-uuid/6abaa68a-2670-4d8b-8d2a-fd7321df9242
File: "/dev/disk/by-uuid/6abaa68a-2670-4d8b-8d2a-fd7321df9242"
ID: eb91af7d7bda02dd Namelen: 255 Type: tmpfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 2012292 Free: 2012292 Available: 2012292
Inodes: Total: 2012292 Free: 2011839
blkid /dev/sdb
/dev/sdb: UUID="6abaa68a-2670-4d8b-8d2a-fd7321df9242"
UUID_SUB="d15f1846-8f18-4ba0-9e2a-a6aaa7bbf83b" BLOCK_SIZE="4096"
TYPE="btrfs"
Not sure why the reported fstype is wrong but obviously it is a bug.
TIA
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#64588
; Package
coreutils
.
(Thu, 13 Jul 2023 10:00:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 64588 <at> debbugs.gnu.org (full text, mbox):
tag 64588 notabug
close 64588
stop
On 12/07/2023 23:46, support wrote:
> coreutils version 9.1-1 on Debian testing, but also exists in previous
> versions.
>
>
> Example:
>
> stat -f /dev/sdb
> File: "/dev/sdb"
> ID: eb91af7d7bda02dd Namelen: 255 Type: tmpfs
> Block size: 4096 Fundamental block size: 4096
> Blocks: Total: 2012292 Free: 2012292 Available: 2012292
> Inodes: Total: 2012292 Free: 2011839
>
>
> stat -f /dev/disk/by-uuid/6abaa68a-2670-4d8b-8d2a-fd7321df9242
> File: "/dev/disk/by-uuid/6abaa68a-2670-4d8b-8d2a-fd7321df9242"
> ID: eb91af7d7bda02dd Namelen: 255 Type: tmpfs
> Block size: 4096 Fundamental block size: 4096
> Blocks: Total: 2012292 Free: 2012292 Available: 2012292
> Inodes: Total: 2012292 Free: 2011839
>
>
> blkid /dev/sdb
> /dev/sdb: UUID="6abaa68a-2670-4d8b-8d2a-fd7321df9242"
> UUID_SUB="d15f1846-8f18-4ba0-9e2a-a6aaa7bbf83b" BLOCK_SIZE="4096"
> TYPE="btrfs"
>
>
> Not sure why the reported fstype is wrong but obviously it is a bug.
This is expected. From the info docs:
"stat does not search for specified device nodes in the file system list,
instead operating on them directly"
I.e. /dev/sdb is a device node in the /dev file system, which is tmpfs.
You can confirm this with:
strace -e statfs stat -f -c %T /dev/sdb
strace -e statfs df --output=fstype /dev/sdb
If you wanted to operate on a file system mounted on the device node you could:
stat -f $(df --output=target /dev/sdb | tail -n1)
cheers,
Pádraig
Added tag(s) notabug.
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Thu, 13 Jul 2023 10:00:03 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
64588 <at> debbugs.gnu.org and "debug <at> roosoft.ltd.uk" <debug <at> roosoft.ltd.uk>
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Thu, 13 Jul 2023 10:00:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#64588
; Package
coreutils
.
(Thu, 13 Jul 2023 10:35:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 64588 <at> debbugs.gnu.org (full text, mbox):
Hmmm ok,
Well the reason I flagged it as a bug, is because the btrfsmaintenance
package uses a script to test to see if a filesystem is btrfs and
incorrectly uses stat -f to do it. This must have worked in the past
else they would not use it.
The code snippet is:
# function: is_btrfs
# parameter: path to a mounted filesystem
#
# check if filesystem is a btrfs
is_btrfs() {
local FS=$(stat -f --format=%T "$1")
[ "$FS" = "btrfs" ] && return 0
return 1
}
Obviously that is targeted at mounted filesystems, but the documentation
and usage always shows "<path>|<device>" as a parameter.
I guess I should file a bug against that package but I am curious as to
when the default behaviour changed.
Thanks for your response.
On 13/07/2023 10:59, Pádraig Brady wrote:
> tag 64588 notabug
> close 64588
> stop
>
> On 12/07/2023 23:46, support wrote:
>> coreutils version 9.1-1 on Debian testing, but also exists in previous
>> versions.
>>
>>
>> Example:
>>
>> stat -f /dev/sdb
>> File: "/dev/sdb"
>> ID: eb91af7d7bda02dd Namelen: 255 Type: tmpfs
>> Block size: 4096 Fundamental block size: 4096
>> Blocks: Total: 2012292 Free: 2012292 Available: 2012292
>> Inodes: Total: 2012292 Free: 2011839
>>
>>
>> stat -f /dev/disk/by-uuid/6abaa68a-2670-4d8b-8d2a-fd7321df9242
>> File: "/dev/disk/by-uuid/6abaa68a-2670-4d8b-8d2a-fd7321df9242"
>> ID: eb91af7d7bda02dd Namelen: 255 Type: tmpfs
>> Block size: 4096 Fundamental block size: 4096
>> Blocks: Total: 2012292 Free: 2012292 Available: 2012292
>> Inodes: Total: 2012292 Free: 2011839
>>
>>
>> blkid /dev/sdb
>> /dev/sdb: UUID="6abaa68a-2670-4d8b-8d2a-fd7321df9242"
>> UUID_SUB="d15f1846-8f18-4ba0-9e2a-a6aaa7bbf83b" BLOCK_SIZE="4096"
>> TYPE="btrfs"
>>
>>
>> Not sure why the reported fstype is wrong but obviously it is a bug.
>
> This is expected. From the info docs:
>
> "stat does not search for specified device nodes in the file system list,
> instead operating on them directly"
>
> I.e. /dev/sdb is a device node in the /dev file system, which is tmpfs.
> You can confirm this with:
>
> strace -e statfs stat -f -c %T /dev/sdb
> strace -e statfs df --output=fstype /dev/sdb
>
> If you wanted to operate on a file system mounted on the device node
> you could:
>
> stat -f $(df --output=target /dev/sdb | tail -n1)
>
> cheers,
> Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#64588
; Package
coreutils
.
(Thu, 13 Jul 2023 12:36:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 64588 <at> debbugs.gnu.org (full text, mbox):
On 13/07/2023 11:33, support wrote:
> Hmmm ok,
>
> Well the reason I flagged it as a bug, is because the btrfsmaintenance
> package uses a script to test to see if a filesystem is btrfs and
> incorrectly uses stat -f to do it. This must have worked in the past
> else they would not use it.
>
> The code snippet is:
>
>
> # function: is_btrfs
> # parameter: path to a mounted filesystem
> #
> # check if filesystem is a btrfs
> is_btrfs() {
> local FS=$(stat -f --format=%T "$1")
> [ "$FS" = "btrfs" ] && return 0
> return 1
> }
>
>
> Obviously that is targeted at mounted filesystems, but the documentation
> and usage always shows "<path>|<device>" as a parameter.
>
> I guess I should file a bug against that package but I am curious as to
> when the default behaviour changed.
It has never changed AFAIK
thanks,
Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#64588
; Package
coreutils
.
(Thu, 13 Jul 2023 16:03:01 GMT)
Full text and
rfc822 format available.
Message #21 received at 64588 <at> debbugs.gnu.org (full text, mbox):
On Jul 13 2023, support wrote:
> # function: is_btrfs
> # parameter: path to a mounted filesystem
A device node is not a path to a mounted filesystem
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 11 Aug 2023 11:24:12 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 312 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.