Seastar
High performance C++ framework for concurrent servers
seastar.hh
1 /*
2  * This file is open source software, licensed to you under the terms
3  * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4  * distributed with this work for additional information regarding copyright
5  * ownership. You may not use this file except in compliance with the License.
6  *
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14  * KIND, either express or implied. See the License for the
15  * specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 /*
20  * Copyright (C) 2015 Cloudius Systems, Ltd.
21  */
22 
23 #pragma once
24 
49 
50 #include <seastar/core/sstring.hh>
51 #include <seastar/core/future.hh>
52 #include <seastar/core/file-types.hh>
53 #include <seastar/core/posix.hh>
54 #include <seastar/util/bool_class.hh>
55 #include <seastar/util/std-compat.hh>
56 #include <seastar/util/modules.hh>
57 #include "./internal/api-level.hh"
58 #ifndef SEASTAR_MODULE
59 #include <cstdint>
60 #include <filesystem>
61 #include <optional>
62 #include <string_view>
63 #endif
64 
65 namespace seastar {
66 
67 SEASTAR_MODULE_EXPORT_BEGIN
68 
69 // iostream.hh
70 template <class CharType> class input_stream;
71 template <class CharType> class output_stream;
72 
73 class server_socket;
74 class socket;
75 class connected_socket;
76 class socket_address;
77 struct listen_options;
78 enum class transport;
79 
80 // file.hh
81 class file;
82 struct file_open_options;
83 struct stat_data;
84 
85 namespace net {
86 
87 using udp_channel = class datagram_channel;
88 
89 }
90 
91 namespace experimental {
92 // process.hh
93 class process;
94 struct spawn_parameters;
95 }
96 
97 // Networking API
98 
110 
113 
124 
136 
145 
156 
157 
162 
169 [[deprecated("Use `make_unbound_datagram_channel` instead")]]
170 net::udp_channel make_udp_channel();
171 
172 
178 [[deprecated("Use `make_bound_datagram_channel` instead")]]
179 net::udp_channel make_udp_channel(const socket_address& local);
180 
197 
207 
209 
222 
225 
238 future<file> open_file_dma(std::string_view name, open_flags flags) noexcept;
239 
253 future<file> open_file_dma(std::string_view name, open_flags flags, file_open_options options) noexcept;
254 
269 future<> check_direct_io_support(std::string_view path) noexcept;
270 
280 future<file> open_directory(std::string_view name) noexcept;
281 
290 future<> make_directory(std::string_view name, file_permissions permissions = file_permissions::default_dir_permissions) noexcept;
291 
304 future<> touch_directory(std::string_view name, file_permissions permissions = file_permissions::default_dir_permissions) noexcept;
305 
318 future<> recursive_touch_directory(std::string_view name, file_permissions permissions = file_permissions::default_dir_permissions) noexcept;
319 
327 future<> sync_directory(std::string_view name) noexcept;
328 
329 
337 future<> remove_file(std::string_view name) noexcept;
338 
347 future<> rename_file(std::string_view old_name, std::string_view new_name) noexcept;
348 
351 
360 future<stat_data> file_stat(std::string_view name, follow_symlink fs = follow_symlink::yes) noexcept;
361 
369 future<uint64_t> file_size(std::string_view name) noexcept;
370 
385 future<bool> file_accessible(std::string_view name, access_flags flags) noexcept;
386 
390 future<bool> file_exists(std::string_view name) noexcept;
391 
400 future<std::optional<directory_entry_type>> file_type(std::string_view name, follow_symlink follow = follow_symlink::yes) noexcept;
401 
402 
408 future<> link_file(std::string_view oldpath, std::string_view newpath) noexcept;
409 
415 future<> chmod(std::string_view name, file_permissions permissions) noexcept;
416 
420 future<fs_type> file_system_at(std::string_view name) noexcept;
421 
425 future<uint64_t> fs_avail(std::string_view name) noexcept;
426 
430 future<uint64_t> fs_free(std::string_view name) noexcept;
432 
433 namespace experimental {
437 
440 
446 
456 future<process> spawn_process(const std::filesystem::path& pathname,
457  spawn_parameters params);
466 future<process> spawn_process(const std::filesystem::path& pathname);
468 }
469 
470 SEASTAR_MODULE_EXPORT_END
471 
472 }
Type-safe boolean.
Definition: bool_class.hh:57
A representation of a possibly not-yet-computed value.
Definition: future.hh:1238
Definition: api.hh:115
A listening socket, waiting to accept incoming network connections.
Definition: api.hh:325
Definition: socket_defs.hh:47
Definition: api.hh:282
future< stat_data > file_stat(std::string_view name, follow_symlink fs=follow_symlink::yes) noexcept
future touch_directory(std::string_view name, file_permissions permissions=file_permissions::default_dir_permissions) noexcept
future< file > open_file_dma(std::string_view name, open_flags flags, file_open_options options) noexcept
future remove_file(std::string_view name) noexcept
future< std::optional< directory_entry_type > > file_type(std::string_view name, follow_symlink follow=follow_symlink::yes) noexcept
future< fs_type > file_system_at(std::string_view name) noexcept
future rename_file(std::string_view old_name, std::string_view new_name) noexcept
future< bool > file_exists(std::string_view name) noexcept
future< uint64_t > fs_free(std::string_view name) noexcept
future chmod(std::string_view name, file_permissions permissions) noexcept
future recursive_touch_directory(std::string_view name, file_permissions permissions=file_permissions::default_dir_permissions) noexcept
future check_direct_io_support(std::string_view path) noexcept
future< file > open_directory(std::string_view name) noexcept
future< uint64_t > file_size(std::string_view name) noexcept
future< file > open_file_dma(std::string_view name, open_flags flags) noexcept
future< uint64_t > fs_avail(std::string_view name) noexcept
future link_file(std::string_view oldpath, std::string_view newpath) noexcept
future< bool > file_accessible(std::string_view name, access_flags flags) noexcept
open_flags
Definition: file-types.hh:41
future sync_directory(std::string_view name) noexcept
future make_directory(std::string_view name, file_permissions permissions=file_permissions::default_dir_permissions) noexcept
future< std::tuple< file_desc, file_desc > > make_pipe()
future< process > spawn_process(const std::filesystem::path &pathname)
server_socket listen(socket_address sa)
future< connected_socket > connect(socket_address sa)
net::udp_channel make_udp_channel()
net::datagram_channel make_unbound_datagram_channel(sa_family_t family)
socket make_socket()
net::datagram_channel make_bound_datagram_channel(const socket_address &local)
::seastar::socket socket(shared_ptr< certificate_credentials >, sstring name)
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: file.hh:91
Definition: api.hh:391