mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-21 07:26:28 -05:00
Preserve directory modes when cloning paths across branches
- Restore source permissions after ownership to preserve setgid and clear unwanted inherited mode bits. - Add regression coverage for directory modes, group inheritance, and existing destination directories. - Update the branch configuration test to use the current API. - Document metadata preservation when cloning directory paths.
This commit is contained in:
parent
5d5d7af90b
commit
74eade91f5
3 changed files with 57 additions and 0 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include "errno.h"
|
||||
#include "fs_attr.hpp"
|
||||
#include "fs_clonepath.hpp"
|
||||
#include "fs_lchmod.hpp"
|
||||
#include "fs_lchown.hpp"
|
||||
#include "fs_lstat.hpp"
|
||||
#include "fs_lutimens.hpp"
|
||||
|
|
@ -111,6 +112,13 @@ fs::clonepath(const fs::path &srcpath_,
|
|||
if(return_metadata_errors_ && (rv < 0))
|
||||
return rv;
|
||||
|
||||
// mkdir(2) on Linux ignores S_ISUID/S_ISGID in mode and may
|
||||
// inherent S_ISGID from the parent. Explicitly set the mode after
|
||||
// chown so the clone matches the source.
|
||||
rv = fs::lchmod_check_on_error(dstpath,st.st_mode);
|
||||
if(return_metadata_errors_ && (rv < 0))
|
||||
return rv;
|
||||
|
||||
rv = fs::lutimens(dstpath,st);
|
||||
if(return_metadata_errors_ && (rv < 0))
|
||||
return rv;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue