0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-26 05:48:20 +02:00

ircd::fs: Support for finding the O_DIRECT alignments from system.

This commit is contained in:
Jason Volk 2018-08-28 19:31:58 -07:00
parent 0f2dd85a47
commit 5dd9b7a3cf
2 changed files with 17 additions and 0 deletions

View file

@ -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 &);
}

View file

@ -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