checkpoint

This commit is contained in:
Antonio SJ Musumeci 2022-05-15 20:54:43 -04:00
parent 5e48ba69b5
commit 551ee1ab05
141 changed files with 8465 additions and 0 deletions

2417
src/EmbeddableWebServer.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_access_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::ACCESS
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const int mask);
private:
POLICY::Base::Ptr _access;
};
}

View file

@ -0,0 +1,37 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include <memory>
namespace FUSE::ACCESS::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const int mask) = 0;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_access_policy_factory.hpp"
#include "fuse_access_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::ACCESS::POLICY
{
Base::Ptr
Factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","access","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_access_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::ACCESS::POLICY
{
Base::Ptr
Factory(const toml::value &);
}

View file

@ -0,0 +1,52 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_access_policy_ff.hpp"
#include "fs_eaccess.hpp"
FUSE::ACCESS::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::ACCESS::POLICY::FF::operator()(const gfs::path &fusepath_,
const int mode_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::eaccess(fullpath,mode_);
if(rv != 0)
continue;
return 0;
}
}
return -errno;
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_access_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::ACCESS::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const int mode) final;
private:
Branches2 _branches;
};
}

42
src/fuse_chmod_policy.hpp Normal file
View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chmod_policy_base.hpp"
#include "toml.hpp"
#include <sys/stat.h>
namespace FUSE::CHMOD
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode);
private:
POLICY::Base::Ptr _chmod;
};
}

View file

@ -0,0 +1,49 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chmod_policy_all.hpp"
#include "fuse_chmod_err.hpp"
#include "fs_lchmod.hpp"
FUSE::CHMOD::POLICY::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CHMOD::POLICYALL::operator()(const gfs::path &fusepath_,
const mode_t mode_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lchmod(fullpath,mode_);
}
}
return rv;
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chmod_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::CHMOD::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,37 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include <memory>
namespace FUSE::CHMOD::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode) = 0;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chmod_policy_factory.hpp"
#include "fuse_chmod_policy_all.hpp"
#include <stdexcept>
namespace FUSE::CHMOD::POLICY
{
Base::Ptr
Factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","chmod","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chmod_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CHMOD::POLICY
{
Base::Ptr
Factory(const toml::value &);
}

43
src/fuse_chown_policy.hpp Normal file
View file

@ -0,0 +1,43 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chown_policy_base.hpp"
#include "toml.hpp"
#include <sys/stat.h>
namespace FUSE::CHOWN
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid);
private:
POLICY::Base::Ptr _chown;
};
}

View file

@ -0,0 +1,50 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chown_policy_all.hpp"
#include "fuse_chown_err.hpp"
#include "fs_lchown.hpp"
FUSE::CHOWN::POLICY::all::all(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CHOWN::POLICY::all::operator()(const gfs::path &fusepath_,
const uid_t uid_,
const gid_t gid_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lchown(fullpath,uid_,gid_);
}
}
return rv;
}

View file

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chown_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::CHOWN::POLICY
{
class all : public base
{
public:
all(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include <memory>
#include <unistd.h>
namespace FUSE::CHOWN::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const uid_t uid,
const gid_t gid) = 0;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chown_policy_factory.hpp"
#include "fuse_chown_policy_all.hpp"
#include <stdexcept>
namespace FUSE::CHOWN::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","chown","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_chown_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CHOWN::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_create_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CREATE
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi);
private:
POLICY::Base::Ptr _create;
};
}

View file

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include "fuse.h"
#include <memory>
namespace FUSE::CREATE::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) = 0;
};
}

View file

