Skip to content

Commit 5a88f61

Browse files
KSXGitHubclaudeCopilot
authored
feat: option to prevent cross-filesystem traversal (#363)
Adds support for skipping directories on different filesystems, similar to the `-x`/`--one-file-system` flag found in tools like `du`. This allows users to analyze disk usage within a single filesystem without counting mounted directories. https://claude.ai/code/session_01LfpnUZrgq93MVZgA3KVqE6 --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ff7ee36 commit 5a88f61

29 files changed

Lines changed: 534 additions & 8 deletions

.devcontainer/devcontainer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "parallel-disk-usage (Rust only)",
33
"image": "mcr.microsoft.com/devcontainers/rust:1",
4+
"remoteEnv": {
5+
"TEST_SKIP": "cross_device_excludes_mount"
6+
},
47
"customizations": {
58
"vscode": {
69
"extensions": [

.devcontainer/full/devcontainer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "parallel-disk-usage (full)",
33
"image": "mcr.microsoft.com/devcontainers/rust:1",
4+
"remoteEnv": {
5+
"TEST_SKIP": "cross_device_excludes_mount"
6+
},
47
"features": {
58
"ghcr.io/devcontainers/features/node:1": {
69
"version": "lts",

.github/workflows/deploy.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ jobs:
2929
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > $installer
3030
bash $installer --default-toolchain $(cat rust-toolchain) -y
3131
32+
- name: Install external test dependencies
33+
if: runner.os == 'Linux'
34+
run: |
35+
sudo apt update
36+
sudo apt install -y squashfs-tools squashfuse fuse3
37+
3238
- name: Test (dev)
3339
shell: bash
3440
env:

.github/workflows/test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ jobs:
4242
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > $installer
4343
bash $installer --default-toolchain $(cat rust-toolchain) -y
4444
45+
- name: Install external test dependencies
46+
if: runner.os == 'Linux'
47+
run: |
48+
sudo apt update
49+
sudo apt install -y squashfs-tools squashfuse fuse3
50+
4551
- name: Test (dev)
4652
shell: bash
4753
env:

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,16 @@ rustup toolchain install "$(< rust-toolchain)"
351351
rustup component add --toolchain "$(< rust-toolchain)" rustfmt clippy
352352
```
353353

354+
## Optional External Dependencies
355+
356+
Some integration tests require external (non-Cargo) tools that are **not** managed by `Cargo.toml`. These tests panic when the tools are absent; CI installs them to get full coverage.
357+
358+
- `squashfs-tools` (provides `mksquashfs`) — cross-device (`--one-file-system`) FUSE test
359+
- `squashfuse` (provides `squashfuse`) — cross-device (`--one-file-system`) FUSE test
360+
- `fuse3` (provides `fusermount3`, `/dev/fuse`) — cross-device (`--one-file-system`) FUSE test
361+
362+
Tests that need these tools will panic with a diagnostic message if they are missing. The panic message includes the specific `TEST_SKIP` variable to skip the test via `./test.sh`.
363+
354364
## Automated Checks
355365

356366
Before submitting, ensure:

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,4 @@ maplit = "1.0.2"
9191
normalize-path = "0.2.1"
9292
pretty_assertions = "1.4.1"
9393
rand = "0.10.0"
94+
which = "8.0.2"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ The benchmark was generated by [a GitHub Workflow](https://github.com/KSXGitHub/
6161

6262
* Ignorant of reflinks (from COW filesystems such as BTRFS and ZFS).
6363
* Does not follow symbolic links.
64-
* Does not differentiate filesystems: Mounted folders are counted as normal folders.
6564
* The runtime is optimized at the expense of binary size.
6665

6766
## Usage

USAGE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ How to display the numbers of bytes.
3939

4040
Detect and subtract the sizes of hardlinks from their parent directory totals.
4141

42+
<a id="option-x" name="option-x"></a><a id="one-file-system" name="one-file-system"></a>
43+
### `--one-file-system`
44+
45+
* _Aliases:_ `-x`.
46+
47+
Skip directories on different filesystems.
48+
4249
<a id="top-down" name="top-down"></a>
4350
### `--top-down`
4451

exports/completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _pdu() {
2323

2424
case "${cmd}" in
2525
pdu)
26-
opts="-b -H -q -d -w -m -s -p -h -V --json-input --json-output --bytes-format --detect-links --dedupe-links --deduplicate-hardlinks --top-down --align-right --quantity --depth --max-depth --width --total-width --column-width --min-ratio --no-sort --no-errors --silent-errors --progress --threads --omit-json-shared-details --omit-json-shared-summary --help --version [FILES]..."
26+
opts="-b -H -x -q -d -w -m -s -p -h -V --json-input --json-output --bytes-format --detect-links --dedupe-links --deduplicate-hardlinks --one-file-system --top-down --align-right --quantity --depth --max-depth --width --total-width --column-width --min-ratio --no-sort --no-errors --silent-errors --progress --threads --omit-json-shared-details --omit-json-shared-summary --help --version [FILES]..."
2727
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
2828
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
2929
return 0

0 commit comments

Comments
 (0)