CardSight 0.1.0
C API reference for the CardSight firmware and application
Loading...
Searching...
No Matches
proxy_lazy.h File Reference

Public interface of the lazy exFAT proxy view. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "storage_proxy.h"

Go to the source code of this file.

Data Structures

struct  storage_proxy_lazy_layout
 Geometry and reservation regions of a running lazy view. More...

Functions

int storage_proxy_lazy_start (const char *source_disk, uint32_t selected_partitions)
 Start the lazy view over selected partitions of a disk.
void storage_proxy_lazy_stop (void)
 Stop the lazy view and release everything it holds.
bool storage_proxy_lazy_running (void)
 Report whether the lazy view is registered as a block device.
const char * storage_proxy_lazy_device_name (void)
 Return the block device name the lazy view is registered under.
int storage_proxy_lazy_layout (struct storage_proxy_lazy_layout *layout)
 Copy the geometry and reservation regions of the running view.
size_t storage_proxy_lazy_directory_count (void)
 Return the number of source directories the view has indexed.
uint32_t storage_proxy_lazy_cached_entries (void)
 Return the number of directory entries currently cached.
uint32_t storage_proxy_lazy_cached_bytes (void)
 Return the number of bytes the directory entry caches currently hold.
bool storage_proxy_lazy_truncated (void)
 Report whether any index limit made part of the source tree invisible.
uint32_t storage_proxy_lazy_cache_evictions (void)
 Return the number of entry caches evicted since start.
void storage_proxy_lazy_set_progress (void(*callback)(void *context, uint32_t entries, const char *path), void *context)
 Install a directory indexing progress callback.
void storage_proxy_lazy_cancel (void)
 Ask a running directory count or load to stop at its next check.
void storage_proxy_lazy_cache_drop (void)
 Drop every cached directory entry, keeping extents and the overlay.

Detailed Description

Public interface of the lazy exFAT proxy view.

The lazy engine synthesises a second exFAT volume, exposed as block device cardview1, whose partition folders are backed by the mounted source file systems. Unlike the eager engine it indexes a source directory only when the host first reads it, keeps those indexes in a bounded LRU cache, and never changes the allocation bitmap after the volume is registered. The view is read-write: host changes go back to the source volumes through a bounded per-view overlay and pending-data table.

Function Documentation

◆ storage_proxy_lazy_cache_drop()

void storage_proxy_lazy_cache_drop ( void )

Drop every cached directory entry, keeping extents and the overlay.

A test or diagnostic helper: the next read reloads each directory from the source readdir result merged with the overlay, which is what proves host-created entries survive cache eviction.

◆ storage_proxy_lazy_cache_evictions()

uint32_t storage_proxy_lazy_cache_evictions ( void )

Return the number of entry caches evicted since start.

Returns
Eviction count, used by diagnostics and host tests to prove the LRU actually had to make room.

◆ storage_proxy_lazy_cached_bytes()

uint32_t storage_proxy_lazy_cached_bytes ( void )

Return the number of bytes the directory entry caches currently hold.

Returns
Cached byte count, including names and cluster order arrays.

◆ storage_proxy_lazy_cached_entries()

uint32_t storage_proxy_lazy_cached_entries ( void )

Return the number of directory entries currently cached.

Returns
Cached entry count.

◆ storage_proxy_lazy_cancel()

void storage_proxy_lazy_cancel ( void )

Ask a running directory count or load to stop at its next check.

Safe to call from any context, including from a progress callback. The interrupted read returns -ECANCELED and leaves no partial cache behind; a later start clears the flag.

◆ storage_proxy_lazy_device_name()

const char * storage_proxy_lazy_device_name ( void )

Return the block device name the lazy view is registered under.

Returns
The constant device name of the lazy view.

◆ storage_proxy_lazy_directory_count()

size_t storage_proxy_lazy_directory_count ( void )

Return the number of source directories the view has indexed.

Returns
Directory header count, including the root and the partition folders.

◆ storage_proxy_lazy_layout()

int storage_proxy_lazy_layout ( struct storage_proxy_lazy_layout * layout)

Copy the geometry and reservation regions of the running view.

Parameters
[out]layoutReceives the layout.
Returns
0 on success, -ENODEV when the view is stopped, or -ETIMEDOUT when the view lock stayed busy.

◆ storage_proxy_lazy_running()

bool storage_proxy_lazy_running ( void )

Report whether the lazy view is registered as a block device.

Returns
True while cardview1 exists.

◆ storage_proxy_lazy_set_progress()

void storage_proxy_lazy_set_progress ( void(* callback )(void *context, uint32_t entries, const char *path),
void * context )

Install a directory indexing progress callback.

The callback runs under the view lock while a source directory is counted or loaded, once every 64 entries, so it must stay short and must not call any other function of this interface except storage_proxy_lazy_cancel(). Set the callback before starting the view.

Parameters
[in]callbackReceives the entry count and the source directory path, or NULL to remove the callback.
[in]contextOpaque pointer passed to callback.

◆ storage_proxy_lazy_start()

int storage_proxy_lazy_start ( const char * source_disk,
uint32_t selected_partitions )

Start the lazy view over selected partitions of a disk.

Probes and mounts the selected partitions, sizes one reservation region per partition, builds the boot region, FAT, allocation bitmap, up-case table and root directory, marks every reservation used, and registers cardview1. No source directory is indexed here.

Parameters
[in]source_diskWhole-disk block device name.
[in]selected_partitionsBit mask of partitions; bit zero is partition one.
Returns
0 on success, or a negative errno.

◆ storage_proxy_lazy_truncated()

bool storage_proxy_lazy_truncated ( void )

Report whether any index limit made part of the source tree invisible.

Returns
True when a directory hit its entry cap, the directory table or name arena filled up, or a cache could not be made to fit.