197 LLFIO_LOG_FUNCTION_CALL(0);
203 auto lockinuse = ret.lock_file_range(_initialisingoffset, 2,
lock_kind::exclusive, std::chrono::seconds(0));
204 if(lockinuse.has_error())
206 if(lockinuse.error() != errc::timed_out)
208 return std::move(lockinuse).error();
214 return std::move(lockinuse).error();
217 memset(buffer, 0,
sizeof(buffer));
218 OUTCOME_TRYV(ret.read(0, {{buffer, 65535}}));
219 path_view temphpath(
reinterpret_cast<filesystem::path::value_type *
>(buffer));
220 result<file_handle> _temph(in_place_type<file_handle>);
226 return errc::no_lock_available;
228 temph = std::move(_temph.value());
231 OUTCOME_TRY(
auto &&temphmap,
map_handle::map(temphsection, HashIndexSize));
235 return memory_map(std::move(ret), std::move(temph), std::move(lockinuse.value()), std::move(hmap), std::move(temphmap));
241 temph = std::move(_temph);
243 OUTCOME_TRYV(temph.truncate(HashIndexSize));
245 OUTCOME_TRY(
auto &&temphmap,
map_handle::map(temphsection, HashIndexSize));
248 OUTCOME_TRY(
auto &&temppath, temph.current_path());
250 memset(buffer, 0,
sizeof(buffer));
251 size_t bytes = temppath.native().size() *
sizeof(*temppath.c_str());
252 file_handle::const_buffer_type buffers[] = {{
reinterpret_cast<const byte *
>(temppath.c_str()), bytes}, {
reinterpret_cast<const byte *
>(buffer), 4096 - (bytes % 4096)}};
253 OUTCOME_TRYV(ret.truncate(65536));
254 OUTCOME_TRYV(ret.write({buffers, 0}));
262 OUTCOME_TRY(
auto &&lockinuse2, ret.lock_file_range(_lockinuseoffset, 1,
lock_kind::shared));
263 lockinuse = std::move(lockinuse2);
264 return memory_map(std::move(ret), std::move(temph), std::move(lockinuse.value()), std::move(hmap), std::move(temphmap));
268 return error_from_exception();
static result< file_handle > file(const path_handle &base, path_view_type path, mode _mode=mode::read, creation _creation=creation::open_existing, caching _caching=caching::all, flag flags=flag::none) noexcept
static result< file_handle > uniquely_named_file(const path_handle &dirpath, mode _mode=mode::write, caching _caching=caching::temporary, flag flags=flag::none) noexcept
Definition: file_handle.hpp:175
bool is_valid() const noexcept
True if the handle is valid (and usually open)
Definition: handle.hpp:323
@ write
Ability to read and write (READ_CONTROL|FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_WRITE_D...
@ reads
Cache reads only. Writes of data and metadata do not complete until reaching storage (O_SYNC)....
@ temporary
Cache reads and writes of data and metadata so they complete immediately, only sending any updates to...
@ if_needed
If filesystem entry exists that is used, else one is created.
@ open_existing
Filesystem entry must already exist.
static result< map_handle > map(size_type bytes, bool zeroed=false, section_handle::flag _flag=section_handle::flag::readwrite) noexcept
Definition: map_handle.hpp:633
static result< section_handle > section(file_handle &backing, extent_type maximum_size, flag _flag) noexcept
Create a memory section backed by a file.
const path_handle & storage_backed_temporary_files_directory() noexcept
Returns a reference to an open handle to a verified temporary directory where files created are store...
const path_handle & memory_backed_temporary_files_directory() noexcept
Returns a reference to an open handle to a verified temporary directory where files created are store...
byte_io_handle::io_result< byte_io_handle::buffers_type > read(byte_io_handle &self, byte_io_handle::io_request< byte_io_handle::buffers_type > reqs, deadline d=deadline()) noexcept
Read data from the open handle.
Definition: byte_io_handle.hpp:654
@ shared
Exclude only those requesting an exclusive lock on the same inode.
@ exclusive
Exclude those requesting any kind of lock on the same inode.