Skip to content
This repository was archived by the owner on Nov 1, 2025. It is now read-only.

Commit 8508566

Browse files
5ec1cffbackslashxx
authored andcommitted
magic_mount: use trusted.overlay.opaque
1 parent dde1efb commit 8508566

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

userspace/ksud/src/magic_mount.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ use std::fs;
1515
use std::fs::{create_dir, create_dir_all, read_dir, DirEntry, FileType};
1616
use std::os::unix::fs::symlink;
1717
use std::path::{Path, PathBuf};
18+
use extattr::lgetxattr;
19+
20+
const REPLACE_DIR_XATTR: &str = "trusted.overlay.opaque";
1821

1922
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
2023
enum NodeFileType {
@@ -52,18 +55,20 @@ impl Node {
5255
let mut has_file = false;
5356
for entry in dir.read_dir()?.flatten() {
5457
let name = entry.file_name().to_string_lossy().to_string();
55-
if name == ".replace" {
56-
has_file = true;
57-
self.replace = true;
58-
continue;
58+
let path = dir.join(&name);
59+
if let Ok(v) = lgetxattr(&path, REPLACE_DIR_XATTR) {
60+
if String::from_utf8_lossy(&v) == "y" {
61+
has_file = true;
62+
self.replace = true;
63+
}
5964
}
6065

6166
let file_type = entry.file_type()?;
6267

6368
let node = match self.children.entry(name.clone()) {
6469
Entry::Occupied(o) => Some(o.into_mut()),
6570
Entry::Vacant(v) => {
66-
Self::new_module(&name, file_type, dir.join(&name)).map(|it| v.insert(it))
71+
Self::new_module(&name, file_type, &path).map(|it| v.insert(it))
6772
}
6873
};
6974

0 commit comments

Comments
 (0)