From 55b2b128c68cc3552bb52da5ba95bb25eeea5b3d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 23 Aug 2018 21:24:35 -0700 Subject: [PATCH] ircd::fs: Add an fallocate wrapper for now. --- include/ircd/fs/write.h | 3 +++ ircd/fs.cc | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/include/ircd/fs/write.h b/include/ircd/fs/write.h index 0853b8219..7e4b8ad3b 100644 --- a/include/ircd/fs/write.h +++ b/include/ircd/fs/write.h @@ -30,6 +30,9 @@ namespace ircd::fs // Truncate file to explicit size void truncate(const fd &, const size_t &, const write_opts & = write_opts_default); void truncate(const string_view &path, const size_t &, const write_opts & = write_opts_default); + + // Allocate + void allocate(const fd &, const size_t &size, const write_opts & = write_opts_default); } /// Options for a write operation diff --git a/ircd/fs.cc b/ircd/fs.cc index 5c5c19d77..a2f3d7131 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -383,6 +383,14 @@ ircd::fs::write_opts const ircd::fs::write_opts_default {}; +void +ircd::fs::allocate(const fd &fd, + const size_t &size, + const write_opts &opts) +{ + syscall(::posix_fallocate, fd, opts.offset, size); +} + void ircd::fs::truncate(const string_view &path, const size_t &size,