summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-28 11:03:37 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-29 18:21:22 -0600
commitfc462d13cb2f49b4c4745742dfaed994596a54b8 (patch)
tree3c78506ca4289822b65a9bdf1731edb888e9eb47
parent0b31e9fa29699bbf140e168a17ead1c993d42e3e (diff)
lib9p: idl: In bitfields, explicitly say "bit" or "alias"
-rw-r--r--lib9p/idl/1992-9P0.9p.wip54
-rw-r--r--lib9p/idl/1995-9P1.9p.wip2
-rw-r--r--lib9p/idl/2002-9P2000.9p76
-rw-r--r--lib9p/idl/2005-9P2000.u.9p12
-rw-r--r--lib9p/idl/2010-9P2000.L.9p170
-rw-r--r--lib9p/idl/__init__.py4
6 files changed, 159 insertions, 159 deletions
diff --git a/lib9p/idl/1992-9P0.9p.wip b/lib9p/idl/1992-9P0.9p.wip
index 968e887..360f320 100644
--- a/lib9p/idl/1992-9P0.9p.wip
+++ b/lib9p/idl/1992-9P0.9p.wip
@@ -37,41 +37,41 @@ struct errstr = "64*(txt[1])"
# "O"pen flags (flags to pass to Topen and Tcreate)
# Unused bits are *ignored*.
bitfield o = 1
- "0=subfield(mode)" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum
- "1=subfield(mode)" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum
- #"2=unused"
- #"3=unused"
- "4=TRUNC"
- "5=reserved(CEXEC)" # close-on-exec
- "6=RCLOSE" # remove-on-close
- #"7=unused"
+ "bit 0=subfield(mode)" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum
+ "bit 1=subfield(mode)" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum
+ #"bit 2=unused"
+ #"bit 3=unused"
+ "bit 4=TRUNC"
+ "bit 5=reserved(CEXEC)" # close-on-exec
+ "bit 6=RCLOSE" # remove-on-close
+ #"bit 7=unused"
- "READ = 0" # make available for this FID: Tread()
- "WRITE = 1" # make available for this FID: Twrite()
- "RDWR = 2" # make available for this FID: Tread() and Twrite()
- "EXEC = 3" # make available for this FID: Tread()
+ "alias READ = 0" # make available for this FID: Tread()
+ "alias WRITE = 1" # make available for this FID: Twrite()
+ "alias RDWR = 2" # make available for this FID: Tread() and Twrite()
+ "alias EXEC = 3" # make available for this FID: Tread()
- "MODE_MASK = 0b00000011"
- "FLAG_MASK = 0b11111100"
+ "alias MODE_MASK = 0b00000011"
+ "alias FLAG_MASK = 0b11111100"
# "CH"annel flags - file permissions and attributes (a "channel" is
# what a file handle is called inside of the Plan 9 kernel).
bitfield ch = 4
- "31=DIR"
- "30=APPEND"
- "29=EXCL"
+ "bit 31=DIR"
+ "bit 30=APPEND"
+ "bit 29=EXCL"
#...
- "8=OWNER_R"
- "7=OWNER_W"
- "6=OWNER_X"
- "5=GROUP_R"
- "4=GROUP_W"
- "3=GROUP_X"
- "2=OTHER_R"
- "1=OTHER_W"
- "0=OTHER_X"
+ "bit 8=OWNER_R"
+ "bit 7=OWNER_W"
+ "bit 6=OWNER_X"
+ "bit 5=GROUP_R"
+ "bit 4=GROUP_W"
+ "bit 3=GROUP_X"
+ "bit 2=OTHER_R"
+ "bit 1=OTHER_W"
+ "bit 0=OTHER_X"
- "PERM_MASK=0777" # {OWNER,GROUP,OTHER}_{R,W,X}
+ "alias PERM_MASK=0777" # {OWNER,GROUP,OTHER}_{R,W,X}
struct stat = "file_name[name]"
"file_owner[name]"
diff --git a/lib9p/idl/1995-9P1.9p.wip b/lib9p/idl/1995-9P1.9p.wip
index 765356c..660e24a 100644
--- a/lib9p/idl/1995-9P1.9p.wip
+++ b/lib9p/idl/1995-9P1.9p.wip
@@ -43,7 +43,7 @@ from ./1992-9P0.9p import tag, fid, qid, name, errstr, o, ch, stat
# draft RFC). As I understand it, CHMOUNT indicates that the file is
# mounted by the kernel as a 9P transport; that the kernel has a lock
# on doing I/O on it, so userspace can't do I/O on it.
-bitfield ch += "28=_PLAN9_MOUNT"
+bitfield ch += "bit 28=_PLAN9_MOUNT"
# Authentication uses DES encryption. The client obtains a ticket and
# a nonce-key from a separate auth-server; how it does this is beyond
diff --git a/lib9p/idl/2002-9P2000.9p b/lib9p/idl/2002-9P2000.9p
index c569c74..204b352 100644
--- a/lib9p/idl/2002-9P2000.9p
+++ b/lib9p/idl/2002-9P2000.9p
@@ -33,46 +33,46 @@ struct s = "len[2] len*(utf8[1])"
# "D"ir-entry "M"ode - file permissions and attributes
bitfield dm = 4
- "31=DIR"
- "30=APPEND"
- "29=EXCL"
+ "bit 31=DIR"
+ "bit 30=APPEND"
+ "bit 29=EXCL"
# DMMOUNT has been around in Plan 9 since 2e (CHMOUNT in <4e),
# but is undocumented, and is explicitly excluded from the
# 9P2000 draft RFC. As I understand it, DMMOUNT indicates
# that the file is mounted by the kernel as a 9P transport;
# that the kernel has a lock on doing I/O on it, so userspace
# can't do I/O on it.
- "28=_PLAN9_MOUNT"
- "27=AUTH"
- "26=TMP"
+ "bit 28=_PLAN9_MOUNT"
+ "bit 27=AUTH"
+ "bit 26=TMP"
#...
- "8=OWNER_R"
- "7=OWNER_W"
- "6=OWNER_X"
- "5=GROUP_R"
- "4=GROUP_W"
- "3=GROUP_X"
- "2=OTHER_R"
- "1=OTHER_W"
- "0=OTHER_X"
+ "bit 8=OWNER_R"
+ "bit 7=OWNER_W"
+ "bit 6=OWNER_X"
+ "bit 5=GROUP_R"
+ "bit 4=GROUP_W"
+ "bit 3=GROUP_X"
+ "bit 2=OTHER_R"
+ "bit 1=OTHER_W"
+ "bit 0=OTHER_X"
- "PERM_MASK=0777" # {OWNER,GROUP,OTHER}_{R,W,X}
+ "alias PERM_MASK=0777" # {OWNER,GROUP,OTHER}_{R,W,X}
# QID Type - see `struct qid` below
bitfield qt = 1
- "7=DIR"
- "6=APPEND"
- "5=EXCL"
- "4=_PLAN9_MOUNT" # See "_PLAN9_MOUNT" in "dm" above.
- "3=AUTH"
+ "bit 7=DIR"
+ "bit 6=APPEND"
+ "bit 5=EXCL"
+ "bit 4=_PLAN9_MOUNT" # See "_PLAN9_MOUNT" in "dm" above.
+ "bit 3=AUTH"
# Fun historical fact: QTTMP was a relatively late addition to
# Plan 9, in 2003-12.
- "2=TMP"
- #"1=unused"
+ "bit 2=TMP"
+ #"bit 1=unused"
# "The name QTFILE, defined to be zero, identifies the value
# of the type for a plain file."
- "FILE=0"
+ "alias FILE=0"
# uni"Q"ue "ID"entification - "two files on the same server hierarchy
# are the same if and only if their qids are the same"
@@ -107,22 +107,22 @@ struct stat = "stat_size[2,val=end-&kern_type]"
# "O"pen flags (flags to pass to Topen and Tcreate)
# Unused bits *must* be 0.
bitfield o = 1
- "0=subfield(mode)" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum
- "1=subfield(mode)" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum
- #"2=unused"
- #"3=unused"
- "4=TRUNC"
- "5=reserved(CEXEC)" # close-on-exec
- "6=RCLOSE" # remove-on-close
- #"7=unused"
+ "bit 0=subfield(mode)" # low bit of the 2-bit READ/WRITE/RDWR/EXEC enum
+ "bit 1=subfield(mode)" # high bit of the 2-bit READ/WRITE/RDWR/EXEC enum
+ #"bit 2=unused"
+ #"bit 3=unused"
+ "bit 4=TRUNC"
+ "bit 5=reserved(CEXEC)" # close-on-exec
+ "bit 6=RCLOSE" # remove-on-close
+ #"bit 7=unused"
- "READ = 0" # make available for this FID: Tread()
- "WRITE = 1" # make available for this FID: Twrite()
- "RDWR = 2" # make available for this FID: Tread() and Twrite()
- "EXEC = 3" # make available for this FID: Tread()
+ "alias READ = 0" # make available for this FID: Tread()
+ "alias WRITE = 1" # make available for this FID: Twrite()
+ "alias RDWR = 2" # make available for this FID: Tread() and Twrite()
+ "alias EXEC = 3" # make available for this FID: Tread()
- "MODE_MASK = 0b00000011"
- "FLAG_MASK = 0b11111100"
+ "alias MODE_MASK = 0b00000011"
+ "alias FLAG_MASK = 0b11111100"
# A 9P2000 session goes:
#
diff --git a/lib9p/idl/2005-9P2000.u.9p b/lib9p/idl/2005-9P2000.u.9p
index 1bf5070..72cc662 100644
--- a/lib9p/idl/2005-9P2000.u.9p
+++ b/lib9p/idl/2005-9P2000.u.9p
@@ -27,10 +27,10 @@ msg Tattach += "n_uid[nuid]"
msg Rerror += "errno[errno]"
-bitfield dm += "23=DEVICE"
- "21=PIPE"
- "20=SOCKET"
- "19=SETUID"
- "18=SETGID"
+bitfield dm += "bit 23=DEVICE"
+ "bit 21=PIPE"
+ "bit 20=SOCKET"
+ "bit 19=SETUID"
+ "bit 18=SETGID"
-bitfield qt += "1=SYMLINK"
+bitfield qt += "bit 1=SYMLINK"
diff --git a/lib9p/idl/2010-9P2000.L.9p b/lib9p/idl/2010-9P2000.L.9p
index 89af6a5..56fcd0d 100644
--- a/lib9p/idl/2010-9P2000.L.9p
+++ b/lib9p/idl/2010-9P2000.L.9p
@@ -39,35 +39,35 @@ num super_magic = 4
# protocol.h (and are different than the Linux kernel's values, which
# vary by architecture).
bitfield lo = 4
- "0=subfield(mode)" # low bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum
- "1=subfield(mode)" # high bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum
- #"2=unused"
- #"3=unused"
- #"4=unused"
- #"5=unused"
- "6=CREATE"
- "7=EXCL"
- "8=NOCTTY"
- "9=TRUNC"
- "10=APPEND"
- "11=NONBLOCK"
- "12=DSYNC"
- "13=BSD_FASYNC"
- "14=DIRECT"
- "15=LARGEFILE"
- "16=DIRECTORY"
- "17=NOFOLLOW"
- "18=NOATIME"
- "19=CLOEXEC"
- "20=SYNC"
-
- "RDONLY = 0"
- "WRONLY = 1"
- "RDWR = 2"
- "NOACCESS = 3"
-
- "MODE_MASK = 0b000000000000000000011"
- "FLAG_MASK = 0b111111111111111000000"
+ "bit 0=subfield(mode)" # low bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum
+ "bit 1=subfield(mode)" # high bit of the 2-bit RDONLY/WRONLY/RDWR/NOACCESS enum
+ #"bit 2=unused"
+ #"bit 3=unused"
+ #"bit 4=unused"
+ #"bit 5=unused"
+ "bit 6=CREATE"
+ "bit 7=EXCL"
+ "bit 8=NOCTTY"
+ "bit 9=TRUNC"
+ "bit 10=APPEND"
+ "bit 11=NONBLOCK"
+ "bit 12=DSYNC"
+ "bit 13=BSD_FASYNC"
+ "bit 14=DIRECT"
+ "bit 15=LARGEFILE"
+ "bit 16=DIRECTORY"
+ "bit 17=NOFOLLOW"
+ "bit 18=NOATIME"
+ "bit 19=CLOEXEC"
+ "bit 20=SYNC"
+
+ "alias RDONLY = 0"
+ "alias WRONLY = 1"
+ "alias RDWR = 2"
+ "alias NOACCESS = 3"
+
+ "alias MODE_MASK = 0b000000000000000000011"
+ "alias FLAG_MASK = 0b111111111111111000000"
# "D"irentry "T"ype
#
@@ -89,34 +89,34 @@ num dt = 1
# instead of just 16? Who knows?
bitfield mode = 4
#...
- "15=subfield(fmt)" # bit of the 4-bit FMT_ enum
- "14=subfield(fmt)" # bit of the 4-bit FMT_ enum
- "13=subfield(fmt)" # bit of the 4-bit FMT_ enum
- "12=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ "bit 15=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ "bit 14=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ "bit 13=subfield(fmt)" # bit of the 4-bit FMT_ enum
+ "bit 12=subfield(fmt)" # bit of the 4-bit FMT_ enum
#...
- "11=PERM_SETGROUP"
- "10=PERM_SETUSER"
- "9=PERM_STICKY"
- "8=PERM_OWNER_R"
- "7=PERM_OWNER_W"
- "6=PERM_OWNER_X"
- "5=PERM_GROUP_R"
- "4=PERM_GROUP_W"
- "3=PERM_GROUP_X"
- "2=PERM_OTHER_R"
- "1=PERM_OTHER_W"
- "0=PERM_OTHER_X"
-
- "FMT_PIPE = LIB9P_DT_PIPE<<12"
- "FMT_CHAR_DEV = LIB9P_DT_CHAR_DEV<<12"
- "FMT_DIRECTORY = LIB9P_DT_DIRECTORY<<12"
- "FMT_BLOCK_DEV = LIB9P_DT_BLOCK_DEV<<12"
- "FMT_REGULAR = LIB9P_DT_REGULAR<<12"
- "FMT_SYMLINK = LIB9P_DT_SYMLINK<<12"
- "FMT_SOCKET = LIB9P_DT_SOCKET<<12"
-
- "PERM_MASK = 0000777" # PERM_*
- "FMT_MASK = 0170000" # _fmt_*
+ "bit 11=PERM_SETGROUP"
+ "bit 10=PERM_SETUSER"
+ "bit 9=PERM_STICKY"
+ "bit 8=PERM_OWNER_R"
+ "bit 7=PERM_OWNER_W"
+ "bit 6=PERM_OWNER_X"
+ "bit 5=PERM_GROUP_R"
+ "bit 4=PERM_GROUP_W"
+ "bit 3=PERM_GROUP_X"
+ "bit 2=PERM_OTHER_R"
+ "bit 1=PERM_OTHER_W"
+ "bit 0=PERM_OTHER_X"
+
+ "alias FMT_PIPE = LIB9P_DT_PIPE<<12"
+ "alias FMT_CHAR_DEV = LIB9P_DT_CHAR_DEV<<12"
+ "alias FMT_DIRECTORY = LIB9P_DT_DIRECTORY<<12"
+ "alias FMT_BLOCK_DEV = LIB9P_DT_BLOCK_DEV<<12"
+ "alias FMT_REGULAR = LIB9P_DT_REGULAR<<12"
+ "alias FMT_SYMLINK = LIB9P_DT_SYMLINK<<12"
+ "alias FMT_SOCKET = LIB9P_DT_SOCKET<<12"
+
+ "alias PERM_MASK = 0000777" # PERM_*
+ "alias FMT_MASK = 0170000" # _fmt_*
# A boolean value that is for some reason 4 bytes wide.
num b4 = 4
@@ -125,35 +125,35 @@ num b4 = 4
# all other values are true also
bitfield getattr = 8
- "0=MODE"
- "1=NLINK"
- "2=UID"
- "3=GID"
- "4=RDEV"
- "5=ATIME"
- "6=MTIME"
- "7=CTIME"
- "8=INO"
- "9=SIZE"
- "10=BLOCKS"
-
- "11=BTIME"
- "12=GEN"
- "13=DATA_VERSION"
-
- "BASIC=0x000007ff" # Mask for fields up to BLOCKS
- "ALL =0x00003fff" # Mask for All fields above
+ "bit 0=MODE"
+ "bit 1=NLINK"
+ "bit 2=UID"
+ "bit 3=GID"
+ "bit 4=RDEV"
+ "bit 5=ATIME"
+ "bit 6=MTIME"
+ "bit 7=CTIME"
+ "bit 8=INO"
+ "bit 9=SIZE"
+ "bit 10=BLOCKS"
+
+ "bit 11=BTIME"
+ "bit 12=GEN"
+ "bit 13=DATA_VERSION"
+
+ "alias BASIC=0x000007ff" # Mask for fields up to BLOCKS
+ "alias ALL =0x00003fff" # Mask for All fields above
bitfield setattr = 4
- "0=MODE"
- "1=UID"
- "2=GID"
- "3=SIZE"
- "4=ATIME"
- "5=MTIME"
- "6=CTIME"
- "7=ATIME_SET"
- "8=MTIME_SET"
+ "bit 0=MODE"
+ "bit 1=UID"
+ "bit 2=GID"
+ "bit 3=SIZE"
+ "bit 4=ATIME"
+ "bit 5=MTIME"
+ "bit 6=CTIME"
+ "bit 7=ATIME_SET"
+ "bit 8=MTIME_SET"
num lock_type = 1
"RDLCK=0"
@@ -161,8 +161,8 @@ num lock_type = 1
"UNLCK=2"
bitfield lock_flags = 4
- "0=BLOCK"
- "1=RECLAIM"
+ "bit 0=BLOCK"
+ "bit 1=RECLAIM"
num lock_status = 1
"SUCCESS=0"
diff --git a/lib9p/idl/__init__.py b/lib9p/idl/__init__.py
index 6fa26b4..78246d2 100644
--- a/lib9p/idl/__init__.py
+++ b/lib9p/idl/__init__.py
@@ -297,7 +297,7 @@ re_expr = f"(?:(?:-|\\+|[0-9]+|&?{re_symname})+)"
re_numspec = f"(?P<name>{re_symname})\\s*=\\s*(?P<val>\\S+)"
re_bitspec_bit = (
- "(?P<bitnum>[0-9]+)\\s*=\\s*(?:"
+ "bit\\s+(?P<bitnum>[0-9]+)\\s*=\\s*(?:"
+ "|".join(
[
f"(?P<name_used>{re_symname_u})",
@@ -307,7 +307,7 @@ re_bitspec_bit = (
)
+ ")"
)
-re_bitspec_alias = f"(?P<name>{re_symname_u})\\s*=\\s*(?P<val>\\S+)"
+re_bitspec_alias = f"alias\\s+(?P<name>{re_symname_u})\\s*=\\s*(?P<val>\\S+)"
re_memberspec = f"(?:(?P<cnt>{re_symname}|[1-9][0-9]*)\\*\\()?(?P<name>{re_symname})\\[(?P<typ>{re_memtype})(?:,max=(?P<max>{re_expr})|,val=(?P<val>{re_expr}))*\\]\\)?"