uutils / uutils/coreutils

`df`: issues when dealing with nested mounts

Open
#6,073 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - df
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

I create this issue from a finding from pullrequest #5821.

When running tests of uutils df on my own android phone (not on AVD),
and after fixing the issue with the integer overflow addressed in #6071,
they are still failing in test test_df::test_type_option_with_file:

---- test_df::test_type_option_with_file stdout ----
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=fstype .
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -t f2fs .
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -t nonexisting .
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df --output=fstype
run: /data/data/com.termux/files/home/rust/coreutils/target/debug/coreutils df -t erofs .
thread 'test_df::test_type_option_with_file' panicked at tests/by-util/test_df.rs:292:14:
Command was expected to fail.
stdout = Filesystem       1K-blocks   Used Available Use% Mounted on
/dev/block/dm-15    595792 595792         0 100% /

 stderr = 
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    test_df::test_type_option_with_file

test result: FAILED. 48 passed; 1 failed; 0 ignored; 0 measured; 2946 filtered out; finished in 0.97s

for easier debugging and comparison (termux uses toybox df) I tried to reproduce the issue on my ubuntu.
There I tried to setup a similar setup as I have it on the phone - two nested filesystem mounts with different fstypes.
As my /home - which is a nested mount - has the same fstype as the root, I can't use it for the test.

So I simply mounted a ISO image I recently downloaded and did the tests manually there:

GNU output:

uli@hp13-ulix:/media/uli/OpenBSD_amd64   7.4 Install CD$ df -T .
Filesystem     Type    1K-blocks   Used Available Use% Mounted on
/dev/loop20    iso9660    617966 617966         0 100% /media/uli/OpenBSD_amd64   7.4 Install CD
uli@hp13-ulix:/media/uli/OpenBSD_amd64   7.4 Install CD$ df -T -t iso9660 .
Filesystem     Type    1K-blocks   Used Available Use% Mounted on
/dev/loop20    iso9660    617966 617966         0 100% /media/uli/OpenBSD_amd64   7.4 Install CD
uli@hp13-ulix:/media/uli/OpenBSD_amd64   7.4 Install CD$ df -T -t ext4 .
df: no file systems processed

uutils output:

uli@hp13-ulix:/media/uli/OpenBSD_amd64   7.4 Install CD$ ~/dev_rust/coreutils/target/debug/coreutils df -T .
Filesystem     Type 1K-blocks     Used Available Use% Mounted on
/dev/nvme0n1p7 ext4 100904268 34242964  61489496  36% /
uli@hp13-ulix:/media/uli/OpenBSD_amd64   7.4 Install CD$ ~/dev_rust/coreutils/target/debug/coreutils df -T -t iso9660 .
df: no file systems processed
uli@hp13-ulix:/media/uli/OpenBSD_amd64   7.4 Install CD$ ~/dev_rust/coreutils/target/debug/coreutils df -T -t ext4 .
Filesystem     Type 1K-blocks     Used Available Use% Mounted on
/dev/nvme0n1p7 ext4 100904268 34242964  61489496  36% /

So, even worse then on android, uutils wrongly ignores the nested mount of ISO image and reports type ext4 of root mount.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/by-util/test_df.rs, especially test_df::test_type_option_with_file, and reproduce the nested-mount cases on Linux or Android. Compare uutils output with GNU df for nested filesystems and -t filters; done means the nested mount is selected and filesystem-type filtering matches the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.