Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function is_btrfs to cover <path|device> correctly. #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

develroo
Copy link

Currently, in the functions is_btrfs, stat -f will incorrectly report device paths because /dev/ is a virtual filesystem and classified as tmpfs.

Eg.

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

This is correct behaviour for stat as according to the coreutils info docs:

"stat does not search for specified device nodes in the file system list, instead operating on them directly"

As the BTRFS documentation specifies <path|device> in all the commands, this is obviously undesirable behaviour for the is_btrfs function.

This patch uses df to work around the virtual nature of devices in Linux, while still retaining compatibility with paths.

Hope this helps.

@TheGreatMcPain
Copy link

I tried this patch on my system which uses RAID5.

Unfortunately this only works for the first device in the array, since df only sees the first disk.

@TheGreatMcPain
Copy link

I think we can change is_btrfs() to this.

is_btrfs() {
    btrfs device stats $1 &>/dev/null
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants