io: add an `fallocate` wrapper

This commit is contained in:
Danny Robson 2020-11-28 08:39:22 +10:00
parent 88f1e8e654
commit 3b66bb9066
3 changed files with 14 additions and 1 deletions

View File

@ -83,7 +83,7 @@ mapped_file::~mapped_file ()
}
//----------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////
size_t
mapped_file::size (void) const
{

View File

@ -107,6 +107,14 @@ fd::stat (void) const
}
///////////////////////////////////////////////////////////////////////////////
void
fd::allocate (int mode, off_t offset, off_t len)
{
error::try_call (fallocate, m_fd, mode, offset, len);
}
///////////////////////////////////////////////////////////////////////////////
void
fd::close (void)

View File

@ -57,6 +57,11 @@ namespace cruft::posix {
struct ::stat stat (void) const;
///////////////////////////////////////////////////////////////////////
/// A thin wrapper around `fallocate`
void allocate (int mode, off_t offset, off_t len);
///////////////////////////////////////////////////////////////////////
void close (void);
void reset (int);