Renamed scratch files -> orphan files

I was originally avoiding naming these orphans, as they're _technically_
not orphans. They do exist in the mtree. But the name orphan just
describes this types purpose too well.

This does lead to some confusing terms, such as the fact that orphan
files can be non-orphaned if there are any in-device references. But I
think this makes sense?

- LFSR_TAG_SCRATCH -> LFSR_TAG_ORPHAN
- LFSR_F_UNCREAT -> LFSR_F_ORPHAN
- test_fscratch.toml -> test_forphan.toml
This commit is contained in:
Christopher Haster
2024-01-16 22:13:58 -06:00
parent f6742eefb3
commit 15593ccc49
8 changed files with 97 additions and 100 deletions
+45 -48
View File
@@ -617,7 +617,7 @@ enum lfsr_tag {
LFSR_TAG_NAME = 0x0200, LFSR_TAG_NAME = 0x0200,
LFSR_TAG_REG = 0x0201, LFSR_TAG_REG = 0x0201,
LFSR_TAG_DIR = 0x0202, LFSR_TAG_DIR = 0x0202,
LFSR_TAG_SCRATCH = 0x0203, LFSR_TAG_ORPHAN = 0x0203,
LFSR_TAG_BOOKMARK = 0x0204, LFSR_TAG_BOOKMARK = 0x0204,
// struct tags // struct tags
@@ -5089,9 +5089,9 @@ static int lfsr_mdir_lookupnext(lfs_t *lfs, const lfsr_mdir_t *mdir,
} }
if (tag_) { if (tag_) {
// intercept pending grms here and pretend they're scratch files // intercept pending grms here and pretend they're orphaned files
// //
// fortunately pending gmrs/scratch files have roughly the same // fortunately pending grms/orphaned files have roughly the same
// semantics, and it's easier to manage the implied mid gap in // semantics, and it's easier to manage the implied mid gap in
// higher-levels // higher-levels
// TODO // TODO
@@ -6664,7 +6664,7 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
// mark as zombied and move onto the next rid, upper // mark as zombied and move onto the next rid, upper
// layers should handle the repercussions // layers should handle the repercussions
opened->flags |= LFS_F_ZOMBIE | LFS_F_UNSYNC | LFS_O_DESYNC; opened->flags |= LFS_F_ZOMBIE | LFS_F_UNSYNC | LFS_O_DESYNC;
opened->flags &= ~LFS_F_UNCREAT; opened->flags &= ~LFS_F_ORPHAN;
opened->mdir.mid = attrs[i].rid; opened->mdir.mid = attrs[i].rid;
} else { } else {
opened->mdir.mid += attrs[i].delta; opened->mdir.mid += attrs[i].delta;
@@ -7881,20 +7881,20 @@ static int lfsr_mountinited(lfs_t *lfs) {
return err; return err;
} }
// check for any scratch files // check for any orphaned files
for (lfs_size_t rid = 0; for (lfs_size_t rid = 0;
rid < (lfs_size_t)tinfo.u.mdir.rbyd.weight; rid < (lfs_size_t)tinfo.u.mdir.rbyd.weight;
rid++) { rid++) {
err = lfsr_mdir_lookup(lfs, &tinfo.u.mdir, err = lfsr_mdir_lookup(lfs, &tinfo.u.mdir,
rid, LFSR_TAG_SCRATCH, rid, LFSR_TAG_ORPHAN,
NULL); NULL);
if (err && err != LFS_ERR_NOENT) { if (err && err != LFS_ERR_NOENT) {
return err; return err;
} }
// found a scratch file? these must be orphaned // found an orphaned file?
if (err != LFS_ERR_NOENT) { if (err != LFS_ERR_NOENT) {
LFS_DEBUG("Found orphaned scratch file " LFS_DEBUG("Found orphaned file "
"%"PRId32".%"PRId32, "%"PRId32".%"PRId32,
lfsr_mid_bid(lfs, tinfo.u.mdir.mid) >> lfs->mbits, lfsr_mid_bid(lfs, tinfo.u.mdir.mid) >> lfs->mbits,
rid); rid);
@@ -8244,7 +8244,7 @@ static int lfsr_fs_fixgrm(lfs_t *lfs) {
} }
static int lfsr_fs_fixorphans(lfs_t *lfs) { static int lfsr_fs_fixorphans(lfs_t *lfs) {
// traverse the filesystem and remove any orphaned scratch files // traverse the filesystem and remove any orphaned files
// //
// note this never takes longer than lfsr_mount // note this never takes longer than lfsr_mount
// //
@@ -8256,15 +8256,15 @@ static int lfsr_fs_fixorphans(lfs_t *lfs) {
} }
while (true) { while (true) {
// are we a scratch file? // are we an orphaned file?
err = lfsr_mdir_lookup(lfs, &mdir, mdir.mid, LFSR_TAG_SCRATCH, err = lfsr_mdir_lookup(lfs, &mdir, mdir.mid, LFSR_TAG_ORPHAN,
NULL); NULL);
if (err && err != LFS_ERR_NOENT) { if (err && err != LFS_ERR_NOENT) {
return err; return err;
} }
if (err != LFS_ERR_NOENT) { if (err != LFS_ERR_NOENT) {
// remove scratch file // remove orphaned file
err = lfsr_mdir_commit(lfs, &mdir, LFSR_ATTRS( err = lfsr_mdir_commit(lfs, &mdir, LFSR_ATTRS(
LFSR_ATTR(mdir.mid, RM, -1, NULL()))); LFSR_ATTR(mdir.mid, RM, -1, NULL())));
if (err) { if (err) {
@@ -8326,9 +8326,9 @@ static int lfsr_fs_preparemutation(lfs_t *lfs) {
lfs_alloc_ckpoint(lfs); lfs_alloc_ckpoint(lfs);
} }
// fix orphaned scratch files // fix orphaned files
// //
// this must happen after fixgrm, since removing scratch files risks // this must happen after fixgrm, since removing orphaned files risks
// outdating the grm // outdating the grm
// //
if (lfs->hasorphans) { if (lfs->hasorphans) {
@@ -8377,9 +8377,9 @@ int lfsr_mkdir(lfs_t *lfs, const char *path) {
return err; return err;
} }
// already exists? note scratch files don't really exist // already exists? note orphans don't really exist
bool exists = (err != LFS_ERR_NOENT); bool exists = (err != LFS_ERR_NOENT);
if (exists && tag != LFSR_TAG_SCRATCH) { if (exists && tag != LFSR_TAG_ORPHAN) {
return LFS_ERR_EXIST; return LFS_ERR_EXIST;
} }
@@ -8514,7 +8514,7 @@ int lfsr_remove(lfs_t *lfs, const char *path) {
} }
// found a zombie? // found a zombie?
if (tag == LFSR_TAG_SCRATCH) { if (tag == LFSR_TAG_ORPHAN) {
// don't worry, zombies aren't real and cannot hurt you // don't worry, zombies aren't real and cannot hurt you
return LFS_ERR_NOENT; return LFS_ERR_NOENT;
} }
@@ -8595,12 +8595,12 @@ int lfsr_remove(lfs_t *lfs, const char *path) {
// remove the metadata entry // remove the metadata entry
err = lfsr_mdir_commit(lfs, &mdir, LFSR_ATTRS( err = lfsr_mdir_commit(lfs, &mdir, LFSR_ATTRS(
// create a scratch file if zombied // create an orphan if zombied
// //
// we use a create+delete here to also clear any attrs // we use a create+delete here to also clear any attrs
// and trim the entry size // and trim the entry size
(zombie) (zombie)
? LFSR_ATTR(mdir.mid+1, SCRATCH, +1, CAT( ? LFSR_ATTR(mdir.mid+1, ORPHAN, +1, CAT(
LFSR_DATA_LEB128(did), LFSR_DATA_LEB128(did),
LFSR_DATA_BUF(name, name_size))) LFSR_DATA_BUF(name, name_size)))
: LFSR_ATTR_NOOP(), : LFSR_ATTR_NOOP(),
@@ -8618,7 +8618,7 @@ int lfsr_remove(lfs_t *lfs, const char *path) {
opened = opened->next) { opened = opened->next) {
if (opened->type == LFS_TYPE_REG if (opened->type == LFS_TYPE_REG
&& opened->mdir.mid == mdir.mid) { && opened->mdir.mid == mdir.mid) {
opened->flags |= LFS_F_UNCREAT; opened->flags |= LFS_F_ORPHAN;
} }
} }
@@ -8645,7 +8645,7 @@ int lfsr_rename(lfs_t *lfs, const char *old_path, const char *new_path) {
} }
// found a zombie? // found a zombie?
if (old_tag == LFSR_TAG_SCRATCH) { if (old_tag == LFSR_TAG_ORPHAN) {
// don't worry, zombies aren't real and cannot hurt you // don't worry, zombies aren't real and cannot hurt you
return LFS_ERR_NOENT; return LFS_ERR_NOENT;
} }
@@ -8690,8 +8690,8 @@ int lfsr_rename(lfs_t *lfs, const char *old_path, const char *new_path) {
} else { } else {
// renaming different types is an error // renaming different types is an error
// //
// unless we found a scratch file, these don't really exist // unless we found a orphan, these don't really exist
if (old_tag != new_tag && new_tag != LFSR_TAG_SCRATCH) { if (old_tag != new_tag && new_tag != LFSR_TAG_ORPHAN) {
return (new_tag == LFSR_TAG_DIR) return (new_tag == LFSR_TAG_DIR)
? LFS_ERR_ISDIR ? LFS_ERR_ISDIR
: LFS_ERR_NOTDIR; : LFS_ERR_NOTDIR;
@@ -8851,8 +8851,8 @@ int lfsr_stat(lfs_t *lfs, const char *path, struct lfs_info *info) {
return err; return err;
} }
// pretend scratch files don't exist // pretend orphans don't exist
if (tag == LFSR_TAG_SCRATCH) { if (tag == LFSR_TAG_ORPHAN) {
return LFS_ERR_NOENT; return LFS_ERR_NOENT;
} }
@@ -8882,7 +8882,7 @@ int lfsr_dir_open(lfs_t *lfs, lfsr_dir_t *dir, const char *path) {
// are we a directory? // are we a directory?
if (tag != LFSR_TAG_DIR) { if (tag != LFSR_TAG_DIR) {
if (tag == LFSR_TAG_SCRATCH) { if (tag == LFSR_TAG_ORPHAN) {
return LFS_ERR_NOENT; return LFS_ERR_NOENT;
} else { } else {
return LFS_ERR_NOTDIR; return LFS_ERR_NOTDIR;
@@ -8975,8 +8975,8 @@ int lfsr_dir_read(lfs_t *lfs, lfsr_dir_t *dir, struct lfs_info *info) {
return LFS_ERR_NOENT; return LFS_ERR_NOENT;
} }
// skip scratch files, we pretend these don't exist // skip orphans, we pretend these don't exist
if (tag != LFSR_TAG_SCRATCH) { if (tag != LFSR_TAG_ORPHAN) {
// fill out our info struct // fill out our info struct
err = lfsr_stat_(lfs, &dir->mdir, tag, data, err = lfsr_stat_(lfs, &dir->mdir, tag, data,
info); info);
@@ -8992,7 +8992,7 @@ int lfsr_dir_read(lfs_t *lfs, lfsr_dir_t *dir, struct lfs_info *info) {
} }
dir->pos += 1; dir->pos += 1;
if (tag != LFSR_TAG_SCRATCH) { if (tag != LFSR_TAG_ORPHAN) {
return 0; return 0;
} }
} }
@@ -9161,8 +9161,8 @@ static inline bool lfsr_f_isunsync(uint32_t flags) {
return flags & LFS_F_UNSYNC; return flags & LFS_F_UNSYNC;
} }
static inline bool lfsr_f_isuncreat(uint32_t flags) { static inline bool lfsr_f_isorphan(uint32_t flags) {
return flags & LFS_F_UNCREAT; return flags & LFS_F_ORPHAN;
} }
static inline bool lfsr_f_iszombie(uint32_t flags) { static inline bool lfsr_f_iszombie(uint32_t flags) {
@@ -9194,7 +9194,7 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file,
// these flags are internal and shouldn't be provided by the user // these flags are internal and shouldn't be provided by the user
LFS_ASSERT(!lfsr_f_isunflush(flags)); LFS_ASSERT(!lfsr_f_isunflush(flags));
LFS_ASSERT(!lfsr_f_isunsync(flags)); LFS_ASSERT(!lfsr_f_isunsync(flags));
LFS_ASSERT(!lfsr_f_isuncreat(flags)); LFS_ASSERT(!lfsr_f_isorphan(flags));
if (!lfsr_o_isrdonly(flags)) { if (!lfsr_o_isrdonly(flags)) {
// prepare our filesystem for writing // prepare our filesystem for writing
@@ -9225,7 +9225,7 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file,
} }
// creating a new entry? // creating a new entry?
if (err == LFS_ERR_NOENT || tag == LFSR_TAG_SCRATCH) { if (err == LFS_ERR_NOENT || tag == LFSR_TAG_ORPHAN) {
if (!lfsr_o_iscreat(flags)) { if (!lfsr_o_iscreat(flags)) {
return LFS_ERR_NOENT; return LFS_ERR_NOENT;
} }
@@ -9236,15 +9236,12 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file,
return LFS_ERR_NAMETOOLONG; return LFS_ERR_NAMETOOLONG;
} }
// create a scratch entry if we don't have one, this reserves the // create an orphan entry if we don't have one, this reserves the
// mid until first sync // mid until first sync
//
// note because of the preparemutation call above, there can be
// no orphaned scratch files at this point
if (err == LFS_ERR_NOENT) { if (err == LFS_ERR_NOENT) {
err = lfsr_mdir_commit(lfs, &file->mdir, LFSR_ATTRS( err = lfsr_mdir_commit(lfs, &file->mdir, LFSR_ATTRS(
LFSR_ATTR(file->mdir.mid, LFSR_ATTR(file->mdir.mid,
SCRATCH, +1, CAT( ORPHAN, +1, CAT(
LFSR_DATA_LEB128(did), LFSR_DATA_LEB128(did),
LFSR_DATA_BUF(name, name_size))))); LFSR_DATA_BUF(name, name_size)))));
if (err) { if (err) {
@@ -9254,7 +9251,7 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file,
// mark as unsync and uncreat, we need to convert to reg file // mark as unsync and uncreat, we need to convert to reg file
// first sync // first sync
file->flags |= LFS_F_UNSYNC | LFS_F_UNCREAT; file->flags |= LFS_F_UNSYNC | LFS_F_ORPHAN;
} else { } else {
if (lfsr_o_isexcl(flags)) { if (lfsr_o_isexcl(flags)) {
@@ -9385,8 +9382,8 @@ int lfsr_file_close(lfs_t *lfs, lfsr_file_t *file) {
} }
// never synced? // never synced?
if (lfsr_f_isuncreat(file->flags)) { if (lfsr_f_isorphan(file->flags)) {
// are we orphaning a scratch file? // are we orphaning a file?
// //
// make sure we check _after_ removing ourselves // make sure we check _after_ removing ourselves
bool orphaned = true; bool orphaned = true;
@@ -11000,7 +10997,7 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
&& file->buffer_size <= lfs->cfg->inline_size && file->buffer_size <= lfs->cfg->inline_size
&& file->buffer_size <= lfs->cfg->fragment_size)); && file->buffer_size <= lfs->cfg->fragment_size));
// uncreat files must be unsync // uncreat files must be unsync
LFS_ASSERT(!lfsr_f_isuncreat(file->flags) LFS_ASSERT(!lfsr_f_isorphan(file->flags)
|| lfsr_f_isunsync(file->flags)); || lfsr_f_isunsync(file->flags));
// don't write to disk if our disk is already in-sync // don't write to disk if our disk is already in-sync
@@ -11029,14 +11026,14 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
uint8_t buf[LFSR_BTREE_DSIZE]; uint8_t buf[LFSR_BTREE_DSIZE];
lfs_size_t buf_size = 0; lfs_size_t buf_size = 0;
// not created yet? need to convert scratch file to normal file // not created yet? need to convert orphan to normal file
if (lfsr_f_isuncreat(file->flags)) { if (lfsr_f_isorphan(file->flags)) {
lfsr_data_t data; lfsr_data_t data;
err = lfsr_mdir_lookup(lfs, &file->mdir, err = lfsr_mdir_lookup(lfs, &file->mdir,
file->mdir.mid, LFSR_TAG_SCRATCH, file->mdir.mid, LFSR_TAG_ORPHAN,
&data); &data);
if (err) { if (err) {
// we must have a scratch file at this point // we must have an orphan at this point
LFS_ASSERT(err != LFS_ERR_NOENT); LFS_ASSERT(err != LFS_ERR_NOENT);
goto failed; goto failed;
} }
@@ -11092,7 +11089,7 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
// don't double update // don't double update
&& file_ != file) { && file_ != file) {
// notify all files of creation // notify all files of creation
file_->flags &= ~LFS_F_UNCREAT; file_->flags &= ~LFS_F_ORPHAN;
// mark desynced files an unsynced // mark desynced files an unsynced
if (lfsr_o_isdesync(file_->flags)) { if (lfsr_o_isdesync(file_->flags)) {
@@ -11116,7 +11113,7 @@ int lfsr_file_sync(lfs_t *lfs, lfsr_file_t *file) {
} }
// mark as synced // mark as synced
file->flags &= ~LFS_F_UNSYNC & ~LFS_F_UNCREAT & ~LFS_O_DESYNC; file->flags &= ~LFS_F_UNSYNC & ~LFS_F_ORPHAN & ~LFS_O_DESYNC;
return 0; return 0;
failed:; failed:;
+1 -1
View File
@@ -139,7 +139,7 @@ enum lfs_open_flags {
// internally used flags // internally used flags
LFS_F_UNFLUSH = 0x1000, // File's data does not match storage LFS_F_UNFLUSH = 0x1000, // File's data does not match storage
LFS_F_UNSYNC = 0x2000, // File's metadata does not match storage LFS_F_UNSYNC = 0x2000, // File's metadata does not match storage
LFS_F_UNCREAT = 0x4000, // File does not exist yet LFS_F_ORPHAN = 0x4000, // File does not exist yet
LFS_F_ZOMBIE = 0x8000, // File has been removed LFS_F_ZOMBIE = 0x8000, // File has been removed
}; };
+1 -1
View File
@@ -26,7 +26,7 @@ TAG_GRMDELTA = 0x0100
TAG_NAME = 0x0200 TAG_NAME = 0x0200
TAG_REG = 0x0201 TAG_REG = 0x0201
TAG_DIR = 0x0202 TAG_DIR = 0x0202
TAG_SCRATCH = 0x0203 TAG_ORPHAN = 0x0203
TAG_BOOKMARK = 0x0204 TAG_BOOKMARK = 0x0204
TAG_STRUCT = 0x0300 TAG_STRUCT = 0x0300
TAG_DATA = 0x0300 TAG_DATA = 0x0300
+2 -2
View File
@@ -24,7 +24,7 @@ TAG_GRMDELTA = 0x0100
TAG_NAME = 0x0200 TAG_NAME = 0x0200
TAG_REG = 0x0201 TAG_REG = 0x0201
TAG_DIR = 0x0202 TAG_DIR = 0x0202
TAG_SCRATCH = 0x0203 TAG_ORPHAN = 0x0203
TAG_BOOKMARK = 0x0204 TAG_BOOKMARK = 0x0204
TAG_STRUCT = 0x0300 TAG_STRUCT = 0x0300
TAG_DATA = 0x0300 TAG_DATA = 0x0300
@@ -188,7 +188,7 @@ def tagrepr(tag, w, size, off=None):
'name' if (tag & 0xfff) == TAG_NAME 'name' if (tag & 0xfff) == TAG_NAME
else 'reg' if (tag & 0xfff) == TAG_REG else 'reg' if (tag & 0xfff) == TAG_REG
else 'dir' if (tag & 0xfff) == TAG_DIR else 'dir' if (tag & 0xfff) == TAG_DIR
else 'scratch' if (tag & 0xfff) == TAG_SCRATCH else 'orphan' if (tag & 0xfff) == TAG_ORPHAN
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
else 'name 0x%02x' % (tag & 0xff), else 'name 0x%02x' % (tag & 0xff),
' w%d' % w if w else '', ' w%d' % w if w else '',
+9 -9
View File
@@ -25,7 +25,7 @@ TAG_GRMDELTA = 0x0100
TAG_NAME = 0x0200 TAG_NAME = 0x0200
TAG_REG = 0x0201 TAG_REG = 0x0201
TAG_DIR = 0x0202 TAG_DIR = 0x0202
TAG_SCRATCH = 0x0203 TAG_ORPHAN = 0x0203
TAG_BOOKMARK = 0x0204 TAG_BOOKMARK = 0x0204
TAG_STRUCT = 0x0300 TAG_STRUCT = 0x0300
TAG_DATA = 0x0300 TAG_DATA = 0x0300
@@ -219,7 +219,7 @@ def tagrepr(tag, w, size, off=None):
'name' if (tag & 0xfff) == TAG_NAME 'name' if (tag & 0xfff) == TAG_NAME
else 'reg' if (tag & 0xfff) == TAG_REG else 'reg' if (tag & 0xfff) == TAG_REG
else 'dir' if (tag & 0xfff) == TAG_DIR else 'dir' if (tag & 0xfff) == TAG_DIR
else 'scratch' if (tag & 0xfff) == TAG_SCRATCH else 'orphan' if (tag & 0xfff) == TAG_ORPHAN
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
else 'name 0x%02x' % (tag & 0xff), else 'name 0x%02x' % (tag & 0xff),
' w%d' % w if w else '', ' w%d' % w if w else '',
@@ -1181,7 +1181,7 @@ class GState:
yield grepr(tag, data), tag, data yield grepr(tag, data), tag, data
def frepr(mdir, rid, tag): def frepr(mdir, rid, tag):
if tag == TAG_REG or tag == TAG_SCRATCH: if tag == TAG_REG or tag == TAG_ORPHAN:
size = 0 size = 0
structs = [] structs = []
# inlined data? # inlined data?
@@ -1208,7 +1208,7 @@ def frepr(mdir, rid, tag):
size = max(size, weight) size = max(size, weight)
structs.append('btree 0x%x.%x' % (block, trunk)) structs.append('btree 0x%x.%x' % (block, trunk))
return '%s %s' % ( return '%s %s' % (
'scratch' if tag == TAG_SCRATCH else 'reg', 'orphan' if tag == TAG_ORPHAN else 'reg',
', '.join(it.chain(['%d' % size], structs))) ', '.join(it.chain(['%d' % size], structs)))
elif tag == TAG_DIR: elif tag == TAG_DIR:
@@ -1983,8 +1983,8 @@ def main(disk, mroots=None, *,
# skip bookmarks # skip bookmarks
if tag == TAG_BOOKMARK: if tag == TAG_BOOKMARK:
continue continue
# skip scratch files # skip orphans
if tag == TAG_SCRATCH: if tag == TAG_ORPHAN:
continue continue
# skip grmed entries # skip grmed entries
if (max(mbid-max(mw-1, 0), 0), rid) in gstate.grm: if (max(mbid-max(mw-1, 0), 0), rid) in gstate.grm:
@@ -2036,7 +2036,7 @@ def main(disk, mroots=None, *,
else '\x1b[90m' else '\x1b[90m'
if color and (grmed if color and (grmed
or tag == TAG_BOOKMARK or tag == TAG_BOOKMARK
or tag == TAG_SCRATCH) or tag == TAG_ORPHAN)
else '', else '',
'{%s}:' % ','.join('%04x' % block '{%s}:' % ','.join('%04x' % block
for block in it.chain([mdir.block], for block in it.chain([mdir.block],
@@ -2055,7 +2055,7 @@ def main(disk, mroots=None, *,
notes notes
or grmed or grmed
or tag == TAG_BOOKMARK or tag == TAG_BOOKMARK
or tag == TAG_SCRATCH) or tag == TAG_ORPHAN)
else '')) else ''))
pmbid = mbid pmbid = mbid
@@ -2099,7 +2099,7 @@ def main(disk, mroots=None, *,
line)) line))
# print file contents? # print file contents?
if ((tag == TAG_REG or tag == TAG_SCRATCH) if ((tag == TAG_REG or tag == TAG_ORPHAN)
and args.get('structs')): and args.get('structs')):
# inlined sprout? # inlined sprout?
done, rid_, tag_, w_, j, d, data, _ = mdir.lookup( done, rid_, tag_, w_, j, d, data, _ = mdir.lookup(
+2 -2
View File
@@ -24,7 +24,7 @@ TAG_GRMDELTA = 0x0100
TAG_NAME = 0x0200 TAG_NAME = 0x0200
TAG_REG = 0x0201 TAG_REG = 0x0201
TAG_DIR = 0x0202 TAG_DIR = 0x0202
TAG_SCRATCH = 0x0203 TAG_ORPHAN = 0x0203
TAG_BOOKMARK = 0x0204 TAG_BOOKMARK = 0x0204
TAG_STRUCT = 0x0300 TAG_STRUCT = 0x0300
TAG_DATA = 0x0300 TAG_DATA = 0x0300
@@ -203,7 +203,7 @@ def tagrepr(tag, w, size, off=None):
'name' if (tag & 0xfff) == TAG_NAME 'name' if (tag & 0xfff) == TAG_NAME
else 'reg' if (tag & 0xfff) == TAG_REG else 'reg' if (tag & 0xfff) == TAG_REG
else 'dir' if (tag & 0xfff) == TAG_DIR else 'dir' if (tag & 0xfff) == TAG_DIR
else 'scratch' if (tag & 0xfff) == TAG_SCRATCH else 'orphan' if (tag & 0xfff) == TAG_ORPHAN
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
else 'name 0x%02x' % (tag & 0xff), else 'name 0x%02x' % (tag & 0xff),
' w%d' % w if w else '', ' w%d' % w if w else '',
+2 -2
View File
@@ -33,7 +33,7 @@ TAG_GRMDELTA = 0x0100
TAG_NAME = 0x0200 TAG_NAME = 0x0200
TAG_REG = 0x0201 TAG_REG = 0x0201
TAG_DIR = 0x0202 TAG_DIR = 0x0202
TAG_SCRATCH = 0x0203 TAG_ORPHAN = 0x0203
TAG_BOOKMARK = 0x0204 TAG_BOOKMARK = 0x0204
TAG_STRUCT = 0x0300 TAG_STRUCT = 0x0300
TAG_DATA = 0x0300 TAG_DATA = 0x0300
@@ -190,7 +190,7 @@ def tagrepr(tag, w, size, off=None):
'name' if (tag & 0xfff) == TAG_NAME 'name' if (tag & 0xfff) == TAG_NAME
else 'reg' if (tag & 0xfff) == TAG_REG else 'reg' if (tag & 0xfff) == TAG_REG
else 'dir' if (tag & 0xfff) == TAG_DIR else 'dir' if (tag & 0xfff) == TAG_DIR
else 'scratch' if (tag & 0xfff) == TAG_SCRATCH else 'orphan' if (tag & 0xfff) == TAG_ORPHAN
else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK else 'bookmark' if (tag & 0xfff) == TAG_BOOKMARK
else 'name 0x%02x' % (tag & 0xff), else 'name 0x%02x' % (tag & 0xff),
' w%d' % w if w else '', ' w%d' % w if w else '',
@@ -1,9 +1,9 @@
# Test scratch files and their various use cases # Test orphaned files and their various use cases
after = ['test_fwrite', 'test_fsync'] after = ['test_fwrite', 'test_fsync']
# Some specific tests # Some specific tests
[cases.test_fscratch_create] [cases.test_forphan_create]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -193,7 +193,7 @@ code = '''
lfsr_unmount(&lfs_) => 0; lfsr_unmount(&lfs_) => 0;
''' '''
[cases.test_fscratch_create_pl] [cases.test_forphan_create_pl]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -270,7 +270,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_create_many_pl] [cases.test_forphan_create_many_pl]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -357,7 +357,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_create_sync_wr] [cases.test_forphan_create_sync_wr]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -539,7 +539,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_create_sync_rw] [cases.test_forphan_create_sync_rw]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -720,7 +720,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_create_desync_wdwr] [cases.test_forphan_create_desync_wdwr]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -1026,7 +1026,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_orphan] [cases.test_forphan_orphan]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -1129,7 +1129,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_orphan_wdwr] [cases.test_forphan_orphan_wdwr]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -1395,7 +1395,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_orphan_open] [cases.test_forphan_orphan_open]
defines.ORPHANS = [1, 2, 3, 100] defines.ORPHANS = [1, 2, 3, 100]
# 0 => don't remount # 0 => don't remount
# 1 => remount after op # 1 => remount after op
@@ -1485,7 +1485,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_orphan_mkdir] [cases.test_forphan_orphan_mkdir]
defines.ORPHANS = [1, 2, 3, 100] defines.ORPHANS = [1, 2, 3, 100]
# 0 => don't remount # 0 => don't remount
# 1 => remount after op # 1 => remount after op
@@ -1562,7 +1562,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_orphan_remove] [cases.test_forphan_orphan_remove]
defines.ORPHANS = [1, 2, 3, 100] defines.ORPHANS = [1, 2, 3, 100]
# 0 => don't remount # 0 => don't remount
# 1 => remount after op # 1 => remount after op
@@ -1634,7 +1634,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_orphan_rename_dst] [cases.test_forphan_orphan_rename_dst]
defines.DIR = [false, true] defines.DIR = [false, true]
defines.INTERDIR = [false, true] defines.INTERDIR = [false, true]
defines.DISTANCE = [0, 1, 100] defines.DISTANCE = [0, 1, 100]
@@ -1779,7 +1779,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_orphan_rename_src] [cases.test_forphan_orphan_rename_src]
defines.ORPHANS = [1, 2, 3, 100] defines.ORPHANS = [1, 2, 3, 100]
# 0 => don't remount # 0 => don't remount
# 1 => remount after op # 1 => remount after op
@@ -1852,7 +1852,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie] [cases.test_forphan_zombie]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -1973,7 +1973,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_posthumous] [cases.test_forphan_zombie_posthumous]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -2094,7 +2094,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_rwrw] [cases.test_forphan_zombie_rwrw]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -2312,7 +2312,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_rwrw_posthumous] [cases.test_forphan_zombie_rwrw_posthumous]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -2530,7 +2530,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_zombie_rwrwrw] [cases.test_forphan_zombie_zombie_rwrwrw]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -2783,7 +2783,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_zombie_rwrwrw_posthumous] [cases.test_forphan_zombie_zombie_rwrwrw_posthumous]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -3036,7 +3036,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_open] [cases.test_forphan_zombie_open]
# 0 => don't close (before end of test) # 0 => don't close (before end of test)
# 1 => close after op # 1 => close after op
# 2 => close before op # 2 => close before op
@@ -3139,7 +3139,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_mkdir] [cases.test_forphan_zombie_mkdir]
# 0 => don't close (before end of test) # 0 => don't close (before end of test)
# 1 => close after op # 1 => close after op
# 2 => close before op # 2 => close before op
@@ -3228,7 +3228,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_remove] [cases.test_forphan_zombie_remove]
# 0 => don't close (before end of test) # 0 => don't close (before end of test)
# 1 => close after op # 1 => close after op
# 2 => close before op # 2 => close before op
@@ -3312,7 +3312,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_rename_dst] [cases.test_forphan_zombie_rename_dst]
defines.DIR = [false, true] defines.DIR = [false, true]
defines.INTERDIR = [false, true] defines.INTERDIR = [false, true]
defines.DISTANCE = [0, 1, 100] defines.DISTANCE = [0, 1, 100]
@@ -3468,7 +3468,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombie_rename_src] [cases.test_forphan_zombie_rename_src]
# 0 => don't close (before end of test) # 0 => don't close (before end of test)
# 1 => close after op # 1 => close after op
# 2 => close before op # 2 => close before op
@@ -3553,7 +3553,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombify_mkdir] [cases.test_forphan_zombify_mkdir]
defines.CLOSE = [false, true] defines.CLOSE = [false, true]
defines.REMOUNT = [false, true] defines.REMOUNT = [false, true]
defines.POSTHUMOUS = [false, true] defines.POSTHUMOUS = [false, true]
@@ -3626,7 +3626,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_zombify_rename_dst] [cases.test_forphan_zombify_rename_dst]
defines.ORPHAN = [false, true] defines.ORPHAN = [false, true]
defines.DIR = [false, true] defines.DIR = [false, true]
defines.INTERDIR = [false, true] defines.INTERDIR = [false, true]
@@ -3773,7 +3773,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_file_on_zombie_remove] [cases.test_forphan_file_on_zombie_remove]
defines.DIR = [false, true] defines.DIR = [false, true]
# 0 => don't close (before end of test) # 0 => don't close (before end of test)
# 1 => close after op # 1 => close after op
@@ -3870,7 +3870,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_file_on_zombie_rename_dst] [cases.test_forphan_file_on_zombie_rename_dst]
defines.DIR = [false, true] defines.DIR = [false, true]
defines.INTERDIR = [false, true] defines.INTERDIR = [false, true]
defines.DISTANCE = [0, 1, 100] defines.DISTANCE = [0, 1, 100]
@@ -4040,7 +4040,7 @@ code = '''
# these doesn't really involve scratch files, but we might as well test # these doesn't really involve scratch files, but we might as well test
# them here # them here
[cases.test_fscratch_rename] [cases.test_forphan_rename]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -4270,7 +4270,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_rename_postrename] [cases.test_forphan_rename_postrename]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -4558,7 +4558,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_rename_rwrw] [cases.test_forphan_rename_rwrw]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -4895,7 +4895,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_rename_rwrw_postrename] [cases.test_forphan_rename_rwrw_postrename]
defines.SIZE = [ defines.SIZE = [
'CACHE_SIZE/2', 'CACHE_SIZE/2',
'2*CACHE_SIZE', '2*CACHE_SIZE',
@@ -5224,7 +5224,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_rename_rename_src] [cases.test_forphan_rename_rename_src]
defines.EXISTS = [false, true] defines.EXISTS = [false, true]
defines.INTERDIR = [false, true] defines.INTERDIR = [false, true]
defines.DISTANCE = [0, 1, 100] defines.DISTANCE = [0, 1, 100]
@@ -5382,7 +5382,7 @@ code = '''
lfsr_unmount(&lfs) => 0; lfsr_unmount(&lfs) => 0;
''' '''
[cases.test_fscratch_file_on_zombie_rename_src] [cases.test_forphan_file_on_zombie_rename_src]
defines.DIR = [false, true] defines.DIR = [false, true]
defines.EXISTS = [false, true] defines.EXISTS = [false, true]
defines.INTERDIR = [false, true] defines.INTERDIR = [false, true]