summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-11 19:08:40 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-11 19:08:40 +0200
commit02028a3239f45ada950e43a9fb34e23c6a8ccbed (patch)
tree32a52c279f1c6ca2c6801379d2a43c9ddce13b07
parentc5cadd4776e5a52489e2daf09012ed7868fec886 (diff)
downloadobnam2-02028a3239f45ada950e43a9fb34e23c6a8ccbed.tar.gz
store mode in fsentry
-rw-r--r--src/fsentry.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/fsentry.rs b/src/fsentry.rs
index b8be212..7adf610 100644
--- a/src/fsentry.rs
+++ b/src/fsentry.rs
@@ -1,5 +1,6 @@
use serde::{Deserialize, Serialize};
use std::fs::{FileType, Metadata};
+use std::os::linux::fs::MetadataExt;
use std::path::{Path, PathBuf};
/// A file system entry.
@@ -16,6 +17,11 @@ pub struct FilesystemEntry {
kind: FilesystemKind,
path: PathBuf,
len: u64,
+
+ // 16 bits should be enough for a Unix mode_t.
+ // https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
+ // However, it's 32 bits on Linux, so that's what we store.
+ mode: u32,
}
#[allow(clippy::len_without_is_empty)]
@@ -24,7 +30,13 @@ impl FilesystemEntry {
let path = path.to_path_buf();
let kind = FilesystemKind::from_file_type(meta.file_type());
let len = meta.len();
- Self { path, kind, len }
+ let mode = meta.st_mode();
+ Self {
+ path,
+ kind,
+ len,
+ mode,
+ }
}
pub fn kind(&self) -> FilesystemKind {