@@ -82,13 +82,15 @@ typedef enum fs_error_t {
8282 FS_ERR_LFN_TOO_LONG ,
8383 FS_ERR_IS_EXFAT ,
8484 FS_ERR_BAD_CLUSTER ,
85+ FS_ERR_INTERNAL ,
86+ FS_ERR_OUT_OF_BOUNDS ,
8587} fs_error_t ;
8688
8789/**
8890 * @brief Retrieve a human-readable string for the last filesystem error code.
8991 *
9092 * This function maps an fs_error_t code to its corresponding descriptive
91- * string. It does not reset or clear the error code — the last error value
93+ * string. It does not reset or clear the error code - the last error value
9294 * is retained until a new filesystem error is set via fs_set_error().
9395 *
9496 * @note The validity of the returned error string depends on the result of the
@@ -246,6 +248,8 @@ typedef struct {
246248 bool is_optical ;
247249} storage_device_ui_t ;
248250
251+ struct block_cache ;
252+
249253/**
250254 * @brief Represents a block storage device e.g. a hard disk, DVD-ROM drive, etc.
251255 *
@@ -301,8 +305,17 @@ typedef struct storage_device_t {
301305 */
302306 void * opaque2 ;
303307
308+ /**
309+ * @brief User interface strings, model name, capacity, type
310+ * as human-readable text.
311+ */
304312 storage_device_ui_t ui ;
305313
314+ /**
315+ * @brief Block cache for the device
316+ */
317+ struct block_cache * cache ;
318+
306319 /**
307320 * @brief Pointer to next storage device, or NULL
308321 */
@@ -668,4 +681,34 @@ uint32_t fs_get_error(void);
668681 */
669682bool install_gpt_esp_rfs_whole_image (const char * devname , const char * esp_image_vfs_path );
670683
671- void installer ();
684+ /**
685+ * @brief Installation stub, installer/main.c
686+ */
687+ void installer ();
688+
689+ /**
690+ * @brief Enable a block-level cache for a storage device.
691+ *
692+ * This attaches a new cache instance to the device if one is not already
693+ * present. The cache is only created when the device has a valid sector size
694+ * and read path. Devices that do not benefit from caching (e.g. ramdisks)
695+ * should not call this function.
696+ *
697+ * @param device Storage device to enable caching for.
698+ * @return true if a cache was successfully created and attached,
699+ * false if caching could not be enabled (invalid arguments,
700+ * already enabled, or allocation failure).
701+ */
702+ bool storage_enable_cache (storage_device_t * device );
703+
704+ /**
705+ * @brief Disable and destroy the cache attached to a storage device.
706+ *
707+ * If a cache is present on the device it will be destroyed and all resources
708+ * freed. After this call, @p sd->cache will be set to NULL. Calling this on
709+ * a device without a cache is safe and has no effect.
710+ *
711+ * @param sd Storage device to disable caching for.
712+ */
713+ void storage_disable_cache (storage_device_t * sd );
714+
0 commit comments