@ -0,0 +1,68 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_create_policy_epff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_open.hpp"
FUSE::CREATE::POLICY::EPFF::EPFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CREATE::POLICY::EPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
continue;
if(rv >= 0)
mode &= umask_;
rv = fs::open(fullpath,ffi_->flags,mode);
if(rv == -ENOENT)
continue;
if(rv < 0)
return rv;
ffi_->fh = reinterpret_cast<uint64_t>(new FileInfo(rv,fusepath_));
return 0;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,44 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_create_policy_base.hpp"
#include "branches.hpp"
#include "fs_path.hpp"
namespace FUSE::CREATE::POLICY
{
class EPFF : public Base
{
public:
EPFF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_create_policy_factory.hpp"
#include "fuse_create_policy_ff.hpp"
#include "fuse_create_policy_epff.hpp"
#include <stdexcept>
namespace FUSE::CREATE::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","create","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
if(str == "epff")
return std::make_shared<EPFF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_create_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::CREATE::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,86 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_create_policy_ff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_clonepath.hpp"
#include "fs_clonepath_branches.hpp"
#include "fs_open.hpp"
#include "ugid.hpp"
FUSE::CREATE::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::CREATE::POLICY::FF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
fuse_file_info_t *ffi_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
rv = fs::acl::dir_has_defaults(fullpath);
}
if(rv >= 0)
mode &= ~umask_;
rv = fs::open(fullpath,ffi_->flags,mode);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
{
rv = fs::acl::dir_has_defaults(fullpath);
if(rv >= 0)
mode &= ~umask_;
rv = fs::open(fullpath,ffi_->flags,mode);
}
}
if(rv < 0)
return rv;
ffi_->fh = reinterpret_cast<uint64_t>(new FileInfo(rv,fusepath_));
return 0;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_create_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::CREATE::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,45 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_base.hpp"
#include "fuse_timeouts.h"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETATTR
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout);
private:
POLICY::Base::Ptr _getattr;
};
}

View file

@ -0,0 +1,75 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_aggregate.hpp"
#include "timespec.hpp"
#include <limits.h>
FUSE::GETATTR::POLICY::Aggregate::Aggregate(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::Aggregate::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
gfs::path fullpath;
struct stat st = {0};
st_->st_mtime = std::numeric_limits<time_t>::min();
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
if(st_->st_mtime == std::numeric_limits<time_t>::min())
{
*st_ = st;
}
else
{
st_->st_nlink += st.st_nlink;
if(st_->st_atim < st.st_atim)
st_->st_atim = st.st_atim;
if(st_->st_mtim < st.st_mtim)
st_->st_mtim = st.st_mtim;
if(st_->st_ctim < st.st_ctim)
st_->st_ctim = st.st_ctim;
}
}
}
if(st_->st_mtime == std::numeric_limits<time_t>::min())
return -ENOENT;
return 0;
}

View file

@ -0,0 +1,45 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
class Aggregate : public Base
{
public:
Aggregate(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include "fuse_timeouts.h"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETATTR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) = 0;
};
}

View file

@ -0,0 +1,95 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_check_ff.hpp"
#include <cstdio>
namespace l
{
static
void
alert(const gfs::path &fullpath_,
const char *attr_,
const uint64_t val1_,
const uint64_t val2_)
{
fprintf(stderr,
"%s: %s - %lx != %lx",
fullpath_.c_str(),
attr_,
val1_,
val2_);
}
}
FUSE::GETATTR::POLICY::CheckFF::CheckFF(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::CheckFF::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
size_t i, ei;
size_t j, ej;
gfs::path fullpath;
struct stat st = {0};
for(i = 0, ei = _branches.size(); i < ei; i++)
{
for(j = 0, ej = _branches[i].size(); j < ej; j++)
{
fullpath = _branches[i][j].path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
j++;
*st_ = st;
goto main_loop;
}
}
main_loop:
for(; i < ei; i++)
{
for(; j < ej; j++)
{
fullpath = _branches[i][j].path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
if(st.st_mode != st_->st_mode)
l::alert(fullpath,"mode",st_->st_mode,st.st_mode);
}
}
return 0;
}

View file

