Skip to content

Commit 6d1c1ec

Browse files
committed
WIP WIP RW Allowed RDRW mounts with unknown file types
1 parent 2a9422d commit 6d1c1ec

4 files changed

Lines changed: 1246 additions & 47 deletions

File tree

lfs.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,12 @@ static inline lfsr_tag_t lfsr_rattr_dtag(lfsr_rattr_t rattr) {
23312331
// lazily tag encoding can be bypassed with explicit data, this is
23322332
// necessary to allow copies during compaction, relocation, etc
23332333
if (rattr.count >= 0) {
2334-
return rattr.tag;
2334+
// map all name tags to LFSR_TAG_NAME for simplicity
2335+
if (lfsr_tag_suptype(rattr.tag) == LFSR_TAG_NAME) {
2336+
return LFSR_TAG_NAME;
2337+
} else {
2338+
return rattr.tag;
2339+
}
23352340
} else {
23362341
return LFSR_TAG_DATA;
23372342
}
@@ -3452,7 +3457,7 @@ static lfsr_data_t lfsr_data_frombtree(const lfsr_btree_t *btree,
34523457
static lfsr_data_t lfsr_data_frommptr(const lfs_block_t mptr[static 2],
34533458
uint8_t buffer[static LFSR_MPTR_DSIZE]);
34543459

3455-
// our core rbyd append algorithm
3460+
// encode rattrs
34563461
static int lfsr_rbyd_appendrattr_(lfs_t *lfs, lfsr_rbyd_t *rbyd,
34573462
lfsr_rattr_t rattr) {
34583463
// tag must not be internal at this point
@@ -3507,7 +3512,6 @@ static int lfsr_rbyd_appendrattr_(lfs_t *lfs, lfsr_rbyd_t *rbyd,
35073512
// leb128?
35083513
case LFSR_TAG_NAMELIMIT:;
35093514
case LFSR_TAG_FILELIMIT:;
3510-
case LFSR_TAG_BOOKMARK:;
35113515
case LFSR_TAG_DID:;
35123516
// leb128s should not exceed 31-bits
35133517
LFS_ASSERT(rattr.u.leb128 <= 0x7fffffff);
@@ -3530,9 +3534,6 @@ static int lfsr_rbyd_appendrattr_(lfs_t *lfs, lfsr_rbyd_t *rbyd,
35303534

35313535
// name?
35323536
case LFSR_TAG_NAME:;
3533-
case LFSR_TAG_REG:;
3534-
case LFSR_TAG_DIR:;
3535-
case LFSR_TAG_STICKYNOTE:;
35363537
const lfsr_name_t *name = rattr.u.etc;
35373538
ctx.u.name.datas[0] = lfsr_data_fromleb128(name->did, ctx.u.name.buf);
35383539
ctx.u.name.datas[1] = LFSR_DATA_BUF(name->name, name->name_len);
@@ -3772,7 +3773,7 @@ static void lfsr_rbyd_p_recolor(
37723773
}
37733774
}
37743775

3775-
// core rbyd algorithm
3776+
// our core rbyd append algorithm
37763777
static int lfsr_rbyd_appendrattr(lfs_t *lfs, lfsr_rbyd_t *rbyd,
37773778
lfsr_srid_t rid, lfsr_rattr_t rattr) {
37783779
// must fetch before mutating!
@@ -10300,8 +10301,8 @@ int lfsr_mkdir(lfs_t *lfs, const char *path) {
1030010301
// commit our bookmark and a grm to self-remove in case of powerloss
1030110302
lfs_alloc_ckpoint(lfs);
1030210303
err = lfsr_mdir_commit(lfs, &mdir, LFSR_RATTRS(
10303-
LFSR_RATTR_LEB128(
10304-
LFSR_TAG_BOOKMARK, +1, did_)));
10304+
LFSR_RATTR_NAME(
10305+
LFSR_TAG_BOOKMARK, +1, did_, NULL, 0)));
1030510306
if (err) {
1030610307
return err;
1030710308
}
@@ -10635,6 +10636,16 @@ int lfsr_rename(lfs_t *lfs, const char *old_path, const char *new_path) {
1063510636
}
1063610637
}
1063710638

10639+
if (old_tag == LFSR_TAG_UNKNOWN) {
10640+
// lookup the actual tag
10641+
err = lfsr_rbyd_lookup(lfs, &old_mdir.rbyd,
10642+
lfsr_mrid(lfs, old_mdir.mid), LFSR_TAG_MASK8 | LFSR_TAG_NAME,
10643+
&old_tag, NULL);
10644+
if (err) {
10645+
return err;
10646+
}
10647+
}
10648+
1063810649
// mark old entry for removal with a grm
1063910650
lfsr_grm_push(lfs, old_mdir.mid);
1064010651

@@ -13602,17 +13613,13 @@ static int lfs_deinit(lfs_t *lfs) {
1360213613

1360313614
#define LFSR_WCOMPAT_NONSTANDARD 0x00000001 // Non-standard filesystem format
1360413615
#define LFSR_WCOMPAT_RDONLY 0x00000002 // Writing is disallowed
13605-
#define LFSR_WCOMPAT_REG 0x00000010 // Regular files in use
13606-
#define LFSR_WCOMPAT_DIR 0x00000020 // Directory files in use
13607-
#define LFSR_WCOMPAT_STICKYNOTE 0x00000040 // Stickynote files in use
13616+
#define LFSR_WCOMPAT_DIR 0x00000010 // Directory files in use
1360813617
#define LFSR_WCOMPAT_GCKSUM 0x00001000 // Global-checksum in use
1360913618
// internal
1361013619
#define LFSR_wcompat_OVERFLOW 0x80000000 // Can't represent all flags
1361113620

1361213621
#define LFSR_WCOMPAT_COMPAT \
13613-
(LFSR_WCOMPAT_REG \
13614-
| LFSR_WCOMPAT_DIR \
13615-
| LFSR_WCOMPAT_STICKYNOTE \
13622+
(LFSR_WCOMPAT_DIR \
1361613623
| LFSR_WCOMPAT_GCKSUM)
1361713624

1361813625
#define LFSR_OCOMPAT_NONSTANDARD 0x00000001 // Non-standard filesystem format
@@ -14294,9 +14301,9 @@ static int lfsr_formatinited(lfs_t *lfs) {
1429414301
LFSR_RATTR_LEB128(
1429514302
LFSR_TAG_FILELIMIT, 0,
1429614303
lfs->file_limit),
14297-
LFSR_RATTR_LEB128(
14304+
LFSR_RATTR_NAME(
1429814305
LFSR_TAG_BOOKMARK, +1,
14299-
0)));
14306+
0, NULL, 0)));
1430014307
if (err) {
1430114308
return err;
1430214309
}

scripts/dbgflags.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,8 @@
183183
0x00000001, "Non-standard filesystem format" ),
184184
('WCOMPAT', 'RDONLY',
185185
0x00000002, "Writing is disallowed" ),
186-
('WCOMPAT', 'REG',
187-
0x00000010, "Regular file types in use" ),
188186
('WCOMPAT', 'DIR',
189-
0x00000020, "Directory file types in use" ),
190-
('WCOMPAT', 'STICKYNOTE',
191-
0x00000040, "Stickynote file types in use" ),
187+
0x00000010, "Directory file types in use" ),
192188
('WCOMPAT', 'GCKSUM',
193189
0x00001000, "Global-checksum in use" ),
194190
('wcompat', 'OVERFLOW',

0 commit comments

Comments
 (0)