Skip to main content

⛓️‍💥 filefrag

Python library to get FIE and command line tool

📦 Install

See the video for a demo including installing from source, but you can install with pip:

pip install filefrag

▶️ Usage

Run pyfilefrag on the command line. See --help for details. It has --verbose, and --json outputs for your parsing pleasure.

To use the library, just call filefrag.FileMap('/path/whatever') to build a map of the extents in the file using ioctl’s interface. Then you can poke about in the guts of a file:

  • ⛓️‍💥 inspect fragmentation
  • 🔍 find out where data is on your physical drive
  • 🟰 compare extents between paths
  • 📔 use them as dict keys
  • 🕳️ check files for holes, like before and after hole punching
  • ✅ verify your deduplication strategy, write your own stats tool
  • 💩 dump file layouts to json (print(f"{filemap:j}")
  • ⚠️ break your disk because you believed the outputs of this alpha release!

Comes with a Device class to do comparisons, so it ought to work with fragments in files on different mountpoints, bind mounts and so on (unfortunately not snap’s FUSE mounts; they’re far too abstract and piped in via a socket)

🎓 Example

from filefrag import FileMap

mapping = FileMap('/usr/bin/bash')

print(mapping.extents)
print(extents)

⚖️ License

Licensed under the WTFPL with one additional clause:

  1. Don't blame me.

Do whatever the fuck you want, just don't blame me.

🤝 Contributing

Not that this thing will ever be big enough to need a code of conduct, but it's a good excuse to pimp out my common fucking sense code of conduct.

🔗 Links

Release files for filefrag 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for filefrag 0.0.3
File Size Uploaded
filefrag-0.0.3.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for filefrag 0.0.3
File Interpreter ABI Platform
filefrag-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / filefrag-0.0.3.tar.gz

Download URL filefrag-0.0.3.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
976453dcdb397fee1bc2caf8218d8b92375f6513324450f4ce06187598c6fc59
BLAKE2b-256 checksum
How to use checksums
5ac0e99b18eb4645948541e41fb3172b7a048a137243f1215b5d2aedf63b3014
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / filefrag-0.0.3-py3-none-any.whl

Download URL filefrag-0.0.3-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c303b9526a9dfb9f38caf0932844a6ec67a545c4ed7cbb78b1b3bb6ece917f87
BLAKE2b-256 checksum
How to use checksums
97ebc486c35aeb5045b70ee109f22647c70b1a253b1d005501d51a57d29e1a8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release history Release notifications | RSS feed

0.1.0

2 release files

0.0.4

2 release files

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page