@ -0,0 +1,45 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
class CheckFF : public Base
{
public:
CheckFF(const toml::value&);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

View file

@ -0,0 +1,48 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_factory.hpp"
#include "fuse_getattr_policy_base.hpp"
#include "fuse_getattr_policy_ff.hpp"
#include "fuse_getattr_policy_newest.hpp"
#include "fuse_getattr_policy_aggregate.hpp"
#include "fuse_getattr_policy_check_ff.hpp"
#include <stdexcept>
namespace FUSE::GETATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","getattr","policy","ff");
if(str == "ff")
return std::make_shared<FuncFF>(toml_);
if(str == "newest")
return std::make_shared<FuncNewest>(toml_);
if(str == "aggregate")
return std::make_shared<FuncAggregate>(toml_);
if(str == "check-ff")
return std::make_shared<FuncCheckFF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,29 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,53 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_ff.hpp"
FUSE::GETATTR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::FF::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,st_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,45 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR
{
class FF : public Base
{
public:
FF(const toml::value&);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

View file

@ -0,0 +1,62 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_newest.hpp"
#include <limits.h>
FUSE::GETATTR::POLICY::Newest::Newest(const toml::value &toml_)
: _branches(toml_)
{
Stat::Func statfunc = Stat::no_follow;
_statfunc = toml::find_or(toml_,"func","getattr","follow-symlinks",statfunc);
}
int
FUSE::GETATTR::POLICY::Newest::operator()(const gfs::path &fusepath_,
struct stat *st_,
fuse_timeouts_t *timeout_)
{
int rv;
struct stat st;
gfs::path fullpath;
st_->st_mtime = std::numeric_limits<time_t>::min();
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = _statfunc(fullpath,&st);
if(rv != 0)
continue;
if(st_->st_mtime < st.st_mtime)
continue;
*st_ = st;
}
}
if(st_->st_mtime == std::numeric_limits<time_t>::min())
return -ENOENT;
return 0;
}

View file

@ -0,0 +1,45 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETATTR::POLICY
{
class Newest : public Base
{
public:
Newest(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
struct stat *st,
fuse_timeouts_t *timeout) final;
private:
Stat::Func _statfunc;
Branches2 _branches;
};
}

View file

@ -0,0 +1,48 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getxattr_policy_base.hpp"
#include "fuse_timeouts.h"
#include "toml.hpp"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETXATTR
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count);
private:
POLICY::Base::Ptr _getxattr;
};
}

View file

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include <memory>
#include <sys/stat.h>
namespace FUSE::GETXATTR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count) = 0;
};
}

View file

@ -0,0 +1,39 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getxattr_policy_factory.hpp"
#include "fuse_getxattr_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::GETXATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","getxattr","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getxattr_func_base.hpp"
#include "toml.hpp"
namespace FUSE::GETXATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,54 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getxattr_policy_ff.hpp"
#include "fs_lgetxattr.hpp"
FUSE::GETXATTR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::GETXATTR::POLICY::FF::operator()(const gfs::path &fusepath_,
const char *attrname_,
char *buf_,
size_t count_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lgetxattr(fullpath,attrname_,buf_,count_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,45 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_getxattr_policy_base.hpp"
#include "branches.hpp"
#include "stat_func.hpp"
#include "toml.hpp"
namespace FUSE::GETXATTR::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const char *attrname,
char *buf,
size_t count) final;
private:
Branches2 _branches;
};
}

43
src/fuse_ioctl_policy.hpp Normal file
View file

@ -0,0 +1,43 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_ioctl_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::IOCTL
{
class Policy
{
public:
Policy(const toml::value &);
public:
int operator()(const fuse_file_info_t *ffi_,
const unsigned long cmd,
const unsigned int flags,
void *data,
uint32_t *out_bufsz);
private:
POLICY::Base::Ptr _ioctl;
};
}

View file

@ -0,0 +1,52 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_ioctl_policy_all.hpp"
#include "fuse_ioctl_err.hpp"
#include "fs_ioctl.hpp"
FUSE::IOCTL::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::IOCTL::POLICY::ALL::operator()(const fuse_file_info_t *ffi_,
const unsigned long cmd_,
const unsigned int flags_,
void *data_,
uint32_t *out_bufsz_)
{
Err rv;
gfs::path fusepath;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath;
}
}
return rv;
}

View file

@ -0,0 +1,43 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_ioctl_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::IOCTL::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const fuse_file_info_t *ffi,
const unsigned long cmd,
const unsigned int flags,
void *data,
uint32_t *out_bufsz) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse.h"
#include <memory>
namespace FUSE::IOCTL::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const fuse_file_info_t *ffi,
const unsigned long cmd,
const unsigned int flags,
void *data,
uint32_t *out_bufsz) = 0;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_ioctl_policy_factory.hpp"
#include "fuse_ioctl_policy_all.hpp"
#include <stdexcept>
namespace FUSE::IOCTL::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","ioctl","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_ioctl_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::IOCTL::POLICY
{
Base::Ptr
factory(const toml::value &);
}

48
src/fuse_link_policy.hpp Normal file
View file

@ -0,0 +1,48 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_link_policy_base.hpp"
#include "fuse_link_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::LINK
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_link = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
return (*_link)(oldpath_,newpath_);
}
private:
POLICY::Base::Ptr _link;
};
}

View file

