# lib9p/idl/2010-9P2000.L.9p - Definitions of 9P2000.L messages # # Copyright (C) 2024-2025 Luke T. Shumaker # SPDX-License-Identifier: AGPL-3.0-or-later # "9P2000.L" Linux extension # https://github.com/chaos/diod/blob/master/protocol.md # https://github.com/chaos/diod/blob/master/src/libnpfs/protocol.h version "9P2000.L" from ./2002-9P2000.9p import tag, fid, s, qt, qid from ./2002-9P2000.9p import Rerror from ./2002-9P2000.9p import Tversion, Rversion, Tflush, Rflush, Twalk, Rwalk, Tread, Rread, Twrite, Rwrite, Tclunk, Rclunk, Tremove, Rremove from ./2005-9P2000.u.9p import nuid, errno, Tauth, Rauth, Tattach, Rattach #num errno += # TODO num super_magic = 4 # See (linux.git include/uapi/linux/magic.h). # # To quote `util-linux.git:include/statfs_magic.h`: # "Unfortunately, Linux kernel header file is # incomplete mess and kernel returns by statfs f_type many numbers # that are nowhere specified (in API)." # # util-linux is also incomplete. As is the # statfs(2) man-page. # # I'm working on a patchset to the kernel to get # to be complete, but in the mean-time I'm just not going to # bother with putting a list here. # # TODO "V9FS_MAGIC=0x01021997" # "L"inux "O"pen flags (flags to pass to Tlopen and Tlcreate) # # The values are not specified in in protocol.md, but are specified in # 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" # "D"irentry "T"ype # # These match the Linux kernel's values. num dt = 1 "UNKNOWN = 0" "NAMED_PIPE = 1" "CHAR_DEV = 2" "DIRECTORY = 4" "BLOCK_DEV = 6" "REGULAR = 8" "SYMLINK = 10" "SOCKET = 12" "WHITEOUT = 14" # Mode # # These match the Linux kernel's values. Why is this 32-bits wide # 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 #... "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_NAMED_PIPE = LIB9P_DT_NAMED_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_* # A boolean value that is for some reason 4 bytes wide. num b4 = 4 "FALSE=0" "TRUE=1" # 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 bitfield setattr = 4 "0=MODE" "1=UID" "2=GID" "3=SIZE" "4=ATIME" "5=MTIME" "6=CTIME" "7=ATIME_SET" "8=MTIME_SET" num lock_type = 1 "RDLCK=0" "WRLCK=1" "UNLCK=2" bitfield lock_flags = 4 "0=BLOCK" "1=RECLAIM" num lock_status = 1 "SUCCESS=0" "BLOCKED=1" "ERROR=2" "GRACE=3" #msg Tlerror = "size[4,val=end-&size] typ[1,val=6] tag[tag] illegal" # analogous to 106/Terror msg Rlerror = "size[4,val=end-&size] typ[1,val=7] tag[tag] ecode[errno]" # analogous to 107/Rerror msg Tstatfs = "size[4,val=end-&size] typ[1,val=8] tag[tag] fid[fid]" msg Rstatfs = "size[4,val=end-&size] typ[1,val=9] tag[tag]" # Description | statfs | statvfs "type[super_magic]" # Type of filesystem | f_type | - "bsize[4]" # Block size in bytes | f_bsize | f_bsize # - # Fragment size in bytes | f_frsize (since Linux 2.6) | f_frsize "blocks[8]" # Size of FS in f_frsize units | f_blocks | f_blocks "bfree[8]" # Number of free blocks | f_bfree | f_bfree "bavail[8]" # Number of free blocks for unprivileged users | f_bavail | b_avail "files[8]" # Number of inodes | f_files | f_files "ffree[8]" # Number of free inodes | f_ffree | f_ffree # - # Number of free inodes for unprivileged users | - | f_favail "fsid[8]" # Filesystem instance ID | f_fsid | f_fsid # - # Mount flags | f_flags (since Linux 2.6.36) | f_flag "namelen[4]" # Maximum filename length | f_namemax | f_namemax msg Tlopen = "size[4,val=end-&size] typ[1,val=12] tag[tag] fid[fid] flags[lo]" # analogous to 112/Topen msg Rlopen = "size[4,val=end-&size] typ[1,val=13] tag[tag] qid[qid] iounit[4]" # analogous to 113/Ropen msg Tlcreate = "size[4,val=end-&size] typ[1,val=14] tag[tag] fid[fid] name[s] flags[lo] mode[mode] gid[nuid]" # analogous to 114/Tcreate msg Rlcreate = "size[4,val=end-&size] typ[1,val=15] tag[tag] qid[qid] iounit[4]" # analogous to 115/Rcreate msg Tsymlink = "size[4,val=end-&size] typ[1,val=16] tag[tag] fid[fid] name[s] symtgt[s] gid[nuid]" msg Rsymlink = "size[4,val=end-&size] typ[1,val=17] tag[tag] qid[qid]" msg Tmknod = "size[4,val=end-&size] typ[1,val=18] tag[tag] dfid[fid] name[s] mode[mode] major[4] minor[4] gid[nuid]" msg Rmknod = "size[4,val=end-&size] typ[1,val=19] tag[tag] qid[qid]" msg Trename = "size[4,val=end-&size] typ[1,val=20] tag[tag] fid[fid] dfid[fid] name[s]" msg Rrename = "size[4,val=end-&size] typ[1,val=21] tag[tag]" msg Treadlink = "size[4,val=end-&size] typ[1,val=22] tag[tag] fid[fid]" msg Rreadlink = "size[4,val=end-&size] typ[1,val=23] tag[tag] target[s]" msg Tgetattr = "size[4,val=end-&size] typ[1,val=24] tag[tag] fid[fid] request_mask[getattr]" msg Rgetattr = "size[4,val=end-&size] typ[1,val=25] tag[tag] valid[getattr] qid[qid] mode[mode] uid[nuid] gid[nuid] nlink[8]" "rdev[8] filesize[8] blksize[8] blocks[8]" "atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]" "ctime_sec[8] ctime_nsec[8] btime_sec[8] btime_nsec[8]" "gen[8] data_version[8]" msg Tsetattr = "size[4,val=end-&size] typ[1,val=26] tag[tag] fid[fid] valid[setattr] mode[mode] uid[nuid] gid[nuid] filesize[8] atime_sec[8] atime_nsec[8] mtime_sec[8] mtime_nsec[8]" msg Rsetattr = "size[4,val=end-&size] typ[1,val=27] tag[tag]" #... msg Txattrwalk = "size[4,val=end-&size] typ[1,val=30] tag[tag] fid[fid] newfid[fid] name[s]" msg Rxattrwalk = "size[4,val=end-&size] typ[1,val=31] tag[tag] attr_size[8]" msg Txattrcreate = "size[4,val=end-&size] typ[1,val=32] tag[tag] fid[fid] name[s] attr_size[8] flags[4]" msg Rxattrcreate = "size[4,val=end-&size] typ[1,val=33] tag[tag]" #... msg Treaddir = "size[4,val=end-&size] typ[1,val=40] tag[tag] fid[fid] offset[8] count[4]" msg Rreaddir = "size[4,val=end-&size] typ[1,val=41] tag[tag] count[4] count*(data[1])" # data is "qid[qid] offset[8] type[dt] name[s]" #... msg Tfsync = "size[4,val=end-&size] typ[1,val=50] tag[tag] fid[fid] datasync[b4]" msg Rfsync = "size[4,val=end-&size] typ[1,val=51] tag[tag]" msg Tlock = "size[4,val=end-&size] typ[1,val=52] tag[tag] fid[fid] type[lock_type] flags[lock_flags] start[8] length[8] proc_id[4] client_id[s]" msg Rlock = "size[4,val=end-&size] typ[1,val=53] tag[tag] status[lock_status]" msg Tgetlock = "size[4,val=end-&size] typ[1,val=54] tag[tag] fid[fid] type[lock_type] start[8] length[8] proc_id[4] client_id[s]" msg Rgetlock = "size[4,val=end-&size] typ[1,val=55] tag[tag] type[lock_type] start[8] length[8] proc_id[4] client_id[s]" # ... msg Tlink = "size[4,val=end-&size] typ[1,val=70] tag[tag] dfid[fid] fid[fid] name[s]" msg Rlink = "size[4,val=end-&size] typ[1,val=71] tag[tag]" msg Tmkdir = "size[4,val=end-&size] typ[1,val=72] tag[tag] dfid[fid] name[s] mode[mode] gid[nuid]" msg Rmkdir = "size[4,val=end-&size] typ[1,val=73] tag[tag] qid[qid]" msg Trenameat = "size[4,val=end-&size] typ[1,val=74] tag[tag] olddirfid[fid] oldname[s] newdirfid[fid] newname[s]" msg Rrenameat = "size[4,val=end-&size] typ[1,val=75] tag[tag]" msg Tunlinkat = "size[4,val=end-&size] typ[1,val=76] tag[tag] dirfd[fid] name[s] flags[4]" msg Runlinkat = "size[4,val=end-&size] typ[1,val=77] tag[tag]"