Fix an issue when using -o atime mount options

This commit is contained in:
Sebastian Messmer 2023-08-06 22:14:40 -07:00
parent 7a3f2b6114
commit d6252896e0
2 changed files with 34 additions and 22 deletions

View File

@ -9,6 +9,10 @@ Version 0.12.0 (unreleased)
* boost 1.79
* spdlog/1.11.0
Version 0.11.5 (unreleased)
---------------
* Fix an issue when using `-o` atime mount options
Version 0.11.4
---------------
* Fixed build issue with GCC 13 (see https://github.com/cryfs/cryfs/pull/448 )

View File

@ -311,9 +311,7 @@ void extractAllAtimeOptionsAndRemoveOnesUnknownToLibfuse_(string* csv_options, v
constexpr std::array<const char*, 3> flags = {"strictatime", "relatime", "nodiratime"};
return flags.end() != std::find(flags.begin(), flags.end(), flag);
};
*csv_options = ranges::make_subrange(csv_options->begin(), csv_options->end())
| ranges::views::split(',')
| ranges::views::filter(
*csv_options = ranges::make_subrange(csv_options->begin(), csv_options->end()) | ranges::views::split(',') | ranges::views::filter(
[&](auto &&elem_) {
// TODO string_view would be better
const std::string elem(&*elem_.begin(), ranges::distance(elem_));
@ -325,9 +323,7 @@ void extractAllAtimeOptionsAndRemoveOnesUnknownToLibfuse_(string* csv_options, v
result->push_back(elem);
}
return true;
})
| ranges::views::join(',')
| ranges::to<string>();
}) | ranges::views::join(',') | ranges::to<string>();
}
// Return a list of all atime options (e.g. atime, noatime, relatime, strictatime, nodiratime) that occur in the
@ -338,12 +334,24 @@ void extractAllAtimeOptionsAndRemoveOnesUnknownToLibfuse_(string* csv_options, v
vector<string> extractAllAtimeOptionsAndRemoveOnesUnknownToLibfuse_(vector<string>* fuseOptions) {
vector<string> result;
bool lastOptionWasDashO = false;
for (string& option : *fuseOptions) {
if (lastOptionWasDashO) {
for (size_t i = 0; i < fuseOptions->size(); ++i)
{
string &option = (*fuseOptions)[i];
if (lastOptionWasDashO)
{
extractAllAtimeOptionsAndRemoveOnesUnknownToLibfuse_(&option, &result);
if (option.empty()) {
// All options were removed, remove the empty argument
fuseOptions->erase(fuseOptions->begin() + i);
--i;
// And also remove the now value-less '-o' before it
fuseOptions->erase(fuseOptions->begin() + i);
--i;
}
}
lastOptionWasDashO = (option == "-o");
}
return result;
}
}