@ -0,0 +1,67 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_link_policy_all.hpp"
#include "fuse_link_err.hpp"
#include "fs_clonepath_branches.hpp"
#include "fs_exists.hpp"
#include "fs_link.hpp"
FUSE::LINK::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::LINK::POLICY::ALL::operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
int rv;
Err err;
gfs::path fulloldpath;
gfs::path fullnewpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fulloldpath = branch.path / oldpath_;
fullnewpath = branch.path / newpath_;
rv = fs::link(fulloldpath,fullnewpath);
if(rv == -ENOENT)
{
if(!fs::exists(fulloldpath))
continue;
rv = fs::clonepath_as_root(_branches,branch.path,newpath_.parent_path());
if(rv < 0)
continue;
rv = fs::link(fulloldpath,fullnewpath);
}
err = rv;
}
}
return err;
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_link_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::LINK::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value&);
public:
int operator()(const gfs::path &oldpath,
const gfs::path &newpath) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include "fuse.h"
#include <memory>
namespace FUSE::LINK::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &oldpath,
const gfs::path &newpath) = 0;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_link_policy_factory.hpp"
#include "fuse_link_all_all.hpp"
#include <stdexcept>
namespace FUSE::LINK::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","link","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_link_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::LINK::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,47 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_listxattr_policy_base.hpp"
#include "fuse_listxattr_policy_factory.hpp"
namespace FUSE::LISTXATTR
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_listxattr = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
char *buf_,
size_t count_)
{
return (*_listxattr)(fusepath_,list_,size_);
}
private:
POLICY::Base::Ptr _listxattr;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include <memory>
namespace FUSE::LISTXATTR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
char *list,
const size_t size) = 0;
};
}

View file

@ -0,0 +1,39 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_listxattr_policy_factory.hpp"
#include "fuse_listxattr_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::LISTXATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","listxattr","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,29 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_listxattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::LISTXATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,53 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_listxattr_policy_ff.hpp"
#include "fs_llistxattr.hpp"
FUSE::LISTXATTR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::LISTXATTR::POLICY::FF::operator()(const gfs::path &fusepath_,
char *list_,
const size_t size_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::llistxattr(fullpath,list_,size_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,43 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_listxattr_policy_base.hpp"
#include "branches.hpp"
#include "toml.hpp"
namespace FUSE::LISTXATTR::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
char *list,
const size_t size) final;
private:
Branches2 _branches;
};
}

47
src/fuse_mkdir_policy.hpp Normal file
View file

@ -0,0 +1,47 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mkdir_func_base.hpp"
#include "toml.hpp"
namespace FUSE::MKDIR
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_mkdir = POLICY::factory(toml_);
}
public:
int operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_)
{
return (*_mkdir)(fusepath_,mode_,umask_);
}
private:
FuncBase::Ptr _mkdir;
};
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include "fuse.h"
#include <memory>
namespace FUSE::MKDIR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask) = 0;
};
}

View file

@ -0,0 +1,52 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mkdir_policy_epff.hpp"
#include "fuse_mkdir_mkdir.hpp"
FUSE::MKDIR::POLICY::EPFF::EPFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKDIR::POLICY::EPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mkdir_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKDIR::POLICY
{
class EPFF : public Base
{
public:
EPFF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mkdir_policy_factory.hpp"
#include "fuse_mkdir_policy_ff.hpp"
#include "fuse_mkdir_policy_epff.hpp"
#include <stdexcept>
namespace FUSE::MKDIR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","mkdir","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
if(str == "epff")
return std::make_shared<EPFF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mkdir_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::MKDIR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,58 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mkdir_policy_ff.hpp"
#include "fuse_mkdir_mkdir.hpp"
#include "fs_clonepath_branches.hpp"
FUSE::MKDIR::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKDIR::POLICY::FF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
rv = FUSE::MKDIR::mkdir(fullpath,mode_,umask_);
}
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mkdir_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKDIR::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask) final;
private:
Branches2 _branches;
};
}

50
src/fuse_mknod_policy.hpp Normal file
View file

@ -0,0 +1,50 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mknod_policy_base.hpp"
#include "fuse_mknod_policy_factory.hpp"
#include "toml.hpp"
namespace FUSE::MKNOD
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_mknod = FuncFactory(toml_);
}
public:
int
operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev)
{
return (*_mknod)(fusepath_,mode_,umask_,dev_);
}
private:
POLICY::Base::Ptr _mknod;
};
}

View file

@ -0,0 +1,44 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include <memory>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace FUSE::MKNOD::POLICY
{
class Base
{
public:
typedef std::shared_ptr<FuncBase> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev) = 0;
};
}

View file

@ -0,0 +1,64 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mknod_policy_epff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_mknod.hpp"
FUSE::MKNOD::POLICY::EPFF::EPFF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKNOD::POLICY::EPFF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
const dev_t dev_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
continue;
if(rv >= 0)
mode &= umask_;
rv = fs::mknod(fullpath,mode,dev_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mknod_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKNOD::POLICY
{
class EPFF : public Base
{
public:
EPFF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,41 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mknod_policy_factory.hpp"
#include "fuse_mknod_policy_ff.hpp"
#include "fuse_mknod_policy_epff.hpp"
#include <stdexcept>
namespace FUSE::MKNOD::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","mknod","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
if(str == "epff")
return std::make_shared<EPFF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mknod_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::MKNOD::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,81 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mknod_policy_ff.hpp"
#include "fileinfo.hpp"
#include "fs_acl.hpp"
#include "fs_clonepath.hpp"
#include "fs_clonepath_branches.hpp"
#include "fs_mknod.hpp"
#include "ugid.hpp"
FUSE::MKNOD::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::MKNOD::POLICY::FF::operator()(const gfs::path &fusepath_,
const mode_t mode_,
const mode_t umask_,
const dev_t dev_)
{
int rv;
mode_t mode;
gfs::path fullpath;
mode = mode_;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::acl::dir_has_defaults(fullpath);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
rv = fs::acl::dir_has_defaults(fullpath);
}
if(rv >= 0)
mode &= ~umask_;
rv = fs::mknod(fullpath,mode,dev_);
if(rv == -ENOENT)
{
rv = fs::clonepath_as_root(_branches,branch.path,fusepath_);
if(rv >= 0)
{
rv = fs::acl::dir_has_defaults(fullpath);
if(rv >= 0)
mode &= ~umask_;
rv = fs::mknod(fullpath,mode,dev_);
}
}
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_mknod_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::MKNOD::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const mode_t mode,
const mode_t umask,
const dev_t dev) final;
private:
Branches2 _branches;
};
}

52
src/fuse_open_policy.hpp Normal file
View file

@ -0,0 +1,52 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_open_policy_base.hpp"
#include "fuse_open_policy_factory.hpp"
#include "fuse.h"
#include "toml.hpp"
#include <memory>
namespace FUSE::OPEN
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_open = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
fuse_file_info_t *ffi_)
{
return (*_open)(fusepath_,ffi_);
}
private:
POLICY::Base::Ptr _open;
};
}

View file

