35namespace fs = std::filesystem;
39ENUM(OverlayType, BWRAP, OVERLAYFS, UNIONFS)
48inline
Value<
void>
write(fs::path const& path_file_binary, OverlayType const& overlay)
53 case OverlayType::BWRAP: mask = 1 << 1;
break;
54 case OverlayType::OVERLAYFS: mask = 1 << 2;
break;
55 case OverlayType::UNIONFS: mask = 1 << 3;
break;
56 case OverlayType::NONE:
57 default:
return Error(
"E::Invalid overlay option");
59 uint64_t offset_begin = ns_reserved::FIM_RESERVED_OFFSET_OVERLAY_BEGIN;
60 uint64_t offset_end = ns_reserved::FIM_RESERVED_OFFSET_OVERLAY_END;
61 uint64_t size = offset_end - offset_begin;
62 return_if(size !=
sizeof(uint8_t), Error(
"E::Incorrect number of bytes to write overlay mask: {} vs {}", size,
sizeof(uint8_t)));
63 return ns_reserved::write(path_file_binary, offset_begin, offset_end,
reinterpret_cast<char*
>(&mask),
sizeof(uint8_t));
74 uint64_t offset_begin = ns_reserved::FIM_RESERVED_OFFSET_OVERLAY_BEGIN;
76 ssize_t bytes = Pop(
ns_reserved::read(path_file_binary, offset_begin,
reinterpret_cast<char*
>(&mask),
sizeof(uint8_t)));
77 log_if(bytes != 1,
"E::Possible error to read overlay byte, count is {}", bytes);
80 case 1 << 1:
return OverlayType::BWRAP;
81 case 1 << 2:
return OverlayType::OVERLAYFS;
82 case 1 << 3:
return OverlayType::UNIONFS;
83 default:
return std::unexpected(
"Invalid overlay option");
Custom enumeration class.
Enhanced error handling framework built on std::expected.
Simplified macros for common control flow patterns with optional logging.
Overlay filesystem type selection in reserved space.
Value< void > write(fs::path const &path_file_binary, OverlayType const &overlay)
Writes a overlay mask to the flatimage binary.
Value< OverlayType > read(fs::path const &path_file_binary)
Read the overlay mask from the flatimage binary.
Value< void > write(fs::path const &path_file_binary, uint64_t offset_begin, uint64_t offset_end, const char *data, uint64_t length) noexcept
Writes data to a file in binary format.
Value< std::streamsize > read(fs::path const &path_file_binary, uint64_t offset, char *data, uint64_t length) noexcept
Reads data from a file in binary format.
Enhanced expected type with integrated logging capabilities.