Lines Matching full:if

15     // do not zero, cheaper if cache is readonly or only going to be  in lfs_cache_drop()
32 if (block >= lfs->cfg->block_count || in lfs_bd_read()
40 if (pcache && block == pcache->block && in lfs_bd_read()
42 if (off >= pcache->off) { in lfs_bd_read()
57 if (block == rcache->block && in lfs_bd_read()
59 if (off >= rcache->off) { in lfs_bd_read()
74 if (size >= hint && off % lfs->cfg->read_size == 0 && in lfs_bd_read()
79 if (err) { in lfs_bd_read()
102 if (err) { in lfs_bd_read()
127 if (err) { in lfs_bd_cmp()
131 if (dat != data[i]) { in lfs_bd_cmp()
141 if (pcache->block != LFS_BLOCK_NULL && pcache->block != LFS_BLOCK_INLINE) { in lfs_bd_flush()
147 if (err) { in lfs_bd_flush()
151 if (validate) { in lfs_bd_flush()
157 if (res < 0) { in lfs_bd_flush()
161 if (res != LFS_CMP_EQ) { in lfs_bd_flush()
177 if (err) { in lfs_bd_sync()
195 if (block == pcache->block && in lfs_bd_prog()
208 if (pcache->size == lfs->cfg->cache_size) { in lfs_bd_prog()
209 // eagerly flush out pcache if we fill up in lfs_bd_prog()
211 if (err) { in lfs_bd_prog()
349 if (((uint32_t*)a)[i] != 0) { in lfs_gstate_iszero()
448 if (off < lfs->free.size) { in lfs_alloc_lookahead()
475 if (!(lfs->free.buffer[off / 32] & (1U << (off % 32)))) { in lfs_alloc()
492 // check if we have looked at all blocks since last ack in lfs_alloc()
493 if (lfs->free.ack == 0) { in lfs_alloc()
507 if (err) { in lfs_alloc()
522 if (lfs_gstate_hasmovehere(&lfs->gdisk, dir->pair) && in lfs_dir_getslice()
536 if (err) { in lfs_dir_getslice()
542 if (lfs_tag_id(gmask) != 0 && in lfs_dir_getslice()
545 if (tag == (LFS_MKTAG(LFS_TYPE_CREATE, 0, 0) | in lfs_dir_getslice()
555 if ((gmask & tag) == (gmask & (gtag - gdiff))) { in lfs_dir_getslice()
556 if (lfs_tag_isdelete(tag)) { in lfs_dir_getslice()
564 if (err) { in lfs_dir_getslice()
589 if (off+size > lfs->cfg->block_size) { in lfs_dir_getread()
596 if (pcache && pcache->block == LFS_BLOCK_INLINE && in lfs_dir_getread()
598 if (off >= pcache->off) { in lfs_dir_getread()
613 if (rcache->block == LFS_BLOCK_INLINE && in lfs_dir_getread()
615 if (off >= rcache->off) { in lfs_dir_getread()
637 if (err < 0) { in lfs_dir_getread()
656 if ((mask & tag) == (mask & *filtertag) || in lfs_dir_traverse_filter()
664 // check if we need to adjust for created/deleted tags in lfs_dir_traverse_filter()
665 if (lfs_tag_type1(tag) == LFS_TYPE_SPLICE && in lfs_dir_traverse_filter()
684 if (off+lfs_tag_dsize(ptag) < dir->off) { in lfs_dir_traverse()
689 if (err) { in lfs_dir_traverse()
698 } else if (attrcount > 0) { in lfs_dir_traverse()
708 if ((mask & tmask & tag) != (mask & tmask & ttag)) { in lfs_dir_traverse()
714 if (lfs_tag_id(tmask) != 0) { in lfs_dir_traverse()
720 if (filter < 0) { in lfs_dir_traverse()
724 if (filter) { in lfs_dir_traverse()
729 if (!(lfs_tag_id(tag) >= begin && lfs_tag_id(tag) < end)) { in lfs_dir_traverse()
735 if (lfs_tag_type3(tag) == LFS_FROM_NOOP) { in lfs_dir_traverse()
737 } else if (lfs_tag_type3(tag) == LFS_FROM_MOVE) { in lfs_dir_traverse()
746 if (err) { in lfs_dir_traverse()
749 } else if (lfs_tag_type3(tag) == LFS_FROM_USERATTRS) { in lfs_dir_traverse()
754 if (err) { in lfs_dir_traverse()
760 if (err) { in lfs_dir_traverse()
775 // if either block address is invalid we return LFS_ERR_CORRUPT here, in lfs_dir_fetchmatch()
777 if (pair[0] >= lfs->cfg->block_count || pair[1] >= lfs->cfg->block_count) { in lfs_dir_fetchmatch()
789 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
793 if (err != LFS_ERR_CORRUPT && in lfs_dir_fetchmatch()
825 if (err) { in lfs_dir_fetchmatch()
826 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
838 if (!lfs_tag_isvalid(tag)) { in lfs_dir_fetchmatch()
842 } else if (off + lfs_tag_dsize(tag) > lfs->cfg->block_size) { in lfs_dir_fetchmatch()
849 if (lfs_tag_type1(tag) == LFS_TYPE_CRC) { in lfs_dir_fetchmatch()
855 if (err) { in lfs_dir_fetchmatch()
856 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
864 if (crc != dcrc) { in lfs_dir_fetchmatch()
869 // reset the next bit if we need to in lfs_dir_fetchmatch()
896 if (err) { in lfs_dir_fetchmatch()
897 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
908 if (lfs_tag_type1(tag) == LFS_TYPE_NAME) { in lfs_dir_fetchmatch()
909 // increase count of files if necessary in lfs_dir_fetchmatch()
910 if (lfs_tag_id(tag) >= tempcount) { in lfs_dir_fetchmatch()
913 } else if (lfs_tag_type1(tag) == LFS_TYPE_SPLICE) { in lfs_dir_fetchmatch()
916 if (tag == (LFS_MKTAG(LFS_TYPE_DELETE, 0, 0) | in lfs_dir_fetchmatch()
919 } else if (tempbesttag != -1 && in lfs_dir_fetchmatch()
923 } else if (lfs_tag_type1(tag) == LFS_TYPE_TAIL) { in lfs_dir_fetchmatch()
929 if (err) { in lfs_dir_fetchmatch()
930 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
939 if ((fmask & tag) == (fmask & ftag)) { in lfs_dir_fetchmatch()
942 if (res < 0) { in lfs_dir_fetchmatch()
943 if (res == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
950 if (res == LFS_CMP_EQ) { in lfs_dir_fetchmatch()
953 } else if ((LFS_MKTAG(0x7ff, 0x3ff, 0) & tag) == in lfs_dir_fetchmatch()
958 } else if (res == LFS_CMP_GT && in lfs_dir_fetchmatch()
967 if (dir->off > 0) { in lfs_dir_fetchmatch()
969 if (lfs_gstate_hasmovehere(&lfs->gdisk, dir->pair)) { in lfs_dir_fetchmatch()
970 if (lfs_tag_id(lfs->gdisk.tag) == lfs_tag_id(besttag)) { in lfs_dir_fetchmatch()
972 } else if (besttag != -1 && in lfs_dir_fetchmatch()
979 if (id) { in lfs_dir_fetchmatch()
983 if (lfs_tag_isvalid(besttag)) { in lfs_dir_fetchmatch()
985 } else if (lfs_tag_id(besttag) < dir->count) { in lfs_dir_fetchmatch()
1015 if (res < 0 && res != LFS_ERR_NOENT) { in lfs_dir_getgstate()
1019 if (res != LFS_ERR_NOENT) { in lfs_dir_getgstate()
1030 if (id == 0x3ff) { in lfs_dir_getinfo()
1039 if (tag < 0) { in lfs_dir_getinfo()
1048 if (tag < 0) { in lfs_dir_getinfo()
1053 if (lfs_tag_type3(tag) == LFS_TYPE_CTZSTRUCT) { in lfs_dir_getinfo()
1055 } else if (lfs_tag_type3(tag) == LFS_TYPE_INLINESTRUCT) { in lfs_dir_getinfo()
1079 if (res != LFS_CMP_EQ) { in lfs_dir_find_match()
1083 // only equal if our size is still the same in lfs_dir_find_match()
1084 if (name->size != lfs_tag_size(tag)) { in lfs_dir_find_match()
1094 // we reduce path to a single name if we can find it in lfs_dir_find()
1096 if (id) { in lfs_dir_find()
1112 if ((namelen == 1 && memcmp(name, ".", 1) == 0) || in lfs_dir_find()
1118 // skip if matched by '..' in name in lfs_dir_find()
1125 if (sufflen == 0) { in lfs_dir_find()
1129 if (sufflen == 2 && memcmp(suffix, "..", 2) == 0) { in lfs_dir_find()
1131 if (depth == 0) { in lfs_dir_find()
1143 if (name[0] == '\0') { in lfs_dir_find()
1150 // only continue if we hit a directory in lfs_dir_find()
1151 if (lfs_tag_type3(tag) != LFS_TYPE_DIR) { in lfs_dir_find()
1156 if (lfs_tag_id(tag) != 0x3ff) { in lfs_dir_find()
1159 if (res < 0) { in lfs_dir_find()
1174 if (tag < 0) { in lfs_dir_find()
1178 if (tag) { in lfs_dir_find()
1182 if (!dir->split) { in lfs_dir_find()
1209 if (err) { in lfs_dir_commitprog()
1220 // check if we fit in lfs_dir_commitattr()
1222 if (commit->off + dsize > commit->end) { in lfs_dir_commitattr()
1229 if (err) { in lfs_dir_commitattr()
1233 if (!(tag & 0x80000000)) { in lfs_dir_commitattr()
1236 if (err) { in lfs_dir_commitattr()
1248 if (err) { in lfs_dir_commitattr()
1253 if (err) { in lfs_dir_commitattr()
1276 if (noff < end) { in lfs_dir_commitcrc()
1285 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_commitcrc()
1301 if (err) { in lfs_dir_commitcrc()
1312 if (err) { in lfs_dir_commitcrc()
1324 if (i == off1 && crc != crc1) { in lfs_dir_commitcrc()
1333 if (err) { in lfs_dir_commitcrc()
1341 if (crc != 0) { in lfs_dir_commitcrc()
1347 if (off < end) { in lfs_dir_commitcrc()
1360 if (err) { in lfs_dir_alloc()
1374 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_alloc()
1397 if (err) { in lfs_dir_drop()
1406 if (err) { in lfs_dir_drop()
1420 if (err) { in lfs_dir_split()
1429 if (err) { in lfs_dir_split()
1437 // update root if needed in lfs_dir_split()
1438 if (lfs_pair_cmp(dir->pair, lfs->root) == 0 && split == 0) { in lfs_dir_split()
1482 if (err) { in lfs_dir_compact()
1489 if (end - begin < 0xff && in lfs_dir_compact()
1502 if (err) { in lfs_dir_compact()
1503 // if we fail to split, we may be able to overcompact, unless in lfs_dir_compact()
1506 if (err == LFS_ERR_NOSPC && size <= lfs->cfg->block_size - 36) { in lfs_dir_compact()
1517 // If our revision count == n * block_cycles, we should force a relocation, in lfs_dir_compact()
1523 if (lfs->cfg->block_cycles > 0 && in lfs_dir_compact()
1525 if (lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) { in lfs_dir_compact()
1529 if (res < 0) { in lfs_dir_compact()
1535 if ((lfs_size_t)res < lfs->cfg->block_count/2) { in lfs_dir_compact()
1539 if (err && err != LFS_ERR_NOSPC) { in lfs_dir_compact()
1543 // welp, we tried, if we ran out of space there's not much in lfs_dir_compact()
1544 // we can do, we'll error later if we've become frozen in lfs_dir_compact()
1545 if (!err) { in lfs_dir_compact()
1550 } else if (lfs->lfs1) { in lfs_dir_compact()
1553 // v1 superblock if we relocate root, and invalidating directory in lfs_dir_compact()
1554 // pointers if we relocate the head of a directory. On top of in lfs_dir_compact()
1581 if (err) { in lfs_dir_compact()
1582 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1593 if (err) { in lfs_dir_compact()
1594 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1608 if (err) { in lfs_dir_compact()
1609 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1616 if (!lfs_pair_isnull(dir->tail)) { in lfs_dir_compact()
1622 if (err) { in lfs_dir_compact()
1623 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1632 if (!relocated) { in lfs_dir_compact()
1640 if (err) { in lfs_dir_compact()
1644 if (!lfs_gstate_iszero(&delta)) { in lfs_dir_compact()
1649 if (err) { in lfs_dir_compact()
1650 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1659 if (err) { in lfs_dir_compact()
1660 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1674 if (!relocated) { in lfs_dir_compact()
1684 if (!tired) { in lfs_dir_compact()
1689 if (lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) { in lfs_dir_compact()
1697 if (err && (err != LFS_ERR_NOSPC || !tired)) { in lfs_dir_compact()
1705 if (relocated) { in lfs_dir_compact()
1706 // update references if we relocated in lfs_dir_compact()
1711 if (err) { in lfs_dir_compact()
1724 if (dir != &f->m && lfs_pair_cmp(f->m.pair, dir->pair) == 0 && in lfs_dir_commit()
1728 if (err) { in lfs_dir_commit()
1733 if (err) { in lfs_dir_commit()
1743 if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_CREATE) { in lfs_dir_commit()
1745 } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE) { in lfs_dir_commit()
1749 } else if (lfs_tag_type1(attrs[i].tag) == LFS_TYPE_TAIL) { in lfs_dir_commit()
1758 if (hasdelete && dir->count == 0) { in lfs_dir_commit()
1761 if (err && err != LFS_ERR_NOENT) { in lfs_dir_commit()
1766 if (err != LFS_ERR_NOENT && pdir.split) { in lfs_dir_commit()
1768 if (err) { in lfs_dir_commit()
1775 if (dir->erased || dir->count >= 0xff) { in lfs_dir_commit()
1795 if (err) { in lfs_dir_commit()
1796 if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) { in lfs_dir_commit()
1803 // commit any global diffs if we have any in lfs_dir_commit()
1809 if (!lfs_gstate_iszero(&delta)) { in lfs_dir_commit()
1811 if (err) { in lfs_dir_commit()
1820 if (err) { in lfs_dir_commit()
1821 if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) { in lfs_dir_commit()
1831 if (err) { in lfs_dir_commit()
1832 if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) { in lfs_dir_commit()
1853 if (err) { in lfs_dir_commit()
1864 // we need to copy the pair so they don't get clobbered if we refetch in lfs_dir_commit()
1867 if (&d->m != dir && lfs_pair_cmp(d->m.pair, olddir.pair) == 0) { in lfs_dir_commit()
1870 if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE && in lfs_dir_commit()
1874 } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE && in lfs_dir_commit()
1877 if (d->type == LFS_TYPE_DIR) { in lfs_dir_commit()
1880 } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_CREATE && in lfs_dir_commit()
1883 if (d->type == LFS_TYPE_DIR) { in lfs_dir_commit()
1892 if (lfs_pair_cmp(d->m.pair, olddir.pair) == 0) { in lfs_dir_commit()
1897 if (err) { in lfs_dir_commit()
1911 // deorphan if we haven't yet, needed at most once after poweron in lfs_mkdir()
1913 if (err) { in lfs_mkdir()
1922 if (!(err == LFS_ERR_NOENT && id != 0x3ff)) { in lfs_mkdir()
1929 if (nlen > lfs->name_max) { in lfs_mkdir()
1938 if (err) { in lfs_mkdir()
1947 if (err) { in lfs_mkdir()
1958 if (err) { in lfs_mkdir()
1964 if (cwd.m.split) { in lfs_mkdir()
1968 // it's possible our predecessor has to be relocated, and if in lfs_mkdir()
1980 if (err) { in lfs_mkdir()
1999 if (err) { in lfs_mkdir()
2011 if (tag < 0) { in lfs_dir_open()
2016 if (lfs_tag_type3(tag) != LFS_TYPE_DIR) { in lfs_dir_open()
2022 if (lfs_tag_id(tag) == 0x3ff) { in lfs_dir_open()
2030 if (res < 0) { in lfs_dir_open()
2039 if (err) { in lfs_dir_open()
2063 if (*p == (struct lfs_mlist*)dir) { in lfs_dir_close()
2079 if (dir->pos == 0) { in lfs_dir_read()
2085 } else if (dir->pos == 1) { in lfs_dir_read()
2094 if (dir->id == dir->m.count) { in lfs_dir_read()
2095 if (!dir->m.split) { in lfs_dir_read()
2101 if (err) { in lfs_dir_read()
2110 if (err && err != LFS_ERR_NOENT) { in lfs_dir_read()
2116 if (err != LFS_ERR_NOENT) { in lfs_dir_read()
2131 if (err) { in lfs_dir_seek()
2149 if (dir->id == dir->m.count) { in lfs_dir_seek()
2150 if (!dir->m.split) { in lfs_dir_seek()
2156 if (err) { in lfs_dir_seek()
2180 if (err) { in lfs_dir_rewind()
2197 if (i == 0) { in lfs_ctz_index()
2210 if (size == 0) { in lfs_ctz_find()
2228 if (err) { in lfs_ctz_find()
2248 if (err) { in lfs_ctz_extend()
2254 if (err) { in lfs_ctz_extend()
2255 if (err == LFS_ERR_CORRUPT) { in lfs_ctz_extend()
2261 if (size == 0) { in lfs_ctz_extend()
2271 // just copy out the last block if it is incomplete in lfs_ctz_extend()
2272 if (noff != lfs->cfg->block_size) { in lfs_ctz_extend()
2278 if (err) { in lfs_ctz_extend()
2285 if (err) { in lfs_ctz_extend()
2286 if (err == LFS_ERR_CORRUPT) { in lfs_ctz_extend()
2307 if (err) { in lfs_ctz_extend()
2308 if (err == LFS_ERR_CORRUPT) { in lfs_ctz_extend()
2314 if (i != skips-1) { in lfs_ctz_extend()
2319 if (err) { in lfs_ctz_extend()
2342 if (size == 0) { in lfs_ctz_traverse()
2350 if (err) { in lfs_ctz_traverse()
2354 if (index == 0) { in lfs_ctz_traverse()
2365 if (err) { in lfs_ctz_traverse()
2371 if (err) { in lfs_ctz_traverse()
2391 // deorphan if we haven't yet, needed at most once after poweron in lfs_file_opencfg()
2392 if ((flags & 3) != LFS_O_RDONLY) { in lfs_file_opencfg()
2394 if (err) { in lfs_file_opencfg()
2408 // allocate entry for file if it doesn't exist in lfs_file_opencfg()
2410 if (tag < 0 && !(tag == LFS_ERR_NOENT && file->id != 0x3ff)) { in lfs_file_opencfg()
2420 if (tag == LFS_ERR_NOENT) { in lfs_file_opencfg()
2421 if (!(flags & LFS_O_CREAT)) { in lfs_file_opencfg()
2428 if (nlen > lfs->name_max) { in lfs_file_opencfg()
2438 if (err) { in lfs_file_opencfg()
2444 } else if (flags & LFS_O_EXCL) { in lfs_file_opencfg()
2447 } else if (lfs_tag_type3(tag) != LFS_TYPE_REG) { in lfs_file_opencfg()
2450 } else if (flags & LFS_O_TRUNC) { in lfs_file_opencfg()
2451 // truncate if requested in lfs_file_opencfg()
2455 // try to load what's on disk, if it's inlined we'll fix it later in lfs_file_opencfg()
2458 if (tag < 0) { in lfs_file_opencfg()
2467 if ((file->flags & 3) != LFS_O_WRONLY) { in lfs_file_opencfg()
2473 if (res < 0 && res != LFS_ERR_NOENT) { in lfs_file_opencfg()
2479 if ((file->flags & 3) != LFS_O_RDONLY) { in lfs_file_opencfg()
2480 if (file->cfg->attrs[i].size > lfs->attr_max) { in lfs_file_opencfg()
2489 // allocate buffer if needed in lfs_file_opencfg()
2490 if (file->cfg->buffer) { in lfs_file_opencfg()
2494 if (!file->cache.buffer) { in lfs_file_opencfg()
2503 if (lfs_tag_type3(tag) == LFS_TYPE_INLINESTRUCT) { in lfs_file_opencfg()
2513 if (file->ctz.size > 0) { in lfs_file_opencfg()
2519 if (res < 0) { in lfs_file_opencfg()
2555 if (*p == (struct lfs_mlist*)file) { in lfs_file_close()
2562 if (!file->cfg->buffer) { in lfs_file_close()
2578 if (err) { in lfs_file_relocate()
2583 if (err) { in lfs_file_relocate()
2584 if (err == LFS_ERR_CORRUPT) { in lfs_file_relocate()
2593 if (file->flags & LFS_F_INLINE) { in lfs_file_relocate()
2600 if (err) { in lfs_file_relocate()
2607 if (err) { in lfs_file_relocate()
2615 if (err) { in lfs_file_relocate()
2616 if (err == LFS_ERR_CORRUPT) { in lfs_file_relocate()
2646 if (err) { in lfs_file_outline()
2657 if (file->flags & LFS_F_READING) { in lfs_file_flush()
2658 if (!(file->flags & LFS_F_INLINE)) { in lfs_file_flush()
2664 if (file->flags & LFS_F_WRITING) { in lfs_file_flush()
2667 if (!(file->flags & LFS_F_INLINE)) { in lfs_file_flush()
2683 if (res < 0) { in lfs_file_flush()
2688 if (res < 0) { in lfs_file_flush()
2693 if (lfs->rcache.block != LFS_BLOCK_NULL) { in lfs_file_flush()
2702 if (err) { in lfs_file_flush()
2703 if (err == LFS_ERR_CORRUPT) { in lfs_file_flush()
2714 if (err) { in lfs_file_flush()
2738 if (file->flags & LFS_F_ERRED) { in lfs_file_sync()
2739 // it's not safe to do anything if our file errored in lfs_file_sync()
2745 if (err) { in lfs_file_sync()
2751 if ((file->flags & LFS_F_DIRTY) && in lfs_file_sync()
2758 if (file->flags & LFS_F_INLINE) { in lfs_file_sync()
2778 if (err) { in lfs_file_sync()
2801 if (file->flags & LFS_F_WRITING) { in lfs_file_read()
2804 if (err) { in lfs_file_read()
2810 if (file->pos >= file->ctz.size) { in lfs_file_read()
2811 // eof if past end in lfs_file_read()
2820 // check if we need a new block in lfs_file_read()
2821 if (!(file->flags & LFS_F_READING) || in lfs_file_read()
2823 if (!(file->flags & LFS_F_INLINE)) { in lfs_file_read()
2827 if (err) { in lfs_file_read()
2841 if (file->flags & LFS_F_INLINE) { in lfs_file_read()
2847 if (err) { in lfs_file_read()
2855 if (err) { in lfs_file_read()
2881 if (file->flags & LFS_F_READING) { in lfs_file_write()
2884 if (err) { in lfs_file_write()
2890 if ((file->flags & LFS_O_APPEND) && file->pos < file->ctz.size) { in lfs_file_write()
2894 if (file->pos + size > lfs->file_max) { in lfs_file_write()
2900 if (!(file->flags & LFS_F_WRITING) && file->pos > file->ctz.size) { in lfs_file_write()
2907 if (res < 0) { in lfs_file_write()
2914 if ((file->flags & LFS_F_INLINE) && in lfs_file_write()
2920 if (err) { in lfs_file_write()
2928 // check if we need a new block in lfs_file_write()
2929 if (!(file->flags & LFS_F_WRITING) || in lfs_file_write()
2931 if (!(file->flags & LFS_F_INLINE)) { in lfs_file_write()
2932 if (!(file->flags & LFS_F_WRITING) && file->pos > 0) { in lfs_file_write()
2937 if (err) { in lfs_file_write()
2952 if (err) { in lfs_file_write()
2970 if (err) { in lfs_file_write()
2971 if (err == LFS_ERR_CORRUPT) { in lfs_file_write()
2982 if (err) { in lfs_file_write()
3008 // write out everything beforehand, may be noop if rdonly in lfs_file_seek()
3010 if (err) { in lfs_file_seek()
3017 if (whence == LFS_SEEK_SET) { in lfs_file_seek()
3019 } else if (whence == LFS_SEEK_CUR) { in lfs_file_seek()
3021 } else if (whence == LFS_SEEK_END) { in lfs_file_seek()
3025 if (npos > lfs->file_max) { in lfs_file_seek()
3043 if (size > LFS_FILE_MAX) { in lfs_file_truncate()
3050 if (size < oldsize) { in lfs_file_truncate()
3053 if (err) { in lfs_file_truncate()
3062 if (err) { in lfs_file_truncate()
3070 } else if (size > oldsize) { in lfs_file_truncate()
3071 // flush+seek if not already at end in lfs_file_truncate()
3072 if (file->pos != oldsize) { in lfs_file_truncate()
3074 if (res < 0) { in lfs_file_truncate()
3083 if (res < 0) { in lfs_file_truncate()
3092 if (res < 0) { in lfs_file_truncate()
3112 if (res < 0) { in lfs_file_rewind()
3125 if (file->flags & LFS_F_WRITING) { in lfs_file_size()
3141 if (tag < 0) { in lfs_stat()
3153 // deorphan if we haven't yet, needed at most once after poweron in lfs_remove()
3155 if (err) { in lfs_remove()
3162 if (tag < 0 || lfs_tag_id(tag) == 0x3ff) { in lfs_remove()
3169 if (lfs_tag_type3(tag) == LFS_TYPE_DIR) { in lfs_remove()
3174 if (res < 0) { in lfs_remove()
3181 if (err) { in lfs_remove()
3186 if (dir.m.count > 0 || dir.m.split) { in lfs_remove()
3195 // commit (if predecessor is child) in lfs_remove()
3204 if (err) { in lfs_remove()
3211 if (lfs_tag_type3(tag) == LFS_TYPE_DIR) { in lfs_remove()
3216 if (err) { in lfs_remove()
3222 if (err) { in lfs_remove()
3235 // deorphan if we haven't yet, needed at most once after poweron in lfs_rename()
3237 if (err) { in lfs_rename()
3245 if (oldtag < 0 || lfs_tag_id(oldtag) == 0x3ff) { in lfs_rename()
3255 if ((prevtag < 0 || lfs_tag_id(prevtag) == 0x3ff) && in lfs_rename()
3262 // if we're in the same pair there's a few special cases... in lfs_rename()
3268 if (prevtag == LFS_ERR_NOENT) { in lfs_rename()
3271 if (nlen > lfs->name_max) { in lfs_rename()
3279 if (samepair && newid <= newoldid) { in lfs_rename()
3282 } else if (lfs_tag_type3(prevtag) != lfs_tag_type3(oldtag)) { in lfs_rename()
3285 } else if (samepair && newid == newoldid) { in lfs_rename()
3289 } else if (lfs_tag_type3(prevtag) == LFS_TYPE_DIR) { in lfs_rename()
3294 if (res < 0) { in lfs_rename()
3302 if (err) { in lfs_rename()
3307 if (prevdir.m.count > 0 || prevdir.m.split) { in lfs_rename()
3316 // commit (if predecessor is child) in lfs_rename()
3322 if (!samepair) { in lfs_rename()
3335 if (err) { in lfs_rename()
3341 // let commit clean up after move (if we're different! otherwise move in lfs_rename()
3343 if (!samepair && lfs_gstate_hasmove(&lfs->gstate)) { in lfs_rename()
3348 if (err) { in lfs_rename()
3356 if (prevtag != LFS_ERR_NOENT && lfs_tag_type3(prevtag) == LFS_TYPE_DIR) { in lfs_rename()
3361 if (err) { in lfs_rename()
3367 if (err) { in lfs_rename()
3383 if (tag < 0) { in lfs_getattr()
3389 if (id == 0x3ff) { in lfs_getattr()
3393 if (err) { in lfs_getattr()
3403 if (tag < 0) { in lfs_getattr()
3404 if (tag == LFS_ERR_NOENT) { in lfs_getattr()
3422 if (tag < 0) { in lfs_commitattr()
3427 if (id == 0x3ff) { in lfs_commitattr()
3431 if (err) { in lfs_commitattr()
3444 if (size > lfs->attr_max) { in lfs_setattr()
3493 if (lfs->cfg->read_buffer) { in lfs_init()
3497 if (!lfs->rcache.buffer) { in lfs_init()
3504 if (lfs->cfg->prog_buffer) { in lfs_init()
3508 if (!lfs->pcache.buffer) { in lfs_init()
3522 if (lfs->cfg->lookahead_buffer) { in lfs_init()
3526 if (!lfs->free.buffer) { in lfs_init()
3535 if (!lfs->name_max) { in lfs_init()
3541 if (!lfs->file_max) { in lfs_init()
3547 if (!lfs->attr_max) { in lfs_init()
3572 if (!lfs->cfg->read_buffer) { in lfs_deinit()
3576 if (!lfs->cfg->prog_buffer) { in lfs_deinit()
3580 if (!lfs->cfg->lookahead_buffer) { in lfs_deinit()
3607 if (err) { in lfs_format()
3623 if (err) { in lfs_format()
3643 if (err) { in lfs_format()
3649 if (err) { in lfs_format()
3657 if (err) { in lfs_format()
3686 if (err) { in lfs_mount()
3695 if (cycle >= lfs->cfg->block_count/2) { in lfs_mount()
3709 if (tag < 0) { in lfs_mount()
3715 if (tag && !lfs_tag_isdelete(tag)) { in lfs_mount()
3725 if (tag < 0) { in lfs_mount()
3734 if ((major_version != LFS_DISK_VERSION_MAJOR || in lfs_mount()
3743 if (superblock.name_max) { in lfs_mount()
3744 if (superblock.name_max > lfs->name_max) { in lfs_mount()
3754 if (superblock.file_max) { in lfs_mount()
3755 if (superblock.file_max > lfs->file_max) { in lfs_mount()
3765 if (superblock.attr_max) { in lfs_mount()
3766 if (superblock.attr_max > lfs->attr_max) { in lfs_mount()
3779 if (err) { in lfs_mount()
3785 if (lfs_pair_isnull(lfs->root)) { in lfs_mount()
3791 if (!lfs_gstate_iszero(&lfs->gstate)) { in lfs_mount()
3829 if (lfs->lfs1) { in lfs_fs_traverseraw()
3831 if (err) { in lfs_fs_traverseraw()
3842 if (cycle >= lfs->cfg->block_count/2) { in lfs_fs_traverseraw()
3850 if (err) { in lfs_fs_traverseraw()
3857 if (err) { in lfs_fs_traverseraw()
3865 if (tag < 0) { in lfs_fs_traverseraw()
3866 if (tag == LFS_ERR_NOENT) { in lfs_fs_traverseraw()
3873 if (lfs_tag_type3(tag) == LFS_TYPE_CTZSTRUCT) { in lfs_fs_traverseraw()
3876 if (err) { in lfs_fs_traverseraw()
3879 } else if (includeorphans && in lfs_fs_traverseraw()
3883 if (err) { in lfs_fs_traverseraw()
3893 if (f->type != LFS_TYPE_REG) { in lfs_fs_traverseraw()
3897 if ((f->flags & LFS_F_DIRTY) && !(f->flags & LFS_F_INLINE)) { in lfs_fs_traverseraw()
3900 if (err) { in lfs_fs_traverseraw()
3905 if ((f->flags & LFS_F_WRITING) && !(f->flags & LFS_F_INLINE)) { in lfs_fs_traverseraw()
3908 if (err) { in lfs_fs_traverseraw()
3933 if (cycle >= lfs->cfg->block_count/2) { in lfs_fs_pred()
3939 if (lfs_pair_cmp(pdir->tail, pair) == 0) { in lfs_fs_pred()
3944 if (err) { in lfs_fs_pred()
3968 if (err) { in lfs_fs_parent_match()
3983 if (cycle >= lfs->cfg->block_count/2) { in lfs_fs_parent()
3995 if (tag && tag != LFS_ERR_NOENT) { in lfs_fs_parent()
4006 if (lfs_pair_cmp(oldpair, lfs->root) == 0) { in lfs_fs_relocate()
4013 if (lfs_pair_cmp(oldpair, d->m.pair) == 0) { in lfs_fs_relocate()
4018 if (d->type == LFS_TYPE_DIR && in lfs_fs_relocate()
4028 if (tag < 0 && tag != LFS_ERR_NOENT) { in lfs_fs_relocate()
4032 if (tag != LFS_ERR_NOENT) { in lfs_fs_relocate()
4039 if (lfs_gstate_hasmovehere(&lfs->gstate, parent.pair)) { in lfs_fs_relocate()
4045 if (moveid < lfs_tag_id(tag)) { in lfs_fs_relocate()
4056 if (err) { in lfs_fs_relocate()
4066 if (err && err != LFS_ERR_NOENT) { in lfs_fs_relocate()
4070 // if we can't find dir, it must be new in lfs_fs_relocate()
4071 if (err != LFS_ERR_NOENT) { in lfs_fs_relocate()
4075 if (lfs_gstate_hasmovehere(&lfs->gstate, parent.pair)) { in lfs_fs_relocate()
4090 if (err) { in lfs_fs_relocate()
4114 if (!lfs_gstate_hasmove(&lfs->gdisk)) { in lfs_fs_demove()
4127 if (err) { in lfs_fs_demove()
4136 if (err) { in lfs_fs_demove()
4144 if (!lfs_gstate_hasorphans(&lfs->gstate)) { in lfs_fs_deorphan()
4155 if (err) { in lfs_fs_deorphan()
4160 if (!pdir.split) { in lfs_fs_deorphan()
4161 // check if we have a parent in lfs_fs_deorphan()
4164 if (tag < 0 && tag != LFS_ERR_NOENT) { in lfs_fs_deorphan()
4168 if (tag == LFS_ERR_NOENT) { in lfs_fs_deorphan()
4174 if (err) { in lfs_fs_deorphan()
4185 if (res < 0) { in lfs_fs_deorphan()
4190 if (!lfs_pair_sync(pair, pdir.tail)) { in lfs_fs_deorphan()
4200 if (err) { in lfs_fs_deorphan()
4219 if (err) { in lfs_fs_forceconsistency()
4224 if (err) { in lfs_fs_forceconsistency()
4242 if (err) { in lfs_fs_size()
4341 // if we ever do more than writes to alternating pairs, in lfs1_bd_read()
4352 if (err) { in lfs1_bd_crc()
4413 if (err) { in lfs1_dir_fetch()
4414 if (err == LFS_ERR_CORRUPT) { in lfs1_dir_fetch()
4420 if (valid && lfs_scmp(test.rev, dir->d.rev) < 0) { in lfs1_dir_fetch()
4424 if ((0x7fffffff & test.size) < sizeof(test)+4 || in lfs1_dir_fetch()
4435 if (err) { in lfs1_dir_fetch()
4436 if (err == LFS_ERR_CORRUPT) { in lfs1_dir_fetch()
4442 if (crc != 0) { in lfs1_dir_fetch()
4455 if (!valid) { in lfs1_dir_fetch()
4466 if (!(0x80000000 & dir->d.size)) { in lfs1_dir_next()
4472 if (err) { in lfs1_dir_next()
4483 if (err) { in lfs1_dir_next()
4495 if (lfs_pair_isnull(lfs->lfs1->root)) { in lfs1_traverse()
4507 if (err) { in lfs1_traverse()
4513 if (err) { in lfs1_traverse()
4522 if (err) { in lfs1_traverse()
4527 if ((0x70 & entry.d.type) == (0x70 & LFS1_TYPE_REG)) { in lfs1_traverse()
4530 if (err) { in lfs1_traverse()
4536 // we also need to check if we contain a threaded v2 directory in lfs1_traverse()
4540 if (err) { in lfs1_traverse()
4546 if (err) { in lfs1_traverse()
4555 if (lfs_pair_isnull(cwd)) { in lfs1_traverse()
4564 if (lfs_pair_isnull(lfs->lfs1->root)) { in lfs1_moved()
4571 if (err) { in lfs1_moved()
4579 if (err) { in lfs1_moved()
4585 if (err && err != LFS_ERR_NOENT) { in lfs1_moved()
4589 if (err == LFS_ERR_NOENT) { in lfs1_moved()
4593 if (!(0x80 & entry.d.type) && in lfs1_moved()
4609 if (err) { in lfs1_mount()
4627 if (err && err != LFS_ERR_CORRUPT) { in lfs1_mount()
4631 if (!err) { in lfs1_mount()
4635 if (err) { in lfs1_mount()
4643 if (err || memcmp(superblock.d.magic, "littlefs", 8) != 0) { in lfs1_mount()
4652 if ((major_version != LFS1_DISK_VERSION_MAJOR || in lfs1_mount()
4691 if (err) { in lfs_migrate()
4706 if (err) { in lfs_migrate()
4712 if (err) { in lfs_migrate()
4723 if (err) { in lfs_migrate()
4730 if (err && err != LFS_ERR_NOENT) { in lfs_migrate()
4734 if (err == LFS_ERR_NOENT) { in lfs_migrate()
4739 if (entry1.d.type & 0x80) { in lfs_migrate()
4741 if (moved < 0) { in lfs_migrate()
4746 if (moved) { in lfs_migrate()
4759 if (err) { in lfs_migrate()
4767 if (err) { in lfs_migrate()
4773 if (!(err == LFS_ERR_NOENT && id != 0x3ff)) { in lfs_migrate()
4790 if (err) { in lfs_migrate()
4795 if (!lfs_pair_isnull(dir1.d.tail)) { in lfs_migrate()
4798 if (err) { in lfs_migrate()
4804 if (err) { in lfs_migrate()
4813 if (err) { in lfs_migrate()
4819 // if this fails there is not much we can do. in lfs_migrate()
4825 if (err) { in lfs_migrate()
4830 if (err) { in lfs_migrate()
4839 if (err) { in lfs_migrate()
4846 if (err) { in lfs_migrate()
4852 if (err) { in lfs_migrate()
4859 if (err) { in lfs_migrate()
4889 if (err) { in lfs_migrate()
4895 if (err) { in lfs_migrate()
4902 if (err) { in lfs_migrate()