mirror of https://github.com/trapexit/mergerfs.git
Antonio SJ Musumeci
4 years ago
30 changed files with 237 additions and 156 deletions
-
2src/branch.cpp
-
1src/config.cpp
-
122src/fs.cpp
-
44src/fs_findallfiles.cpp
-
20src/fs_findallfiles.hpp
-
28src/fs_getfl.cpp
-
24src/fs_getfl.hpp
-
2src/fs_movefile.cpp
-
42src/fs_realpathize.cpp
-
28src/fs_realpathize.hpp
-
29src/fs_setfl.cpp
-
28src/fs_setfl.hpp
-
1src/fuse_getxattr.cpp
-
1src/fuse_ioctl.cpp
-
1src/policy.cpp
-
1src/policy.hpp
-
1src/policy_epall.cpp
-
1src/policy_epff.cpp
-
1src/policy_eplfs.cpp
-
1src/policy_eplus.cpp
-
1src/policy_epmfs.cpp
-
1src/policy_ff.cpp
-
1src/policy_lfs.cpp
-
1src/policy_lus.cpp
-
1src/policy_mfs.cpp
-
1src/policy_msplfs.cpp
-
1src/policy_msplus.cpp
-
1src/policy_mspmfs.cpp
-
1src/policy_newest.cpp
-
6src/ugid.cpp
@ -1,122 +0,0 @@ |
|||
/*
|
|||
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
#include <fcntl.h>
|
|||
#include <limits.h>
|
|||
#include <stdint.h>
|
|||
#include <stdlib.h>
|
|||
|
|||
#include "errno.hpp"
|
|||
#include "fs_attr.hpp"
|
|||
#include "fs_base_realpath.hpp"
|
|||
#include "fs_base_stat.hpp"
|
|||
#include "fs_exists.hpp"
|
|||
#include "fs_path.hpp"
|
|||
#include "fs_statvfs_cache.hpp"
|
|||
#include "fs_xattr.hpp"
|
|||
#include "str.hpp"
|
|||
|
|||
using std::string; |
|||
using std::vector; |
|||
|
|||
namespace fs |
|||
{ |
|||
void |
|||
findallfiles(const vector<string> &basepaths_, |
|||
const char *fusepath_, |
|||
vector<string> *paths_) |
|||
{ |
|||
string fullpath; |
|||
|
|||
for(size_t i = 0, ei = basepaths_.size(); i != ei; i++) |
|||
{ |
|||
fullpath = fs::path::make(basepaths_[i],fusepath_); |
|||
|
|||
if(!fs::exists(fullpath)) |
|||
continue; |
|||
|
|||
paths_->push_back(fullpath); |
|||
} |
|||
} |
|||
|
|||
int |
|||
findonfs(const vector<string> &basepaths, |
|||
const string &fusepath, |
|||
const int fd, |
|||
string &basepath) |
|||
{ |
|||
int rv; |
|||
dev_t dev; |
|||
string fullpath; |
|||
struct stat st; |
|||
|
|||
rv = fs::fstat(fd,&st); |
|||
if(rv == -1) |
|||
return -1; |
|||
|
|||
dev = st.st_dev; |
|||
for(size_t i = 0, ei = basepaths.size(); i != ei; i++) |
|||
{ |
|||
fullpath = fs::path::make(basepaths[i],fusepath); |
|||
|
|||
rv = fs::lstat(fullpath,&st); |
|||
if(rv == -1) |
|||
continue; |
|||
|
|||
if(st.st_dev != dev) |
|||
continue; |
|||
|
|||
basepath = basepaths[i]; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
return (errno=ENOENT,-1); |
|||
} |
|||
|
|||
void |
|||
realpathize(vector<string> *strs_) |
|||
{ |
|||
char *rv; |
|||
|
|||
for(size_t i = 0; i < strs_->size(); i++) |
|||
{ |
|||
rv = fs::realpath((*strs_)[i]); |
|||
if(rv == NULL) |
|||
continue; |
|||
|
|||
(*strs_)[i] = rv; |
|||
|
|||
::free(rv); |
|||
} |
|||
} |
|||
|
|||
int |
|||
getfl(const int fd) |
|||
{ |
|||
return ::fcntl(fd,F_GETFL,0); |
|||
} |
|||
|
|||
int |
|||
setfl(const int fd, |
|||
const mode_t mode) |
|||
{ |
|||
return ::fcntl(fd,F_SETFL,mode); |
|||
} |
|||
}; |
@ -0,0 +1,44 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#include "fs_exists.hpp"
|
|||
#include "fs_path.hpp"
|
|||
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
namespace fs |
|||
{ |
|||
void |
|||
findallfiles(const std::vector<std::string> &basepaths_, |
|||
const char *fusepath_, |
|||
std::vector<std::string> *paths_) |
|||
{ |
|||
std::string fullpath; |
|||
|
|||
for(size_t i = 0, ei = basepaths_.size(); i != ei; i++) |
|||
{ |
|||
fullpath = fs::path::make(basepaths_[i],fusepath_); |
|||
|
|||
if(!fs::exists(fullpath)) |
|||
continue; |
|||
|
|||
paths_->push_back(fullpath); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#include <fcntl.h>
|
|||
|
|||
namespace fs |
|||
{ |
|||
int |
|||
getfl(const int fd_) |
|||
{ |
|||
return ::fcntl(fd_,F_GETFL,0); |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
namespace fs |
|||
{ |
|||
int getfl(const int fd); |
|||
} |
@ -0,0 +1,42 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#include "fs_base_realpath.hpp"
|
|||
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
namespace fs |
|||
{ |
|||
void |
|||
realpathize(std::vector<std::string> *strs_) |
|||
{ |
|||
char *rv; |
|||
|
|||
for(size_t i = 0; i < strs_->size(); i++) |
|||
{ |
|||
rv = fs::realpath((*strs_)[i]); |
|||
if(rv == NULL) |
|||
continue; |
|||
|
|||
(*strs_)[i] = rv; |
|||
|
|||
::free(rv); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
namespace fs |
|||
{ |
|||
void |
|||
realpathize(std::vector<std::string> *strs); |
|||
} |
@ -0,0 +1,29 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#include <fcntl.h>
|
|||
|
|||
namespace fs |
|||
{ |
|||
int |
|||
setfl(const int fd_, |
|||
const mode_t mode_) |
|||
{ |
|||
return ::fcntl(fd_,F_SETFL,mode_); |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
/*
|
|||
ISC License |
|||
|
|||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|||
|
|||
Permission to use, copy, modify, and/or distribute this software for any |
|||
purpose with or without fee is hereby granted, provided that the above |
|||
copyright notice and this permission notice appear in all copies. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|||
*/ |
|||
|
|||
#pragma once
|
|||
|
|||
#include <fcntl.h>
|
|||
|
|||
namespace fs |
|||
{ |
|||
int |
|||
setfl(const int fd, |
|||
const mode_t mode); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue