@@ -1003,7 +1003,7 @@ int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) {
1003
1003
1004
1004
1005
1005
/// File index list operations ///
1006
- static int lfs_index (lfs_t * lfs , lfs_off_t * off ) {
1006
+ static int lfs_ctz_index (lfs_t * lfs , lfs_off_t * off ) {
1007
1007
lfs_off_t i = 0 ;
1008
1008
1009
1009
while (* off >= lfs -> cfg -> block_size ) {
@@ -1015,7 +1015,7 @@ static int lfs_index(lfs_t *lfs, lfs_off_t *off) {
1015
1015
return i ;
1016
1016
}
1017
1017
1018
- static int lfs_index_find (lfs_t * lfs ,
1018
+ static int lfs_ctz_find (lfs_t * lfs ,
1019
1019
lfs_cache_t * rcache , const lfs_cache_t * pcache ,
1020
1020
lfs_block_t head , lfs_size_t size ,
1021
1021
lfs_size_t pos , lfs_block_t * block , lfs_off_t * off ) {
@@ -1025,8 +1025,8 @@ static int lfs_index_find(lfs_t *lfs,
1025
1025
return 0 ;
1026
1026
}
1027
1027
1028
- lfs_off_t current = lfs_index (lfs , & (lfs_off_t ){size - 1 });
1029
- lfs_off_t target = lfs_index (lfs , & pos );
1028
+ lfs_off_t current = lfs_ctz_index (lfs , & (lfs_off_t ){size - 1 });
1029
+ lfs_off_t target = lfs_ctz_index (lfs , & pos );
1030
1030
1031
1031
while (current > target ) {
1032
1032
lfs_size_t skip = lfs_min (
@@ -1047,7 +1047,7 @@ static int lfs_index_find(lfs_t *lfs,
1047
1047
return 0 ;
1048
1048
}
1049
1049
1050
- static int lfs_index_extend (lfs_t * lfs ,
1050
+ static int lfs_ctz_extend (lfs_t * lfs ,
1051
1051
lfs_cache_t * rcache , lfs_cache_t * pcache ,
1052
1052
lfs_block_t head , lfs_size_t size ,
1053
1053
lfs_off_t * block , lfs_block_t * off ) {
@@ -1073,7 +1073,7 @@ static int lfs_index_extend(lfs_t *lfs,
1073
1073
}
1074
1074
1075
1075
size -= 1 ;
1076
- lfs_off_t index = lfs_index (lfs , & size );
1076
+ lfs_off_t index = lfs_ctz_index (lfs , & size );
1077
1077
size += 1 ;
1078
1078
1079
1079
// just copy out the last block if it is incomplete
@@ -1133,15 +1133,15 @@ static int lfs_index_extend(lfs_t *lfs,
1133
1133
}
1134
1134
}
1135
1135
1136
- static int lfs_index_traverse (lfs_t * lfs ,
1136
+ static int lfs_ctz_traverse (lfs_t * lfs ,
1137
1137
lfs_cache_t * rcache , const lfs_cache_t * pcache ,
1138
1138
lfs_block_t head , lfs_size_t size ,
1139
1139
int (* cb )(void * , lfs_block_t ), void * data ) {
1140
1140
if (size == 0 ) {
1141
1141
return 0 ;
1142
1142
}
1143
1143
1144
- lfs_off_t index = lfs_index (lfs , & (lfs_off_t ){size - 1 });
1144
+ lfs_off_t index = lfs_ctz_index (lfs , & (lfs_off_t ){size - 1 });
1145
1145
1146
1146
while (true) {
1147
1147
int err = cb (data , head );
@@ -1455,7 +1455,7 @@ lfs_ssize_t lfs_file_read(lfs_t *lfs, lfs_file_t *file,
1455
1455
// check if we need a new block
1456
1456
if (!(file -> flags & LFS_F_READING ) ||
1457
1457
file -> off == lfs -> cfg -> block_size ) {
1458
- int err = lfs_index_find (lfs , & file -> cache , NULL ,
1458
+ int err = lfs_ctz_find (lfs , & file -> cache , NULL ,
1459
1459
file -> head , file -> size ,
1460
1460
file -> pos , & file -> block , & file -> off );
1461
1461
if (err ) {
@@ -1522,7 +1522,7 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
1522
1522
file -> off == lfs -> cfg -> block_size ) {
1523
1523
if (!(file -> flags & LFS_F_WRITING ) && file -> pos > 0 ) {
1524
1524
// find out which block we're extending from
1525
- int err = lfs_index_find (lfs , & file -> cache , NULL ,
1525
+ int err = lfs_ctz_find (lfs , & file -> cache , NULL ,
1526
1526
file -> head , file -> size ,
1527
1527
file -> pos - 1 , & file -> block , & file -> off );
1528
1528
if (err ) {
@@ -1535,7 +1535,7 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
1535
1535
1536
1536
// extend file with new blocks
1537
1537
lfs_alloc_ack (lfs );
1538
- int err = lfs_index_extend (lfs , & lfs -> rcache , & file -> cache ,
1538
+ int err = lfs_ctz_extend (lfs , & lfs -> rcache , & file -> cache ,
1539
1539
file -> block , file -> pos ,
1540
1540
& file -> block , & file -> off );
1541
1541
if (err ) {
@@ -2070,7 +2070,7 @@ int lfs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data) {
2070
2070
2071
2071
dir .off += lfs_entry_size (& entry );
2072
2072
if ((0x70 & entry .d .type ) == (0x70 & LFS_TYPE_REG )) {
2073
- int err = lfs_index_traverse (lfs , & lfs -> rcache , NULL ,
2073
+ int err = lfs_ctz_traverse (lfs , & lfs -> rcache , NULL ,
2074
2074
entry .d .u .file .head , entry .d .u .file .size , cb , data );
2075
2075
if (err ) {
2076
2076
return err ;
@@ -2089,15 +2089,15 @@ int lfs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data) {
2089
2089
// iterate over any open files
2090
2090
for (lfs_file_t * f = lfs -> files ; f ; f = f -> next ) {
2091
2091
if (f -> flags & LFS_F_DIRTY ) {
2092
- int err = lfs_index_traverse (lfs , & lfs -> rcache , & f -> cache ,
2092
+ int err = lfs_ctz_traverse (lfs , & lfs -> rcache , & f -> cache ,
2093
2093
f -> head , f -> size , cb , data );
2094
2094
if (err ) {
2095
2095
return err ;
2096
2096
}
2097
2097
}
2098
2098
2099
2099
if (f -> flags & LFS_F_WRITING ) {
2100
- int err = lfs_index_traverse (lfs , & lfs -> rcache , & f -> cache ,
2100
+ int err = lfs_ctz_traverse (lfs , & lfs -> rcache , & f -> cache ,
2101
2101
f -> block , f -> pos , cb , data );
2102
2102
if (err ) {
2103
2103
return err ;
0 commit comments