WIP custom attributes

This commit is contained in:
Christopher Haster
2018-04-05 19:03:58 -05:00
parent a82ea60658
commit 2aee22aa49
2 changed files with 224 additions and 32 deletions

32
lfs.h
View File

@@ -89,6 +89,8 @@ enum lfs_error {
LFS_ERR_NOSPC = -28, // No space left on device
LFS_ERR_NOMEM = -12, // No more memory available
LFS_ERR_NAMETOOLONG = -36, // File name too long
LFS_ERR_NODATA = -61, // No data/attr available
LFS_ERR_RANGE = -34, // Result not representable
};
// File types
@@ -253,6 +255,13 @@ typedef struct lfs_entry {
} d;
} lfs_entry_t;
typedef struct lfs_attr {
struct lfs_disk_attr {
uint8_t type;
uint8_t len;
} d;
} lfs_attr_t;
typedef struct lfs_cache {
lfs_block_t block;
lfs_off_t off;
@@ -379,6 +388,29 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath);
// Returns a negative error code on failure.
int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info);
// Get a custom attribute
//
// Attributes are identified by an 8-bit type and are limited to at
// most LFS_ATTRS_SIZE bytes.
// Returns the size of the attribute, or a negative error code on failure.
int lfs_getattr(lfs_t *lfs, const char *path,
uint8_t type, void *buffer, lfs_size_t size);
// Set a custom attribute
//
// Attributes are identified by an 8-bit type and are limited to at
// most LFS_ATTRS_SIZE bytes.
// Returns a negative error code on failure.
int lfs_setattr(lfs_t *lfs, const char *path,
uint8_t type, const void *buffer, lfs_size_t size);
// Remove a custom attribute
//
// Attributes are identified by an 8-bit type and are limited to at
// most LFS_ATTRS_SIZE bytes.
// Returns a negative error code on failure.
int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type);
/// File operations ///