Lines Matching refs:tag
320 static inline bool lfs_tag_isvalid(lfs_tag_t tag) { in lfs_tag_isvalid() argument
321 return !(tag & 0x80000000); in lfs_tag_isvalid()
324 static inline bool lfs_tag_isdelete(lfs_tag_t tag) { in lfs_tag_isdelete() argument
325 return ((int32_t)(tag << 22) >> 22) == -1; in lfs_tag_isdelete()
328 static inline uint16_t lfs_tag_type1(lfs_tag_t tag) { in lfs_tag_type1() argument
329 return (tag & 0x70000000) >> 20; in lfs_tag_type1()
332 static inline uint16_t lfs_tag_type3(lfs_tag_t tag) { in lfs_tag_type3() argument
333 return (tag & 0x7ff00000) >> 20; in lfs_tag_type3()
336 static inline uint8_t lfs_tag_chunk(lfs_tag_t tag) { in lfs_tag_chunk() argument
337 return (tag & 0x0ff00000) >> 20; in lfs_tag_chunk()
340 static inline int8_t lfs_tag_splice(lfs_tag_t tag) { in lfs_tag_splice() argument
341 return (int8_t)lfs_tag_chunk(tag); in lfs_tag_splice()
344 static inline uint16_t lfs_tag_id(lfs_tag_t tag) { in lfs_tag_id() argument
345 return (tag & 0x000ffc00) >> 10; in lfs_tag_id()
348 static inline lfs_size_t lfs_tag_size(lfs_tag_t tag) { in lfs_tag_size() argument
349 return tag & 0x000003ff; in lfs_tag_size()
352 static inline lfs_size_t lfs_tag_dsize(lfs_tag_t tag) { in lfs_tag_dsize() argument
353 return sizeof(tag) + lfs_tag_size(tag + lfs_tag_isdelete(tag)); in lfs_tag_dsize()
358 lfs_tag_t tag; member
389 return lfs_tag_size(a->tag); in lfs_gstate_hasorphans()
393 return lfs_tag_size(a->tag); in lfs_gstate_getorphans()
397 return lfs_tag_type1(a->tag); in lfs_gstate_hasmove()
403 return lfs_tag_type1(a->tag) && lfs_pair_cmp(a->pair, pair) == 0; in lfs_gstate_hasmovehere()
407 a->tag = lfs_fromle32(a->tag); in lfs_gstate_fromle32()
414 a->tag = lfs_tole32(a->tag); in lfs_gstate_tole32()
620 lfs_tag_id(lfs->gdisk.tag) <= lfs_tag_id(gtag)) { in lfs_dir_getslice()
628 lfs_tag_t tag = ntag; in lfs_dir_getslice() local
636 ntag = (lfs_frombe32(ntag) ^ tag) & 0x7fffffff; in lfs_dir_getslice()
639 lfs_tag_type1(tag) == LFS_TYPE_SPLICE && in lfs_dir_getslice()
640 lfs_tag_id(tag) <= lfs_tag_id(gtag - gdiff)) { in lfs_dir_getslice()
641 if (tag == (LFS_MKTAG(LFS_TYPE_CREATE, 0, 0) | in lfs_dir_getslice()
648 gdiff += LFS_MKTAG(0, lfs_tag_splice(tag), 0); in lfs_dir_getslice()
651 if ((gmask & tag) == (gmask & (gtag - gdiff))) { in lfs_dir_getslice()
652 if (lfs_tag_isdelete(tag)) { in lfs_dir_getslice()
656 lfs_size_t diff = lfs_min(lfs_tag_size(tag), gsize); in lfs_dir_getslice()
659 dir->pair[0], off+sizeof(tag)+goff, gbuffer, diff); in lfs_dir_getslice()
666 return tag + gdiff; in lfs_dir_getslice()
743 lfs_tag_t tag, const void *buffer) { in lfs_dir_traverse_filter() argument
748 uint32_t mask = (tag & LFS_MKTAG(0x100, 0, 0)) in lfs_dir_traverse_filter()
753 if ((mask & tag) == (mask & *filtertag) || in lfs_dir_traverse_filter()
755 (LFS_MKTAG(0x7ff, 0x3ff, 0) & tag) == ( in lfs_dir_traverse_filter()
763 if (lfs_tag_type1(tag) == LFS_TYPE_SPLICE && in lfs_dir_traverse_filter()
764 lfs_tag_id(tag) <= lfs_tag_id(*filtertag)) { in lfs_dir_traverse_filter()
765 *filtertag += LFS_MKTAG(0, lfs_tag_splice(tag), 0); in lfs_dir_traverse_filter()
794 int (*cb)(void *data, lfs_tag_t tag, const void *buffer);
797 lfs_tag_t tag; member
807 int (*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) { in lfs_dir_traverse() argument
815 lfs_tag_t tag; in lfs_dir_traverse() local
823 NULL, &lfs->rcache, sizeof(tag), in lfs_dir_traverse()
824 dir->pair[0], off, &tag, sizeof(tag)); in lfs_dir_traverse()
829 tag = (lfs_frombe32(tag) ^ ptag) | 0x80000000; in lfs_dir_traverse()
833 ptag = tag; in lfs_dir_traverse()
835 tag = attrs[0].tag; in lfs_dir_traverse()
847 if ((mask & tmask & tag) != (mask & tmask & ttag)) { in lfs_dir_traverse()
868 .tag = tag, in lfs_dir_traverse()
885 data = &stack[sp-1].tag; in lfs_dir_traverse()
893 !(lfs_tag_id(tag) >= begin && lfs_tag_id(tag) < end)) { in lfs_dir_traverse()
898 if (lfs_tag_type3(tag) == LFS_FROM_NOOP) { in lfs_dir_traverse()
900 } else if (lfs_tag_type3(tag) == LFS_FROM_MOVE) { in lfs_dir_traverse()
935 .tag = LFS_MKTAG(LFS_FROM_NOOP, 0, 0), in lfs_dir_traverse()
939 uint16_t fromid = lfs_tag_size(tag); in lfs_dir_traverse()
940 uint16_t toid = lfs_tag_id(tag); in lfs_dir_traverse()
951 } else if (lfs_tag_type3(tag) == LFS_FROM_USERATTRS) { in lfs_dir_traverse()
952 for (unsigned i = 0; i < lfs_tag_size(tag); i++) { in lfs_dir_traverse()
955 lfs_tag_id(tag) + diff, a[i].size), a[i].buffer); in lfs_dir_traverse()
965 res = cb(data, tag + LFS_MKTAG(0, diff, 0), buffer); in lfs_dir_traverse()
991 tag = stack[sp-1].tag; in lfs_dir_traverse()
1005 int (*cb)(void *data, lfs_tag_t tag, const void *buffer), void *data) { in lfs_dir_fetchmatch() argument
1055 lfs_tag_t tag; in lfs_dir_fetchmatch() local
1059 dir->pair[0], off, &tag, sizeof(tag)); in lfs_dir_fetchmatch()
1069 crc = lfs_crc(crc, &tag, sizeof(tag)); in lfs_dir_fetchmatch()
1070 tag = lfs_frombe32(tag) ^ ptag; in lfs_dir_fetchmatch()
1073 if (!lfs_tag_isvalid(tag)) { in lfs_dir_fetchmatch()
1077 } else if (off + lfs_tag_dsize(tag) > lfs->cfg->block_size) { in lfs_dir_fetchmatch()
1082 ptag = tag; in lfs_dir_fetchmatch()
1084 if (lfs_tag_type1(tag) == LFS_TYPE_CRC) { in lfs_dir_fetchmatch()
1089 dir->pair[0], off+sizeof(tag), &dcrc, sizeof(dcrc)); in lfs_dir_fetchmatch()
1105 ptag ^= (lfs_tag_t)(lfs_tag_chunk(tag) & 1U) << 31; in lfs_dir_fetchmatch()
1115 dir->off = off + lfs_tag_dsize(tag); in lfs_dir_fetchmatch()
1128 for (lfs_off_t j = sizeof(tag); j < lfs_tag_dsize(tag); j++) { in lfs_dir_fetchmatch()
1145 if (lfs_tag_type1(tag) == LFS_TYPE_NAME) { in lfs_dir_fetchmatch()
1147 if (lfs_tag_id(tag) >= tempcount) { in lfs_dir_fetchmatch()
1148 tempcount = lfs_tag_id(tag) + 1; in lfs_dir_fetchmatch()
1150 } else if (lfs_tag_type1(tag) == LFS_TYPE_SPLICE) { in lfs_dir_fetchmatch()
1151 tempcount += lfs_tag_splice(tag); in lfs_dir_fetchmatch()
1153 if (tag == (LFS_MKTAG(LFS_TYPE_DELETE, 0, 0) | in lfs_dir_fetchmatch()
1157 lfs_tag_id(tag) <= lfs_tag_id(tempbesttag)) { in lfs_dir_fetchmatch()
1158 tempbesttag += LFS_MKTAG(0, lfs_tag_splice(tag), 0); in lfs_dir_fetchmatch()
1160 } else if (lfs_tag_type1(tag) == LFS_TYPE_TAIL) { in lfs_dir_fetchmatch()
1161 tempsplit = (lfs_tag_chunk(tag) & 1); in lfs_dir_fetchmatch()
1165 dir->pair[0], off+sizeof(tag), &temptail, 8); in lfs_dir_fetchmatch()
1176 if ((fmask & tag) == (fmask & ftag)) { in lfs_dir_fetchmatch()
1177 int res = cb(data, tag, &(struct lfs_diskoff){ in lfs_dir_fetchmatch()
1178 dir->pair[0], off+sizeof(tag)}); in lfs_dir_fetchmatch()
1189 tempbesttag = tag; in lfs_dir_fetchmatch()
1190 } else if ((LFS_MKTAG(0x7ff, 0x3ff, 0) & tag) == in lfs_dir_fetchmatch()
1196 lfs_tag_id(tag) <= lfs_tag_id(tempbesttag)) { in lfs_dir_fetchmatch()
1198 tempbesttag = tag | 0x80000000; in lfs_dir_fetchmatch()
1207 if (lfs_tag_id(lfs->gdisk.tag) == lfs_tag_id(besttag)) { in lfs_dir_fetchmatch()
1210 lfs_tag_id(lfs->gdisk.tag) < lfs_tag_id(besttag)) { in lfs_dir_fetchmatch()
1274 lfs_stag_t tag = lfs_dir_get(lfs, dir, LFS_MKTAG(0x780, 0x3ff, 0), in lfs_dir_getinfo() local
1276 if (tag < 0) { in lfs_dir_getinfo()
1277 return (int)tag; in lfs_dir_getinfo()
1280 info->type = lfs_tag_type3(tag); in lfs_dir_getinfo()
1283 tag = lfs_dir_get(lfs, dir, LFS_MKTAG(0x700, 0x3ff, 0), in lfs_dir_getinfo()
1285 if (tag < 0) { in lfs_dir_getinfo()
1286 return (int)tag; in lfs_dir_getinfo()
1290 if (lfs_tag_type3(tag) == LFS_TYPE_CTZSTRUCT) { in lfs_dir_getinfo()
1292 } else if (lfs_tag_type3(tag) == LFS_TYPE_INLINESTRUCT) { in lfs_dir_getinfo()
1293 info->size = lfs_tag_size(tag); in lfs_dir_getinfo()
1306 lfs_tag_t tag, const void *buffer) { in lfs_dir_find_match() argument
1312 lfs_size_t diff = lfs_min(name->size, lfs_tag_size(tag)); in lfs_dir_find_match()
1321 if (name->size != lfs_tag_size(tag)) { in lfs_dir_find_match()
1322 return (name->size < lfs_tag_size(tag)) ? LFS_CMP_LT : LFS_CMP_GT; in lfs_dir_find_match()
1338 lfs_stag_t tag = LFS_MKTAG(LFS_TYPE_DIR, 0x3ff, 0); in lfs_dir_find() local
1381 return tag; in lfs_dir_find()
1388 if (lfs_tag_type3(tag) != LFS_TYPE_DIR) { in lfs_dir_find()
1393 if (lfs_tag_id(tag) != 0x3ff) { in lfs_dir_find()
1395 LFS_MKTAG(LFS_TYPE_STRUCT, lfs_tag_id(tag), 8), dir->tail); in lfs_dir_find()
1404 tag = lfs_dir_fetchmatch(lfs, dir, dir->tail, in lfs_dir_find()
1411 if (tag < 0) { in lfs_dir_find()
1412 return tag; in lfs_dir_find()
1415 if (tag) { in lfs_dir_find()
1459 lfs_tag_t tag, const void *buffer) { in lfs_dir_commitattr() argument
1461 lfs_size_t dsize = lfs_tag_dsize(tag); in lfs_dir_commitattr()
1467 lfs_tag_t ntag = lfs_tobe32((tag & 0x7fffffff) ^ commit->ptag); in lfs_dir_commitattr()
1473 if (!(tag & 0x80000000)) { in lfs_dir_commitattr()
1475 err = lfs_dir_commitprog(lfs, commit, buffer, dsize-sizeof(tag)); in lfs_dir_commitattr()
1482 for (lfs_off_t i = 0; i < dsize-sizeof(tag); i++) { in lfs_dir_commitattr()
1486 NULL, &lfs->rcache, dsize-sizeof(tag)-i, in lfs_dir_commitattr()
1499 commit->ptag = tag & 0x7fffffff; in lfs_dir_commitattr()
1524 lfs_tag_t tag = 0xffffffff; in lfs_dir_commitcrc() local
1526 NULL, &lfs->rcache, sizeof(tag), in lfs_dir_commitcrc()
1527 commit->block, noff, &tag, sizeof(tag)); in lfs_dir_commitcrc()
1533 bool reset = ~lfs_frombe32(tag) >> 31; in lfs_dir_commitcrc()
1534 tag = LFS_MKTAG(LFS_TYPE_CRC + reset, 0x3ff, noff - off); in lfs_dir_commitcrc()
1538 footer[0] = lfs_tobe32(tag ^ commit->ptag); in lfs_dir_commitcrc()
1554 commit->off += sizeof(tag)+lfs_tag_size(tag); in lfs_dir_commitcrc()
1555 commit->ptag = tag ^ ((lfs_tag_t)reset << 31); in lfs_dir_commitcrc()
1707 static int lfs_dir_commit_size(void *p, lfs_tag_t tag, const void *buffer) { in lfs_dir_commit_size() argument
1711 *size += lfs_tag_dsize(tag); in lfs_dir_commit_size()
1724 static int lfs_dir_commit_commit(void *p, lfs_tag_t tag, const void *buffer) { in lfs_dir_commit_commit() argument
1726 return lfs_dir_commitattr(commit->lfs, commit->commit, tag, buffer); in lfs_dir_commit_commit()
1844 delta.tag &= ~LFS_MKTAG(0, 0, 0x3ff); in lfs_dir_compact()
2022 if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_CREATE) { in lfs_dir_relocatingcommit()
2024 } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE) { in lfs_dir_relocatingcommit()
2028 } else if (lfs_tag_type1(attrs[i].tag) == LFS_TYPE_TAIL) { in lfs_dir_relocatingcommit()
2031 dir->split = (lfs_tag_chunk(attrs[i].tag) & 1); in lfs_dir_relocatingcommit()
2083 delta.tag &= ~LFS_MKTAG(0, 0, 0x3ff); in lfs_dir_relocatingcommit()
2148 if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE && in lfs_dir_relocatingcommit()
2149 d->id == lfs_tag_id(attrs[i].tag)) { in lfs_dir_relocatingcommit()
2152 } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_DELETE && in lfs_dir_relocatingcommit()
2153 d->id > lfs_tag_id(attrs[i].tag)) { in lfs_dir_relocatingcommit()
2158 } else if (lfs_tag_type3(attrs[i].tag) == LFS_TYPE_CREATE && in lfs_dir_relocatingcommit()
2159 d->id >= lfs_tag_id(attrs[i].tag)) { in lfs_dir_relocatingcommit()
2276 lfs_stag_t tag = lfs_fs_parent(lfs, lpair, &pdir); in lfs_dir_orphaningcommit() local
2277 if (tag < 0 && tag != LFS_ERR_NOENT) { in lfs_dir_orphaningcommit()
2278 return tag; in lfs_dir_orphaningcommit()
2281 bool hasparent = (tag != LFS_ERR_NOENT); in lfs_dir_orphaningcommit()
2282 if (tag != LFS_ERR_NOENT) { in lfs_dir_orphaningcommit()
2294 moveid = lfs_tag_id(lfs->gstate.tag); in lfs_dir_orphaningcommit()
2299 if (moveid < lfs_tag_id(tag)) { in lfs_dir_orphaningcommit()
2300 tag -= LFS_MKTAG(0, 1, 0); in lfs_dir_orphaningcommit()
2309 {tag, ldir.pair}), in lfs_dir_orphaningcommit()
2346 moveid = lfs_tag_id(lfs->gstate.tag); in lfs_dir_orphaningcommit()
2498 lfs_stag_t tag = lfs_dir_find(lfs, &dir->m, &path, NULL); in lfs_dir_rawopen() local
2499 if (tag < 0) { in lfs_dir_rawopen()
2500 return tag; in lfs_dir_rawopen()
2503 if (lfs_tag_type3(tag) != LFS_TYPE_DIR) { in lfs_dir_rawopen()
2508 if (lfs_tag_id(tag) == 0x3ff) { in lfs_dir_rawopen()
2515 LFS_MKTAG(LFS_TYPE_STRUCT, lfs_tag_id(tag), 8), pair); in lfs_dir_rawopen()
2865 lfs_stag_t tag = lfs_dir_find(lfs, &file->m, &path, &file->id); local
2866 if (tag < 0 && !(tag == LFS_ERR_NOENT && file->id != 0x3ff)) {
2867 err = tag;
2876 if (tag == LFS_ERR_NOENT) {
2880 if (tag == LFS_ERR_NOENT) {
2906 tag = LFS_MKTAG(LFS_TYPE_INLINESTRUCT, 0, 0);
2911 } else if (lfs_tag_type3(tag) != LFS_TYPE_REG) {
2917 tag = LFS_MKTAG(LFS_TYPE_INLINESTRUCT, file->id, 0);
2922 tag = lfs_dir_get(lfs, &file->m, LFS_MKTAG(0x700, 0x3ff, 0),
2924 if (tag < 0) {
2925 err = tag;
2973 if (lfs_tag_type3(tag) == LFS_TYPE_INLINESTRUCT) {
2976 file->ctz.size = lfs_tag_size(tag);
3613 lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL); local
3614 if (tag < 0) {
3615 return (int)tag;
3618 return lfs_dir_getinfo(lfs, &cwd, lfs_tag_id(tag), info);
3630 lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL); local
3631 if (tag < 0 || lfs_tag_id(tag) == 0x3ff) {
3632 return (tag < 0) ? (int)tag : LFS_ERR_INVAL;
3637 if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
3641 LFS_MKTAG(LFS_TYPE_STRUCT, lfs_tag_id(tag), 8), pair);
3671 {LFS_MKTAG(LFS_TYPE_DELETE, lfs_tag_id(tag), 0), NULL}));
3678 if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
3839 lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL); local
3840 if (tag < 0) {
3841 return tag;
3844 uint16_t id = lfs_tag_id(tag);
3854 tag = lfs_dir_get(lfs, &cwd, LFS_MKTAG(0x7ff, 0x3ff, 0),
3858 if (tag < 0) {
3859 if (tag == LFS_ERR_NOENT) {
3863 return tag;
3866 return lfs_tag_size(tag);
3873 lfs_stag_t tag = lfs_dir_find(lfs, &cwd, &path, NULL); local
3874 if (tag < 0) {
3875 return tag;
3878 uint16_t id = lfs_tag_id(tag);
4122 lfs_stag_t tag = lfs_dir_fetchmatch(lfs, &dir, dir.tail, local
4128 if (tag < 0) {
4129 err = tag;
4134 if (tag && !lfs_tag_isdelete(tag)) {
4141 tag = lfs_dir_get(lfs, &dir, LFS_MKTAG(0x7ff, 0x3ff, 0),
4144 if (tag < 0) {
4145 err = tag;
4226 lfs->gstate.tag,
4230 lfs->gstate.tag += !lfs_tag_isvalid(lfs->gstate.tag);
4293 lfs_stag_t tag = lfs_dir_get(lfs, &dir, LFS_MKTAG(0x700, 0x3ff, 0), local
4295 if (tag < 0) {
4296 if (tag == LFS_ERR_NOENT) {
4299 return tag;
4303 if (lfs_tag_type3(tag) == LFS_TYPE_CTZSTRUCT) {
4310 lfs_tag_type3(tag) == LFS_TYPE_DIRSTRUCT) {
4386 lfs_tag_t tag, const void *buffer) { argument
4390 (void)tag;
4419 lfs_stag_t tag = lfs_dir_fetchmatch(lfs, parent, parent->tail, local
4425 if (tag && tag != LFS_ERR_NOENT) {
4426 return tag;
4436 LFS_ASSERT(lfs_tag_size(lfs->gstate.tag) > 0 || orphans >= 0);
4437 lfs->gstate.tag += orphans;
4438 lfs->gstate.tag = ((lfs->gstate.tag & ~LFS_MKTAG(0x800, 0, 0)) |
4448 lfs->gstate.tag = ((lfs->gstate.tag & ~LFS_MKTAG(0x7ff, 0x3ff, 0)) |
4465 lfs_tag_id(lfs->gdisk.tag));
4475 uint16_t moveid = lfs_tag_id(lfs->gdisk.tag);
4511 lfs_stag_t tag = lfs_fs_parent(lfs, pdir.tail, &parent); local
4512 if (tag < 0 && tag != LFS_ERR_NOENT) {
4513 return tag;
4519 if (tag == LFS_ERR_NOENT && powerloss) {
4551 if (tag != LFS_ERR_NOENT) {
4554 LFS_MKTAG(0x7ff, 0x3ff, 0), tag, pair);
4572 moveid = lfs_tag_id(lfs->gstate.tag);