diff --git a/include/ircd/fs/fd.h b/include/ircd/fs/fd.h index 15a90c26e..7d591430e 100644 --- a/include/ircd/fs/fd.h +++ b/include/ircd/fs/fd.h @@ -16,6 +16,7 @@ namespace ircd::fs struct fd; size_t size(const fd &); + size_t block_size(const fd &); string_view uuid(const fd &, const mutable_buffer &); } diff --git a/ircd/fs.cc b/ircd/fs.cc index 7961b0c19..bc0b41d71 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -556,6 +556,22 @@ namespace ircd::fs static uint posix_flags(const std::ios::open_mode &mode); } +#ifdef HAVE_SYS_STAT_H +size_t +ircd::fs::block_size(const fd &fd) +{ + struct stat stat; + syscall(::fstat, fd, &stat); + return stat.st_blksize; +} +#else +size_t +ircd::fs::block_size(const fd &fd) +{ + return info::page_size; +} +#endif + /// This is not a standard UUID of any sort; this is custom, and intended for /// rocksdb (though rocksdb has no requirement for its format specifically). /// The format is plain-text, fs major and minor number, inode number, and