magic_mount: use trusted.overlay.opaque
This commit is contained in:
@@ -15,6 +15,9 @@ use std::fs;
|
|||||||
use std::fs::{create_dir, create_dir_all, read_dir, DirEntry, FileType};
|
use std::fs::{create_dir, create_dir_all, read_dir, DirEntry, FileType};
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use extattr::lgetxattr;
|
||||||
|
|
||||||
|
const REPLACE_DIR_XATTR: &str = "trusted.overlay.opaque";
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
|
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
|
||||||
enum NodeFileType {
|
enum NodeFileType {
|
||||||
@@ -52,10 +55,12 @@ impl Node {
|
|||||||
let mut has_file = false;
|
let mut has_file = false;
|
||||||
for entry in dir.read_dir()?.flatten() {
|
for entry in dir.read_dir()?.flatten() {
|
||||||
let name = entry.file_name().to_string_lossy().to_string();
|
let name = entry.file_name().to_string_lossy().to_string();
|
||||||
if name == ".replace" {
|
let path = dir.join(&name);
|
||||||
has_file = true;
|
if let Ok(v) = lgetxattr(&path, REPLACE_DIR_XATTR) {
|
||||||
self.replace = true;
|
if String::from_utf8_lossy(&v) == "y" {
|
||||||
continue;
|
has_file = true;
|
||||||
|
self.replace = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_type = entry.file_type()?;
|
let file_type = entry.file_type()?;
|
||||||
@@ -63,7 +68,7 @@ impl Node {
|
|||||||
let node = match self.children.entry(name.clone()) {
|
let node = match self.children.entry(name.clone()) {
|
||||||
Entry::Occupied(o) => Some(o.into_mut()),
|
Entry::Occupied(o) => Some(o.into_mut()),
|
||||||
Entry::Vacant(v) => {
|
Entry::Vacant(v) => {
|
||||||
Self::new_module(&name, file_type, dir.join(&name)).map(|it| v.insert(it))
|
Self::new_module(&name, file_type, &path).map(|it| v.insert(it))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user