0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-19 18:38:21 +02:00

ircd::fs: Test if O_DIRECT possible on path target.

This commit is contained in:
Jason Volk 2018-09-04 01:15:10 -07:00
parent 67d202a5e4
commit 3426fc650f
2 changed files with 25 additions and 0 deletions

View file

@ -52,6 +52,7 @@ namespace ircd::fs
bool is_dir(const string_view &path);
bool is_reg(const string_view &path);
size_t size(const string_view &path);
bool direct_io_support(const string_view &path);
std::vector<std::string> ls(const string_view &path);
std::vector<std::string> ls_recursive(const string_view &path);

View file

@ -860,6 +860,30 @@ catch(const filesystem::filesystem_error &e)
throw error{e};
}
bool
ircd::fs::direct_io_support(const string_view &path)
try
{
fd::opts opts{std::ios::out};
opts.direct = true;
fd{path, opts};
return true;
}
catch(const std::system_error &e)
{
const auto &code(e.code());
if(code.category() == std::system_category()) switch(code.value())
{
case int(std::errc::invalid_argument):
return false;
default:
break;
}
throw;
}
size_t
ircd::fs::size(const string_view &path)
{