Seastar provides a file API to deal with persistent storage. Unlike most file APIs, seastar offers unbuffered file I/O (similar to, and based on, O_DIRECT
). Unbuffered I/O means that the application is required to do its own caching, but delivers better performance if this caching is done correctly.
|
enum class | seastar::open_flags {
rw = O_RDWR
, ro = O_RDONLY
, wo = O_WRONLY
, create = O_CREAT
,
truncate = O_TRUNC
, exclusive = O_EXCL
, dsync = O_DSYNC
} |
|
enum class | seastar::directory_entry_type {
unknown
, block_device
, char_device
, directory
,
fifo
, link
, regular
, socket
} |
|
enum class | seastar::fs_type {
other
, xfs
, ext2
, ext3
,
ext4
, btrfs
, hfs
, tmpfs
} |
| Enumeration describing the type of a particular filesystem.
|
|
enum class | access_flags {
exists = F_OK
, read = R_OK
, write = W_OK
, execute = X_OK
,
lookup = execute
} |
|
enum class | file_permissions {
user_read = S_IRUSR
, user_write = S_IWUSR
, user_execute = S_IXUSR
, group_read = S_IRGRP
,
group_write = S_IWGRP
, group_execute = S_IXGRP
, others_read = S_IROTH
, others_write = S_IWOTH
,
others_execute = S_IXOTH
, user_permissions = user_read | user_write | user_execute
, group_permissions = group_read | group_write | group_execute
, others_permissions = others_read | others_write | others_execute
,
all_permissions = user_permissions | group_permissions | others_permissions
, default_file_permissions = user_read | user_write | group_read | group_write | others_read | others_write
, default_dir_permissions = all_permissions
} |
|
|
open_flags | seastar::operator| (open_flags a, open_flags b) |
|
void | seastar::operator|= (open_flags &a, open_flags b) |
|
open_flags | seastar::operator& (open_flags a, open_flags b) |
|
void | seastar::operator&= (open_flags &a, open_flags b) |
|
access_flags | seastar::operator| (access_flags a, access_flags b) |
|
access_flags | seastar::operator& (access_flags a, access_flags b) |
|
constexpr file_permissions | seastar::operator| (file_permissions a, file_permissions b) |
|
constexpr file_permissions | seastar::operator& (file_permissions a, file_permissions b) |
|
future< shared_ptr< file_impl > > | seastar::make_file_impl (int fd, file_open_options options, int oflags, struct stat st) noexcept |
|
template<std::invocable< file & > Func>
requires std::is_nothrow_move_constructible_v<Func> |
auto | seastar::with_file (future< file > file_fut, Func func) noexcept |
| Helper for ensuring a file is closed after func is called. More...
|
|
template<std::invocable< file & > Func>
requires std::is_nothrow_move_constructible_v<Func> |
auto | seastar::with_file_close_on_failure (future< file > file_fut, Func func) noexcept |
| Helper for ensuring a file is closed if func fails. More...
|
|
future | seastar::check_direct_io_support (std::string_view path) noexcept |
|
future | seastar::make_directory (std::string_view name, file_permissions permissions=file_permissions::default_dir_permissions) noexcept |
|
future | seastar::touch_directory (std::string_view name, file_permissions permissions=file_permissions::default_dir_permissions) noexcept |
|
future | seastar::recursive_touch_directory (std::string_view name, file_permissions permissions=file_permissions::default_dir_permissions) noexcept |
|
future | seastar::sync_directory (std::string_view name) noexcept |
|
future | seastar::remove_file (std::string_view name) noexcept |
|
future | seastar::rename_file (std::string_view old_name, std::string_view new_name) noexcept |
|
future< stat_data > | seastar::file_stat (std::string_view name, follow_symlink fs=follow_symlink::yes) noexcept |
|
future< uint64_t > | seastar::file_size (std::string_view name) noexcept |
|
future< bool > | seastar::file_accessible (std::string_view name, access_flags flags) noexcept |
|
future< bool > | seastar::file_exists (std::string_view name) noexcept |
|
future< std::optional< directory_entry_type > > | seastar::file_type (std::string_view name, follow_symlink follow=follow_symlink::yes) noexcept |
|
future | seastar::link_file (std::string_view oldpath, std::string_view newpath) noexcept |
|
future | seastar::chmod (std::string_view name, file_permissions permissions) noexcept |
|
future< fs_type > | seastar::file_system_at (std::string_view name) noexcept |
|
future< uint64_t > | seastar::fs_avail (std::string_view name) noexcept |
|
future< uint64_t > | seastar::fs_free (std::string_view name) noexcept |
|
future< file > | open_file_dma (std::string_view name, open_flags flags) noexcept |
|
future< file > | open_file_dma (std::string_view name, open_flags flags, file_open_options options) noexcept |
|
future< file > | open_directory (std::string_view name) noexcept |
|
future seastar::check_direct_io_support |
( |
std::string_view |
path | ) |
|
|
noexcept |
Checks if a given directory supports direct io
Seastar bypasses the Operating System caches and issues direct io to the underlying block devices. Projects using seastar should check if the directory lies in a filesystem that support such operations. This function can be used to do that.
It will return if direct io can be used, or throw an std::system_error exception, with the EINVAL error code.
A std::system_error with the respective error code is also thrown if path
is not a directory.
- Parameters
-
path | the directory we need to verify. |
future< bool > seastar::file_accessible |
( |
std::string_view |
name, |
|
|
access_flags |
flags |
|
) |
| |
|
noexcept |
Check file access.
- Parameters
-
name | name of the file to check |
flags | bit pattern containing type of access to check (read/write/execute or exists). |
If only access_flags::exists is queried, returns true if the file exists, or false otherwise. Throws a std::filesystem::filesystem_error exception if any error other than ENOENT is encountered.
If any of the access_flags (read/write/execute) is set, returns true if the file exists and is accessible with the requested flags, or false if the file exists and is not accessible as queried. Throws a std::filesystem::filesystem_error exception if any error other than EACCES is encountered. Note that if any path component leading to the file is not searchable, the file is considered inaccessible with the requested mode and false will be returned.