mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 21:00:13 -05:00
refactor: remove the unfinished _clonepath2
It was never called and only produced an unused-function warning. Drop the includes only it used and a duplicate fs_clonepath.hpp include, and fix a typo in a comment.
This commit is contained in:
parent
cf8c489ae2
commit
e47e82b3f9
1 changed files with 1 additions and 72 deletions
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "errno.h"
|
||||
#include "fs_attr.hpp"
|
||||
#include "fs_clonepath.hpp"
|
||||
#include "fs_lchmod.hpp"
|
||||
#include "fs_lchown.hpp"
|
||||
#include "fs_lstat.hpp"
|
||||
|
|
@ -29,16 +28,6 @@
|
|||
#include "fs_path.hpp"
|
||||
#include "fs_xattr.hpp"
|
||||
|
||||
#include "fs_close.hpp"
|
||||
#include "fs_fstat.hpp"
|
||||
#include "fs_mkdirat.hpp"
|
||||
#include "fs_openat.hpp"
|
||||
#include "fs_fchown.hpp"
|
||||
#include "fs_fchmod.hpp"
|
||||
#include "fs_futimens.hpp"
|
||||
|
||||
#include "scope_guard/scope_guard.hpp"
|
||||
|
||||
|
||||
static
|
||||
bool
|
||||
|
|
@ -113,7 +102,7 @@ fs::clonepath(const fs::path &srcpath_,
|
|||
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
|
||||
// inherit 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))
|
||||
|
|
@ -125,63 +114,3 @@ fs::clonepath(const fs::path &srcpath_,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// WORK IN PROGRESS
|
||||
static
|
||||
int
|
||||
_clonepath2(const int srcfd_,
|
||||
const int dstfd_,
|
||||
const fs::path &dirname_,
|
||||
const bool return_metadata_errors_)
|
||||
{
|
||||
int rv;
|
||||
int srcdirfd;
|
||||
int dstdirfd;
|
||||
struct stat st;
|
||||
|
||||
if(dirname_.empty())
|
||||
return 0;
|
||||
|
||||
rv = fs::mkdirat(dstfd_,dirname_,0);
|
||||
if(rv < 0)
|
||||
return ((rv == -EEXIST) ? 0 : rv);
|
||||
|
||||
srcdirfd = fs::openat(srcfd_,dirname_,O_DIRECTORY);
|
||||
if(srcdirfd < 0)
|
||||
return srcdirfd;
|
||||
DEFER { fs::close(srcdirfd); };
|
||||
|
||||
dstdirfd = fs::openat(dstfd_,dirname_,O_DIRECTORY);
|
||||
if(dstdirfd < 0)
|
||||
return dstdirfd;
|
||||
DEFER { fs::close(dstdirfd); };
|
||||
|
||||
rv = fs::attr::copy(srcdirfd,dstdirfd,FS_ATTR_CLEAR_IMMUTABLE);
|
||||
if(return_metadata_errors_ && (rv < 0) && !::_ignorable_error(-rv))
|
||||
return rv;
|
||||
|
||||
rv = fs::xattr::copy(srcdirfd,dstdirfd);
|
||||
if(return_metadata_errors_ && (rv < 0) && !::_ignorable_error(-rv))
|
||||
return rv;
|
||||
|
||||
rv = fs::fstat(srcdirfd,&st);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
if(!S_ISDIR(st.st_mode))
|
||||
return -ENOTDIR;
|
||||
|
||||
rv = fs::fchown_check_on_error(dstdirfd,st);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
|
||||
rv = fs::fchmod_check_on_error(dstdirfd,st);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
|
||||
rv = fs::futimens(dstdirfd,st);
|
||||
if(rv < 0)
|
||||
return rv;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue