Lines Matching +full:0 +full:xffff

23     memset(pcache->buffer, 0xff, lfs->cfg->cache_size);  in lfs_cache_zero()
37 while (size > 0) { in lfs_bd_read()
74 if (size >= hint && off % lfs->cfg->read_size == 0 && in lfs_bd_read()
101 LFS_ASSERT(err <= 0); in lfs_bd_read()
107 return 0; in lfs_bd_read()
111 LFS_CMP_EQ = 0,
122 for (lfs_off_t i = 0; i < size; i++) { in lfs_bd_cmp()
146 LFS_ASSERT(err <= 0); in lfs_bd_flush()
157 if (res < 0) { in lfs_bd_flush()
169 return 0; in lfs_bd_flush()
182 LFS_ASSERT(err <= 0); in lfs_bd_sync()
194 while (size > 0) { in lfs_bd_prog()
226 pcache->size = 0; in lfs_bd_prog()
229 return 0; in lfs_bd_prog()
235 LFS_ASSERT(err <= 0); in lfs_bd_erase()
243 lfs_block_t t = pair[0]; in lfs_pair_swap()
244 pair[0] = pair[1]; in lfs_pair_swap()
249 return pair[0] == LFS_BLOCK_NULL || pair[1] == LFS_BLOCK_NULL; in lfs_pair_isnull()
255 return !(paira[0] == pairb[0] || paira[1] == pairb[1] || in lfs_pair_cmp()
256 paira[0] == pairb[1] || paira[1] == pairb[0]); in lfs_pair_cmp()
262 return (paira[0] == pairb[0] && paira[1] == pairb[1]) || in lfs_pair_sync()
263 (paira[0] == pairb[1] && paira[1] == pairb[0]); in lfs_pair_sync()
267 pair[0] = lfs_fromle32(pair[0]); in lfs_pair_fromle32()
272 pair[0] = lfs_tole32(pair[0]); in lfs_pair_tole32()
284 ((cond) ? LFS_MKTAG(type, id, size) : LFS_MKTAG(LFS_FROM_NOOP, 0, 0))
290 return !(tag & 0x80000000); in lfs_tag_isvalid()
298 return (tag & 0x70000000) >> 20; in lfs_tag_type1()
302 return (tag & 0x7ff00000) >> 20; in lfs_tag_type3()
306 return (tag & 0x0ff00000) >> 20; in lfs_tag_chunk()
314 return (tag & 0x000ffc00) >> 10; in lfs_tag_id()
318 return tag & 0x000003ff; in lfs_tag_size()
342 for (int i = 0; i < 3; i++) { in lfs_gstate_xor()
348 for (int i = 0; i < 3; i++) { in lfs_gstate_iszero()
349 if (((uint32_t*)a)[i] != 0) { in lfs_gstate_iszero()
370 return lfs_tag_type1(a->tag) && lfs_pair_cmp(a->pair, pair) == 0; in lfs_gstate_hasmovehere()
375 a->pair[0] = lfs_fromle32(a->pair[0]); in lfs_gstate_fromle32()
381 a->pair[0] = lfs_tole32(a->pair[0]); in lfs_gstate_tole32()
452 return 0; in lfs_alloc_lookahead()
463 lfs->free.size = 0; in lfs_alloc_reset()
464 lfs->free.i = 0; in lfs_alloc_reset()
488 return 0; in lfs_alloc()
493 if (lfs->free.ack == 0) { in lfs_alloc()
502 lfs->free.i = 0; in lfs_alloc()
505 memset(lfs->free.buffer, 0, lfs->cfg->lookahead_size); in lfs_alloc()
520 lfs_stag_t gdiff = 0; in lfs_dir_getslice()
523 lfs_tag_id(gmask) != 0 && in lfs_dir_getslice()
526 gdiff -= LFS_MKTAG(0, 1, 0); in lfs_dir_getslice()
535 dir->pair[0], off, &ntag, sizeof(ntag)); in lfs_dir_getslice()
540 ntag = (lfs_frombe32(ntag) ^ tag) & 0x7fffffff; 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()
546 (LFS_MKTAG(0, 0x3ff, 0) & (gtag - gdiff)))) { in lfs_dir_getslice()
552 gdiff += LFS_MKTAG(0, lfs_tag_splice(tag), 0); in lfs_dir_getslice()
563 dir->pair[0], off+sizeof(tag)+goff, gbuffer, diff); in lfs_dir_getslice()
568 memset((uint8_t*)gbuffer + diff, 0, gsize - diff); in lfs_dir_getslice()
581 0, buffer, lfs_tag_size(gtag)); in lfs_dir_get()
593 while (size > 0) { in lfs_dir_getread()
637 if (err < 0) { in lfs_dir_getread()
642 return 0; in lfs_dir_getread()
651 uint32_t mask = (tag & LFS_MKTAG(0x100, 0, 0)) in lfs_dir_traverse_filter()
652 ? LFS_MKTAG(0x7ff, 0x3ff, 0) in lfs_dir_traverse_filter()
653 : LFS_MKTAG(0x700, 0x3ff, 0); in lfs_dir_traverse_filter()
658 (LFS_MKTAG(0x7ff, 0x3ff, 0) & tag) == ( in lfs_dir_traverse_filter()
659 LFS_MKTAG(LFS_TYPE_DELETE, 0, 0) | in lfs_dir_traverse_filter()
660 (LFS_MKTAG(0, 0x3ff, 0) & *filtertag))) { in lfs_dir_traverse_filter()
667 *filtertag += LFS_MKTAG(0, lfs_tag_splice(tag), 0); in lfs_dir_traverse_filter()
688 dir->pair[0], off, &tag, sizeof(tag)); in lfs_dir_traverse()
693 tag = (lfs_frombe32(tag) ^ ptag) | 0x80000000; in lfs_dir_traverse()
694 disk.block = dir->pair[0]; in lfs_dir_traverse()
698 } else if (attrcount > 0) { in lfs_dir_traverse()
699 tag = attrs[0].tag; in lfs_dir_traverse()
700 buffer = attrs[0].buffer; in lfs_dir_traverse()
704 return 0; in lfs_dir_traverse()
707 lfs_tag_t mask = LFS_MKTAG(0x7ff, 0, 0); in lfs_dir_traverse()
714 if (lfs_tag_id(tmask) != 0) { in lfs_dir_traverse()
718 0, 0, 0, 0, 0, in lfs_dir_traverse()
720 if (filter < 0) { in lfs_dir_traverse()
741 buffer, 0, 0xffffffff, NULL, 0, in lfs_dir_traverse()
742 LFS_MKTAG(0x600, 0x3ff, 0), in lfs_dir_traverse()
743 LFS_MKTAG(LFS_TYPE_STRUCT, 0, 0), in lfs_dir_traverse()
750 for (unsigned i = 0; i < lfs_tag_size(tag); i++) { in lfs_dir_traverse()
759 int err = cb(data, tag + LFS_MKTAG(0, diff, 0), buffer); in lfs_dir_traverse()
777 if (pair[0] >= lfs->cfg->block_count || pair[1] >= lfs->cfg->block_count) { in lfs_dir_fetchmatch()
782 uint32_t revs[2] = {0, 0}; in lfs_dir_fetchmatch()
783 int r = 0; in lfs_dir_fetchmatch()
784 for (int i = 0; i < 2; i++) { in lfs_dir_fetchmatch()
787 pair[i], 0, &revs[i], sizeof(revs[i])); in lfs_dir_fetchmatch()
794 lfs_scmp(revs[i], revs[(i+1)%2]) > 0) { in lfs_dir_fetchmatch()
799 dir->pair[0] = pair[(r+0)%2]; in lfs_dir_fetchmatch()
801 dir->rev = revs[(r+0)%2]; in lfs_dir_fetchmatch()
802 dir->off = 0; // nonzero = found some commits in lfs_dir_fetchmatch()
805 for (int i = 0; i < 2; i++) { in lfs_dir_fetchmatch()
806 lfs_off_t off = 0; in lfs_dir_fetchmatch()
807 lfs_tag_t ptag = 0xffffffff; in lfs_dir_fetchmatch()
809 uint16_t tempcount = 0; in lfs_dir_fetchmatch()
815 uint32_t crc = lfs_crc(0xffffffff, &dir->rev, sizeof(dir->rev)); in lfs_dir_fetchmatch()
824 dir->pair[0], off, &tag, sizeof(tag)); in lfs_dir_fetchmatch()
840 dir->off % lfs->cfg->prog_size == 0); in lfs_dir_fetchmatch()
854 dir->pair[0], off+sizeof(tag), &dcrc, sizeof(dcrc)); in lfs_dir_fetchmatch()
881 dir->tail[0] = temptail[0]; in lfs_dir_fetchmatch()
886 crc = 0xffffffff; in lfs_dir_fetchmatch()
895 dir->pair[0], off+j, &dat, 1); in lfs_dir_fetchmatch()
916 if (tag == (LFS_MKTAG(LFS_TYPE_DELETE, 0, 0) | in lfs_dir_fetchmatch()
917 (LFS_MKTAG(0, 0x3ff, 0) & tempbesttag))) { in lfs_dir_fetchmatch()
918 tempbesttag |= 0x80000000; in lfs_dir_fetchmatch()
921 tempbesttag += LFS_MKTAG(0, lfs_tag_splice(tag), 0); in lfs_dir_fetchmatch()
928 dir->pair[0], off+sizeof(tag), &temptail, 8); in lfs_dir_fetchmatch()
941 dir->pair[0], off+sizeof(tag)}); in lfs_dir_fetchmatch()
942 if (res < 0) { in lfs_dir_fetchmatch()
953 } else if ((LFS_MKTAG(0x7ff, 0x3ff, 0) & tag) == in lfs_dir_fetchmatch()
954 (LFS_MKTAG(0x7ff, 0x3ff, 0) & tempbesttag)) { in lfs_dir_fetchmatch()
961 tempbesttag = tag | 0x80000000; in lfs_dir_fetchmatch()
967 if (dir->off > 0) { in lfs_dir_fetchmatch()
971 besttag |= 0x80000000; in lfs_dir_fetchmatch()
974 besttag -= LFS_MKTAG(0, 1, 0); in lfs_dir_fetchmatch()
988 return 0; in lfs_dir_fetchmatch()
997 LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}", in lfs_dir_fetchmatch()
998 dir->pair[0], dir->pair[1]); in lfs_dir_fetchmatch()
1013 lfs_stag_t res = lfs_dir_get(lfs, dir, LFS_MKTAG(0x7ff, 0, 0), in lfs_dir_getgstate()
1014 LFS_MKTAG(LFS_TYPE_MOVESTATE, 0, sizeof(temp)), &temp); in lfs_dir_getgstate()
1015 if (res < 0 && res != LFS_ERR_NOENT) { in lfs_dir_getgstate()
1025 return 0; in lfs_dir_getgstate()
1030 if (id == 0x3ff) { in lfs_dir_getinfo()
1034 return 0; in lfs_dir_getinfo()
1037 lfs_stag_t tag = lfs_dir_get(lfs, dir, LFS_MKTAG(0x780, 0x3ff, 0), in lfs_dir_getinfo()
1039 if (tag < 0) { in lfs_dir_getinfo()
1046 tag = lfs_dir_get(lfs, dir, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_dir_getinfo()
1048 if (tag < 0) { in lfs_dir_getinfo()
1059 return 0; in lfs_dir_getinfo()
1097 *id = 0x3ff; in lfs_dir_find()
1101 lfs_stag_t tag = LFS_MKTAG(LFS_TYPE_DIR, 0x3ff, 0); in lfs_dir_find()
1102 dir->tail[0] = lfs->root[0]; in lfs_dir_find()
1112 if ((namelen == 1 && memcmp(name, ".", 1) == 0) || in lfs_dir_find()
1113 (namelen == 2 && memcmp(name, "..", 2) == 0)) { 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()
1156 if (lfs_tag_id(tag) != 0x3ff) { in lfs_dir_find()
1157 lfs_stag_t res = lfs_dir_get(lfs, dir, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_dir_find()
1159 if (res < 0) { in lfs_dir_find()
1168 LFS_MKTAG(0x780, 0, 0), in lfs_dir_find()
1169 LFS_MKTAG(LFS_TYPE_NAME, 0, namelen), in lfs_dir_find()
1174 if (tag < 0) { in lfs_dir_find()
1215 return 0; in lfs_dir_commitprog()
1227 lfs_tag_t ntag = lfs_tobe32((tag & 0x7fffffff) ^ commit->ptag); in lfs_dir_commitattr()
1233 if (!(tag & 0x80000000)) { in lfs_dir_commitattr()
1242 for (lfs_off_t i = 0; i < dsize-sizeof(tag); i++) { in lfs_dir_commitattr()
1259 commit->ptag = tag & 0x7fffffff; in lfs_dir_commitattr()
1260 return 0; in lfs_dir_commitattr()
1275 lfs_off_t noff = lfs_min(end - off, 0x3fe) + off; in lfs_dir_commitcrc()
1281 lfs_tag_t tag = 0xffffffff; in lfs_dir_commitcrc()
1291 tag = LFS_MKTAG(LFS_TYPE_CRC + reset, 0x3ff, noff - off); in lfs_dir_commitcrc()
1295 footer[0] = lfs_tobe32(tag ^ commit->ptag); in lfs_dir_commitcrc()
1296 commit->crc = lfs_crc(commit->crc, &footer[0], sizeof(footer[0])); in lfs_dir_commitcrc()
1307 commit->crc = 0xffffffff; // reset crc for next "commit" in lfs_dir_commitcrc()
1320 uint32_t crc = 0xffffffff; in lfs_dir_commitcrc()
1341 if (crc != 0) { in lfs_dir_commitcrc()
1346 off = lfs_min(end - noff, 0x3fe) + noff; in lfs_dir_commitcrc()
1353 return 0; in lfs_dir_commitcrc()
1358 for (int i = 0; i < 2; i++) { in lfs_dir_alloc()
1366 dir->rev = 0; in lfs_dir_alloc()
1372 dir->pair[0], 0, &dir->rev, sizeof(dir->rev)); in lfs_dir_alloc()
1383 dir->etag = 0xffffffff; in lfs_dir_alloc()
1384 dir->count = 0; in lfs_dir_alloc()
1385 dir->tail[0] = LFS_BLOCK_NULL; in lfs_dir_alloc()
1391 return 0; in lfs_dir_alloc()
1404 {LFS_MKTAG(LFS_TYPE_TAIL + tail->split, 0x3ff, 8), tail->tail})); in lfs_dir_drop()
1410 return 0; in lfs_dir_drop()
1425 tail.tail[0] = dir->tail[0]; in lfs_dir_split()
1433 dir->tail[0] = tail.pair[0]; in lfs_dir_split()
1438 if (lfs_pair_cmp(dir->pair, lfs->root) == 0 && split == 0) { in lfs_dir_split()
1439 lfs->root[0] = tail.pair[0]; in lfs_dir_split()
1443 return 0; in lfs_dir_split()
1451 return 0; in lfs_dir_commit_size()
1468 const lfs_block_t oldpair[2] = {dir->pair[0], dir->pair[1]}; in lfs_dir_compact()
1475 lfs_size_t size = 0; in lfs_dir_compact()
1477 source, 0, 0xffffffff, attrs, attrcount, in lfs_dir_compact()
1478 LFS_MKTAG(0x400, 0x3ff, 0), in lfs_dir_compact()
1479 LFS_MKTAG(LFS_TYPE_NAME, 0, 0), in lfs_dir_compact()
1489 if (end - begin < 0xff && in lfs_dir_compact()
1523 if (lfs->cfg->block_cycles > 0 && in lfs_dir_compact()
1524 (dir->rev % ((lfs->cfg->block_cycles+1)|1) == 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()
1571 .off = 0, in lfs_dir_compact()
1572 .ptag = 0xffffffff, in lfs_dir_compact()
1573 .crc = 0xffffffff, in lfs_dir_compact()
1575 .begin = 0, in lfs_dir_compact()
1602 source, 0, 0xffffffff, attrs, attrcount, in lfs_dir_compact()
1603 LFS_MKTAG(0x400, 0x3ff, 0), in lfs_dir_compact()
1604 LFS_MKTAG(LFS_TYPE_NAME, 0, 0), in lfs_dir_compact()
1619 LFS_MKTAG(LFS_TYPE_TAIL + dir->split, 0x3ff, 8), in lfs_dir_compact()
1631 lfs_gstate_t delta = {0}; in lfs_dir_compact()
1637 delta.tag &= ~LFS_MKTAG(0, 0, 0x3ff); in lfs_dir_compact()
1647 LFS_MKTAG(LFS_TYPE_MOVESTATE, 0x3ff, in lfs_dir_compact()
1667 LFS_ASSERT(commit.off % lfs->cfg->prog_size == 0); in lfs_dir_compact()
1673 lfs->gdelta = (lfs_gstate_t){0}; in lfs_dir_compact()
1685 LFS_DEBUG("Bad block at 0x%"PRIx32, dir->pair[1]); in lfs_dir_compact()
1689 if (lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) { in lfs_dir_compact()
1690 LFS_WARN("Superblock 0x%"PRIx32" has become unwritable", in lfs_dir_compact()
1707 LFS_DEBUG("Relocating {0x%"PRIx32", 0x%"PRIx32"} " in lfs_dir_compact()
1708 "-> {0x%"PRIx32", 0x%"PRIx32"}", in lfs_dir_compact()
1709 oldpair[0], oldpair[1], dir->pair[0], dir->pair[1]); in lfs_dir_compact()
1716 return 0; in lfs_dir_compact()
1724 if (dir != &f->m && lfs_pair_cmp(f->m.pair, dir->pair) == 0 && in lfs_dir_commit()
1742 for (int i = 0; i < attrcount; i++) { in lfs_dir_commit()
1746 LFS_ASSERT(dir->count > 0); in lfs_dir_commit()
1750 dir->tail[0] = ((lfs_block_t*)attrs[i].buffer)[0]; in lfs_dir_commit()
1758 if (hasdelete && dir->count == 0) { in lfs_dir_commit()
1775 if (dir->erased || dir->count >= 0xff) { in lfs_dir_commit()
1778 .block = dir->pair[0], in lfs_dir_commit()
1781 .crc = 0xffffffff, in lfs_dir_commit()
1791 0, 0, 0, 0, 0, in lfs_dir_commit()
1804 lfs_gstate_t delta = {0}; in lfs_dir_commit()
1808 delta.tag &= ~LFS_MKTAG(0, 0, 0x3ff); in lfs_dir_commit()
1818 LFS_MKTAG(LFS_TYPE_MOVESTATE, 0x3ff, in lfs_dir_commit()
1840 LFS_ASSERT(commit.off % lfs->cfg->prog_size == 0); in lfs_dir_commit()
1845 lfs->gdelta = (lfs_gstate_t){0}; in lfs_dir_commit()
1852 dir, 0, dir->count); in lfs_dir_commit()
1867 if (&d->m != dir && lfs_pair_cmp(d->m.pair, olddir.pair) == 0) { in lfs_dir_commit()
1869 for (int i = 0; i < attrcount; i++) { in lfs_dir_commit()
1872 d->m.pair[0] = LFS_BLOCK_NULL; in lfs_dir_commit()
1892 if (lfs_pair_cmp(d->m.pair, olddir.pair) == 0) { in lfs_dir_commit()
1904 return 0; in lfs_dir_commit()
1922 if (!(err == LFS_ERR_NOENT && id != 0x3ff)) { in lfs_mkdir()
1923 LFS_TRACE("lfs_mkdir -> %d", (err < 0) ? err : LFS_ERR_EXIST); in lfs_mkdir()
1924 return (err < 0) ? err : LFS_ERR_EXIST; in lfs_mkdir()
1956 {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8), pred.tail})); in lfs_mkdir()
1972 cwd.type = 0; in lfs_mkdir()
1973 cwd.id = 0; in lfs_mkdir()
1978 {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8), dir.pair})); in lfs_mkdir()
1993 {LFS_MKTAG(LFS_TYPE_CREATE, id, 0), NULL}, in lfs_mkdir()
1997 LFS_TYPE_SOFTTAIL, 0x3ff, 8), dir.pair})); in lfs_mkdir()
2004 LFS_TRACE("lfs_mkdir -> %d", 0); in lfs_mkdir()
2005 return 0; in lfs_mkdir()
2011 if (tag < 0) { in lfs_dir_open()
2022 if (lfs_tag_id(tag) == 0x3ff) { in lfs_dir_open()
2024 pair[0] = lfs->root[0]; in lfs_dir_open()
2028 lfs_stag_t res = lfs_dir_get(lfs, &dir->m, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_dir_open()
2030 if (res < 0) { in lfs_dir_open()
2045 dir->head[0] = dir->m.pair[0]; in lfs_dir_open()
2047 dir->id = 0; in lfs_dir_open()
2048 dir->pos = 0; in lfs_dir_open()
2055 LFS_TRACE("lfs_dir_open -> %d", 0); in lfs_dir_open()
2056 return 0; in lfs_dir_open()
2069 LFS_TRACE("lfs_dir_close -> %d", 0); in lfs_dir_close()
2070 return 0; in lfs_dir_close()
2076 memset(info, 0, sizeof(*info)); in lfs_dir_read()
2079 if (dir->pos == 0) { in lfs_dir_read()
2106 dir->id = 0; in lfs_dir_read()
2141 dir->id = (off > 0 && lfs_pair_cmp(dir->head, lfs->root) == 0); in lfs_dir_seek()
2143 while (off > 0) { in lfs_dir_seek()
2161 dir->id = 0; in lfs_dir_seek()
2165 LFS_TRACE("lfs_dir_seek -> %d", 0); in lfs_dir_seek()
2166 return 0; in lfs_dir_seek()
2185 dir->id = 0; in lfs_dir_rewind()
2186 dir->pos = 0; in lfs_dir_rewind()
2187 LFS_TRACE("lfs_dir_rewind -> %d", 0); in lfs_dir_rewind()
2188 return 0; in lfs_dir_rewind()
2197 if (i == 0) { in lfs_ctz_index()
2198 return 0; in lfs_ctz_index()
2210 if (size == 0) { in lfs_ctz_find()
2212 *off = 0; in lfs_ctz_find()
2213 return 0; in lfs_ctz_find()
2237 return 0; in lfs_ctz_find()
2261 if (size == 0) { in lfs_ctz_extend()
2263 *off = 0; in lfs_ctz_extend()
2264 return 0; in lfs_ctz_extend()
2273 for (lfs_off_t i = 0; i < noff; i++) { in lfs_ctz_extend()
2295 return 0; in lfs_ctz_extend()
2302 for (lfs_off_t i = 0; i < skips; i++) { in lfs_ctz_extend()
2327 return 0; in lfs_ctz_extend()
2331 LFS_DEBUG("Bad block at 0x%"PRIx32, nblock); in lfs_ctz_extend()
2342 if (size == 0) { in lfs_ctz_traverse()
2343 return 0; in lfs_ctz_traverse()
2354 if (index == 0) { in lfs_ctz_traverse()
2355 return 0; in lfs_ctz_traverse()
2362 head, 0, &heads, count*sizeof(head)); in lfs_ctz_traverse()
2363 heads[0] = lfs_fromle32(heads[0]); in lfs_ctz_traverse()
2369 for (int i = 0; i < count-1; i++) { in lfs_ctz_traverse()
2404 file->pos = 0; in lfs_file_opencfg()
2405 file->off = 0; in lfs_file_opencfg()
2410 if (tag < 0 && !(tag == LFS_ERR_NOENT && file->id != 0x3ff)) { in lfs_file_opencfg()
2435 {LFS_MKTAG(LFS_TYPE_CREATE, file->id, 0)}, in lfs_file_opencfg()
2437 {LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0)})); in lfs_file_opencfg()
2443 tag = LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, 0); in lfs_file_opencfg()
2452 tag = LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0); in lfs_file_opencfg()
2456 tag = lfs_dir_get(lfs, &file->m, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_file_opencfg()
2458 if (tag < 0) { in lfs_file_opencfg()
2466 for (unsigned i = 0; i < file->cfg->attr_count; i++) { in lfs_file_opencfg()
2469 LFS_MKTAG(0x7ff, 0x3ff, 0), in lfs_file_opencfg()
2473 if (res < 0 && res != LFS_ERR_NOENT) { in lfs_file_opencfg()
2509 file->cache.off = 0; in lfs_file_opencfg()
2513 if (file->ctz.size > 0) { in lfs_file_opencfg()
2515 LFS_MKTAG(0x700, 0x3ff, 0), in lfs_file_opencfg()
2517 lfs_min(file->cache.size, 0x3fe)), in lfs_file_opencfg()
2519 if (res < 0) { in lfs_file_opencfg()
2526 LFS_TRACE("lfs_file_opencfg -> %d", 0); in lfs_file_opencfg()
2527 return 0; in lfs_file_opencfg()
2541 static const struct lfs_file_config defaults = {0}; in lfs_file_open()
2591 for (lfs_off_t i = 0; i < file->off; i++) { in lfs_file_relocate()
2597 LFS_MKTAG(0xfff, 0x1ff, 0), in lfs_file_relocate()
2598 LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0), in lfs_file_relocate()
2632 return 0; in lfs_file_relocate()
2635 LFS_DEBUG("Bad block at 0x%"PRIx32, nblock); in lfs_file_relocate()
2651 return 0; in lfs_file_outline()
2683 if (res < 0) { in lfs_file_flush()
2688 if (res < 0) { in lfs_file_flush()
2712 LFS_DEBUG("Bad block at 0x%"PRIx32, file->block); in lfs_file_flush()
2731 return 0; in lfs_file_flush()
2740 LFS_TRACE("lfs_file_sync -> %d", 0); in lfs_file_sync()
2741 return 0; in lfs_file_sync()
2787 LFS_TRACE("lfs_file_sync -> %d", 0); in lfs_file_sync()
2788 return 0; in lfs_file_sync()
2812 LFS_TRACE("lfs_file_read -> %d", 0); in lfs_file_read()
2813 return 0; in lfs_file_read()
2819 while (nsize > 0) { in lfs_file_read()
2844 LFS_MKTAG(0xfff, 0x1ff, 0), in lfs_file_read()
2845 LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0), in lfs_file_read()
2906 lfs_ssize_t res = lfs_file_write(lfs, file, &(uint8_t){0}, 1); in lfs_file_write()
2907 if (res < 0) { in lfs_file_write()
2916 lfs_min(0x3fe, lfs_min( in lfs_file_write()
2927 while (nsize > 0) { in lfs_file_write()
2932 if (!(file->flags & LFS_F_WRITING) && file->pos > 0) { in lfs_file_write()
3073 lfs_soff_t res = lfs_file_seek(lfs, file, 0, LFS_SEEK_END); in lfs_file_truncate()
3074 if (res < 0) { in lfs_file_truncate()
3082 lfs_ssize_t res = lfs_file_write(lfs, file, &(uint8_t){0}, 1); in lfs_file_truncate()
3083 if (res < 0) { in lfs_file_truncate()
3092 if (res < 0) { in lfs_file_truncate()
3097 LFS_TRACE("lfs_file_truncate -> %d", 0); in lfs_file_truncate()
3098 return 0; in lfs_file_truncate()
3111 lfs_soff_t res = lfs_file_seek(lfs, file, 0, LFS_SEEK_SET); in lfs_file_rewind()
3112 if (res < 0) { in lfs_file_rewind()
3117 LFS_TRACE("lfs_file_rewind -> %d", 0); in lfs_file_rewind()
3118 return 0; in lfs_file_rewind()
3141 if (tag < 0) { in lfs_stat()
3162 if (tag < 0 || lfs_tag_id(tag) == 0x3ff) { in lfs_remove()
3163 LFS_TRACE("lfs_remove -> %"PRId32, (tag < 0) ? tag : LFS_ERR_INVAL); in lfs_remove()
3164 return (tag < 0) ? (int)tag : LFS_ERR_INVAL; in lfs_remove()
3172 lfs_stag_t res = lfs_dir_get(lfs, &cwd, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_remove()
3174 if (res < 0) { in lfs_remove()
3186 if (dir.m.count > 0 || dir.m.split) { in lfs_remove()
3196 dir.type = 0; in lfs_remove()
3197 dir.id = 0; in lfs_remove()
3203 {LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(tag), 0)})); in lfs_remove()
3228 LFS_TRACE("lfs_remove -> %d", 0); in lfs_remove()
3229 return 0; in lfs_remove()
3245 if (oldtag < 0 || lfs_tag_id(oldtag) == 0x3ff) { in lfs_rename()
3247 (oldtag < 0) ? oldtag : LFS_ERR_INVAL); in lfs_rename()
3248 return (oldtag < 0) ? (int)oldtag : LFS_ERR_INVAL; in lfs_rename()
3255 if ((prevtag < 0 || lfs_tag_id(prevtag) == 0x3ff) && in lfs_rename()
3256 !(prevtag == LFS_ERR_NOENT && newid != 0x3ff)) { in lfs_rename()
3258 (prevtag < 0) ? prevtag : LFS_ERR_INVAL); in lfs_rename()
3259 return (prevtag < 0) ? (int)prevtag : LFS_ERR_INVAL; in lfs_rename()
3263 bool samepair = (lfs_pair_cmp(oldcwd.pair, newcwd.pair) == 0); in lfs_rename()
3287 LFS_TRACE("lfs_rename -> %d", 0); in lfs_rename()
3288 return 0; in lfs_rename()
3292 lfs_stag_t res = lfs_dir_get(lfs, &newcwd, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_rename()
3294 if (res < 0) { in lfs_rename()
3307 if (prevdir.m.count > 0 || prevdir.m.split) { in lfs_rename()
3317 prevdir.type = 0; in lfs_rename()
3318 prevdir.id = 0; in lfs_rename()
3329 LFS_TYPE_DELETE, newid, 0)}, in lfs_rename()
3330 {LFS_MKTAG(LFS_TYPE_CREATE, newid, 0)}, in lfs_rename()
3334 LFS_TYPE_DELETE, newoldid, 0)})); in lfs_rename()
3345 lfs_fs_prepmove(lfs, 0x3ff, NULL); in lfs_rename()
3347 {LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(oldtag), 0)})); in lfs_rename()
3373 LFS_TRACE("lfs_rename -> %d", 0); in lfs_rename()
3374 return 0; in lfs_rename()
3383 if (tag < 0) { in lfs_getattr()
3389 if (id == 0x3ff) { in lfs_getattr()
3391 id = 0; in lfs_getattr()
3399 tag = lfs_dir_get(lfs, &cwd, LFS_MKTAG(0x7ff, 0x3ff, 0), in lfs_getattr()
3403 if (tag < 0) { in lfs_getattr()
3422 if (tag < 0) { in lfs_commitattr()
3427 if (id == 0x3ff) { in lfs_commitattr()
3429 id = 0; in lfs_commitattr()
3456 int err = lfs_commitattr(lfs, path, type, NULL, 0x3ff); in lfs_removeattr()
3465 int err = 0; in lfs_init()
3469 LFS_ASSERT(lfs->cfg->read_size != 0); in lfs_init()
3470 LFS_ASSERT(lfs->cfg->prog_size != 0); in lfs_init()
3471 LFS_ASSERT(lfs->cfg->cache_size != 0); in lfs_init()
3475 LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->read_size == 0); in lfs_init()
3476 LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->prog_size == 0); in lfs_init()
3477 LFS_ASSERT(lfs->cfg->block_size % lfs->cfg->cache_size == 0); in lfs_init()
3480 LFS_ASSERT(4*lfs_npw2(0xffffffff / (lfs->cfg->block_size-2*4)) in lfs_init()
3483 // block_cycles = 0 is no longer supported. in lfs_init()
3489 LFS_ASSERT(lfs->cfg->block_cycles != 0); in lfs_init()
3519 LFS_ASSERT(lfs->cfg->lookahead_size > 0); in lfs_init()
3520 LFS_ASSERT(lfs->cfg->lookahead_size % 8 == 0 && in lfs_init()
3521 (uintptr_t)lfs->cfg->lookahead_buffer % 4 == 0); in lfs_init()
3552 lfs->root[0] = LFS_BLOCK_NULL; in lfs_init()
3555 lfs->seed = 0; in lfs_init()
3556 lfs->gdisk = (lfs_gstate_t){0}; in lfs_init()
3557 lfs->gstate = (lfs_gstate_t){0}; in lfs_init()
3558 lfs->gdelta = (lfs_gstate_t){0}; in lfs_init()
3563 return 0; in lfs_init()
3584 return 0; in lfs_deinit()
3604 int err = 0; in lfs_format()
3613 memset(lfs->free.buffer, 0, lfs->cfg->lookahead_size); in lfs_format()
3614 lfs->free.off = 0; in lfs_format()
3617 lfs->free.i = 0; in lfs_format()
3639 {LFS_MKTAG(LFS_TYPE_CREATE, 0, 0)}, in lfs_format()
3640 {LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8), "littlefs"}, in lfs_format()
3641 {LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)), in lfs_format()
3648 err = lfs_dir_fetch(lfs, &root, (const lfs_block_t[2]){0, 1}); in lfs_format()
3656 err = lfs_dir_commit(lfs, &root, NULL, 0); in lfs_format()
3692 lfs_mdir_t dir = {.tail = {0, 1}}; in lfs_mount()
3693 lfs_block_t cycle = 0; in lfs_mount()
3704 LFS_MKTAG(0x7ff, 0x3ff, 0), in lfs_mount()
3705 LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8), in lfs_mount()
3709 if (tag < 0) { in lfs_mount()
3717 lfs->root[0] = dir.pair[0]; in lfs_mount()
3722 tag = lfs_dir_get(lfs, &dir, LFS_MKTAG(0x7ff, 0x3ff, 0), in lfs_mount()
3723 LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)), in lfs_mount()
3725 if (tag < 0) { in lfs_mount()
3732 uint16_t major_version = (0xffff & (superblock.version >> 16)); in lfs_mount()
3733 uint16_t minor_version = (0xffff & (superblock.version >> 0)); in lfs_mount()
3792 LFS_DEBUG("Found pending gstate 0x%08"PRIx32"%08"PRIx32"%08"PRIx32, in lfs_mount()
3794 lfs->gstate.pair[0], in lfs_mount()
3803 LFS_TRACE("lfs_mount -> %d", 0); in lfs_mount()
3804 return 0; in lfs_mount()
3825 lfs_mdir_t dir = {.tail = {0, 1}}; in lfs_fs_traverseraw()
3835 dir.tail[0] = lfs->root[0]; in lfs_fs_traverseraw()
3840 lfs_block_t cycle = 0; in lfs_fs_traverseraw()
3848 for (int i = 0; i < 2; i++) { in lfs_fs_traverseraw()
3861 for (uint16_t id = 0; id < dir.count; id++) { in lfs_fs_traverseraw()
3863 lfs_stag_t tag = lfs_dir_get(lfs, &dir, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_fs_traverseraw()
3865 if (tag < 0) { in lfs_fs_traverseraw()
3881 for (int i = 0; i < 2; i++) { in lfs_fs_traverseraw()
3914 return 0; in lfs_fs_traverseraw()
3922 LFS_TRACE("lfs_fs_traverse -> %d", 0); in lfs_fs_traverse()
3929 pdir->tail[0] = 0; in lfs_fs_pred()
3931 lfs_block_t cycle = 0; in lfs_fs_pred()
3939 if (lfs_pair_cmp(pdir->tail, pair) == 0) { in lfs_fs_pred()
3940 return 0; in lfs_fs_pred()
3973 return (lfs_pair_cmp(child, find->pair) == 0) ? LFS_CMP_EQ : LFS_CMP_LT; in lfs_fs_parent_match()
3979 parent->tail[0] = 0; in lfs_fs_parent()
3981 lfs_block_t cycle = 0; in lfs_fs_parent()
3990 LFS_MKTAG(0x7ff, 0, 0x3ff), in lfs_fs_parent()
3991 LFS_MKTAG(LFS_TYPE_DIRSTRUCT, 0, 8), in lfs_fs_parent()
3994 lfs, {pair[0], pair[1]}}); in lfs_fs_parent()
4006 if (lfs_pair_cmp(oldpair, lfs->root) == 0) { in lfs_fs_relocate()
4007 lfs->root[0] = newpair[0]; in lfs_fs_relocate()
4013 if (lfs_pair_cmp(oldpair, d->m.pair) == 0) { in lfs_fs_relocate()
4014 d->m.pair[0] = newpair[0]; in lfs_fs_relocate()
4019 lfs_pair_cmp(oldpair, ((lfs_dir_t*)d)->head) == 0) { in lfs_fs_relocate()
4020 ((lfs_dir_t*)d)->head[0] = newpair[0]; in lfs_fs_relocate()
4028 if (tag < 0 && tag != LFS_ERR_NOENT) { in lfs_fs_relocate()
4038 uint16_t moveid = 0x3ff; in lfs_fs_relocate()
4042 "{0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16"\n", in lfs_fs_relocate()
4043 parent.pair[0], parent.pair[1], moveid); in lfs_fs_relocate()
4044 lfs_fs_prepmove(lfs, 0x3ff, NULL); in lfs_fs_relocate()
4046 tag -= LFS_MKTAG(0, 1, 0); in lfs_fs_relocate()
4052 {LFS_MKTAG_IF(moveid != 0x3ff, in lfs_fs_relocate()
4053 LFS_TYPE_DELETE, moveid, 0)}, in lfs_fs_relocate()
4074 uint16_t moveid = 0x3ff; in lfs_fs_relocate()
4078 "{0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16"\n", in lfs_fs_relocate()
4079 parent.pair[0], parent.pair[1], moveid); in lfs_fs_relocate()
4080 lfs_fs_prepmove(lfs, 0x3ff, NULL); in lfs_fs_relocate()
4086 {LFS_MKTAG_IF(moveid != 0x3ff, in lfs_fs_relocate()
4087 LFS_TYPE_DELETE, moveid, 0)}, in lfs_fs_relocate()
4088 {LFS_MKTAG(LFS_TYPE_TAIL + parent.split, 0x3ff, 8), newpair})); in lfs_fs_relocate()
4095 return 0; in lfs_fs_relocate()
4099 LFS_ASSERT(lfs_tag_size(lfs->gstate.tag) > 0 || orphans >= 0); in lfs_fs_preporphans()
4101 lfs->gstate.tag = ((lfs->gstate.tag & ~LFS_MKTAG(0x800, 0, 0)) | in lfs_fs_preporphans()
4107 lfs->gstate.tag = ((lfs->gstate.tag & ~LFS_MKTAG(0x7ff, 0x3ff, 0)) | in lfs_fs_prepmove()
4108 ((id != 0x3ff) ? LFS_MKTAG(LFS_TYPE_DELETE, id, 0) : 0)); in lfs_fs_prepmove()
4109 lfs->gstate.pair[0] = (id != 0x3ff) ? pair[0] : 0; in lfs_fs_prepmove()
4110 lfs->gstate.pair[1] = (id != 0x3ff) ? pair[1] : 0; in lfs_fs_prepmove()
4115 return 0; in lfs_fs_demove()
4119 LFS_DEBUG("Fixing move {0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16, in lfs_fs_demove()
4120 lfs->gdisk.pair[0], in lfs_fs_demove()
4133 lfs_fs_prepmove(lfs, 0x3ff, NULL); in lfs_fs_demove()
4135 {LFS_MKTAG(LFS_TYPE_DELETE, moveid, 0)})); in lfs_fs_demove()
4140 return 0; in lfs_fs_demove()
4145 return 0; in lfs_fs_deorphan()
4149 lfs_mdir_t pdir = {.split = true, .tail = {0, 1}}; in lfs_fs_deorphan()
4164 if (tag < 0 && tag != LFS_ERR_NOENT) { in lfs_fs_deorphan()
4170 LFS_DEBUG("Fixing orphan {0x%"PRIx32", 0x%"PRIx32"}", in lfs_fs_deorphan()
4171 pdir.tail[0], pdir.tail[1]); in lfs_fs_deorphan()
4184 LFS_MKTAG(0x7ff, 0x3ff, 0), tag, pair); in lfs_fs_deorphan()
4185 if (res < 0) { in lfs_fs_deorphan()
4192 LFS_DEBUG("Fixing half-orphan {0x%"PRIx32", 0x%"PRIx32"} " in lfs_fs_deorphan()
4193 "-> {0x%"PRIx32", 0x%"PRIx32"}", in lfs_fs_deorphan()
4194 pdir.tail[0], pdir.tail[1], pair[0], pair[1]); in lfs_fs_deorphan()
4198 {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8), pair})); in lfs_fs_deorphan()
4214 return 0; in lfs_fs_deorphan()
4228 return 0; in lfs_fs_forceconsistency()
4235 return 0; in lfs_fs_size_count()
4240 lfs_size_t size = 0; in lfs_fs_size()
4259 #define LFS1_VERSION 0x00010007
4260 #define LFS1_VERSION_MAJOR (0xffff & (LFS1_VERSION >> 16))
4261 #define LFS1_VERSION_MINOR (0xffff & (LFS1_VERSION >> 0))
4266 #define LFS1_DISK_VERSION 0x00010001
4267 #define LFS1_DISK_VERSION_MAJOR (0xffff & (LFS1_DISK_VERSION >> 16))
4268 #define LFS1_DISK_VERSION_MINOR (0xffff & (LFS1_DISK_VERSION >> 0))
4275 LFS1_TYPE_REG = 0x11,
4276 LFS1_TYPE_DIR = 0x22,
4277 LFS1_TYPE_SUPERBLOCK = 0x2e,
4349 for (lfs_off_t i = 0; i < size; i++) { in lfs1_bd_crc()
4359 return 0; in lfs1_bd_crc()
4367 d->tail[0] = lfs_fromle32(d->tail[0]); in lfs1_dir_fromle32()
4374 d->tail[0] = lfs_tole32(d->tail[0]); in lfs1_dir_tole32()
4379 d->u.dir[0] = lfs_fromle32(d->u.dir[0]); in lfs1_entry_fromle32()
4384 d->u.dir[0] = lfs_tole32(d->u.dir[0]); in lfs1_entry_tole32()
4389 d->root[0] = lfs_fromle32(d->root[0]); in lfs1_superblock_fromle32()
4405 const lfs_block_t tpair[2] = {pair[0], pair[1]}; in lfs1_dir_fetch()
4409 for (int i = 0; i < 2; i++) { in lfs1_dir_fetch()
4411 int err = lfs1_bd_read(lfs, tpair[i], 0, &test, sizeof(test)); 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()
4425 (0x7fffffff & test.size) > lfs->cfg->block_size) { in lfs1_dir_fetch()
4429 uint32_t crc = 0xffffffff; in lfs1_dir_fetch()
4434 (0x7fffffff & test.size) - sizeof(test), &crc); in lfs1_dir_fetch()
4442 if (crc != 0) { in lfs1_dir_fetch()
4449 dir->pair[0] = tpair[(i+0) % 2]; in lfs1_dir_fetch()
4456 LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}", in lfs1_dir_fetch()
4457 tpair[0], tpair[1]); in lfs1_dir_fetch()
4461 return 0; in lfs1_dir_fetch()
4465 while (dir->off + sizeof(entry->d) > (0x7fffffff & dir->d.size)-4) { in lfs1_dir_next()
4466 if (!(0x80000000 & dir->d.size)) { in lfs1_dir_next()
4480 int err = lfs1_bd_read(lfs, dir->pair[0], dir->off, in lfs1_dir_next()
4490 return 0; in lfs1_dir_next()
4496 return 0; in lfs1_traverse()
4502 lfs_block_t cwd[2] = {0, 1}; in lfs1_traverse()
4505 for (int i = 0; i < 2; i++) { in lfs1_traverse()
4518 while (dir.off + sizeof(entry.d) <= (0x7fffffff & dir.d.size)-4) { in lfs1_traverse()
4519 err = lfs1_bd_read(lfs, dir.pair[0], dir.off, in lfs1_traverse()
4527 if ((0x70 & entry.d.type) == (0x70 & LFS1_TYPE_REG)) { in lfs1_traverse()
4537 lfs_mdir_t dir2 = {.split=true, .tail={cwd[0], cwd[1]}}; in lfs1_traverse()
4544 for (int i = 0; i < 2; i++) { in lfs1_traverse()
4552 cwd[0] = dir.d.tail[0]; in lfs1_traverse()
4560 return 0; in lfs1_traverse()
4565 return 0; in lfs1_moved()
4570 int err = lfs1_dir_fetch(lfs, &cwd, (const lfs_block_t[2]){0, 1}); in lfs1_moved()
4593 if (!(0x80 & entry.d.type) && in lfs1_moved()
4594 memcmp(&entry.d.u, e, sizeof(entry.d.u)) == 0) { in lfs1_moved()
4606 int err = 0; in lfs1_mount()
4614 lfs->lfs1->root[0] = LFS_BLOCK_NULL; in lfs1_mount()
4618 lfs->free.off = 0; in lfs1_mount()
4619 lfs->free.size = 0; in lfs1_mount()
4620 lfs->free.i = 0; in lfs1_mount()
4626 err = lfs1_dir_fetch(lfs, &dir, (const lfs_block_t[2]){0, 1}); in lfs1_mount()
4632 err = lfs1_bd_read(lfs, dir.pair[0], sizeof(dir.d), in lfs1_mount()
4639 lfs->lfs1->root[0] = superblock.d.root[0]; in lfs1_mount()
4643 if (err || memcmp(superblock.d.magic, "littlefs", 8) != 0) { in lfs1_mount()
4644 LFS_ERROR("Invalid superblock at {0x%"PRIx32", 0x%"PRIx32"}", in lfs1_mount()
4645 0, 1); in lfs1_mount()
4650 uint16_t major_version = (0xffff & (superblock.d.version >> 16)); in lfs1_mount()
4651 uint16_t minor_version = (0xffff & (superblock.d.version >> 0)); in lfs1_mount()
4659 return 0; in lfs1_mount()
4701 dir1.d.tail[0] = lfs->lfs1->root[0]; in lfs_migrate()
4717 dir1.head[0] = dir1.pair[0]; in lfs_migrate()
4719 lfs->root[0] = dir2.pair[0]; in lfs_migrate()
4722 err = lfs_dir_commit(lfs, &dir2, NULL, 0); in lfs_migrate()
4739 if (entry1.d.type & 0x80) { in lfs_migrate()
4741 if (moved < 0) { in lfs_migrate()
4750 entry1.d.type &= ~0x80; in lfs_migrate()
4755 memset(name, 0, sizeof(name)); in lfs_migrate()
4756 err = lfs1_bd_read(lfs, dir1.pair[0], in lfs_migrate()
4773 if (!(err == LFS_ERR_NOENT && id != 0x3ff)) { in lfs_migrate()
4774 err = (err < 0) ? err : LFS_ERR_EXIST; in lfs_migrate()
4780 {LFS_MKTAG(LFS_TYPE_CREATE, id, 0)}, in lfs_migrate()
4811 {LFS_MKTAG(LFS_TYPE_SOFTTAIL, 0x3ff, 8), dir1.d.tail})); in lfs_migrate()
4820 LFS_DEBUG("Migrating {0x%"PRIx32", 0x%"PRIx32"} " in lfs_migrate()
4821 "-> {0x%"PRIx32", 0x%"PRIx32"}", in lfs_migrate()
4822 lfs->root[0], lfs->root[1], dir1.head[0], dir1.head[1]); in lfs_migrate()
4834 for (lfs_off_t i = 0; i < dir2.off; i++) { in lfs_migrate()
4838 dir2.pair[0], i, &dat, 1); in lfs_migrate()
4858 err = lfs1_dir_fetch(lfs, &dir1, (const lfs_block_t[2]){0, 1}); in lfs_migrate()
4863 dir2.pair[0] = dir1.pair[0]; in lfs_migrate()
4867 dir2.etag = 0xffffffff; in lfs_migrate()
4868 dir2.count = 0; in lfs_migrate()
4869 dir2.tail[0] = lfs->lfs1->root[0]; in lfs_migrate()
4885 {LFS_MKTAG(LFS_TYPE_CREATE, 0, 0)}, in lfs_migrate()
4886 {LFS_MKTAG(LFS_TYPE_SUPERBLOCK, 0, 8), "littlefs"}, in lfs_migrate()
4887 {LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, sizeof(superblock)), in lfs_migrate()
4894 err = lfs_dir_fetch(lfs, &dir2, (const lfs_block_t[2]){0, 1}); in lfs_migrate()
4901 err = lfs_dir_commit(lfs, &dir2, NULL, 0); in lfs_migrate()