Skip to main content

exfat-raw

PyPI version Python License OS

CI codecov

Downloads total Downloads/month Downloads/week

Raw block-level read/write of exFAT filesystem timestamps — birth time (btime) and modification time (mtime), directly from the on-disk directory entry, bypassing the kernel driver's cache.

Features

  • Read btime/mtime — parse the exFAT directory entry on the raw block device
  • Write btime and mtime — atomically update both timestamps in one raw-block access
  • 3-tier I/O fallback — tries direct os.pread/os.pwrite first (works on regular image files and accessible block devices), then loop device backing files, and finally falls back to sudo dd for restricted block devices
  • No kernel cache corruption — understands the exFAT kernel driver's directory-entry cache incoherence and avoids os.utime() / sync() after raw writes
  • Pure stdlib — zero runtime dependencies

Usage

from exfat_raw import ExfatRawIO, ExfatRawFilesystem, ExfatRawOps
from datetime import datetime, timezone

io = ExfatRawIO()
fs = ExfatRawFilesystem(io)
ops = ExfatRawOps(io, fs)

# Read birth time from a file on an exFAT mount
ts = ops.read_btime_raw("/mnt/sdcard/DCIM/100GOPRO/GH010001.MP4")
print(datetime.fromtimestamp(ts, tz=timezone.utc))

# Correct the timestamp
target = datetime(2025, 6, 15, 12, 0, 0, tzinfo=timezone.utc)
ops.fix_exfat_raw("/mnt/sdcard/DCIM/100GOPRO/GH010001.MP4", target, dry_run=False)

# Preserve btime while updating mtime
orig_btime_ts = ops.read_btime_raw(filepath)
orig_btime_dt = datetime.fromtimestamp(orig_btime_ts, tz=timezone.utc)
ops.fix_exfat_raw(filepath, new_mtime_dt, dry_run=False, btime_dt=orig_btime_dt)

# Work directly on a raw image file (no sudo, no mount)
io = ExfatRawIO()
fs = ExfatRawFilesystem(io)
boot = io.parse_boot("path/to/sdcard.img")
chain = fs.cluster_chain(boot, "path/to/sdcard.img", boot["root_cluster"])

Note: All datetime parameters must be timezone-aware (e.g., tzinfo=timezone.utc). Naive datetimes are rejected with ValueError.

Dependencies

  • Python ≥ 3.10 (stdlib only — os, struct, subprocess, tempfile, pathlib)
  • System tools: sudo, dd, findmnt, losetup — only needed for physical block devices; regular image files work with stdlib alone

Development

Running tests

Sandbox-safe (no sudo, no mount — runs a pure-Python exFAT image):

python -m unittest discover -s tests -p 'test_exfat_raw_image.py' -v

Full suite (requires sudo + loop device + exfat-fuse):

python -m unittest discover -s tests -p 'test_*.py' -v

With Nix:

nix develop                   # enter dev shell
python -m unittest discover -s tests -p 'test_*.py' -v

The Nix package's checkPhase runs only the sandbox-safe tests (see nix/exfat-raw/default.nix).


License

GNU General Public License v3.0 or later.

Metadata

Release files for exfat-raw 0.2.1

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

Source distribution (sdist)

Source distribution for exfat-raw 0.2.1
File Size Uploaded Provenance Actions
exfat_raw-0.2.1.tar.gz 34.5 kB With provenance Details for exfat_raw-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exfat-raw 0.2.1
File Interpreter ABI Platform Actions
exfat_raw-0.2.1-py3-none-any.whl Python 3 none any Details for exfat_raw-0.2.1-py3-none-any.whl

Total release size: 62.6 kB

Release files / exfat_raw-0.2.1.tar.gz

Download URL exfat_raw-0.2.1.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bb01c014d3fd945b0b458f2d8f7d84e0eea89c223aafb56e34b8d0448ac1cbd3
BLAKE2b-256 checksum
How to use checksums
87b8869b728f90573de70be8a7bd98a2c9efbcfe33203cfbcf440486e990cee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.

Transparency log

Release files / exfat_raw-0.2.1-py3-none-any.whl

Download URL exfat_raw-0.2.1-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c25e7e41132b365c89ede1014ea563d26e91ddac7cfa526957e9e9470b269f3c
BLAKE2b-256 checksum
How to use checksums
fb30b7b7c667973bbb264aea70e9f7c948730336e5f1a7aa9bef14a857e3d078
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.

Transparency log

Security for exfat-raw 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for exfat_raw-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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