Skip to content

[Feature] Handle searching sparse Linux files with holesΒ #2658

@linux4life798

Description

@linux4life798

What feature would you like to see?

Add logic to detect sparse files and traverse them correctly, without getting lost in a hole.

How will this feature be useful to you and others?

I would hope that this allows for searching for ascii text in coredumps, that can sometimes be terabytes in length (via ls -alh), but it actually contains a few megabytes in real data (du -sh). The holes are just compressed spans of 0s.

Open a bunch of tabs in Chrome and try running gcore on a few chrome processes (might need to echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope to make debugging more permissive). Check the resultant core dump file size, open a large one in imhex, and try searching for any ASCII text. On my side, it simply hangs there making no progress and then eventually just gives up without an error.

Request Type

  • I can provide a PoC for this feature or am willing to work on it myself and submit a PR

Additional context?

The binutil strings gets lost in holes, too, thus I am considering this a feature add.
However, grep does not seem to get bogged down by searching the endless hole of 0s.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions