Misc cleanup

This commit is contained in:
Antonio SJ Musumeci 2026-04-13 18:55:56 -05:00
parent ff48ff6047
commit fa06b4b8bd
74 changed files with 809 additions and 619 deletions

View file

@ -34,7 +34,7 @@
#include <fnmatch.h>
Branches::Impl::Impl(const u64 &default_minfreespace_)
Branches::Impl::Impl(const u64 *default_minfreespace_)
: _default_minfreespace(default_minfreespace_)
{
}
@ -48,6 +48,12 @@ Branches::Impl::operator=(Branches::Impl &rval_)
*this_base = *rval_base;
for(auto &branch : *this)
{
if(std::holds_alternative<const u64*>(branch._minfreespace))
branch._minfreespace = _default_minfreespace;
}
return *this;
}
@ -60,6 +66,12 @@ Branches::Impl::operator=(Branches::Impl &&rval_)
*this_base = std::move(*rval_base);
for(auto &branch : *this)
{
if(std::holds_alternative<const u64*>(branch._minfreespace))
branch._minfreespace = _default_minfreespace;
}
return *this;
}
@ -67,7 +79,7 @@ const
u64&
Branches::Impl::minfreespace(void) const
{
return _default_minfreespace;
return *_default_minfreespace;
}
namespace l
@ -148,7 +160,7 @@ namespace l
case 2:
*glob_ = v[0];
options = v[1];
v = str::split(options,',');
v = str::split(options,',');
switch(v.size())
{
case 2:
@ -229,7 +241,7 @@ namespace l
{
int rv;
StrVec paths;
Branches::Impl tmp_branches(branches_->minfreespace());
Branches::Impl tmp_branches(&branches_->minfreespace());
paths = str::split(str_,':');
for(auto &path : paths)
@ -251,7 +263,7 @@ namespace l
{
int rv;
std::vector<std::string> paths;
Branches::Impl tmp_branches(branches_->minfreespace());
Branches::Impl tmp_branches(&branches_->minfreespace());
paths = str::split(str_,':');
for(auto &path : paths)
@ -275,7 +287,7 @@ namespace l
{
int rv;
StrVec paths;
Branches::Impl tmp_branches(branches_->minfreespace());
Branches::Impl tmp_branches(&branches_->minfreespace());
paths = str::split(str_,':');
for(auto &path : paths)
@ -419,7 +431,7 @@ Branches::from_string(const std::string_view str_)
impl = std::atomic_load(&_impl);
new_impl = std::make_shared<Branches::Impl>(impl->minfreespace());
new_impl = std::make_shared<Branches::Impl>(&minfreespace);
*new_impl = *impl;
rv = new_impl->from_string(str_);
@ -440,7 +452,16 @@ Branches::to_string(void) const
void
Branches::find_and_set_mode_ro()
{
for(auto &branch : *_impl)
Branches::Ptr impl;
Branches::Ptr new_impl;
impl = std::atomic_load(&_impl);
new_impl = std::make_shared<Branches::Impl>(&minfreespace);
*new_impl = *impl;
bool changed = false;
for(auto &branch : *new_impl)
{
if(branch.mode != Branch::Mode::RW)
continue;
@ -452,7 +473,13 @@ Branches::find_and_set_mode_ro()
branch.path.string());
branch.mode = Branch::Mode::RO;
changed = true;
}
if(not changed)
return;
std::atomic_store(&_impl,new_impl);
}
SrcMounts::SrcMounts(Branches &b_)