CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
PluginStorage.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <cstdint>
13#include <cstddef>
14#include <vector>
15#include <string>
16
17namespace cdc::plugin_manager {
18
20public:
25 static bool mount();
26
30 static void unmount();
31
35 static const char* basePath();
36
41 static std::vector<std::string> listPluginIds();
42
47 static std::string binaryPath(const std::string& id);
48
52 static std::string wasmPath(const std::string& id);
53
57 static std::string aotPath(const std::string& id);
58
62 static std::string metaPath(const std::string& id);
63
67 static std::string langPath(const std::string& id);
68
72 static std::string disabledPath(const std::string& id);
73
77 static bool isDisabled(const std::string& id);
78
82 static bool setDisabled(const std::string& id, bool disabled);
83
87 static bool stats(uint64_t& free_bytes, uint64_t& total_bytes);
88
89 // --- USB Mass Storage block access (vfat wear-levelling device) ---
90
95 static uint16_t blockSize();
96
101 static uint64_t blockTotalBytes();
102
111 static bool blockRead(uint32_t lba, uint32_t offset, void* buf, uint32_t len);
112
124 static bool blockWrite(uint32_t lba, uint32_t offset, const void* buf, uint32_t len);
125
126 // --- USB Mass Storage host-active gate ---
127
137 static void setHostActive(bool active);
138
143 static bool hostActive();
144
152 static void remountIfPending();
153
160 static void protectSystemDir();
161};
162
163} // namespace cdc::plugin_manager
static bool blockWrite(uint32_t lba, uint32_t offset, const void *buf, uint32_t len)
Erases and writes raw bytes to the wear-levelling logical space.
static bool mount()
Mount the plugins partition. Auto-formats if empty.
static const char * basePath()
Returns the VFS path prefix, e.g. "/vfat".
static uint16_t blockSize()
Logical sector size of the vfat volume in bytes (MSC block size).
static std::string langPath(const std::string &id)
Returns the full VFS path of <id>.lang (translation overlay).
static void unmount()
Unmount the plugins partition (rarely used; mostly tests).
static std::string aotPath(const std::string &id)
Returns the full VFS path of <id>.aot.
static bool stats(uint64_t &free_bytes, uint64_t &total_bytes)
Returns the free and total bytes on the plugins partition.
static bool blockRead(uint32_t lba, uint32_t offset, void *buf, uint32_t len)
Reads raw bytes from the wear-levelling logical space.
static bool isDisabled(const std::string &id)
True when the plugin has a persistent disabled marker.
static bool setDisabled(const std::string &id, bool disabled)
Create or remove the persistent disabled marker for a plugin.
static std::string disabledPath(const std::string &id)
Returns the full VFS path of <id>.disabled.
static void setHostActive(bool active)
Marks whether a USB host currently holds the volume over MSC.
static void protectSystemDir()
Applies advisory read-only + hidden + system FAT attributes to the system folder so standard host fil...
static std::vector< std::string > listPluginIds()
Discover all installed plugin ids. A plugin is recognised by the presence of both <id>....
static uint64_t blockTotalBytes()
Total accessible size of the vfat volume in bytes.
static bool hostActive()
Reports whether a USB host currently holds the volume over MSC.
static std::string wasmPath(const std::string &id)
Returns the full VFS path of <id>.wasm.
static void remountIfPending()
Performs a deferred remount scheduled by setHostActive(false).
static std::string metaPath(const std::string &id)
Returns the full VFS path of <id>.meta.
static std::string binaryPath(const std::string &id)
Returns the path that should be loaded for <id>: <id>.aot if it exists on disk, otherwise <id>....