Lines Matching refs:off
50 lfs_block_t block, lfs_off_t off, in lfs_bd_read() argument
54 off+size > lfs->cfg->block_size) { in lfs_bd_read()
62 off < pcache->off + pcache->size) { in lfs_bd_read()
63 if (off >= pcache->off) { in lfs_bd_read()
65 diff = lfs_min(diff, pcache->size - (off-pcache->off)); in lfs_bd_read()
66 memcpy(data, &pcache->buffer[off-pcache->off], diff); in lfs_bd_read()
69 off += diff; in lfs_bd_read()
75 diff = lfs_min(diff, pcache->off-off); in lfs_bd_read()
79 off < rcache->off + rcache->size) { in lfs_bd_read()
80 if (off >= rcache->off) { in lfs_bd_read()
82 diff = lfs_min(diff, rcache->size - (off-rcache->off)); in lfs_bd_read()
83 memcpy(data, &rcache->buffer[off-rcache->off], diff); in lfs_bd_read()
86 off += diff; in lfs_bd_read()
92 diff = lfs_min(diff, rcache->off-off); in lfs_bd_read()
95 if (size >= hint && off % lfs->cfg->read_size == 0 && in lfs_bd_read()
99 int err = lfs->cfg->read(lfs->cfg, block, off, data, diff); in lfs_bd_read()
105 off += diff; in lfs_bd_read()
113 rcache->off = lfs_aligndown(off, lfs->cfg->read_size); in lfs_bd_read()
116 lfs_alignup(off+hint, lfs->cfg->read_size), in lfs_bd_read()
118 - rcache->off, in lfs_bd_read()
121 rcache->off, rcache->buffer, rcache->size); in lfs_bd_read()
133 lfs_block_t block, lfs_off_t off, in lfs_bd_cmp() argument
144 block, off+i, &dat, diff); in lfs_bd_cmp()
165 pcache->off, pcache->buffer, diff); in lfs_bd_flush()
176 pcache->block, pcache->off, pcache->buffer, diff); in lfs_bd_flush()
212 lfs_block_t block, lfs_off_t off, in lfs_bd_prog() argument
216 LFS_ASSERT(off + size <= lfs->cfg->block_size); in lfs_bd_prog()
220 off >= pcache->off && in lfs_bd_prog()
221 off < pcache->off + lfs->cfg->cache_size) { in lfs_bd_prog()
224 lfs->cfg->cache_size - (off-pcache->off)); in lfs_bd_prog()
225 memcpy(&pcache->buffer[off-pcache->off], data, diff); in lfs_bd_prog()
228 off += diff; in lfs_bd_prog()
231 pcache->size = lfs_max(pcache->size, off - pcache->off); in lfs_bd_prog()
249 pcache->off = lfs_aligndown(off, lfs->cfg->prog_size); in lfs_bd_prog()
364 lfs_off_t off; member
536 lfs_block_t off = ((block - lfs->free.off) in lfs_alloc_lookahead() local
539 if (off < lfs->free.size) { in lfs_alloc_lookahead()
540 lfs->free.buffer[off / 32] |= 1U << (off % 32); in lfs_alloc_lookahead()
566 lfs_block_t off = lfs->free.i; in lfs_alloc() local
570 if (!(lfs->free.buffer[off / 32] & (1U << (off % 32)))) { in lfs_alloc()
572 *block = (lfs->free.off + off) % lfs->cfg->block_count; in lfs_alloc()
590 lfs->free.i + lfs->free.off); in lfs_alloc()
594 lfs->free.off = (lfs->free.off + lfs->free.size) in lfs_alloc()
614 lfs_off_t off = dir->off; in lfs_dir_getslice() local
626 while (off >= sizeof(lfs_tag_t) + lfs_tag_dsize(ntag)) { in lfs_dir_getslice()
627 off -= lfs_tag_dsize(ntag); in lfs_dir_getslice()
631 dir->pair[0], off, &ntag, sizeof(ntag)); in lfs_dir_getslice()
659 dir->pair[0], off+sizeof(tag)+goff, gbuffer, diff); in lfs_dir_getslice()
683 lfs_off_t off, void *buffer, lfs_size_t size) { in lfs_dir_getread() argument
685 if (off+size > lfs->cfg->block_size) { in lfs_dir_getread()
693 off < pcache->off + pcache->size) { in lfs_dir_getread()
694 if (off >= pcache->off) { in lfs_dir_getread()
696 diff = lfs_min(diff, pcache->size - (off-pcache->off)); in lfs_dir_getread()
697 memcpy(data, &pcache->buffer[off-pcache->off], diff); in lfs_dir_getread()
700 off += diff; in lfs_dir_getread()
706 diff = lfs_min(diff, pcache->off-off); in lfs_dir_getread()
710 off < rcache->off + rcache->size) { in lfs_dir_getread()
711 if (off >= rcache->off) { in lfs_dir_getread()
713 diff = lfs_min(diff, rcache->size - (off-rcache->off)); in lfs_dir_getread()
714 memcpy(data, &rcache->buffer[off-rcache->off], diff); in lfs_dir_getread()
717 off += diff; in lfs_dir_getread()
723 diff = lfs_min(diff, rcache->off-off); in lfs_dir_getread()
728 rcache->off = lfs_aligndown(off, lfs->cfg->read_size); in lfs_dir_getread()
729 rcache->size = lfs_min(lfs_alignup(off+hint, lfs->cfg->read_size), in lfs_dir_getread()
732 rcache->off, rcache->buffer, rcache->size); in lfs_dir_getread()
783 lfs_off_t off; member
803 const lfs_mdir_t *dir, lfs_off_t off, lfs_tag_t ptag, in lfs_dir_traverse() argument
820 if (off+lfs_tag_dsize(ptag) < dir->off) { in lfs_dir_traverse()
821 off += lfs_tag_dsize(ptag); in lfs_dir_traverse()
824 dir->pair[0], off, &tag, sizeof(tag)); in lfs_dir_traverse()
831 disk.off = off+sizeof(lfs_tag_t); in lfs_dir_traverse()
857 .off = off, in lfs_dir_traverse()
875 off = off; in lfs_dir_traverse()
924 .off = off, in lfs_dir_traverse()
942 off = 0; in lfs_dir_traverse()
980 off = stack[sp-1].off; in lfs_dir_traverse()
1037 dir->off = 0; // nonzero = found some commits in lfs_dir_fetchmatch()
1041 lfs_off_t off = 0; in lfs_dir_fetchmatch() local
1056 off += lfs_tag_dsize(ptag); in lfs_dir_fetchmatch()
1059 dir->pair[0], off, &tag, sizeof(tag)); in lfs_dir_fetchmatch()
1075 dir->off % lfs->cfg->prog_size == 0); in lfs_dir_fetchmatch()
1077 } else if (off + lfs_tag_dsize(tag) > lfs->cfg->block_size) { in lfs_dir_fetchmatch()
1089 dir->pair[0], off+sizeof(tag), &dcrc, sizeof(dcrc)); in lfs_dir_fetchmatch()
1115 dir->off = off + lfs_tag_dsize(tag); in lfs_dir_fetchmatch()
1132 dir->pair[0], off+j, &dat, 1); in lfs_dir_fetchmatch()
1165 dir->pair[0], off+sizeof(tag), &temptail, 8); in lfs_dir_fetchmatch()
1178 dir->pair[0], off+sizeof(tag)}); in lfs_dir_fetchmatch()
1204 if (dir->off > 0) { in lfs_dir_fetchmatch()
1315 disk->block, disk->off, name->name, diff); in lfs_dir_find_match()
1432 lfs_off_t off; member
1445 commit->block, commit->off , in lfs_dir_commitprog()
1452 commit->off += size; in lfs_dir_commitprog()
1462 if (commit->off + dsize > commit->end) { in lfs_dir_commitattr()
1487 disk->block, disk->off+i, &dat, 1); in lfs_dir_commitattr()
1507 const lfs_off_t end = lfs_alignup(commit->off + 2*sizeof(uint32_t), in lfs_dir_commitcrc()
1516 while (commit->off < end) { in lfs_dir_commitcrc()
1517 lfs_off_t off = commit->off + sizeof(lfs_tag_t); in lfs_dir_commitcrc() local
1518 lfs_off_t noff = lfs_min(end - off, 0x3fe) + off; in lfs_dir_commitcrc()
1534 tag = LFS_MKTAG(LFS_TYPE_CRC + reset, 0x3ff, noff - off); in lfs_dir_commitcrc()
1543 commit->block, commit->off, &footer, sizeof(footer)); in lfs_dir_commitcrc()
1550 off1 = commit->off + sizeof(uint32_t); in lfs_dir_commitcrc()
1554 commit->off += sizeof(tag)+lfs_tag_size(tag); in lfs_dir_commitcrc()
1566 lfs_off_t off = commit->begin; in lfs_dir_commitcrc() local
1568 while (off < end) { in lfs_dir_commitcrc()
1570 for (lfs_off_t i = off; i < noff+sizeof(uint32_t); i++) { in lfs_dir_commitcrc()
1595 off = lfs_min(end - noff, 0x3fe) + noff; in lfs_dir_commitcrc()
1596 if (off < end) { in lfs_dir_commitcrc()
1597 off = lfs_min(off, end - 2*sizeof(uint32_t)); in lfs_dir_commitcrc()
1599 noff = off + sizeof(uint32_t); in lfs_dir_commitcrc()
1637 dir->off = sizeof(dir->rev); in lfs_dir_alloc()
1777 .off = 0, in lfs_dir_compact()
1874 LFS_ASSERT(commit.off % lfs->cfg->prog_size == 0); in lfs_dir_compact()
1877 dir->off = commit.off; in lfs_dir_compact()
2054 .off = dir->off, in lfs_dir_relocatingcommit()
2058 .begin = dir->off, in lfs_dir_relocatingcommit()
2066 dir, dir->off, dir->etag, attrs, attrcount, in lfs_dir_relocatingcommit()
2112 LFS_ASSERT(commit.off % lfs->cfg->prog_size == 0); in lfs_dir_relocatingcommit()
2113 dir->off = commit.off; in lfs_dir_relocatingcommit()
2593 static int lfs_dir_rawseek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) { in lfs_dir_rawseek() argument
2601 dir->pos = lfs_min(2, off); in lfs_dir_rawseek()
2602 off -= dir->pos; in lfs_dir_rawseek()
2605 dir->id = (off > 0 && lfs_pair_cmp(dir->head, lfs->root) == 0); in lfs_dir_rawseek()
2607 while (off > 0) { in lfs_dir_rawseek()
2608 int diff = lfs_min(dir->m.count - dir->id, off); in lfs_dir_rawseek()
2611 off -= diff; in lfs_dir_rawseek()
2649 static int lfs_ctz_index(lfs_t *lfs, lfs_off_t *off) { in lfs_ctz_index() argument
2650 lfs_off_t size = *off; in lfs_ctz_index()
2658 *off = size - b*i - 4*lfs_popc(i); in lfs_ctz_index()
2665 lfs_size_t pos, lfs_block_t *block, lfs_off_t *off) { in lfs_ctz_find() argument
2668 *off = 0; in lfs_ctz_find()
2692 *off = pos; in lfs_ctz_find()
2700 lfs_block_t *block, lfs_off_t *off) { in lfs_ctz_extend() argument
2720 *off = 0; in lfs_ctz_extend()
2751 *off = noff; in lfs_ctz_extend()
2783 *off = 4*skips; in lfs_ctz_extend()
2861 file->off = 0;
2979 file->cache.off = 0;
3052 for (lfs_off_t i = 0; i < file->off; i++) {
3057 NULL, &file->cache, file->off-i,
3066 &file->cache, &lfs->rcache, file->off-i,
3087 file->cache.off = lfs->pcache.off;
3106 file->off = file->pos;
3267 file->off == lfs->cfg->block_size) {
3271 file->pos, &file->block, &file->off);
3277 file->off = file->pos;
3284 lfs_size_t diff = lfs_min(nsize, lfs->cfg->block_size - file->off);
3290 file->off, data, diff);
3297 file->block, file->off, data, diff);
3304 file->off += diff;
3353 file->off == lfs->cfg->block_size) {
3359 file->pos-1, &file->block, &file->off);
3373 &file->block, &file->off);
3380 file->off = file->pos;
3387 lfs_size_t diff = lfs_min(nsize, lfs->cfg->block_size - file->off);
3390 file->block, file->off, data, diff);
3409 file->off += diff;
3464 lfs_soff_t off, int whence) { argument
3468 npos = off;
3470 if ((lfs_soff_t)file->pos + off < 0) {
3473 npos = file->pos + off;
3476 lfs_soff_t res = lfs_file_rawsize(lfs, file) + off;
3507 && noff >= file->cache.off
3508 && noff < file->cache.off + file->cache.size) {
3510 file->off = noff;
3546 size, &file->block, &file->off);
4049 lfs->free.off = 0;
4235 lfs->free.off = lfs->seed % lfs->cfg->block_count;
4395 disk->block, disk->off, &child, sizeof(child));
4681 lfs_off_t off; member
4701 lfs_off_t off; member
4714 lfs_off_t off; member
4736 lfs_off_t off, void *buffer, lfs_size_t size) { argument
4740 block, off, buffer, size);
4744 lfs_off_t off, lfs_size_t size, uint32_t *crc) { argument
4747 int err = lfs1_bd_read(lfs, block, off+i, &c, 1);
4847 dir->off = sizeof(dir->d);
4861 while (dir->off + sizeof(entry->d) > (0x7fffffff & dir->d.size)-4) {
4863 entry->off = dir->off;
4872 dir->off = sizeof(dir->d);
4876 int err = lfs1_bd_read(lfs, dir->pair[0], dir->off,
4883 entry->off = dir->off;
4884 dir->off += lfs1_entry_size(entry);
4914 while (dir.off + sizeof(entry.d) <= (0x7fffffff & dir.d.size)-4) {
4915 err = lfs1_bd_read(lfs, dir.pair[0], dir.off,
4922 dir.off += lfs1_entry_size(&entry);
5014 lfs->free.off = 0;
5136 entry1.off + 4+entry1.d.elen+entry1.d.alen,
5213 for (lfs_off_t i = 0; i < dir2.off; i++) {
5216 NULL, &lfs->rcache, dir2.off,
5245 dir2.off = sizeof(dir2.rev);
5585 lfs_soff_t off, int whence) { argument
5591 (void*)lfs, (void*)file, off, whence);
5594 lfs_soff_t res = lfs_file_rawseek(lfs, file, off, whence);
5723 int lfs_dir_seek(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) { argument
5729 (void*)lfs, (void*)dir, off);
5731 err = lfs_dir_rawseek(lfs, dir, off);