Fix clone_attr for newly created dirs

This commit is contained in:
LoveSy 2023-12-09 00:55:25 +08:00 committed by John Wu
parent c013a349af
commit f7e471616d

View File

@ -163,7 +163,7 @@ void module_node::mount() {
void tmpfs_node::mount() { void tmpfs_node::mount() {
string src = mirror_path(); string src = mirror_path();
const char *src_path = access(src.data(), F_OK) == 0 ? src.data() : parent()->node_path().data(); const char *src_path = access(src.data(), F_OK) == 0 ? src.data() : nullptr;
if (!isa<tmpfs_node>(parent())) { if (!isa<tmpfs_node>(parent())) {
const string &dest = node_path(); const string &dest = node_path();
auto worker_dir = worker_path(); auto worker_dir = worker_path();
@ -172,12 +172,12 @@ void tmpfs_node::mount() {
dir_node::mount(); dir_node::mount();
VLOGD(skip_mirror() ? "replace" : "move", worker_dir.data(), dest.data()); VLOGD(skip_mirror() ? "replace" : "move", worker_dir.data(), dest.data());
xmount(worker_dir.data(), dest.data(), nullptr, MS_MOVE, nullptr); xmount(worker_dir.data(), dest.data(), nullptr, MS_MOVE, nullptr);
clone_attr(src_path, dest.data()); clone_attr(src_path ?: parent()->node_path().data(), dest.data());
} else { } else {
const string dest = worker_path(); const string dest = worker_path();
// We don't need another layer of tmpfs if parent is tmpfs // We don't need another layer of tmpfs if parent is tmpfs
mkdir(dest.data(), 0); mkdir(dest.data(), 0);
clone_attr(src_path, dest.data()); clone_attr(src_path ?: parent()->worker_path().data(), dest.data());
dir_node::mount(); dir_node::mount();
} }
} }