mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::fs::fd: Replace open(2) with openat(2); additional constructor.
This commit is contained in:
parent
56219f9eaa
commit
a1de7e8e08
2 changed files with 25 additions and 5 deletions
|
@ -42,6 +42,7 @@ struct ircd::fs::fd
|
||||||
int release() noexcept;
|
int release() noexcept;
|
||||||
|
|
||||||
explicit fd(const int &);
|
explicit fd(const int &);
|
||||||
|
fd(const int &dirfd, const string_view &path, const opts &);
|
||||||
fd(const string_view &path, const opts &);
|
fd(const string_view &path, const opts &);
|
||||||
fd(const string_view &path);
|
fd(const string_view &path);
|
||||||
fd() = default;
|
fd() = default;
|
||||||
|
|
29
ircd/fs.cc
29
ircd/fs.cc
|
@ -1994,19 +1994,38 @@ ircd::fs::fd::opts::opts(const std::ios::openmode &mode)
|
||||||
//
|
//
|
||||||
|
|
||||||
ircd::fs::fd::fd(const int &fdno)
|
ircd::fs::fd::fd(const int &fdno)
|
||||||
:fdno{fdno}
|
:fdno
|
||||||
|
{
|
||||||
|
fdno
|
||||||
|
}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::fs::fd::fd(const string_view &path)
|
ircd::fs::fd::fd(const string_view &path)
|
||||||
:fd{path, opts{}}
|
:fd
|
||||||
|
{
|
||||||
|
path, opts{}
|
||||||
|
}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::fs::fd::fd(const string_view &path,
|
ircd::fs::fd::fd(const string_view &path,
|
||||||
const opts &opts)
|
const opts &opts)
|
||||||
|
:fd
|
||||||
|
{
|
||||||
|
AT_FDCWD, path, opts
|
||||||
|
}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ircd::fs::fd::fd(const int &dirfd,
|
||||||
|
const string_view &path,
|
||||||
|
const opts &opts)
|
||||||
try
|
try
|
||||||
:fdno{-1}
|
:fdno
|
||||||
|
{
|
||||||
|
-1 // sentinel value for inert dtor
|
||||||
|
}
|
||||||
{
|
{
|
||||||
const mode_t mode
|
const mode_t mode
|
||||||
{
|
{
|
||||||
|
@ -2033,11 +2052,11 @@ try
|
||||||
|
|
||||||
const prof::syscall_usage_warning message
|
const prof::syscall_usage_warning message
|
||||||
{
|
{
|
||||||
"fs::fs::fd(): open(2): %s", path
|
"fs::fs::fd(): openat(2): %s", path
|
||||||
};
|
};
|
||||||
|
|
||||||
assert((flags & ~O_CREAT) || mode != 0);
|
assert((flags & ~O_CREAT) || mode != 0);
|
||||||
fdno = syscall(::open, path_cstr(path), flags, mode);
|
fdno = syscall(::openat, dirfd, path_cstr(path), flags, mode);
|
||||||
|
|
||||||
if(advise)
|
if(advise)
|
||||||
fs::advise(*this, advise);
|
fs::advise(*this, advise);
|
||||||
|
|
Loading…
Reference in a new issue