Crate e2p_fileflags

source ·
Expand description

Read and set ext2/ext3/ext4/btrfs/xfs/f2fs file flags like with lsattr and chattr from e2fsprogs

e2p-fileflags provides access to ext* file flags. This provides similar functionality as to the lsattr and chattr command line tools on Linux. Which flags exist, depends on the file system used. This crate uses libe2p in the background, which originates from e2fsprogs and supports flags for ext2, ext3, ext4, btrfs, xfs and f2fs file systems.

Example

use std::fs::{remove_file,File};
use std::path::Path;
use e2p_fileflags::{FileFlags,Flags};

let f = File::create("./fileflags_testfile.txt").expect("Could not create testfile");
f.set_flags(Flags::NOCOW).expect("Could not set flags");
println!("New flags: {:?}", f.flags().expect("Could not read flags"));

let p = Path::new("./fileflags_testfile.txt");
p.set_flags(Flags::NOCOW | Flags::NOATIME).expect("Could not set flags");
println!("New flags: {:?}", p.flags().expect("Could not read flags"));

drop(f);
let _ = remove_file(p);

Structs

  • Bitflags struct representing one or multiple file flags

Traits