Skip to main content

Raw block-level read/write of exFAT filesystem timestamps (birth time, modification time)

Project description

exfat-raw

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
  • Backing-file fast path — uses os.pread/os.pwrite on loop device backing files (no subprocess overhead) with fallback to sudo dd for physical 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)

Dependencies

  • Python ≥ 3.10 (stdlib only — os, struct, subprocess, tempfile, pathlib)
  • System tools: sudo, dd, findmnt, losetup (for backing-file resolution and physical device fallback)

License

GNU General Public License v3.0 or later.


Extracted from gopro-timestamp-corrector.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exfat_raw-0.1.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

exfat_raw-0.1.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file exfat_raw-0.1.0.tar.gz.

File metadata

  • Download URL: exfat_raw-0.1.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for exfat_raw-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e49d6b59df1ca6c3de7d1d61dcb26c11a6efae4ce3067715d17b38deb6892198
MD5 b0b15dab75d7a560b177face39c65e15
BLAKE2b-256 0a1104e506156291c5fb763529cf2bf03d2584e05914321cf9bcbcddb2453569

See more details on using hashes here.

Provenance

The following attestation bundles were made for exfat_raw-0.1.0.tar.gz:

Publisher: publish.yml on MBanucu/exfat-raw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file exfat_raw-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: exfat_raw-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for exfat_raw-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a113964b188cf156bddf08669de078b16d6ce2de17e7eda9279f3c1506b1cd72
MD5 57f33f9f66907ca055902860242d3c0a
BLAKE2b-256 ea0fa329d2099171dd5d5e9f6e72604283813eb401cd7afb4acd43687f086132

See more details on using hashes here.

Provenance

The following attestation bundles were made for exfat_raw-0.1.0-py3-none-any.whl:

Publisher: publish.yml on MBanucu/exfat-raw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page