Added grm rcompat flag, dropped ocompat, tweaked compat flags a bit

I'm just not seeing a use case for optional compat flags (ocompat), so
dropping for now. It seems their *nix equivalent, feature_compat, is
used to inform fsck of things, but this doesn't really make since in
littlefs since there is no fsck. Or from a different perspective,
littlefs is always running fsck.

Ocompat flags can always be added later (since they do nothing).

Unfortunately this really ruins the alignment of the tag encoding. For
whatever reason config limits tend to come in pairs. For now the best
solution is just leave tag 0x0006 unused. I guess you can consider it
reserved for hypothetical ocompat flags in the future.

---

This adds an rcompat flag for the grm, since in theory a filesystem
doesn't need to support grms if it never renames files (or creates
directories?). But if a filesystem doesn't support grms and a grms gets
written into the filesystem, this can lead to corruption.

I think every piece of gstate will end up with its own compat flag for
this reason.

---

Also renamed r/w/oflags -> r/w/ocompatflags to make their purpose
clearer.

---

The code impact of adding the grm rcompat flag is minimal, and will
probably be less for additional rcompat flags:

            code          stack
  before:  31528           2752
  after:   31584 (+0.2%)   2752 (+0.0%)
This commit is contained in:
Christopher Haster
2023-12-07 15:04:29 -06:00
parent c76ff08f67
commit 04c6b5a067
6 changed files with 281 additions and 272 deletions
+61 -32
View File
@@ -578,7 +578,7 @@ static int lfsr_bd_erase(lfs_t *lfs, lfs_block_t block) {
// 16-bit metadata tags // 16-bit metadata tags
enum lfsr_tag_type { enum lfsr_tag {
// the null tag is reserved // the null tag is reserved
LFSR_TAG_NULL = 0x0000, LFSR_TAG_NULL = 0x0000,
@@ -586,9 +586,8 @@ enum lfsr_tag_type {
LFSR_TAG_CONFIG = 0x0000, LFSR_TAG_CONFIG = 0x0000,
LFSR_TAG_MAGIC = 0x0003, LFSR_TAG_MAGIC = 0x0003,
LFSR_TAG_VERSION = 0x0004, LFSR_TAG_VERSION = 0x0004,
LFSR_TAG_RFLAGS = 0x0005, LFSR_TAG_RCOMPATFLAGS = 0x0006,
LFSR_TAG_WFLAGS = 0x0006, LFSR_TAG_WCOMPATFLAGS = 0x0007,
LFSR_TAG_OFLAGS = 0x0007,
LFSR_TAG_BLOCKSIZE = 0x0008, LFSR_TAG_BLOCKSIZE = 0x0008,
LFSR_TAG_BLOCKCOUNT = 0x0009, LFSR_TAG_BLOCKCOUNT = 0x0009,
LFSR_TAG_NAMELIMIT = 0x000a, LFSR_TAG_NAMELIMIT = 0x000a,
@@ -7656,6 +7655,28 @@ static int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *traversal,
// return LFSR_DATA_BUF(buffer, d); // return LFSR_DATA_BUF(buffer, d);
//} //}
// compatibility flags
//
// - WCOMPAT => Must understand to write to the filesystem
// - RCOMPAT => Must understand to read the filesystem
//
// note, "understanding" does not necessarily mean support
//
enum lfsr_rcompat {
LFSR_RCOMPAT_GRM = 0x01,
};
typedef uint8_t lfsr_rcompat_t;
typedef uint8_t lfsr_wcompat_t;
static inline bool lfsr_rcompat_hasgrm(lfsr_rcompat_t rcompat) {
return rcompat & LFSR_RCOMPAT_GRM;
}
static inline bool lfsr_rcompat_hasunknown(lfsr_rcompat_t rcompat) {
return rcompat & ~LFSR_RCOMPAT_GRM;
}
/// Filesystem init functions /// /// Filesystem init functions ///
@@ -7726,53 +7747,59 @@ static int lfsr_mountmroot(lfs_t *lfs, const lfsr_mdir_t *mroot) {
return LFS_ERR_INVAL; return LFS_ERR_INVAL;
} }
// check for any rflags, we must understand these to read // check for any rcompatflags, we must understand these to read
// the filesystem // the filesystem
err = lfsr_mdir_lookup(lfs, mroot, -1, LFSR_TAG_RFLAGS, err = lfsr_mdir_lookup(lfs, mroot, -1, LFSR_TAG_RCOMPATFLAGS,
NULL, &data); NULL, &data);
if (err && err != LFS_ERR_NOENT) { if (err && err != LFS_ERR_NOENT) {
return err; return err;
} }
if (err == LFS_ERR_NOENT) {
data = LFSR_DATA_NULL();
}
if (err != LFS_ERR_NOENT && lfsr_data_size(&data) > 0) { lfsr_rcompat_t rcompat;
LFS_ERROR("Incompatible rflag 0x%s%"PRIx32, lfs_ssize_t size = lfsr_data_read(lfs, &data, &rcompat, 1);
(lfsr_data_size(&data) > 0) ? "?" : "", if (size < 0) {
0); return size;
}
if (size < 1) {
rcompat = 0;
}
// unknown rcompat flags? flags must be tightly sized
if (lfsr_rcompat_hasunknown(rcompat) || lfsr_data_size(&data) > 0) {
LFS_ERROR("Incompatible rcompat flags 0x%s%"PRIx8,
(lfsr_data_size(&data) > 0) ? "??" : "",
rcompat);
return LFS_ERR_INVAL; return LFS_ERR_INVAL;
} }
// check for any wflags, we must understand these to write // grm supported?
if (!lfsr_rcompat_hasgrm(rcompat)) {
LFS_ERROR("Incompatible rcompat flags, no grm");
// TODO switch to read-only? upgrade?
return LFS_ERR_INVAL;
}
// check for any wcompatflags, we must understand these to write
// the filesystem // the filesystem
err = lfsr_mdir_lookup(lfs, mroot, -1, LFSR_TAG_WFLAGS, err = lfsr_mdir_lookup(lfs, mroot, -1, LFSR_TAG_WCOMPATFLAGS,
NULL, &data); NULL, &data);
if (err && err != LFS_ERR_NOENT) { if (err && err != LFS_ERR_NOENT) {
return err; return err;
} }
if (err == LFS_ERR_NOENT) {
data = LFSR_DATA_NULL();
}
if (err != LFS_ERR_NOENT && lfsr_data_size(&data) > 0) { // unknown wcompat flags? flags must be tightly sized
LFS_ERROR("Incompatible wflag 0x%s%"PRIx32, if (lfsr_data_size(&data) > 0) {
(lfsr_data_size(&data) > 0) ? "?" : "", LFS_ERROR("Incompatible wcompat flags 0x??");
0);
// TODO switch to read-only? // TODO switch to read-only?
return LFS_ERR_INVAL; return LFS_ERR_INVAL;
} }
// check for any oflags, these are optional, if we don't
// understand an oflag we can simply clear it
err = lfsr_mdir_lookup(lfs, mroot, -1, LFSR_TAG_OFLAGS,
NULL, &data);
if (err && err != LFS_ERR_NOENT) {
return err;
}
if (err != LFS_ERR_NOENT && lfsr_data_size(&data) > 0) {
LFS_DEBUG("Found unknown oflag 0x%s%"PRIx32,
(lfsr_data_size(&data) > 0) ? "?" : "",
0);
// TODO track and clear oflags in mkconsistent?
LFS_ASSERT(false);
}
// check block size // check block size
err = lfsr_mdir_lookup(lfs, mroot, -1, LFSR_TAG_BLOCKSIZE, err = lfsr_mdir_lookup(lfs, mroot, -1, LFSR_TAG_BLOCKSIZE,
NULL, &data); NULL, &data);
@@ -8198,6 +8225,8 @@ static int lfsr_formatinited(lfs_t *lfs) {
LFSR_ATTR(-1, VERSION, 0, IMM(((const uint8_t[2]){ LFSR_ATTR(-1, VERSION, 0, IMM(((const uint8_t[2]){
LFS_DISK_VERSION_MAJOR, LFS_DISK_VERSION_MAJOR,
LFS_DISK_VERSION_MINOR}), 2)), LFS_DISK_VERSION_MINOR}), 2)),
LFSR_ATTR(-1, RCOMPATFLAGS, 0, IMM((&(uint8_t){
LFSR_RCOMPAT_GRM}), 1)),
LFSR_ATTR(-1, BLOCKSIZE, 0, LEB128(lfs->cfg->block_size-1)), LFSR_ATTR(-1, BLOCKSIZE, 0, LEB128(lfs->cfg->block_size-1)),
LFSR_ATTR(-1, BLOCKCOUNT, 0, LEB128(lfs->cfg->block_count-1)), LFSR_ATTR(-1, BLOCKCOUNT, 0, LEB128(lfs->cfg->block_count-1)),
LFSR_ATTR(-1, NAMELIMIT, 0, LEB128(lfs->name_limit)), LFSR_ATTR(-1, NAMELIMIT, 0, LEB128(lfs->name_limit)),
+40 -41
View File
@@ -10,47 +10,46 @@ import shutil
import struct import struct
TAG_NULL = 0x0000 TAG_NULL = 0x0000
TAG_CONFIG = 0x0000 TAG_CONFIG = 0x0000
TAG_MAGIC = 0x0003 TAG_MAGIC = 0x0003
TAG_VERSION = 0x0004 TAG_VERSION = 0x0004
TAG_RFLAGS = 0x0005 TAG_RCOMPATFLAGS = 0x0006
TAG_WFLAGS = 0x0006 TAG_WCOMPATFLAGS = 0x0007
TAG_OFLAGS = 0x0007 TAG_BLOCKSIZE = 0x0008
TAG_BLOCKSIZE = 0x0008 TAG_BLOCKCOUNT = 0x0009
TAG_BLOCKCOUNT = 0x0009 TAG_NAMELIMIT = 0x000a
TAG_NAMELIMIT = 0x000a TAG_SIZELIMIT = 0x000b
TAG_SIZELIMIT = 0x000b TAG_UTAGLIMIT = 0x000c
TAG_UTAGLIMIT = 0x000c TAG_UATTRLIMIT = 0x000d
TAG_UATTRLIMIT = 0x000d TAG_STAGLIMIT = 0x000e
TAG_STAGLIMIT = 0x000e TAG_SATTRLIMIT = 0x000f
TAG_SATTRLIMIT = 0x000f TAG_MDIRLIMIT = 0x0010
TAG_MDIRLIMIT = 0x0010 TAG_MTREELIMIT = 0x0011
TAG_MTREELIMIT = 0x0011 TAG_GSTATE = 0x0100
TAG_GSTATE = 0x0100 TAG_GRM = 0x0100
TAG_GRM = 0x0100 TAG_NAME = 0x0200
TAG_NAME = 0x0200 TAG_BOOKMARK = 0x0201
TAG_BOOKMARK = 0x0201 TAG_REG = 0x0202
TAG_REG = 0x0202 TAG_DIR = 0x0203
TAG_DIR = 0x0203 TAG_STRUCT = 0x0300
TAG_STRUCT = 0x0300 TAG_DATA = 0x0300
TAG_DATA = 0x0300 TAG_TRUNK = 0x0304
TAG_TRUNK = 0x0304 TAG_BLOCK = 0x0308
TAG_BLOCK = 0x0308 TAG_BTREE = 0x030c
TAG_BTREE = 0x030c TAG_BRANCH = 0x031c
TAG_BRANCH = 0x031c TAG_MDIR = 0x0321
TAG_MDIR = 0x0321 TAG_MTREE = 0x0324
TAG_MTREE = 0x0324 TAG_MROOT = 0x0329
TAG_MROOT = 0x0329 TAG_DID = 0x032c
TAG_DID = 0x032c TAG_UATTR = 0x0400
TAG_UATTR = 0x0400 TAG_SATTR = 0x0600
TAG_SATTR = 0x0600 TAG_SHRUB = 0x1000
TAG_SHRUB = 0x1000 TAG_CKSUM = 0x3000
TAG_CKSUM = 0x3000 TAG_ECKSUM = 0x3100
TAG_ECKSUM = 0x3100 TAG_ALT = 0x4000
TAG_ALT = 0x4000 TAG_GT = 0x2000
TAG_GT = 0x2000 TAG_R = 0x1000
TAG_R = 0x1000
CHARS = 'mbd-' CHARS = 'mbd-'
+42 -44
View File
@@ -8,47 +8,46 @@ import os
import struct import struct
TAG_NULL = 0x0000 TAG_NULL = 0x0000
TAG_CONFIG = 0x0000 TAG_CONFIG = 0x0000
TAG_MAGIC = 0x0003 TAG_MAGIC = 0x0003
TAG_VERSION = 0x0004 TAG_VERSION = 0x0004
TAG_RFLAGS = 0x0005 TAG_RCOMPATFLAGS = 0x0006
TAG_WFLAGS = 0x0006 TAG_WCOMPATFLAGS = 0x0007
TAG_OFLAGS = 0x0007 TAG_BLOCKSIZE = 0x0008
TAG_BLOCKSIZE = 0x0008 TAG_BLOCKCOUNT = 0x0009
TAG_BLOCKCOUNT = 0x0009 TAG_NAMELIMIT = 0x000a
TAG_NAMELIMIT = 0x000a TAG_SIZELIMIT = 0x000b
TAG_SIZELIMIT = 0x000b TAG_UTAGLIMIT = 0x000c
TAG_UTAGLIMIT = 0x000c TAG_UATTRLIMIT = 0x000d
TAG_UATTRLIMIT = 0x000d TAG_STAGLIMIT = 0x000e
TAG_STAGLIMIT = 0x000e TAG_SATTRLIMIT = 0x000f
TAG_SATTRLIMIT = 0x000f TAG_MDIRLIMIT = 0x0010
TAG_MDIRLIMIT = 0x0010 TAG_MTREELIMIT = 0x0011
TAG_MTREELIMIT = 0x0011 TAG_GSTATE = 0x0100
TAG_GSTATE = 0x0100 TAG_GRM = 0x0100
TAG_GRM = 0x0100 TAG_NAME = 0x0200
TAG_NAME = 0x0200 TAG_BOOKMARK = 0x0201
TAG_BOOKMARK = 0x0201 TAG_REG = 0x0202
TAG_REG = 0x0202 TAG_DIR = 0x0203
TAG_DIR = 0x0203 TAG_STRUCT = 0x0300
TAG_STRUCT = 0x0300 TAG_DATA = 0x0300
TAG_DATA = 0x0300 TAG_TRUNK = 0x0304
TAG_TRUNK = 0x0304 TAG_BLOCK = 0x0308
TAG_BLOCK = 0x0308 TAG_BTREE = 0x030c
TAG_BTREE = 0x030c TAG_BRANCH = 0x031c
TAG_BRANCH = 0x031c TAG_MDIR = 0x0321
TAG_MDIR = 0x0321 TAG_MTREE = 0x0324
TAG_MTREE = 0x0324 TAG_MROOT = 0x0329
TAG_MROOT = 0x0329 TAG_DID = 0x032c
TAG_DID = 0x032c TAG_UATTR = 0x0400
TAG_UATTR = 0x0400 TAG_SATTR = 0x0600
TAG_SATTR = 0x0600 TAG_SHRUB = 0x1000
TAG_SHRUB = 0x1000 TAG_CKSUM = 0x3000
TAG_CKSUM = 0x3000 TAG_ECKSUM = 0x3100
TAG_ECKSUM = 0x3100 TAG_ALT = 0x4000
TAG_ALT = 0x4000 TAG_GT = 0x2000
TAG_GT = 0x2000 TAG_R = 0x1000
TAG_R = 0x1000
# some ways of block geometry representations # some ways of block geometry representations
@@ -169,9 +168,8 @@ def tagrepr(tag, w, size, off=None):
'shrub' if tag & TAG_SHRUB else '', 'shrub' if tag & TAG_SHRUB else '',
'magic' if (tag & 0xfff) == TAG_MAGIC 'magic' if (tag & 0xfff) == TAG_MAGIC
else 'version' if (tag & 0xfff) == TAG_VERSION else 'version' if (tag & 0xfff) == TAG_VERSION
else 'rflags' if (tag & 0xfff) == TAG_RFLAGS else 'rcompatflags' if (tag & 0xfff) == TAG_RCOMPATFLAGS
else 'wflags' if (tag & 0xfff) == TAG_WFLAGS else 'wcompatflags' if (tag & 0xfff) == TAG_WCOMPATFLAGS
else 'oflags' if (tag & 0xfff) == TAG_OFLAGS
else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE
else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT
else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT
+54 -67
View File
@@ -9,47 +9,46 @@ import os
import struct import struct
TAG_NULL = 0x0000 TAG_NULL = 0x0000
TAG_CONFIG = 0x0000 TAG_CONFIG = 0x0000
TAG_MAGIC = 0x0003 TAG_MAGIC = 0x0003
TAG_VERSION = 0x0004 TAG_VERSION = 0x0004
TAG_RFLAGS = 0x0005 TAG_RCOMPATFLAGS = 0x0006
TAG_WFLAGS = 0x0006 TAG_WCOMPATFLAGS = 0x0007
TAG_OFLAGS = 0x0007 TAG_BLOCKSIZE = 0x0008
TAG_BLOCKSIZE = 0x0008 TAG_BLOCKCOUNT = 0x0009
TAG_BLOCKCOUNT = 0x0009 TAG_NAMELIMIT = 0x000a
TAG_NAMELIMIT = 0x000a TAG_SIZELIMIT = 0x000b
TAG_SIZELIMIT = 0x000b TAG_UTAGLIMIT = 0x000c
TAG_UTAGLIMIT = 0x000c TAG_UATTRLIMIT = 0x000d
TAG_UATTRLIMIT = 0x000d TAG_STAGLIMIT = 0x000e
TAG_STAGLIMIT = 0x000e TAG_SATTRLIMIT = 0x000f
TAG_SATTRLIMIT = 0x000f TAG_MDIRLIMIT = 0x0010
TAG_MDIRLIMIT = 0x0010 TAG_MTREELIMIT = 0x0011
TAG_MTREELIMIT = 0x0011 TAG_GSTATE = 0x0100
TAG_GSTATE = 0x0100 TAG_GRM = 0x0100
TAG_GRM = 0x0100 TAG_NAME = 0x0200
TAG_NAME = 0x0200 TAG_BOOKMARK = 0x0201
TAG_BOOKMARK = 0x0201 TAG_REG = 0x0202
TAG_REG = 0x0202 TAG_DIR = 0x0203
TAG_DIR = 0x0203 TAG_STRUCT = 0x0300
TAG_STRUCT = 0x0300 TAG_DATA = 0x0300
TAG_DATA = 0x0300 TAG_TRUNK = 0x0304
TAG_TRUNK = 0x0304 TAG_BLOCK = 0x0308
TAG_BLOCK = 0x0308 TAG_BTREE = 0x030c
TAG_BTREE = 0x030c TAG_BRANCH = 0x031c
TAG_BRANCH = 0x031c TAG_MDIR = 0x0321
TAG_MDIR = 0x0321 TAG_MTREE = 0x0324
TAG_MTREE = 0x0324 TAG_MROOT = 0x0329
TAG_MROOT = 0x0329 TAG_DID = 0x032c
TAG_DID = 0x032c TAG_UATTR = 0x0400
TAG_UATTR = 0x0400 TAG_SATTR = 0x0600
TAG_SATTR = 0x0600 TAG_SHRUB = 0x1000
TAG_SHRUB = 0x1000 TAG_CKSUM = 0x3000
TAG_CKSUM = 0x3000 TAG_ECKSUM = 0x3100
TAG_ECKSUM = 0x3100 TAG_ALT = 0x4000
TAG_ALT = 0x4000 TAG_GT = 0x2000
TAG_GT = 0x2000 TAG_R = 0x1000
TAG_R = 0x1000
# some ways of block geometry representations # some ways of block geometry representations
@@ -198,9 +197,8 @@ def tagrepr(tag, w, size, off=None):
'shrub' if tag & TAG_SHRUB else '', 'shrub' if tag & TAG_SHRUB else '',
'magic' if (tag & 0xfff) == TAG_MAGIC 'magic' if (tag & 0xfff) == TAG_MAGIC
else 'version' if (tag & 0xfff) == TAG_VERSION else 'version' if (tag & 0xfff) == TAG_VERSION
else 'rflags' if (tag & 0xfff) == TAG_RFLAGS else 'rcompatflags' if (tag & 0xfff) == TAG_RCOMPATFLAGS
else 'wflags' if (tag & 0xfff) == TAG_WFLAGS else 'wcompatflags' if (tag & 0xfff) == TAG_WCOMPATFLAGS
else 'oflags' if (tag & 0xfff) == TAG_OFLAGS
else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE
else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT
else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT
@@ -1036,25 +1034,17 @@ class Config:
return (None, None) return (None, None)
@ft.cached_property @ft.cached_property
def rflags(self): def rcompatflags(self):
if TAG_RFLAGS in self.config: if TAG_RCOMPATFLAGS in self.config:
_, data = self.config[TAG_RFLAGS] _, data = self.config[TAG_RCOMPATFLAGS]
return data return data
else: else:
return None return None
@ft.cached_property @ft.cached_property
def wflags(self): def wcompatflags(self):
if TAG_WFLAGS in self.config: if TAG_WCOMPATFLAGS in self.config:
_, data = self.config[TAG_WFLAGS] _, data = self.config[TAG_WCOMPATFLAGS]
return data
else:
return None
@ft.cached_property
def oflags(self):
if TAG_OFLAGS in self.config:
_, data = self.config[TAG_OFLAGS]
return data return data
else: else:
return None return None
@@ -1157,15 +1147,12 @@ class Config:
for b in map(chr, self.magic)) for b in map(chr, self.magic))
elif tag == TAG_VERSION: elif tag == TAG_VERSION:
return 'version v%d.%d' % self.version return 'version v%d.%d' % self.version
elif tag == TAG_RFLAGS: elif tag == TAG_RCOMPATFLAGS:
return 'rflags 0x%s' % ''.join( return 'rcompatflags 0x%s' % ''.join(
'%02x' % f for f in reversed(self.rflags)) '%02x' % f for f in reversed(self.rcompatflags))
elif tag == TAG_WFLAGS: elif tag == TAG_WCOMPATFLAGS:
return 'wflags 0x%s' % ''.join( return 'wcompatflags 0x%s' % ''.join(
'%02x' % f for f in reversed(self.wflags)) '%02x' % f for f in reversed(self.wcompatflags))
elif tag == TAG_OFLAGS:
return 'oflags 0x%s' % ''.join(
'%02x' % f for f in reversed(self.oflags))
elif tag == TAG_BLOCKSIZE: elif tag == TAG_BLOCKSIZE:
return 'blocksize %d' % self.block_size return 'blocksize %d' % self.block_size
elif tag == TAG_BLOCKCOUNT: elif tag == TAG_BLOCKCOUNT:
+42 -44
View File
@@ -8,47 +8,46 @@ import os
import struct import struct
TAG_NULL = 0x0000 TAG_NULL = 0x0000
TAG_CONFIG = 0x0000 TAG_CONFIG = 0x0000
TAG_MAGIC = 0x0003 TAG_MAGIC = 0x0003
TAG_VERSION = 0x0004 TAG_VERSION = 0x0004
TAG_RFLAGS = 0x0005 TAG_RCOMPATFLAGS = 0x0006
TAG_WFLAGS = 0x0006 TAG_WCOMPATFLAGS = 0x0007
TAG_OFLAGS = 0x0007 TAG_BLOCKSIZE = 0x0008
TAG_BLOCKSIZE = 0x0008 TAG_BLOCKCOUNT = 0x0009
TAG_BLOCKCOUNT = 0x0009 TAG_NAMELIMIT = 0x000a
TAG_NAMELIMIT = 0x000a TAG_SIZELIMIT = 0x000b
TAG_SIZELIMIT = 0x000b TAG_UTAGLIMIT = 0x000c
TAG_UTAGLIMIT = 0x000c TAG_UATTRLIMIT = 0x000d
TAG_UATTRLIMIT = 0x000d TAG_STAGLIMIT = 0x000e
TAG_STAGLIMIT = 0x000e TAG_SATTRLIMIT = 0x000f
TAG_SATTRLIMIT = 0x000f TAG_MDIRLIMIT = 0x0010
TAG_MDIRLIMIT = 0x0010 TAG_MTREELIMIT = 0x0011
TAG_MTREELIMIT = 0x0011 TAG_GSTATE = 0x0100
TAG_GSTATE = 0x0100 TAG_GRM = 0x0100
TAG_GRM = 0x0100 TAG_NAME = 0x0200
TAG_NAME = 0x0200 TAG_BOOKMARK = 0x0201
TAG_BOOKMARK = 0x0201 TAG_REG = 0x0202
TAG_REG = 0x0202 TAG_DIR = 0x0203
TAG_DIR = 0x0203 TAG_STRUCT = 0x0300
TAG_STRUCT = 0x0300 TAG_DATA = 0x0300
TAG_DATA = 0x0300 TAG_TRUNK = 0x0304
TAG_TRUNK = 0x0304 TAG_BLOCK = 0x0308
TAG_BLOCK = 0x0308 TAG_BTREE = 0x030c
TAG_BTREE = 0x030c TAG_BRANCH = 0x031c
TAG_BRANCH = 0x031c TAG_MDIR = 0x0321
TAG_MDIR = 0x0321 TAG_MTREE = 0x0324
TAG_MTREE = 0x0324 TAG_MROOT = 0x0329
TAG_MROOT = 0x0329 TAG_DID = 0x032c
TAG_DID = 0x032c TAG_UATTR = 0x0400
TAG_UATTR = 0x0400 TAG_SATTR = 0x0600
TAG_SATTR = 0x0600 TAG_SHRUB = 0x1000
TAG_SHRUB = 0x1000 TAG_CKSUM = 0x3000
TAG_CKSUM = 0x3000 TAG_ECKSUM = 0x3100
TAG_ECKSUM = 0x3100 TAG_ALT = 0x4000
TAG_ALT = 0x4000 TAG_GT = 0x2000
TAG_GT = 0x2000 TAG_R = 0x1000
TAG_R = 0x1000
# some ways of block geometry representations # some ways of block geometry representations
@@ -184,9 +183,8 @@ def tagrepr(tag, w, size, off=None):
'shrub' if tag & TAG_SHRUB else '', 'shrub' if tag & TAG_SHRUB else '',
'magic' if (tag & 0xfff) == TAG_MAGIC 'magic' if (tag & 0xfff) == TAG_MAGIC
else 'version' if (tag & 0xfff) == TAG_VERSION else 'version' if (tag & 0xfff) == TAG_VERSION
else 'rflags' if (tag & 0xfff) == TAG_RFLAGS else 'rcompatflags' if (tag & 0xfff) == TAG_RCOMPATFLAGS
else 'wflags' if (tag & 0xfff) == TAG_WFLAGS else 'wcompatflags' if (tag & 0xfff) == TAG_WCOMPATFLAGS
else 'oflags' if (tag & 0xfff) == TAG_OFLAGS
else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE
else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT
else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT
+42 -44
View File
@@ -17,47 +17,46 @@ COLORS = [
] ]
TAG_NULL = 0x0000 TAG_NULL = 0x0000
TAG_CONFIG = 0x0000 TAG_CONFIG = 0x0000
TAG_MAGIC = 0x0003 TAG_MAGIC = 0x0003
TAG_VERSION = 0x0004 TAG_VERSION = 0x0004
TAG_RFLAGS = 0x0005 TAG_RCOMPATFLAGS = 0x0006
TAG_WFLAGS = 0x0006 TAG_WCOMPATFLAGS = 0x0007
TAG_OFLAGS = 0x0007 TAG_BLOCKSIZE = 0x0008
TAG_BLOCKSIZE = 0x0008 TAG_BLOCKCOUNT = 0x0009
TAG_BLOCKCOUNT = 0x0009 TAG_NAMELIMIT = 0x000a
TAG_NAMELIMIT = 0x000a TAG_SIZELIMIT = 0x000b
TAG_SIZELIMIT = 0x000b TAG_UTAGLIMIT = 0x000c
TAG_UTAGLIMIT = 0x000c TAG_UATTRLIMIT = 0x000d
TAG_UATTRLIMIT = 0x000d TAG_STAGLIMIT = 0x000e
TAG_STAGLIMIT = 0x000e TAG_SATTRLIMIT = 0x000f
TAG_SATTRLIMIT = 0x000f TAG_MDIRLIMIT = 0x0010
TAG_MDIRLIMIT = 0x0010 TAG_MTREELIMIT = 0x0011
TAG_MTREELIMIT = 0x0011 TAG_GSTATE = 0x0100
TAG_GSTATE = 0x0100 TAG_GRM = 0x0100
TAG_GRM = 0x0100 TAG_NAME = 0x0200
TAG_NAME = 0x0200 TAG_BOOKMARK = 0x0201
TAG_BOOKMARK = 0x0201 TAG_REG = 0x0202
TAG_REG = 0x0202 TAG_DIR = 0x0203
TAG_DIR = 0x0203 TAG_STRUCT = 0x0300
TAG_STRUCT = 0x0300 TAG_DATA = 0x0300
TAG_DATA = 0x0300 TAG_TRUNK = 0x0304
TAG_TRUNK = 0x0304 TAG_BLOCK = 0x0308
TAG_BLOCK = 0x0308 TAG_BTREE = 0x030c
TAG_BTREE = 0x030c TAG_BRANCH = 0x031c
TAG_BRANCH = 0x031c TAG_MDIR = 0x0321
TAG_MDIR = 0x0321 TAG_MTREE = 0x0324
TAG_MTREE = 0x0324 TAG_MROOT = 0x0329
TAG_MROOT = 0x0329 TAG_DID = 0x032c
TAG_DID = 0x032c TAG_UATTR = 0x0400
TAG_UATTR = 0x0400 TAG_SATTR = 0x0600
TAG_SATTR = 0x0600 TAG_SHRUB = 0x1000
TAG_SHRUB = 0x1000 TAG_CKSUM = 0x3000
TAG_CKSUM = 0x3000 TAG_ECKSUM = 0x3100
TAG_ECKSUM = 0x3100 TAG_ALT = 0x4000
TAG_ALT = 0x4000 TAG_GT = 0x2000
TAG_GT = 0x2000 TAG_R = 0x1000
TAG_R = 0x1000
# some ways of block geometry representations # some ways of block geometry representations
@@ -171,9 +170,8 @@ def tagrepr(tag, w, size, off=None):
'shrub' if tag & TAG_SHRUB else '', 'shrub' if tag & TAG_SHRUB else '',
'magic' if (tag & 0xfff) == TAG_MAGIC 'magic' if (tag & 0xfff) == TAG_MAGIC
else 'version' if (tag & 0xfff) == TAG_VERSION else 'version' if (tag & 0xfff) == TAG_VERSION
else 'rflags' if (tag & 0xfff) == TAG_RFLAGS else 'rcompatflags' if (tag & 0xfff) == TAG_RCOMPATFLAGS
else 'wflags' if (tag & 0xfff) == TAG_WFLAGS else 'wcompatflags' if (tag & 0xfff) == TAG_WCOMPATFLAGS
else 'oflags' if (tag & 0xfff) == TAG_OFLAGS
else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE else 'blocksize' if (tag & 0xfff) == TAG_BLOCKSIZE
else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT else 'blockcount' if (tag & 0xfff) == TAG_BLOCKCOUNT
else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT else 'sizelimit' if (tag & 0xfff) == TAG_SIZELIMIT