VSF Documented
esp_littlefs.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * esp_littlefs.h -- mount/unmount helpers binding a LittleFS volume stored
20 * in an ESP-IDF partition to a POSIX path prefix. API matches the widely
21 * used joltwallet/esp_littlefs component so that code written against it
22 * compiles unchanged.
23 *
24 * Threading: all APIs MUST be invoked from a vsf_thread_t context.
25 */
26
27#ifndef __VSF_ESPIDF_ESP_LITTLEFS_H__
28#define __VSF_ESPIDF_ESP_LITTLEFS_H__
29
30/*============================ INCLUDES ======================================*/
31
32#include "esp_err.h"
33
34#include <stdint.h>
35#include <stddef.h>
36#include <stdbool.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/*============================ TYPES =========================================*/
43
45 const char *base_path; // mount point, e.g. "/littlefs"
46 const char *partition_label; // target partition label
49 uint8_t dont_mount : 1; // prepare only, no mount
50 uint8_t grow_on_mount : 1; // accepted for compat; no-op
52
53/*============================ PROTOTYPES ====================================*/
54
55/*
56 * Register and (by default) mount a LittleFS volume.
57 *
58 * Returns ESP_OK on success, otherwise:
59 * ESP_ERR_INVALID_ARG conf / base_path / partition_label invalid.
60 * ESP_ERR_NOT_FOUND partition_label does not match any entry.
61 * ESP_ERR_NO_MEM out-of-memory for fs info allocation.
62 * ESP_ERR_INVALID_STATE base_path already in use.
63 * ESP_FAIL underlying vk_fs_mount returned an error.
64 */
66
67/* Unregister a previously registered LittleFS instance, identified by its
68 * partition label. */
69extern esp_err_t esp_vfs_littlefs_unregister(const char *partition_label);
70
71/* Force-format the LittleFS volume on the given partition. The volume
72 * MUST be unregistered when this is called. */
73extern esp_err_t esp_littlefs_format(const char *partition_label);
74
75/* Query used/total bytes of a mounted LittleFS volume. Either pointer may
76 * be NULL to skip that field.
77 *
78 * Accuracy note: VSF's current lfs port does not expose a cheap used-bytes
79 * counter; total_bytes is derived from the partition size and used_bytes
80 * is reported as 0 until a proper traversal helper lands. Callers relying
81 * on exact values should treat them as lower bounds.
82 */
83extern esp_err_t esp_littlefs_info(const char *partition_label,
84 size_t *total_bytes,
85 size_t *used_bytes);
86
87/* Return true iff a LittleFS instance is currently registered against
88 * this partition label. */
89extern bool esp_littlefs_mounted(const char *partition_label);
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif // __VSF_ESPIDF_ESP_LITTLEFS_H__
int esp_err_t
Definition esp_err.h:41
bool esp_littlefs_mounted(const char *partition_label)
Definition esp_littlefs_port.c:272
esp_err_t esp_vfs_littlefs_register(const esp_vfs_littlefs_conf_t *conf)
Definition esp_littlefs_port.c:139
esp_err_t esp_littlefs_format(const char *partition_label)
Definition esp_littlefs_port.c:211
esp_err_t esp_vfs_littlefs_unregister(const char *partition_label)
Definition esp_littlefs_port.c:198
esp_err_t esp_littlefs_info(const char *partition_label, size_t *total_bytes, size_t *used_bytes)
Definition esp_littlefs_port.c:253
unsigned char uint8_t
Definition stdint.h:5
Definition esp_littlefs.h:44
uint8_t grow_on_mount
Definition esp_littlefs.h:50
uint8_t format_if_mount_failed
Definition esp_littlefs.h:47
uint8_t read_only
Definition esp_littlefs.h:48
const char * base_path
Definition esp_littlefs.h:45
const char * partition_label
Definition esp_littlefs.h:46
uint8_t dont_mount
Definition esp_littlefs.h:49
Generated from commit: vsfteam/vsf@015f4d1