From d08bcc2f3205be299b4624b57d47998c212e3bb7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 22 Apr 2019 08:55:42 -0700 Subject: [PATCH] ircd::fs: Add fd::release() memfn. --- include/ircd/fs/fd.h | 2 ++ ircd/fs.cc | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/ircd/fs/fd.h b/include/ircd/fs/fd.h index 07d33bfa0..b5ca78a4c 100644 --- a/include/ircd/fs/fd.h +++ b/include/ircd/fs/fd.h @@ -34,6 +34,8 @@ struct ircd::fs::fd operator bool() const; bool operator!() const; + int release() noexcept; + explicit fd(const int &); fd(const string_view &path, const opts &); fd(const string_view &path); diff --git a/ircd/fs.cc b/ircd/fs.cc index 1ae0a6a36..331e41b24 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -1621,6 +1621,15 @@ noexcept(false) syscall(::close, fdno); } +int +ircd::fs::fd::release() +noexcept +{ + const int fdno(this->fdno); + this->fdno = -1; + return fdno; +} + /////////////////////////////////////////////////////////////////////////////// // // fs/device.h