Seastar
High performance C++ framework for concurrent servers
|
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.
For random I/O or sequential unbuffered I/O, the file class provides a set of methods for reading, writing, discarding, or otherwise manipulating a file. For buffered sequential I/O, see make_file_input_stream() and make_file_output_stream().
Modules | |
File and Stream Utilities | |
These utilities are provided to help perform operations on files and I/O streams. | |
Classes | |
struct | seastar::directory_entry |
A directory entry being listed. More... | |
struct | seastar::group_details |
Group details from the system group database. More... | |
struct | seastar::stat_data |
Filesystem object stat information. More... | |
struct | seastar::file_open_options |
class | seastar::file_handle_impl |
class | seastar::file_impl |
class | seastar::file |
class | seastar::file_handle |
A shard-transportable handle to a file. More... | |
class | seastar::layered_file_impl |
struct | seastar::follow_symlink_tag |
Typedefs | |
using | seastar::follow_symlink = bool_class< follow_symlink_tag > |
Enumerations | |
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 } |
Functions | |
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< std::optional< struct group_details > > | seastar::getgrnam (std::string_view name) |
future | seastar::chown (std::string_view filepath, uid_t owner, gid_t group) |
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 |
struct seastar::directory_entry |
Class Members | ||
---|---|---|
sstring | name | Name of the file in a directory entry. Will never be "." or "..". Only the last component is included. |
optional< directory_entry_type > | type | Type of the directory entry, if known. |
struct seastar::group_details |
struct seastar::stat_data |
Class Members | ||
---|---|---|
uint64_t | allocated_size | |
uint64_t | block_size | |
uint64_t | device_id | |
uint64_t | gid | |
uint64_t | inode_number | |
uint64_t | mode | |
uint64_t | number_of_links | |
uint64_t | rdev | |
uint64_t | size | |
time_point | time_accessed | |
time_point | time_changed | |
time_point | time_modified | |
directory_entry_type | type | |
uint64_t | uid |
struct seastar::follow_symlink_tag |
|
strong |
Enumeration describing the type of a directory entry being listed.
|
strong |
Enumeration describing how a file is to be opened.
|
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.
path | the directory we need to verify. |
|
noexcept |
Changes the permissions mode of a file or directory
name | name of the file ot directory to change |
permissions | permissions to set |
future seastar::chown | ( | std::string_view | filepath, |
uid_t | owner, | ||
gid_t | group | ||
) |
Change the owner and group of file. This is a wrapper around chown syscall. The function throws std::system_error, when the chown syscall fails.
filepath | |
owner | |
group |
|
noexcept |
Check file access.
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.
|
noexcept |
check if a file exists.
name | name of the file to check |
|
noexcept |
Return the size of a file.
name | name of the file to return the size |
Note that file_size of a symlink is NOT the size of the symlink - which is the length of the pathname it contains - but rather the size of the file to which it points.
|
noexcept |
Return stat information about a file.
name | name of the file to return its stat information |
fs | a follow_symlink flag to follow symbolic links. |
Return information about the filesystem where a file is located.
name | name of the file to inspect |
|
noexcept |
Determine the type of a file (regular file, directory, etc.)
name | name of the file for which type information is requested |
follow | a follow_symlink flag that determines whether a trailing symbolic link should be followed or not |
|
noexcept |
Return space available to unprivileged users in filesystem where a file is located, in bytes.
name | name of the file to inspect |
|
noexcept |
Return free space in filesystem where a file is located, in bytes.
name | name of the file to inspect |
future< std::optional< struct group_details > > seastar::getgrnam | ( | std::string_view | name | ) |
Wrapper around getgrnam_r. If the provided group name does not exist in the group database, this call will return an empty optional. If the provided group name exists in the group database, the optional returned will contain the struct group_details information. When an unexpected error is thrown by the getgrnam_r libc call, this function throws std::system_error with std::error_code.
groupname | name of the group |
|
noexcept |
Creates a hard link for a file
oldpath | existing file name |
newpath | name of link |
|
noexcept |
Creates a new directory.
name | name of the directory to create |
permissions | optional file permissions of the directory to create. |
Opens a directory.
name | name of the directory to open |
|
related |
Opens or creates a file. The "dma" in the name refers to the fact that data transfers are unbuffered and uncached.
name | the name of the file to open or create |
flags | various flags controlling the open process |
|
related |
Opens or creates a file. The "dma" in the name refers to the fact that data transfers are unbuffered and uncached.
name | the name of the file to open or create |
flags | various flags controlling the open process |
options | options for opening the file |
|
noexcept |
Recursively ensures a directory exists
Checks whether each component of a directory exists, and if not, creates it.
name | name of the directory to potentially create |
permissions | optional file permissions of the directory to create. |
|
noexcept |
Removes (unlinks) a file or an empty directory
name | name of the file or the directory to remove |
|
noexcept |
Renames (moves) a file.
old_name | existing file name |
new_name | new file name |
|
noexcept |
Synchronizes a directory to disk
Makes sure the modifications in a directory are synchronized in disk. This is useful, for instance, after creating or removing a file inside the directory.
name | name of the directory to potentially create |
|
noexcept |
Ensures a directory exists
Checks whether a directory exists, and if not, creates it. Only the last component of the directory name is created.
name | name of the directory to potentially create |
permissions | optional file permissions of the directory to create. |
|
noexcept |
Helper for ensuring a file is closed after func
is called.
The file provided by the file_fut
future is passed to func
.
file_fut | A future that produces a file |
func | A function that uses a file |
func
, or an exceptional future if either file_fut
or closing the file failed.
|
noexcept |
Helper for ensuring a file is closed if func
fails.
The file provided by the file_fut
future is passed to func
.
file_fut | A future that produces a file |
func | A function that uses a file |
func
, or an exceptional future if file_fut
failed or a nested exception if closing the file failed.