@ -0,0 +1,39 @@
/*
ISC License
Copyright (c) 2022, 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 "fs_path.hpp"
#include "fuse.h"
#include <memory>
namespace FUSE::OPEN::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
fuse_file_info_t *ffi) = 0;
};
}

View file

@ -0,0 +1,39 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_open_policy_factory.hpp"
#include "fuse_open_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::OPEN::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","open","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_open_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::OPEN::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,57 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_open_policy_ff.hpp"
#include "fs_open.hpp"
#include "fileinfo.hpp"
FUSE::OPEN::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::OPEN::POLICY::FF::operator()(const gfs::path &fusepath_,
fuse_file_info_t *ffi_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::open(fullpath,ffi_->flags);
if(rv == -ENOENT)
continue;
if(rv < 0)
return rv;
ffi_->fh = reinterpret_cast<uint64_t>(new FileInfo(rv,fusepath_));
return 0;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_open_policy.hpp"
#include "branches.hpp"
#include "toml.hpp"
namespace FUSE::OPEN::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
fuse_file_info_t *ffi) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,52 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_readlink_policy_base.hpp"
#include "fuse_timeouts.h"
#include <memory>
#include <sys/stat.h>
namespace FUSE::READLINK
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_readlink = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
char *buf_,
const size_t bufsiz_)
{
return (*_readlink)(fusepath_,buf_,bufsiz_);
}
private:
POLICY::Base::Ptr _readlink;
};
}

View file

@ -0,0 +1,36 @@
/*
ISC License
Copyright (c) 2022, 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 <memory>
namespace FUSE::READLINK::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
char *buf,
const size_t bufsiz) = 0;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_readlink_policy_factory.hpp"
#include "fuse_readlink_policy_ff.hpp"
#include <stdexcept>
namespace FUSE::READLINK::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","readlink","policy","ff");
if(str == "ff")
return std::make_shared<FF>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_readlink_func_base.hpp"
#include "toml.hpp"
namespace FUSE::READLINK::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,53 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_readlink_policy_ff.hpp"
#include "fs_readlink.hpp"
FUSE::READLINK::POLICY::FF::FF(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::READLINK::POLICY::FF::operator()(const gfs::path &fusepath_,
char *buf_,
const size_t bufsiz_)
{
int rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::readlink(fullpath,buf_,bufsiz_);
if(rv == -ENOENT)
continue;
return rv;
}
}
return -ENOENT;
}

View file

@ -0,0 +1,43 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_readlink_policy_base.hpp"
#include "branches.hpp"
#include "toml.hpp"
namespace FUSE::READLINK::POLICY
{
class FF : public Base
{
public:
FF(const toml::value &);
public:
int operator()(const gfs::path &fusepath,,
char *buf,
const size_t bufsiz) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,47 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_removexattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::REMOVEXATTR
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_removexattr = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &fusepath_,
const char *attrname_)
{
return (*_removexattr)(fusepath_,attrname_);
}
private:
POLICY::Base::Ptr _removexattr;
};
}

View file

@ -0,0 +1,49 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_removexattr_policy_all.hpp"
#include "fuse_removexattr_err.hpp"
#include "fs_lremovexattr.hpp"
FUSE::REMOVEXATTR::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::REMOVEXATTR::POLICY::ALL::operator()(const gfs::path &fusepath_,
const char *attrname_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / fusepath_;
rv = fs::lremovexattr(fullpath,attrname_);
}
}
return rv;
}

View file

@ -0,0 +1,40 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_removexattr_policy_base.hpp"
#include "branches.hpp"
namespace FUSE::REMOVEXATTR::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const gfs::path &fusepath,
const char *attrname) final;
private:
Branches2 _branches;
};
}

View file

@ -0,0 +1,35 @@
/*
ISC License
Copyright (c) 2022, 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 <memory>
namespace FUSE::REMOVEXATTR::POLICY
{
class Base
{
public:
typedef std::shared_ptr<Base> Ptr;
public:
virtual int operator()(const gfs::path &fusepath,
const char *attrname) = 0;
};
}

View file

@ -0,0 +1,38 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_removexattr_policy_factory.hpp"
#include "fuse_removexattr_policy_all.hpp"
#include <stdexcept>
namespace FUSE::REMOVEXATTR::POLICY
{
Base::Ptr
factory(const toml::value &toml_)
{
std::string str;
str = toml::find_or(toml_,"func","removexattr","policy","all");
if(str == "all")
return std::make_shared<ALL>(toml_);
throw std::runtime_error("");
}
}

View file

@ -0,0 +1,30 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_removexattr_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::REMOVEXATTR::POLICY
{
Base::Ptr
factory(const toml::value &);
}

View file

@ -0,0 +1,47 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_rename_policy_base.hpp"
#include "toml.hpp"
namespace FUSE::RENAME
{
class Policy
{
public:
Policy(const toml::value &toml_)
{
_rename = POLICY::factory(toml_);
}
public:
int
operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
return (*_rename)(oldpath_,newpath_);
}
private:
POLICY::Base::Ptr _rename;
};
}

View file

@ -0,0 +1,51 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_rename_policy_all.hpp"
#include "fuse_rename_err.hpp"
#include "fs_rename.hpp"
#include "fs_path.hpp"
FUSE::RENAME::POLICY::ALL::ALL(const toml::value &toml_)
: _branches(toml_)
{
}
int
FUSE::RENAME::POLICY::ALL::operator()(const gfs::path &oldpath_,
const gfs::path &newpath_)
{
Err rv;
gfs::path fullpath;
for(const auto &branch_group : _branches)
{
for(const auto &branch : branch_group)
{
fullpath = branch.path / oldpath_;
rv = 0;
}
}
return rv;
}

View file

@ -0,0 +1,42 @@
/*
ISC License
Copyright (c) 2022, 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 "fuse_rename_policy_base.hpp"
#include "branches.hpp"
#include "fs_path.hpp"
namespace FUSE::RENAME::POLICY
{
class ALL : public Base
{
public:
ALL(const toml::value &);
public:
int operator()(const gfs::path &oldpath,
const gfs::path &newpath) final;
private:
Branches2 _branches;
};
}

Some files were not shown because too many files have changed in this diff Show more