Skip to content

Commit 6f2fa3d

Browse files
committed
fix: add support for ZFS and reiserfs
1 parent a887676 commit 6f2fa3d

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

build.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn get_supported_filesystems() -> Result<Vec<String>, std::io::Error> {
1111
let file = File::open("/proc/filesystems")?;
1212
let reader = BufReader::new(file);
1313
let mut filesystems = Vec::new();
14-
14+
1515
for line in reader.lines() {
1616
if let Ok(line) = line {
1717
let parts: Vec<&str> = line.split_whitespace().collect();
@@ -21,7 +21,7 @@ fn get_supported_filesystems() -> Result<Vec<String>, std::io::Error> {
2121
}
2222
}
2323
}
24-
24+
2525
Ok(filesystems)
2626
}
2727

@@ -34,8 +34,7 @@ fn get_supported_filesystems() -> Result<Vec<String>, std::io::Error> {
3434
fn main() {
3535
// Re-run build script if filesystem list changes
3636
println!("cargo:rerun-if-changed=/proc/filesystems");
37-
38-
37+
3938
//set threadcounts for rayon.
4039
const MIN_THREADS: usize = 1;
4140
let num_threads =
@@ -46,24 +45,19 @@ fn main() {
4645
let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) };
4746
println!("cargo:rustc-env=FDF_PAGE_SIZE={page_size}");
4847

49-
5048
// Check for reiser filesystem support and set env var appropriately
5149
match get_supported_filesystems() {
5250
Ok(filesystems) => {
5351
let has_reiser = filesystems.iter().any(|fs| fs.starts_with("reiser"));
5452

5553
if has_reiser {
56-
57-
println!("cargo:rustc-env=HAS_REISER_FS=TRUE");
54+
println!("cargo:rustc-env=HAS_REISER_FS=TRUE");
5855
}
59-
60-
6156
}
6257
Err(e) => {
6358
// If we can't read /proc/filesystems, assume reiserfs is false
6459
println!("cargo:warning=Failed to read /proc/filesystems: {}", e);
6560
//Don't set env var, it's irrelevant, it only has to exist for reiser fs to be detected
66-
6761
}
6862
}
6963
}

src/iter.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,17 @@ pub trait DirentConstructor {
456456
XFS 255 bytes
457457
ZFS 1023 bytes
458458
NTFS 255 UTF-16 / 510 bytes
459-
459+
460460
*/
461461

462462
// Max dirent length determined at build time based on supported filesystems
463-
// Reiser4 max (3976) + NUL otherwise to set to ZFS max (1023) +NUL
464-
const MAX_SIZED_DIRENT_LENGTH: usize = if option_env!("HAS_REISER_FS").is_some() { 3976 + 1 } else { 1023 + 1 };
465-
463+
// Reiser4 max (3976) + NUL otherwise to set to ZFS max (1023) +NUL
464+
const MAX_SIZED_DIRENT_LENGTH: usize = if option_env!("HAS_REISER_FS").is_some() {
465+
3976 + 1
466+
} else {
467+
1023 + 1
468+
};
469+
466470
// Allocate exact size and copy in one operation
467471
let total_capacity = base_len + needs_slash + MAX_SIZED_DIRENT_LENGTH;
468472
let mut path_buffer = Vec::with_capacity(total_capacity);

0 commit comments

Comments
 (0)