scripts: dbgflags.py: Tweaked internals for readability

Mainly just using 'P_NAME' instead of 'P', 'NAME' in the FLAGS table,
every bit of horizontal spacing helps with these definitions.
This commit is contained in:
Christopher Haster
2025-07-04 13:52:17 -05:00
parent 19747f691e
commit 090611af14

View File

@@ -22,190 +22,171 @@ FILTERS = [
FLAGS = [ FLAGS = [
# File open flags # File open flags
('O', 'MODE', 3, "The file's access mode" ), ('O_MODE', 3, "The file's access mode" ),
('^', 'RDONLY', 0, "Open a file as read only" ), ('^_RDONLY', 0, "Open a file as read only" ),
('^', 'WRONLY', 1, "Open a file as write only" ), ('^_WRONLY', 1, "Open a file as write only" ),
('^', 'RDWR', 2, "Open a file as read and write" ), ('^_RDWR', 2, "Open a file as read and write" ),
('O', 'CREAT', 0x00000004, "Create a file if it does not exist" ), ('O_CREAT', 0x00000004, "Create a file if it does not exist" ),
('O', 'EXCL', 0x00000008, "Fail if a file already exists" ), ('O_EXCL', 0x00000008, "Fail if a file already exists" ),
('O', 'TRUNC', 0x00000010, "Truncate the existing file to zero size" ), ('O_TRUNC', 0x00000010, "Truncate the existing file to zero size" ),
('O', 'APPEND', 0x00000020, "Move to end of file on every write" ), ('O_APPEND', 0x00000020, "Move to end of file on every write" ),
('O', 'FLUSH', 0x00000040, "Flush data on every write" ), ('O_FLUSH', 0x00000040, "Flush data on every write" ),
('O', 'SYNC', 0x00000080, "Sync metadata on every write" ), ('O_SYNC', 0x00000080, "Sync metadata on every write" ),
('O', 'DESYNC', 0x04000000, "Do not sync or recieve file updates" ), ('O_DESYNC', 0x04000000, "Do not sync or recieve file updates" ),
('O', 'CKMETA', 0x00001000, "Check metadata checksums" ), ('O_CKMETA', 0x00001000, "Check metadata checksums" ),
('O', 'CKDATA', 0x00002000, "Check metadata + data checksums" ), ('O_CKDATA', 0x00002000, "Check metadata + data checksums" ),
('o', 'WRSET', 3, "Open a file as an atomic write" ), ('o_WRSET', 3, "Open a file as an atomic write" ),
('o', 'TYPE', 0xf0000000, "The file's type" ), ('o_TYPE', 0xf0000000, "The file's type" ),
('^', 'REG', 0x10000000, "Type = regular-file" ), ('^_REG', 0x10000000, "Type = regular-file" ),
('^', 'DIR', 0x20000000, "Type = directory" ), ('^_DIR', 0x20000000, "Type = directory" ),
('^', 'STICKYNOTE',0x30000000, "Type = stickynote" ), ('^_STICKYNOTE', 0x30000000, "Type = stickynote" ),
('^', 'BOOKMARK', 0x40000000, "Type = bookmark" ), ('^_BOOKMARK', 0x40000000, "Type = bookmark" ),
('^', 'ORPHAN', 0x50000000, "Type = orphan" ), ('^_ORPHAN', 0x50000000, "Type = orphan" ),
('^', 'TRAVERSAL', 0x60000000, "Type = traversal" ), ('^_TRAVERSAL', 0x60000000, "Type = traversal" ),
('^', 'UNKNOWN', 0x70000000, "Type = unknown" ), ('^_UNKNOWN', 0x70000000, "Type = unknown" ),
('o', 'ZOMBIE', 0x08000000, "File has been removed" ), ('o_ZOMBIE', 0x08000000, "File has been removed" ),
('o', 'UNCREAT', 0x02000000, "File does not exist yet" ), ('o_UNCREAT', 0x02000000, "File does not exist yet" ),
('o', 'UNSYNC', 0x01000000, "File's metadata does not match disk" ), ('o_UNSYNC', 0x01000000, "File's metadata does not match disk" ),
('o', 'UNCRYST', 0x00800000, "File's leaf not fully crystallized" ), ('o_UNCRYST', 0x00800000, "File's leaf not fully crystallized" ),
('o', 'UNFLUSH', 0x00400000, "File's cache does not match disk" ), ('o_UNFLUSH', 0x00400000, "File's cache does not match disk" ),
# Custom attribute flags # Custom attribute flags
('A', 'MODE', 3, "The attr's access mode" ), ('A_MODE', 3, "The attr's access mode" ),
('^', 'RDONLY', 0, "Open an attr as read only" ), ('^_RDONLY', 0, "Open an attr as read only" ),
('^', 'WRONLY', 1, "Open an attr as write only" ), ('^_WRONLY', 1, "Open an attr as write only" ),
('^', 'RDWR', 2, "Open an attr as read and write" ), ('^_RDWR', 2, "Open an attr as read and write" ),
('A', 'LAZY', 0x04, "Only write attr if file changed" ), ('A_LAZY', 0x04, "Only write attr if file changed" ),
# Filesystem format flags # Filesystem format flags
('F', 'MODE', 1, "Format's access mode" ), ('F_MODE', 1, "Format's access mode" ),
('^', 'RDWR', 0, "Format the filesystem as read and write" ), ('^_RDWR', 0, "Format the filesystem as read and write" ),
('F', 'REVDBG', 0x00000010, "Add debug info to revision counts" ), ('F_REVDBG', 0x00000010, "Add debug info to revision counts" ),
('F', 'REVNOISE', 0x00000020, "Add noise to revision counts" ), ('F_REVNOISE', 0x00000020, "Add noise to revision counts" ),
('F', 'CKPROGS', 0x00080000, "Check progs by reading back progged data" ), ('F_CKPROGS', 0x00080000, "Check progs by reading back progged data" ),
('F', 'CKFETCHES', 0x00100000, "Check block checksums before first use" ), ('F_CKFETCHES', 0x00100000, "Check block checksums before first use" ),
('F', 'CKMETAPARITY', ('F_CKMETAPARITY', 0x00200000, "Check metadata tag parity bits" ),
0x00200000, "Check metadata tag parity bits" ), ('F_CKDATACKSUMREADS',
('F', 'CKDATACKSUMREADS',
0x00800000, "Check data checksums on reads" ), 0x00800000, "Check data checksums on reads" ),
('F', 'CKMETA', 0x00001000, "Check metadata checksums" ), ('F_CKMETA', 0x00001000, "Check metadata checksums" ),
('F', 'CKDATA', 0x00002000, "Check metadata + data checksums" ), ('F_CKDATA', 0x00002000, "Check metadata + data checksums" ),
# Filesystem mount flags # Filesystem mount flags
('M', 'MODE', 1, "Mount's access mode" ), ('M_MODE', 1, "Mount's access mode" ),
('^', 'RDWR', 0, "Mount the filesystem as read and write" ), ('^_RDWR', 0, "Mount the filesystem as read and write" ),
('^', 'RDONLY', 1, "Mount the filesystem as read only" ), ('^_RDONLY', 1, "Mount the filesystem as read only" ),
('M', 'FLUSH', 0x00000040, "Open all files with LFS3_O_FLUSH" ), ('M_FLUSH', 0x00000040, "Open all files with LFS3_O_FLUSH" ),
('M', 'SYNC', 0x00000080, "Open all files with LFS3_O_SYNC" ), ('M_SYNC', 0x00000080, "Open all files with LFS3_O_SYNC" ),
('M', 'REVDBG', 0x00000010, "Add debug info to revision counts" ), ('M_REVDBG', 0x00000010, "Add debug info to revision counts" ),
('M', 'REVNOISE', 0x00000020, "Add noise to revision counts" ), ('M_REVNOISE', 0x00000020, "Add noise to revision counts" ),
('M', 'CKPROGS', 0x00080000, "Check progs by reading back progged data" ), ('M_CKPROGS', 0x00080000, "Check progs by reading back progged data" ),
('M', 'CKFETCHES', 0x00100000, "Check block checksums before first use" ), ('M_CKFETCHES', 0x00100000, "Check block checksums before first use" ),
('M', 'CKMETAPARITY', ('M_CKMETAPARITY', 0x00200000, "Check metadata tag parity bits" ),
0x00200000, "Check metadata tag parity bits" ), ('M_CKDATACKSUMREADS',
('M', 'CKDATACKSUMREADS',
0x00800000, "Check data checksums on reads" ), 0x00800000, "Check data checksums on reads" ),
('M', 'MKCONSISTENT', ('M_MKCONSISTENT', 0x00000100, "Make the filesystem consistent" ),
0x00000100, "Make the filesystem consistent" ), ('M_LOOKAHEAD', 0x00000200, "Populate lookahead buffer" ),
('M', 'LOOKAHEAD', 0x00000200, "Populate lookahead buffer" ), ('M_COMPACT', 0x00000800, "Compact metadata logs" ),
('M', 'COMPACT', 0x00000800, "Compact metadata logs" ), ('M_CKMETA', 0x00001000, "Check metadata checksums" ),
('M', 'CKMETA', 0x00001000, "Check metadata checksums" ), ('M_CKDATA', 0x00002000, "Check metadata + data checksums" ),
('M', 'CKDATA', 0x00002000, "Check metadata + data checksums" ),
# GC flags # GC flags
('GC', 'MKCONSISTENT', ('GC_MKCONSISTENT',0x00000100, "Make the filesystem consistent" ),
0x00000100, "Make the filesystem consistent" ), ('GC_LOOKAHEAD', 0x00000200, "Populate lookahead buffer" ),
('GC', 'LOOKAHEAD',0x00000200, "Populate lookahead buffer" ), ('GC_COMPACT', 0x00000800, "Compact metadata logs" ),
('GC', 'COMPACT', 0x00000800, "Compact metadata logs" ), ('GC_CKMETA', 0x00001000, "Check metadata checksums" ),
('GC', 'CKMETA', 0x00001000, "Check metadata checksums" ), ('GC_CKDATA', 0x00002000, "Check metadata + data checksums" ),
('GC', 'CKDATA', 0x00002000, "Check metadata + data checksums" ),
# Filesystem info flags # Filesystem info flags
('I', 'RDONLY', 0x00000001, "Mounted read only" ), ('I_RDONLY', 0x00000001, "Mounted read only" ),
('I', 'FLUSH', 0x00000040, "Mounted with LFS3_M_FLUSH" ), ('I_FLUSH', 0x00000040, "Mounted with LFS3_M_FLUSH" ),
('I', 'SYNC', 0x00000080, "Mounted with LFS3_M_SYNC" ), ('I_SYNC', 0x00000080, "Mounted with LFS3_M_SYNC" ),
('I', 'REVDBG', 0x00000010, "Mounted with LFS3_M_REVDBG" ), ('I_REVDBG', 0x00000010, "Mounted with LFS3_M_REVDBG" ),
('I', 'REVNOISE', 0x00000020, "Mounted with LFS3_M_REVNOISE" ), ('I_REVNOISE', 0x00000020, "Mounted with LFS3_M_REVNOISE" ),
('I', 'CKPROGS', 0x00080000, "Mounted with LFS3_M_CKPROGS" ), ('I_CKPROGS', 0x00080000, "Mounted with LFS3_M_CKPROGS" ),
('I', 'CKFETCHES', 0x00100000, "Mounted with LFS3_M_CKFETCHES" ), ('I_CKFETCHES', 0x00100000, "Mounted with LFS3_M_CKFETCHES" ),
('I', 'CKMETAPARITY', ('I_CKMETAPARITY', 0x00200000, "Mounted with LFS3_M_CKMETAPARITY" ),
0x00200000, "Mounted with LFS3_M_CKMETAPARITY" ), ('I_CKDATACKSUMREADS',
('I', 'CKDATACKSUMREADS',
0x00800000, "Mounted with LFS3_M_CKDATACKSUMREADS" ), 0x00800000, "Mounted with LFS3_M_CKDATACKSUMREADS" ),
('I', 'MKCONSISTENT',
0x00000100, "Filesystem needs mkconsistent to write" ),
('I', 'LOOKAHEAD', 0x00000200, "Lookahead buffer is not full" ),
('I', 'COMPACT', 0x00000800, "Filesystem may have uncompacted metadata" ),
('I', 'CKMETA', 0x00001000, "Metadata checksums not checked recently" ),
('I', 'CKDATA', 0x00002000, "Data checksums not checked recently" ),
('i', 'INMTREE', 0x08000000, "Committing to mtree" ), ('I_MKCONSISTENT', 0x00000100, "Filesystem needs mkconsistent to write" ),
('I_LOOKAHEAD', 0x00000200, "Lookahead buffer is not full" ),
('I_COMPACT', 0x00000800, "Filesystem may have uncompacted metadata" ),
('I_CKMETA', 0x00001000, "Metadata checksums not checked recently" ),
('I_CKDATA', 0x00002000, "Data checksums not checked recently" ),
('i_INMTREE', 0x08000000, "Committing to mtree" ),
# Traversal flags # Traversal flags
('T', 'MODE', 1, "The traversal's access mode" ), ('T_MODE', 1, "The traversal's access mode" ),
('^', 'RDWR', 0, "Open traversal as read and write" ), ('^_RDWR', 0, "Open traversal as read and write" ),
('^', 'RDONLY', 1, "Open traversal as read only" ), ('^_RDONLY', 1, "Open traversal as read only" ),
('T', 'MTREEONLY', 0x00000002, "Only traverse the mtree" ), ('T_MTREEONLY', 0x00000002, "Only traverse the mtree" ),
('T', 'MKCONSISTENT', ('T_MKCONSISTENT',
0x00000100, "Make the filesystem consistent" ), 0x00000100, "Make the filesystem consistent" ),
('T', 'LOOKAHEAD', 0x00000200, "Populate lookahead buffer" ), ('T_LOOKAHEAD', 0x00000200, "Populate lookahead buffer" ),
('T', 'COMPACT', 0x00000800, "Compact metadata logs" ), ('T_COMPACT', 0x00000800, "Compact metadata logs" ),
('T', 'CKMETA', 0x00001000, "Check metadata checksums" ), ('T_CKMETA', 0x00001000, "Check metadata checksums" ),
('T', 'CKDATA', 0x00002000, "Check metadata + data checksums" ), ('T_CKDATA', 0x00002000, "Check metadata + data checksums" ),
('t', 'TYPE', 0xf0000000, "The traversal's type" ), ('t_TYPE', 0xf0000000, "The traversal's type" ),
('^', 'REG', 0x10000000, "Type = regular-file" ), ('^_REG', 0x10000000, "Type = regular-file" ),
('^', 'DIR', 0x20000000, "Type = directory" ), ('^_DIR', 0x20000000, "Type = directory" ),
('^', 'STICKYNOTE',0x30000000, "Type = stickynote" ), ('^_STICKYNOTE', 0x30000000, "Type = stickynote" ),
('^', 'BOOKMARK', 0x40000000, "Type = bookmark" ), ('^_BOOKMARK', 0x40000000, "Type = bookmark" ),
('^', 'ORPHAN', 0x50000000, "Type = orphan" ), ('^_ORPHAN', 0x50000000, "Type = orphan" ),
('^', 'TRAVERSAL', 0x60000000, "Type = traversal" ), ('^_TRAVERSAL', 0x60000000, "Type = traversal" ),
('^', 'UNKNOWN', 0x70000000, "Type = unknown" ), ('^_UNKNOWN', 0x70000000, "Type = unknown" ),
('t', 'TSTATE', 0x000f0000, "The current traversal state" ), ('t_TSTATE', 0x000f0000, "The current traversal state" ),
('^', 'MROOTANCHOR', ('^_MROOTANCHOR',
0x00000000, "Tstate = mroot-anchor" ), 0x00000000, "Tstate = mroot-anchor" ),
('^', 'MROOTCHAIN',0x00010000, "Tstate = mroot-chain" ), ('^_MROOTCHAIN', 0x00010000, "Tstate = mroot-chain" ),
('^', 'MTREE', 0x00020000, "Tstate = mtree" ), ('^_MTREE', 0x00020000, "Tstate = mtree" ),
('^', 'MDIRS', 0x00030000, "Tstate = mtree-mdirs" ), ('^_MDIRS', 0x00030000, "Tstate = mtree-mdirs" ),
('^', 'MDIR', 0x00040000, "Tstate = mdir" ), ('^_MDIR', 0x00040000, "Tstate = mdir" ),
('^', 'BTREE', 0x00050000, "Tstate = btree" ), ('^_BTREE', 0x00050000, "Tstate = btree" ),
('^', 'OMDIRS', 0x00060000, "Tstate = open-mdirs" ), ('^_OMDIRS', 0x00060000, "Tstate = open-mdirs" ),
('^', 'OBTREE', 0x00070000, "Tstate = open-btree" ), ('^_OBTREE', 0x00070000, "Tstate = open-btree" ),
('^', 'DONE', 0x00080000, "Tstate = done" ), ('^_DONE', 0x00080000, "Tstate = done" ),
('t', 'BTYPE', 0x00f00000, "The current block type" ), ('t_BTYPE', 0x00f00000, "The current block type" ),
('^', 'MDIR', 0x00100000, "Btype = mdir" ), ('^_MDIR', 0x00100000, "Btype = mdir" ),
('^', 'BTREE', 0x00200000, "Btype = btree" ), ('^_BTREE', 0x00200000, "Btype = btree" ),
('^', 'DATA', 0x00300000, "Btype = data" ), ('^_DATA', 0x00300000, "Btype = data" ),
('t', 'ZOMBIE', 0x08000000, "File has been removed" ), ('t_ZOMBIE', 0x08000000, "File has been removed" ),
('t', 'DIRTY', 0x02000000, "Filesystem modified during traversal" ), ('t_DIRTY', 0x02000000, "Filesystem modified during traversal" ),
('t', 'MUTATED', 0x01000000, "Filesystem modified by traversal" ), ('t_MUTATED', 0x01000000, "Filesystem modified by traversal" ),
# Read-compat flags # Read-compat flags
('RCOMPAT', 'NONSTANDARD', ('RCOMPAT_NONSTANDARD',
0x00000001, "Non-standard filesystem format" ), 0x00000001, "Non-standard filesystem format" ),
('RCOMPAT', 'WRONLY', ('RCOMPAT_WRONLY', 0x00000002, "Reading is disallowed" ),
0x00000002, "Reading is disallowed" ), ('RCOMPAT_BMOSS', 0x00000010, "Files may use inlined data" ),
('RCOMPAT', 'BMOSS', ('RCOMPAT_BSPROUT',0x00000020, "Files may use block pointers" ),
0x00000010, "Files may use inlined data" ), ('RCOMPAT_BSHRUB', 0x00000040, "Files may use inlined btrees" ),
('RCOMPAT', 'BSPROUT', ('RCOMPAT_BTREE', 0x00000080, "Files may use btrees" ),
0x00000020, "Files may use block pointers" ), ('RCOMPAT_MMOSS', 0x00000100, "May use an inlined mdir" ),
('RCOMPAT', 'BSHRUB', ('RCOMPAT_MSPROUT',0x00000200, "May use an mdir pointer" ),
0x00000040, "Files may use inlined btrees" ), ('RCOMPAT_MSHRUB', 0x00000400, "May use an inlined mtree" ),
('RCOMPAT', 'BTREE', ('RCOMPAT_MTREE', 0x00000800, "May use an mdir btree" ),
0x00000080, "Files may use btrees" ), ('RCOMPAT_GRM', 0x00001000, "Global-remove in use" ),
('RCOMPAT', 'MMOSS', ('rcompat_OVERFLOW',
0x00000100, "May use an inlined mdir" ),
('RCOMPAT', 'MSPROUT',
0x00000200, "May use an mdir pointer" ),
('RCOMPAT', 'MSHRUB',
0x00000400, "May use an inlined mtree" ),
('RCOMPAT', 'MTREE',
0x00000800, "May use an mdir btree" ),
('RCOMPAT', 'GRM',
0x00001000, "Global-remove in use" ),
('rcompat', 'OVERFLOW',
0x80000000, "Can't represent all flags" ), 0x80000000, "Can't represent all flags" ),
# Write-compat flags # Write-compat flags
('WCOMPAT', 'NONSTANDARD', ('WCOMPAT_NONSTANDARD',
0x00000001, "Non-standard filesystem format" ), 0x00000001, "Non-standard filesystem format" ),
('WCOMPAT', 'RDONLY', ('WCOMPAT_RDONLY', 0x00000002, "Writing is disallowed" ),
0x00000002, "Writing is disallowed" ), ('WCOMPAT_DIR', 0x00000010, "Directory file types in use" ),
('WCOMPAT', 'DIR', ('WCOMPAT_GCKSUM', 0x00001000, "Global-checksum in use" ),
0x00000010, "Directory file types in use" ), ('wcompat_OVERFLOW',
('WCOMPAT', 'GCKSUM',
0x00001000, "Global-checksum in use" ),
('wcompat', 'OVERFLOW',
0x80000000, "Can't represent all flags" ), 0x80000000, "Can't represent all flags" ),
# Optional-compat flags # Optional-compat flags
('OCOMPAT', 'NONSTANDARD', ('OCOMPAT_NONSTANDARD',
0x00000001, "Non-standard filesystem format" ), 0x00000001, "Non-standard filesystem format" ),
('ocompat', 'OVERFLOW', ('ocompat_OVERFLOW',
0x80000000, "Can't represent all flags" ), 0x80000000, "Can't represent all flags" ),
] ]
@@ -223,7 +204,8 @@ def main(flags, *,
filter__ = set(filter_) filter__ = set(filter_)
flags__ = [] flags__ = []
types__ = co.defaultdict(lambda: set()) types__ = co.defaultdict(lambda: set())
for p, n, f, h in FLAGS: for n, f, h in FLAGS:
p, n = n.split('_', 1)
if p == '^': if p == '^':
p = last_p p = last_p
t = last_t t = last_t
@@ -232,6 +214,7 @@ def main(flags, *,
t = None t = None
last_p = p last_p = p
last_t = f last_t = f
if not filter__ or p.upper() in filter__: if not filter__ or p.upper() in filter__:
flags__.append((p, t, n, f, h)) flags__.append((p, t, n, f, h))