Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lfs.h
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2019-01-08 17:52:03 +0300
committerChristopher Haster <chaster@utexas.edu>2019-01-14 08:56:53 +0300
commit51b2c7e4b64a692d3c71396e1cf2230245516f76 (patch)
treea30c63bd16f7a0ce1acd1a0de3430bf4c5d4e7e5 /lfs.h
parent66d751544d3b63d6650ed66ae2cdb0cdab25a0f3 (diff)
Changed custom attribute descriptors to used arrays
While linked-lists do have some minor benefits, arrays are more idiomatic in C and may provide a more intuitive API. Initially the linked-list approach was more beneficial than it is now, since it allowed custom attributes to be chained to internal linked lists of attributes. However, this was dropped because exposing the internal attribute list in this way created a rather messy user interface that required strictly encoding the attributes with the on-disk tag format. Minor downside, users can no longer introduce custom attributes in different layers (think OS vs app). Minor upside, the code size and stack usage was reduced a bit. Fortunately, this API can always be changed in the future without breaking anything (except maybe API compatibility).
Diffstat (limited to 'lfs.h')
-rw-r--r--lfs.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/lfs.h b/lfs.h
index 4dba2b7..61ef66f 100644
--- a/lfs.h
+++ b/lfs.h
@@ -123,6 +123,7 @@ enum lfs_type {
LFS_TYPE_MOVESTATE = 0x7ff,
// internal chip sources
+ LFS_FROM_NOOP = 0x000,
LFS_FROM_MOVE = 0x101,
LFS_FROM_USERATTRS = 0x102,
};
@@ -268,7 +269,8 @@ struct lfs_info {
char name[LFS_NAME_MAX+1];
};
-// Custom attribute structure
+// Custom attribute structure, used to describe custom attributes
+// committed atomically during file writes.
struct lfs_attr {
// 8-bit type of attribute, provided by user and used to
// identify the attribute
@@ -279,9 +281,6 @@ struct lfs_attr {
// Size of attribute in bytes, limited to LFS_ATTR_MAX
lfs_size_t size;
-
- // Pointer to next attribute in linked list
- struct lfs_attr *next;
};
// Optional configuration provided during lfs_file_opencfg
@@ -290,8 +289,8 @@ struct lfs_file_config {
// By default lfs_malloc is used to allocate this buffer.
void *buffer;
- // Optional linked list of custom attributes related to the file. If the
- // file is opened with read access, the attributes will be read from
+ // Optional list of custom attributes related to the file. If the file
+ // is opened with read access, these attributes will be read from disk
// during the open call. If the file is opened with write access, the
// attributes will be written to disk every file sync or close. This
// write occurs atomically with update to the file's contents.
@@ -302,6 +301,9 @@ struct lfs_file_config {
// is larger, then it will be silently truncated. If the attribute is not
// found, it will be created implicitly.
struct lfs_attr *attrs;
+
+ // Number of custom attributes in the list
+ lfs_size_t attr_count;
};