t: Replaced LFS_T_EXCL with LFS_I_DIRTY flag in lfsr_tinfo
This just forwards the internal LFS_I_DIRTY flag to the user via the
lfsr_tinfo flags field.
Benefits of this approach:
- Gives the user more flexibility on what to do if the filesystem is
modified, maybe you want to keep traversing depending on some other
logic.
- Can eventually add other flags to tinfo.flags, such as
LFS_I_COMPACTED, LFS_I_REPAIRED, LFS_I_INCONSISTENT, etc.
- Avoids confusion around the very different behaviors of LFS_O_EXCL and
LFS_T_EXCL.
I tried to come up with a better name (maybe LFS_T_WATCH?) but it was
a bit of a struggle... Switching to a flags approach sidesteps the
issue.
- Can drop the LFS_ERR_BUSY error code for now.
Code changes were fairly insignificant:
code stack
before: 35244 2680
after: 35224 (-0.1%) 2680 (+0.0%)
The only concern is that the tests highlighted it's possible for our
flag scheme to miss mutation if it happens after/during the last set of
blocks... Not sure how to handle this yet...
This commit is contained in:
@@ -98,7 +98,6 @@ enum lfs_error {
|
||||
LFS_ERR_UNKNOWN = -1, // Unknown error
|
||||
LFS_ERR_INVAL = -22, // Invalid parameter
|
||||
LFS_ERR_NOTSUP = -95, // Operation not supported
|
||||
LFS_ERR_BUSY = -16, // Device or resource busy
|
||||
LFS_ERR_IO = -5, // Error during device operation
|
||||
LFS_ERR_CORRUPT = -84, // Corrupted
|
||||
LFS_ERR_NOENT = -2, // No directory entry
|
||||
@@ -169,8 +168,7 @@ enum lfs_btype {
|
||||
// Traversal flags
|
||||
enum lfs_traversal_flags {
|
||||
// traversal open flags
|
||||
LFS_T_MTREEONLY = 0x0008, // Only traverse the mtree
|
||||
LFS_T_EXCL = 0x0010, // Terminate if filesystem modified
|
||||
LFS_T_MTREEONLY = 0x0010, // Only traverse the mtree
|
||||
LFS_T_MKCONSISTENT = 0x0020, // Make the filesystem consistent
|
||||
LFS_T_LOOKAHEAD = 0x0040, // Populate lookahead buffer
|
||||
LFS_T_COMPACT = 0x0080, // Compact metadata logs
|
||||
@@ -179,9 +177,11 @@ enum lfs_traversal_flags {
|
||||
// TODO
|
||||
// LFS_T_REPAIRMETA = 0x0400, // Repair metadata blocks
|
||||
// LFS_T_REPAIRDATA = 0x0c00, // Repair metadata + data blocks
|
||||
};
|
||||
|
||||
// internally used flags
|
||||
LFS_F_DIRTY = 0x1000, // Filesystem has been modified
|
||||
enum lfs_tinfo_flags {
|
||||
// traversal info flags
|
||||
LFS_I_DIRTY = 0x1000, // Filesystem has been modified
|
||||
};
|
||||
|
||||
|
||||
@@ -385,6 +385,9 @@ struct lfs_fsinfo {
|
||||
|
||||
// Traversal info structure
|
||||
struct lfs_tinfo {
|
||||
// Traversal flags
|
||||
uint16_t flags;
|
||||
|
||||
// Type of the block
|
||||
uint8_t btype;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user