Lines Matching refs:err

98             int err = lfs->cfg->read(lfs->cfg, block, off, data, diff);  in lfs_bd_read()  local
99 if (err) { in lfs_bd_read()
100 return err; in lfs_bd_read()
119 int err = lfs->cfg->read(lfs->cfg, rcache->block, in lfs_bd_read() local
121 LFS_ASSERT(err <= 0); in lfs_bd_read()
122 if (err) { in lfs_bd_read()
123 return err; in lfs_bd_read()
141 int err = lfs_bd_read(lfs, in lfs_bd_cmp() local
144 if (err) { in lfs_bd_cmp()
145 return err; in lfs_bd_cmp()
165 int err = lfs_bd_read(lfs, in lfs_bd_crc() local
168 if (err) { in lfs_bd_crc()
169 return err; in lfs_bd_crc()
184 int err = lfs->cfg->prog(lfs->cfg, pcache->block, in lfs_bd_flush() local
186 LFS_ASSERT(err <= 0); in lfs_bd_flush()
187 if (err) { in lfs_bd_flush()
188 return err; in lfs_bd_flush()
218 int err = lfs_bd_flush(lfs, pcache, rcache, validate); in lfs_bd_sync() local
219 if (err) { in lfs_bd_sync()
220 return err; in lfs_bd_sync()
223 err = lfs->cfg->sync(lfs->cfg); in lfs_bd_sync()
224 LFS_ASSERT(err <= 0); in lfs_bd_sync()
225 return err; in lfs_bd_sync()
254 int err = lfs_bd_flush(lfs, pcache, rcache, validate); in lfs_bd_prog() local
255 if (err) { in lfs_bd_prog()
256 return err; in lfs_bd_prog()
280 int err = lfs->cfg->erase(lfs->cfg, block); in lfs_bd_erase() local
281 LFS_ASSERT(err <= 0); in lfs_bd_erase()
282 return err; in lfs_bd_erase()
640 int err = lfs_fs_rawtraverse(lfs, lfs_alloc_lookahead, lfs, true); in lfs_fs_rawgc() local
641 if (err) { in lfs_fs_rawgc()
643 return err; in lfs_fs_rawgc()
682 int err = lfs_fs_rawgc(lfs); in lfs_alloc() local
683 if(err) { in lfs_alloc()
684 return err; in lfs_alloc()
709 int err = lfs_bd_read(lfs, in lfs_dir_getslice() local
712 if (err) { in lfs_dir_getslice()
713 return err; in lfs_dir_getslice()
737 err = lfs_bd_read(lfs, in lfs_dir_getslice()
740 if (err) { in lfs_dir_getslice()
741 return err; in lfs_dir_getslice()
811 int err = lfs_dir_getslice(lfs, dir, gmask, gtag, in lfs_dir_getread() local
813 if (err < 0) { in lfs_dir_getread()
814 return err; in lfs_dir_getread()
902 int err = lfs_bd_read(lfs, in lfs_dir_traverse() local
905 if (err) { in lfs_dir_traverse()
906 return err; in lfs_dir_traverse()
1096 int err = lfs_bd_read(lfs, in lfs_dir_fetchmatch() local
1100 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
1101 return err; in lfs_dir_fetchmatch()
1104 if (err != LFS_ERR_CORRUPT && in lfs_dir_fetchmatch()
1138 int err = lfs_bd_read(lfs, in lfs_dir_fetchmatch() local
1141 if (err) { in lfs_dir_fetchmatch()
1142 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
1146 return err; in lfs_dir_fetchmatch()
1167 err = lfs_bd_read(lfs, in lfs_dir_fetchmatch()
1170 if (err) { in lfs_dir_fetchmatch()
1171 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
1174 return err; in lfs_dir_fetchmatch()
1206 err = lfs_bd_crc(lfs, in lfs_dir_fetchmatch()
1210 if (err) { in lfs_dir_fetchmatch()
1211 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
1214 return err; in lfs_dir_fetchmatch()
1236 err = lfs_bd_read(lfs, in lfs_dir_fetchmatch()
1239 if (err) { in lfs_dir_fetchmatch()
1240 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
1243 return err; in lfs_dir_fetchmatch()
1247 err = lfs_bd_read(lfs, in lfs_dir_fetchmatch()
1251 if (err) { in lfs_dir_fetchmatch()
1252 if (err == LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
1315 int err = lfs_bd_crc(lfs, in lfs_dir_fetchmatch() local
1318 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_fetchmatch()
1319 return err; in lfs_dir_fetchmatch()
1560 int err = lfs_bd_prog(lfs, in lfs_dir_commitprog() local
1564 if (err) { in lfs_dir_commitprog()
1565 return err; in lfs_dir_commitprog()
1585 int err = lfs_dir_commitprog(lfs, commit, &ntag, sizeof(ntag)); in lfs_dir_commitattr() local
1586 if (err) { in lfs_dir_commitattr()
1587 return err; in lfs_dir_commitattr()
1592 err = lfs_dir_commitprog(lfs, commit, buffer, dsize-sizeof(tag)); in lfs_dir_commitattr()
1593 if (err) { in lfs_dir_commitattr()
1594 return err; in lfs_dir_commitattr()
1602 err = lfs_bd_read(lfs, in lfs_dir_commitattr()
1605 if (err) { in lfs_dir_commitattr()
1606 return err; in lfs_dir_commitattr()
1609 err = lfs_dir_commitprog(lfs, commit, &dat, 1); in lfs_dir_commitattr()
1610 if (err) { in lfs_dir_commitattr()
1611 return err; in lfs_dir_commitattr()
1653 int err = lfs_bd_read(lfs, in lfs_dir_commitcrc() local
1656 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_commitcrc()
1657 return err; in lfs_dir_commitcrc()
1674 err = lfs_bd_crc(lfs, in lfs_dir_commitcrc()
1677 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_commitcrc()
1678 return err; in lfs_dir_commitcrc()
1682 err = lfs_dir_commitattr(lfs, commit, in lfs_dir_commitcrc()
1685 if (err) { in lfs_dir_commitcrc()
1686 return err; in lfs_dir_commitcrc()
1703 int err = lfs_bd_prog(lfs, in lfs_dir_commitcrc() local
1706 if (err) { in lfs_dir_commitcrc()
1707 return err; in lfs_dir_commitcrc()
1726 int err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false); in lfs_dir_commitcrc() local
1727 if (err) { in lfs_dir_commitcrc()
1728 return err; in lfs_dir_commitcrc()
1739 int err = lfs_bd_crc(lfs, in lfs_dir_commitcrc() local
1742 if (err) { in lfs_dir_commitcrc()
1743 return err; in lfs_dir_commitcrc()
1753 err = lfs_bd_crc(lfs, in lfs_dir_commitcrc()
1756 if (err) { in lfs_dir_commitcrc()
1757 return err; in lfs_dir_commitcrc()
1772 int err = lfs_alloc(lfs, &dir->pair[(i+1)%2]); in lfs_dir_alloc() local
1773 if (err) { in lfs_dir_alloc()
1774 return err; in lfs_dir_alloc()
1783 int err = lfs_bd_read(lfs, in lfs_dir_alloc() local
1787 if (err && err != LFS_ERR_CORRUPT) { in lfs_dir_alloc()
1788 return err; in lfs_dir_alloc()
1815 int err = lfs_dir_getgstate(lfs, tail, &lfs->gdelta); in lfs_dir_drop() local
1816 if (err) { in lfs_dir_drop()
1817 return err; in lfs_dir_drop()
1822 err = lfs_dir_commit(lfs, dir, LFS_MKATTRS( in lfs_dir_drop()
1825 if (err) { in lfs_dir_drop()
1826 return err; in lfs_dir_drop()
1839 int err = lfs_dir_alloc(lfs, &tail); in lfs_dir_split() local
1840 if (err) { in lfs_dir_split()
1841 return err; in lfs_dir_split()
1949 int err = lfs_bd_erase(lfs, dir->pair[1]); in lfs_dir_compact() local
1950 if (err) { in lfs_dir_compact()
1951 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1954 return err; in lfs_dir_compact()
1959 err = lfs_dir_commitprog(lfs, &commit, in lfs_dir_compact()
1962 if (err) { in lfs_dir_compact()
1963 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1966 return err; in lfs_dir_compact()
1970 err = lfs_dir_traverse(lfs, in lfs_dir_compact()
1977 if (err) { in lfs_dir_compact()
1978 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1981 return err; in lfs_dir_compact()
1987 err = lfs_dir_commitattr(lfs, &commit, in lfs_dir_compact()
1991 if (err) { in lfs_dir_compact()
1992 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
1995 return err; in lfs_dir_compact()
2008 err = lfs_dir_getgstate(lfs, dir, &delta); in lfs_dir_compact()
2009 if (err) { in lfs_dir_compact()
2010 return err; in lfs_dir_compact()
2015 err = lfs_dir_commitattr(lfs, &commit, in lfs_dir_compact()
2018 if (err) { in lfs_dir_compact()
2019 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
2022 return err; in lfs_dir_compact()
2027 err = lfs_dir_commitcrc(lfs, &commit); in lfs_dir_compact()
2028 if (err) { in lfs_dir_compact()
2029 if (err == LFS_ERR_CORRUPT) { in lfs_dir_compact()
2032 return err; in lfs_dir_compact()
2065 int err = lfs_alloc(lfs, &dir->pair[1]); in lfs_dir_compact() local
2066 if (err && (err != LFS_ERR_NOSPC || !tired)) { in lfs_dir_compact()
2067 return err; in lfs_dir_compact()
2092 int err = lfs_dir_traverse(lfs, in lfs_dir_splittingcompact() local
2098 if (err) { in lfs_dir_splittingcompact()
2099 return err; in lfs_dir_splittingcompact()
2133 int err = lfs_dir_split(lfs, dir, attrs, attrcount, in lfs_dir_splittingcompact() local
2135 if (err && err != LFS_ERR_NOSPC) { in lfs_dir_splittingcompact()
2136 return err; in lfs_dir_splittingcompact()
2139 if (err) { in lfs_dir_splittingcompact()
2163 int err = lfs_dir_split(lfs, dir, attrs, attrcount, in lfs_dir_splittingcompact() local
2165 if (err && err != LFS_ERR_NOSPC) { in lfs_dir_splittingcompact()
2166 return err; in lfs_dir_splittingcompact()
2169 if (err) { in lfs_dir_splittingcompact()
2210 int err = lfs_fs_pred(lfs, dir->pair, pdir); in lfs_dir_relocatingcommit() local
2211 if (err && err != LFS_ERR_NOENT) { in lfs_dir_relocatingcommit()
2212 return err; in lfs_dir_relocatingcommit()
2215 if (err != LFS_ERR_NOENT && pdir->split) { in lfs_dir_relocatingcommit()
2236 int err = lfs_dir_traverse(lfs, in lfs_dir_relocatingcommit() local
2242 if (err) { in lfs_dir_relocatingcommit()
2243 if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) { in lfs_dir_relocatingcommit()
2246 return err; in lfs_dir_relocatingcommit()
2256 err = lfs_dir_getgstate(lfs, dir, &delta); in lfs_dir_relocatingcommit()
2257 if (err) { in lfs_dir_relocatingcommit()
2258 return err; in lfs_dir_relocatingcommit()
2262 err = lfs_dir_commitattr(lfs, &commit, in lfs_dir_relocatingcommit()
2265 if (err) { in lfs_dir_relocatingcommit()
2266 if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) { in lfs_dir_relocatingcommit()
2269 return err; in lfs_dir_relocatingcommit()
2274 err = lfs_dir_commitcrc(lfs, &commit); in lfs_dir_relocatingcommit()
2275 if (err) { in lfs_dir_relocatingcommit()
2276 if (err == LFS_ERR_NOSPC || err == LFS_ERR_CORRUPT) { in lfs_dir_relocatingcommit()
2279 return err; in lfs_dir_relocatingcommit()
2342 int err = lfs_dir_fetch(lfs, &d->m, d->m.tail); in lfs_dir_relocatingcommit() local
2343 if (err) { in lfs_dir_relocatingcommit()
2344 return err; in lfs_dir_relocatingcommit()
2363 int err = lfs_file_outline(lfs, f); in lfs_dir_orphaningcommit() local
2364 if (err) { in lfs_dir_orphaningcommit()
2365 return err; in lfs_dir_orphaningcommit()
2368 err = lfs_file_flush(lfs, f); in lfs_dir_orphaningcommit()
2369 if (err) { in lfs_dir_orphaningcommit()
2370 return err; in lfs_dir_orphaningcommit()
2397 int err = lfs_dir_getgstate(lfs, dir, &lfs->gdelta); in lfs_dir_orphaningcommit() local
2398 if (err) { in lfs_dir_orphaningcommit()
2399 return err; in lfs_dir_orphaningcommit()
2456 int err = lfs_fs_preporphans(lfs, +1); in lfs_dir_orphaningcommit() local
2457 if (err) { in lfs_dir_orphaningcommit()
2458 return err; in lfs_dir_orphaningcommit()
2497 int err = lfs_fs_pred(lfs, lpair, &pdir); in lfs_dir_orphaningcommit() local
2498 if (err && err != LFS_ERR_NOENT) { in lfs_dir_orphaningcommit()
2499 return err; in lfs_dir_orphaningcommit()
2501 LFS_ASSERT(!(hasparent && err == LFS_ERR_NOENT)); in lfs_dir_orphaningcommit()
2504 if (err != LFS_ERR_NOENT) { in lfs_dir_orphaningcommit()
2507 err = lfs_fs_preporphans(lfs, -hasparent); in lfs_dir_orphaningcommit()
2508 if (err) { in lfs_dir_orphaningcommit()
2509 return err; in lfs_dir_orphaningcommit()
2559 int err = lfs_fs_deorphan(lfs, false); in lfs_dir_commit() local
2560 if (err) { in lfs_dir_commit()
2561 return err; in lfs_dir_commit()
2574 int err = lfs_fs_forceconsistency(lfs); in lfs_rawmkdir() local
2575 if (err) { in lfs_rawmkdir()
2576 return err; in lfs_rawmkdir()
2582 err = lfs_dir_find(lfs, &cwd.m, &path, &id); in lfs_rawmkdir()
2583 if (!(err == LFS_ERR_NOENT && id != 0x3ff)) { in lfs_rawmkdir()
2584 return (err < 0) ? err : LFS_ERR_EXIST; in lfs_rawmkdir()
2596 err = lfs_dir_alloc(lfs, &dir); in lfs_rawmkdir()
2597 if (err) { in lfs_rawmkdir()
2598 return err; in lfs_rawmkdir()
2604 err = lfs_dir_fetch(lfs, &pred, pred.tail); in lfs_rawmkdir()
2605 if (err) { in lfs_rawmkdir()
2606 return err; in lfs_rawmkdir()
2612 err = lfs_dir_commit(lfs, &dir, LFS_MKATTRS( in lfs_rawmkdir()
2615 if (err) { in lfs_rawmkdir()
2616 return err; in lfs_rawmkdir()
2622 err = lfs_fs_preporphans(lfs, +1); in lfs_rawmkdir()
2623 if (err) { in lfs_rawmkdir()
2624 return err; in lfs_rawmkdir()
2636 err = lfs_dir_commit(lfs, &pred, LFS_MKATTRS( in lfs_rawmkdir()
2639 if (err) { in lfs_rawmkdir()
2641 return err; in lfs_rawmkdir()
2645 err = lfs_fs_preporphans(lfs, -1); in lfs_rawmkdir()
2646 if (err) { in lfs_rawmkdir()
2647 return err; in lfs_rawmkdir()
2653 err = lfs_dir_commit(lfs, &cwd.m, LFS_MKATTRS( in lfs_rawmkdir()
2660 if (err) { in lfs_rawmkdir()
2661 return err; in lfs_rawmkdir()
2694 int err = lfs_dir_fetch(lfs, &dir->m, pair); in lfs_dir_rawopen() local
2695 if (err) { in lfs_dir_rawopen()
2696 return err; in lfs_dir_rawopen()
2741 int err = lfs_dir_fetch(lfs, &dir->m, dir->m.tail); in lfs_dir_rawread() local
2742 if (err) { in lfs_dir_rawread()
2743 return err; in lfs_dir_rawread()
2749 int err = lfs_dir_getinfo(lfs, &dir->m, dir->id, info); in lfs_dir_rawread() local
2750 if (err && err != LFS_ERR_NOENT) { in lfs_dir_rawread()
2751 return err; in lfs_dir_rawread()
2755 if (err != LFS_ERR_NOENT) { in lfs_dir_rawread()
2766 int err = lfs_dir_rawrewind(lfs, dir); in lfs_dir_rawseek() local
2767 if (err) { in lfs_dir_rawseek()
2768 return err; in lfs_dir_rawseek()
2784 err = lfs_dir_fetch(lfs, &dir->m, dir->m.tail); in lfs_dir_rawseek()
2785 if (err) { in lfs_dir_rawseek()
2786 return err; in lfs_dir_rawseek()
2808 int err = lfs_dir_fetch(lfs, &dir->m, dir->head); in lfs_dir_rawrewind() local
2809 if (err) { in lfs_dir_rawrewind()
2810 return err; in lfs_dir_rawrewind()
2851 int err = lfs_bd_read(lfs, in lfs_ctz_find() local
2855 if (err) { in lfs_ctz_find()
2856 return err; in lfs_ctz_find()
2875 int err = lfs_alloc(lfs, &nblock); in lfs_ctz_extend() local
2876 if (err) { in lfs_ctz_extend()
2877 return err; in lfs_ctz_extend()
2881 err = lfs_bd_erase(lfs, nblock); in lfs_ctz_extend()
2882 if (err) { in lfs_ctz_extend()
2883 if (err == LFS_ERR_CORRUPT) { in lfs_ctz_extend()
2886 return err; in lfs_ctz_extend()
2903 err = lfs_bd_read(lfs, in lfs_ctz_extend()
2906 if (err) { in lfs_ctz_extend()
2907 return err; in lfs_ctz_extend()
2910 err = lfs_bd_prog(lfs, in lfs_ctz_extend()
2913 if (err) { in lfs_ctz_extend()
2914 if (err == LFS_ERR_CORRUPT) { in lfs_ctz_extend()
2917 return err; in lfs_ctz_extend()
2932 err = lfs_bd_prog(lfs, pcache, rcache, true, in lfs_ctz_extend()
2935 if (err) { in lfs_ctz_extend()
2936 if (err == LFS_ERR_CORRUPT) { in lfs_ctz_extend()
2939 return err; in lfs_ctz_extend()
2943 err = lfs_bd_read(lfs, in lfs_ctz_extend()
2947 if (err) { in lfs_ctz_extend()
2948 return err; in lfs_ctz_extend()
2978 int err = cb(data, head); in lfs_ctz_traverse() local
2979 if (err) { in lfs_ctz_traverse()
2980 return err; in lfs_ctz_traverse()
2989 err = lfs_bd_read(lfs, in lfs_ctz_traverse()
2994 if (err) { in lfs_ctz_traverse()
2995 return err; in lfs_ctz_traverse()
2999 err = cb(data, heads[i]); in lfs_ctz_traverse()
3000 if (err) { in lfs_ctz_traverse()
3001 return err; in lfs_ctz_traverse()
3018 int err = lfs_fs_forceconsistency(lfs); local
3019 if (err) {
3020 return err;
3028 int err; local
3038 err = tag;
3048 err = LFS_ERR_NOENT;
3053 err = LFS_ERR_NOENT;
3060 err = LFS_ERR_NAMETOOLONG;
3065 err = lfs_dir_commit(lfs, &file->m, LFS_MKATTRS(
3072 err = (err == LFS_ERR_NOSPC) ? LFS_ERR_NAMETOOLONG : err;
3073 if (err) {
3079 err = LFS_ERR_EXIST;
3083 err = LFS_ERR_ISDIR;
3096 err = tag;
3112 err = res;
3121 err = LFS_ERR_NOSPC;
3136 err = LFS_ERR_NOMEM;
3161 err = res;
3175 return err;
3182 int err = lfs_file_rawopencfg(lfs, file, path, flags, &defaults); local
3183 return err;
3189 int err = lfs_file_rawsync(lfs, file); local
3191 int err = 0;
3202 return err;
3211 int err = lfs_alloc(lfs, &nblock); local
3212 if (err) {
3213 return err;
3216 err = lfs_bd_erase(lfs, nblock);
3217 if (err) {
3218 if (err == LFS_ERR_CORRUPT) {
3221 return err;
3228 err = lfs_dir_getread(lfs, &file->m,
3234 if (err) {
3235 return err;
3238 err = lfs_bd_read(lfs,
3241 if (err) {
3242 return err;
3246 err = lfs_bd_prog(lfs,
3249 if (err) {
3250 if (err == LFS_ERR_CORRUPT) {
3253 return err;
3281 int err = lfs_file_relocate(lfs, file); local
3282 if (err) {
3283 return err;
3337 int err = lfs_bd_flush(lfs, &file->cache, &lfs->rcache, true); local
3338 if (err) {
3339 if (err == LFS_ERR_CORRUPT) {
3342 return err;
3349 err = lfs_file_relocate(lfs, file);
3350 if (err) {
3351 return err;
3378 int err = lfs_file_flush(lfs, file); local
3379 if (err) {
3381 return err;
3408 err = lfs_dir_commit(lfs, &file->m, LFS_MKATTRS(
3412 if (err) {
3414 return err;
3442 int err = lfs_ctz_find(lfs, NULL, &file->cache, local
3445 if (err) {
3446 return err;
3459 int err = lfs_dir_getread(lfs, &file->m, local
3464 if (err) {
3465 return err;
3468 int err = lfs_bd_read(lfs, local
3471 if (err) {
3472 return err;
3492 int err = lfs_file_flush(lfs, file); local
3493 if (err) {
3494 return err;
3516 int err = lfs_file_outline(lfs, file); local
3517 if (err) {
3519 return err;
3530 int err = lfs_ctz_find(lfs, NULL, &file->cache, local
3533 if (err) {
3535 return err;
3544 int err = lfs_ctz_extend(lfs, &file->cache, &lfs->rcache, local
3547 if (err) {
3549 return err;
3562 int err = lfs_bd_prog(lfs, &file->cache, &lfs->rcache, true, local
3564 if (err) {
3565 if (err == LFS_ERR_CORRUPT) {
3569 return err;
3574 err = lfs_file_relocate(lfs, file);
3575 if (err) {
3577 return err;
3598 int err = lfs_file_flush(lfs, file); local
3599 if (err) {
3600 return err;
3689 int err = lfs_file_flush(lfs, file); local
3690 if (err) {
3691 return err;
3739 int err = lfs_file_flush(lfs, file); local
3740 if (err) {
3741 return err;
3745 err = lfs_ctz_find(lfs, NULL, &file->cache,
3748 if (err) {
3749 return err;
3826 int err = lfs_fs_forceconsistency(lfs); local
3827 if (err) {
3828 return err;
3849 err = lfs_dir_fetch(lfs, &dir.m, pair);
3850 if (err) {
3851 return err;
3859 err = lfs_fs_preporphans(lfs, +1);
3860 if (err) {
3861 return err;
3872 err = lfs_dir_commit(lfs, &cwd, LFS_MKATTRS(
3874 if (err) {
3876 return err;
3882 err = lfs_fs_preporphans(lfs, -1);
3883 if (err) {
3884 return err;
3887 err = lfs_fs_pred(lfs, dir.m.pair, &cwd);
3888 if (err) {
3889 return err;
3892 err = lfs_dir_drop(lfs, &cwd, &dir.m);
3893 if (err) {
3894 return err;
3905 int err = lfs_fs_forceconsistency(lfs); local
3906 if (err) {
3907 return err;
3961 err = lfs_dir_fetch(lfs, &prevdir.m, prevpair);
3962 if (err) {
3963 return err;
3971 err = lfs_fs_preporphans(lfs, +1);
3972 if (err) {
3973 return err;
3988 err = lfs_dir_commit(lfs, &newcwd, LFS_MKATTRS(
3996 if (err) {
3998 return err;
4006 err = lfs_dir_commit(lfs, &oldcwd, LFS_MKATTRS(
4008 if (err) {
4010 return err;
4018 err = lfs_fs_preporphans(lfs, -1);
4019 if (err) {
4020 return err;
4023 err = lfs_fs_pred(lfs, prevdir.m.pair, &newcwd);
4024 if (err) {
4025 return err;
4028 err = lfs_dir_drop(lfs, &newcwd, &prevdir.m);
4029 if (err) {
4030 return err;
4050 int err = lfs_dir_fetch(lfs, &cwd, lfs->root); local
4051 if (err) {
4052 return err;
4084 int err = lfs_dir_fetch(lfs, &cwd, lfs->root); local
4085 if (err) {
4086 return err;
4117 int err = 0; local
4168 err = LFS_ERR_NOMEM;
4179 err = LFS_ERR_NOMEM;
4197 err = LFS_ERR_NOMEM;
4239 return err;
4263 int err = 0; local
4265 err = lfs_init(lfs, cfg);
4266 if (err) {
4267 return err;
4282 err = lfs_dir_alloc(lfs, &root);
4283 if (err) {
4298 err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
4303 if (err) {
4310 err = lfs_dir_commit(lfs, &root, NULL, 0);
4311 if (err) {
4316 err = lfs_dir_fetch(lfs, &root, (const lfs_block_t[2]){0, 1});
4317 if (err) {
4324 return err;
4330 int err = lfs_init(lfs, cfg); local
4331 if (err) {
4332 return err;
4344 err = LFS_ERR_CORRUPT;
4363 err = tag;
4379 err = tag;
4395 err = LFS_ERR_INVAL;
4419 err = LFS_ERR_INVAL;
4430 err = LFS_ERR_INVAL;
4441 err = LFS_ERR_INVAL;
4453 err = LFS_ERR_INVAL;
4462 err = LFS_ERR_INVAL;
4468 err = lfs_dir_getgstate(lfs, &dir, &lfs->gstate);
4469 if (err) {
4493 return err;
4512 int err = lfs_dir_fetch(lfs, &dir, lfs->root); local
4513 if (err) {
4514 return err;
4551 int err = lfs1_traverse(lfs, cb, data); local
4552 if (err) {
4553 return err;
4579 int err = cb(data, dir.tail[i]); local
4580 if (err) {
4581 return err;
4586 int err = lfs_dir_fetch(lfs, &dir, dir.tail); local
4587 if (err) {
4588 return err;
4604 err = lfs_ctz_traverse(lfs, NULL, &lfs->rcache,
4606 if (err) {
4607 return err;
4612 err = cb(data, (&ctz.head)[i]);
4613 if (err) {
4614 return err;
4629 int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache, local
4631 if (err) {
4632 return err;
4637 int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache, local
4639 if (err) {
4640 return err;
4676 int err = lfs_dir_fetch(lfs, pdir, pdir->tail); local
4677 if (err) {
4678 return err;
4702 int err = lfs_bd_read(lfs, local
4705 if (err) {
4706 return err;
4790 int err = lfs_dir_fetch(lfs, &root, lfs->root); local
4791 if (err) {
4792 return err;
4806 err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
4809 if (err) {
4810 return err;
4836 int err = lfs_dir_fetch(lfs, &movedir, lfs->gdisk.pair); local
4837 if (err) {
4838 return err;
4844 err = lfs_dir_commit(lfs, &movedir, LFS_MKATTRS(
4846 if (err) {
4847 return err;
4877 int err = lfs_dir_fetch(lfs, &dir, pdir.tail); local
4878 if (err) {
4879 return err;
4949 err = lfs_dir_getgstate(lfs, &dir, &lfs->gdelta);
4950 if (err) {
4951 return err;
4987 int err = lfs_fs_desuperblock(lfs); local
4988 if (err) {
4989 return err;
4992 err = lfs_fs_demove(lfs);
4993 if (err) {
4994 return err;
4997 err = lfs_fs_deorphan(lfs, true);
4998 if (err) {
4999 return err;
5009 int err = lfs_fs_forceconsistency(lfs); local
5010 if (err) {
5011 return err;
5021 err = lfs_dir_fetch(lfs, &root, lfs->root);
5022 if (err) {
5023 return err;
5026 err = lfs_dir_commit(lfs, &root, NULL, 0);
5027 if (err) {
5028 return err;
5045 int err = lfs_fs_rawtraverse(lfs, lfs_fs_size_count, &size, false); local
5046 if (err) {
5047 return err;
5063 int err = lfs_dir_fetch(lfs, &root, lfs->root); local
5064 if (err) {
5065 return err;
5081 err = lfs_dir_commit(lfs, &root, LFS_MKATTRS(
5083 if (err) {
5084 return err;
5192 int err = lfs1_bd_read(lfs, block, off+i, &c, 1); local
5193 if (err) {
5194 return err;
5252 int err = lfs1_bd_read(lfs, tpair[i], 0, &test, sizeof(test)); local
5254 if (err) {
5255 if (err == LFS_ERR_CORRUPT) {
5258 return err;
5274 err = lfs1_bd_crc(lfs, tpair[i], sizeof(test),
5276 if (err) {
5277 if (err == LFS_ERR_CORRUPT) {
5280 return err;
5312 int err = lfs1_dir_fetch(lfs, dir, dir->d.tail); local
5313 if (err) {
5314 return err;
5321 int err = lfs1_bd_read(lfs, dir->pair[0], dir->off, local
5324 if (err) {
5325 return err;
5347 int err = cb(data, cwd[i]); local
5348 if (err) {
5349 return err;
5353 int err = lfs1_dir_fetch(lfs, &dir, cwd); local
5354 if (err) {
5355 return err;
5360 err = lfs1_bd_read(lfs, dir.pair[0], dir.off,
5363 if (err) {
5364 return err;
5369 err = lfs_ctz_traverse(lfs, NULL, &lfs->rcache,
5371 if (err) {
5372 return err;
5380 err = lfs_dir_fetch(lfs, &dir2, dir2.tail);
5381 if (err) {
5386 err = cb(data, dir2.pair[i]);
5387 if (err) {
5388 return err;
5411 int err = lfs1_dir_fetch(lfs, &cwd, (const lfs_block_t[2]){0, 1}); local
5412 if (err) {
5413 return err;
5419 err = lfs1_dir_fetch(lfs, &cwd, cwd.d.tail);
5420 if (err) {
5421 return err;
5425 err = lfs1_dir_next(lfs, &cwd, &entry);
5426 if (err && err != LFS_ERR_NOENT) {
5427 return err;
5430 if (err == LFS_ERR_NOENT) {
5447 int err = 0; local
5449 err = lfs_init(lfs, cfg);
5450 if (err) {
5451 return err;
5467 err = lfs1_dir_fetch(lfs, &dir, (const lfs_block_t[2]){0, 1});
5468 if (err && err != LFS_ERR_CORRUPT) {
5472 if (!err) {
5473 err = lfs1_bd_read(lfs, dir.pair[0], sizeof(dir.d),
5476 if (err) {
5484 if (err || memcmp(superblock.d.magic, "littlefs", 8) != 0) {
5487 err = LFS_ERR_CORRUPT;
5496 err = LFS_ERR_INVAL;
5505 return err;
5519 int err = lfs1_mount(lfs, &lfs1, cfg); local
5520 if (err) {
5521 return err;
5533 err = lfs1_dir_fetch(lfs, &dir1, dir1.d.tail);
5534 if (err) {
5539 err = lfs_dir_alloc(lfs, &dir2);
5540 if (err) {
5550 err = lfs_dir_commit(lfs, &dir2, NULL, 0);
5551 if (err) {
5557 err = lfs1_dir_next(lfs, &dir1, &entry1);
5558 if (err && err != LFS_ERR_NOENT) {
5562 if (err == LFS_ERR_NOENT) {
5570 err = moved;
5584 err = lfs1_bd_read(lfs, dir1.pair[0],
5587 if (err) {
5594 err = lfs_dir_fetch(lfs, &dir2, lfs->root);
5595 if (err) {
5600 err = lfs_dir_find(lfs, &dir2, &(const char*){name}, &id);
5601 if (!(err == LFS_ERR_NOENT && id != 0x3ff)) {
5602 err = (err < 0) ? err : LFS_ERR_EXIST;
5607 err = lfs_dir_commit(lfs, &dir2, LFS_MKATTRS(
5618 if (err) {
5625 err = lfs_dir_fetch(lfs, &dir2, lfs->root);
5626 if (err) {
5631 err = lfs_dir_fetch(lfs, &dir2, dir2.tail);
5632 if (err) {
5638 err = lfs_dir_commit(lfs, &dir2, LFS_MKATTRS(
5641 if (err) {
5652 err = lfs_bd_erase(lfs, dir1.head[1]);
5653 if (err) {
5657 err = lfs_dir_fetch(lfs, &dir2, lfs->root);
5658 if (err) {
5664 err = lfs_bd_read(lfs,
5667 if (err) {
5671 err = lfs_bd_prog(lfs,
5674 if (err) {
5679 err = lfs_bd_flush(lfs, &lfs->pcache, &lfs->rcache, true);
5680 if (err) {
5686 err = lfs1_dir_fetch(lfs, &dir1, (const lfs_block_t[2]){0, 1});
5687 if (err) {
5712 err = lfs_dir_commit(lfs, &dir2, LFS_MKATTRS(
5717 if (err) {
5722 err = lfs_dir_fetch(lfs, &dir2, (const lfs_block_t[2]){0, 1});
5723 if (err) {
5729 err = lfs_dir_commit(lfs, &dir2, NULL, 0);
5730 if (err) {
5737 return err;
5759 int err = LFS_LOCK(cfg); local
5760 if (err) {
5761 return err;
5780 err = lfs_rawformat(lfs, cfg);
5782 LFS_TRACE("lfs_format -> %d", err);
5784 return err;
5789 int err = LFS_LOCK(cfg); local
5790 if (err) {
5791 return err;
5810 err = lfs_rawmount(lfs, cfg);
5812 LFS_TRACE("lfs_mount -> %d", err);
5814 return err;
5818 int err = LFS_LOCK(lfs->cfg); local
5819 if (err) {
5820 return err;
5824 err = lfs_rawunmount(lfs);
5826 LFS_TRACE("lfs_unmount -> %d", err);
5828 return err;
5833 int err = LFS_LOCK(lfs->cfg); local
5834 if (err) {
5835 return err;
5839 err = lfs_rawremove(lfs, path);
5841 LFS_TRACE("lfs_remove -> %d", err);
5843 return err;
5849 int err = LFS_LOCK(lfs->cfg); local
5850 if (err) {
5851 return err;
5855 err = lfs_rawrename(lfs, oldpath, newpath);
5857 LFS_TRACE("lfs_rename -> %d", err);
5859 return err;
5864 int err = LFS_LOCK(lfs->cfg); local
5865 if (err) {
5866 return err;
5870 err = lfs_rawstat(lfs, path, info);
5872 LFS_TRACE("lfs_stat -> %d", err);
5874 return err;
5879 int err = LFS_LOCK(lfs->cfg); local
5880 if (err) {
5881 return err;
5896 int err = LFS_LOCK(lfs->cfg); local
5897 if (err) {
5898 return err;
5903 err = lfs_rawsetattr(lfs, path, type, buffer, size);
5905 LFS_TRACE("lfs_setattr -> %d", err);
5907 return err;
5913 int err = LFS_LOCK(lfs->cfg); local
5914 if (err) {
5915 return err;
5919 err = lfs_rawremoveattr(lfs, path, type);
5921 LFS_TRACE("lfs_removeattr -> %d", err);
5923 return err;
5929 int err = LFS_LOCK(lfs->cfg); local
5930 if (err) {
5931 return err;
5937 err = lfs_file_rawopen(lfs, file, path, flags);
5939 LFS_TRACE("lfs_file_open -> %d", err);
5941 return err;
5948 int err = LFS_LOCK(lfs->cfg); local
5949 if (err) {
5950 return err;
5958 err = lfs_file_rawopencfg(lfs, file, path, flags, cfg);
5960 LFS_TRACE("lfs_file_opencfg -> %d", err);
5962 return err;
5966 int err = LFS_LOCK(lfs->cfg); local
5967 if (err) {
5968 return err;
5973 err = lfs_file_rawclose(lfs, file);
5975 LFS_TRACE("lfs_file_close -> %d", err);
5977 return err;
5982 int err = LFS_LOCK(lfs->cfg); local
5983 if (err) {
5984 return err;
5989 err = lfs_file_rawsync(lfs, file);
5991 LFS_TRACE("lfs_file_sync -> %d", err);
5993 return err;
5999 int err = LFS_LOCK(lfs->cfg); local
6000 if (err) {
6001 return err;
6017 int err = LFS_LOCK(lfs->cfg); local
6018 if (err) {
6019 return err;
6035 int err = LFS_LOCK(lfs->cfg); local
6036 if (err) {
6037 return err;
6052 int err = LFS_LOCK(lfs->cfg); local
6053 if (err) {
6054 return err;
6060 err = lfs_file_rawtruncate(lfs, file, size);
6062 LFS_TRACE("lfs_file_truncate -> %d", err);
6064 return err;
6069 int err = LFS_LOCK(lfs->cfg); local
6070 if (err) {
6071 return err;
6084 int err = LFS_LOCK(lfs->cfg); local
6085 if (err) {
6086 return err;
6090 err = lfs_file_rawrewind(lfs, file);
6092 LFS_TRACE("lfs_file_rewind -> %d", err);
6094 return err;
6098 int err = LFS_LOCK(lfs->cfg); local
6099 if (err) {
6100 return err;
6114 int err = LFS_LOCK(lfs->cfg); local
6115 if (err) {
6116 return err;
6120 err = lfs_rawmkdir(lfs, path);
6122 LFS_TRACE("lfs_mkdir -> %d", err);
6124 return err;
6129 int err = LFS_LOCK(lfs->cfg); local
6130 if (err) {
6131 return err;
6136 err = lfs_dir_rawopen(lfs, dir, path);
6138 LFS_TRACE("lfs_dir_open -> %d", err);
6140 return err;
6144 int err = LFS_LOCK(lfs->cfg); local
6145 if (err) {
6146 return err;
6150 err = lfs_dir_rawclose(lfs, dir);
6152 LFS_TRACE("lfs_dir_close -> %d", err);
6154 return err;
6158 int err = LFS_LOCK(lfs->cfg); local
6159 if (err) {
6160 return err;
6165 err = lfs_dir_rawread(lfs, dir, info);
6167 LFS_TRACE("lfs_dir_read -> %d", err);
6169 return err;
6173 int err = LFS_LOCK(lfs->cfg); local
6174 if (err) {
6175 return err;
6180 err = lfs_dir_rawseek(lfs, dir, off);
6182 LFS_TRACE("lfs_dir_seek -> %d", err);
6184 return err;
6188 int err = LFS_LOCK(lfs->cfg); local
6189 if (err) {
6190 return err;
6202 int err = LFS_LOCK(lfs->cfg); local
6203 if (err) {
6204 return err;
6208 err = lfs_dir_rawrewind(lfs, dir);
6210 LFS_TRACE("lfs_dir_rewind -> %d", err);
6212 return err;
6216 int err = LFS_LOCK(lfs->cfg); local
6217 if (err) {
6218 return err;
6222 err = lfs_fs_rawstat(lfs, fsinfo);
6224 LFS_TRACE("lfs_fs_stat -> %d", err);
6226 return err;
6230 int err = LFS_LOCK(lfs->cfg); local
6231 if (err) {
6232 return err;
6244 int err = LFS_LOCK(lfs->cfg); local
6245 if (err) {
6246 return err;
6251 err = lfs_fs_rawtraverse(lfs, cb, data, true);
6253 LFS_TRACE("lfs_fs_traverse -> %d", err);
6255 return err;
6260 int err = LFS_LOCK(lfs->cfg); local
6261 if (err) {
6262 return err;
6266 err = lfs_fs_rawgc(lfs);
6268 LFS_TRACE("lfs_fs_gc -> %d", err);
6270 return err;
6276 int err = LFS_LOCK(lfs->cfg); local
6277 if (err) {
6278 return err;
6282 err = lfs_fs_rawmkconsistent(lfs);
6284 LFS_TRACE("lfs_fs_mkconsistent -> %d", err);
6286 return err;
6292 int err = LFS_LOCK(lfs->cfg); local
6293 if (err) {
6294 return err;
6298 err = lfs_fs_rawgrow(lfs, block_count);
6300 LFS_TRACE("lfs_fs_grow -> %d", err);
6302 return err;
6308 int err = LFS_LOCK(cfg); local
6309 if (err) {
6310 return err;
6329 err = lfs_rawmigrate(lfs, cfg);
6331 LFS_TRACE("lfs_migrate -> %d", err);
6333 return err;