Feature Request: Support std::fs::Metadata.created() on proc and tmpfs FS on linux


If you try to use Metadata in std::fs - Rust on linux on /proc or tmpfs filesystems, you get the following error:

Error { kind: Uncategorized, message: "creation time is not available for the filesystem" }'

Looking at rust/fs.rs at 3b263ceb5cb89b6d53b5a03b47ec447c3a7f7765 · rust-lang/rust · GitHub

It seems those 2 FS are not supported on linux? The created() method works on ext4 for example.

If the underlying filesystem does not support it then there's not much Rust can do. A file creation timestamp (btime) is simply not supported by a lot of filesystems.


If you look at the rest of the module in rust/fs.rs, you'll see that the Rust side of the code is translating return codes from the statx syscall into Rust errors or successful results.

To get created() working on procfs and tmpfs, you'll unfortunately need to work on the Linux kernel code for those filesystems, and shepherd a suitable patch set through the Linux kernel process. Once you're on a kernel that supports creation time for procfs and tmpfs, the Rust code for std::fs::Metadata will automatically pick up the creation time.


Related discussion: tmpfs: support for file creation time

1 Like

Support of created time for tmpfs is now in linux-next: tmpfs: support for file creation time · torvalds/linux@f7cd16a · GitHub

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.