An implementation of the NTFS filesystem in a Rust crate

 2 years ago
source link: https://colinfinck.de/posts/an-implementation-of-the-ntfs-filesystem-in-a-rust-crate/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

An implementation of the NTFS filesystem in a Rust crate


Happy new year everybody! It’s finally time to reveal a project I have been working on over several weekends of the past year. It’s also the next building block on my mission to write a ReactOS/Windows bootloader in Rust.

ntfs is a Rust library that implements the low-level structures of the NTFS filesystem.
For those of you who are not running Windows: NTFS is the primary filesystem in Windows, from Windows NT’s release in 1993 up to the current Windows 11. Unlike FAT32, NTFS has no practical limits for file and partition sizes, comes with B-Tree Indexes for faster lookups, and adds a few resilience and efficiency features (such as journaling, compression, and sparse files). This plethora of features combined with the lack of official documentation is also what has kept the number of alternative NTFS implementations low. Although you can expect NTFS on pretty much every external hard drive you buy in a store, it never replaced FAT32 as the filesystem of choice for multiplatform data exchange.

Like my previous nt-hive crate, the ntfs crate supports Rust’s no_std environment and is therefore not tied to a specific platform API. It aims to be embedded in firmware-level code and kernel-mode filesystem drivers just as well as in user-mode applications.

ntfs-shell example

My crate comes with ntfs-shell, an example application to demonstrate all library features.
Use it to explore the internal structures of an NTFS filesystem at any detail level, even of your running Windows partition. No artificial security restrictions will block you from accessing files and folders, extracting their data or Alternate Data Streams. The filesystem is opened read-only, so you can safely browse even a mounted filesystem without worrying about data corruption.


As most Rust crates, this one is dual-licensed under the Apache 2.0 and MIT licenses to enable a broad usage. Check out the GitHub repo for the code, crates.io for the crate, and docs.rs for the documentation.

I hope my work contributes towards making NTFS less of a mystery, and a supported filesystem for future Rust-powered operating systems.
For that, I will also be talking about NTFS and my crate at the upcoming virtual FOSDEM event on 5 February. Looking forward to see you!

Finally, a big shoutout to the Linux-NTFS Documentation! This was by far the resource I consulted most during development. Implementations come and go, but good documentation is forever :)

About Joyk

Aggregate valuable and interesting links.
Joyk means Joy of geeK