Create functions can set branches RO on EROFS

This commit is contained in:
Antonio SJ Musumeci 2023-07-09 22:42:47 -05:00
parent 36a4b7a23a
commit 707d298d7c
14 changed files with 230 additions and 56 deletions

View file

@ -21,10 +21,12 @@
#include "errno.hpp"
#include "from_string.hpp"
#include "fs_glob.hpp"
#include "fs_is_rofs.hpp"
#include "fs_realpathize.hpp"
#include "nonstd/optional.hpp"
#include "num.hpp"
#include "str.hpp"
#include "syslog.hpp"
#include <string>
@ -415,6 +417,24 @@ Branches::to_string(void) const
return _impl->to_string();
}
void
Branches::find_and_set_mode_ro()
{
for(auto &branch : *_impl)
{
if(branch.mode != Branch::Mode::RW)
continue;
if(!fs::is_rofs_but_not_mounted_ro(branch.path))
continue;
syslog_warning("Branch %s found to be readonly - setting its mode to RO",
branch.path.c_str());
branch.mode = Branch::Mode::RO;
}
}
SrcMounts::SrcMounts(Branches &b_)
: _branches(b_)
{