| 1 |
|
| 2 | |
| 3 | * 9P protocol definitions.
|
| 4 | *
|
| 5 | * Copyright (C) 2005 by Latchesar Ionkov <[email protected]>
|
| 6 | * Copyright (C) 2004 by Eric Van Hensbergen <[email protected]>
|
| 7 | * Copyright (C) 2002 by Ron Minnich <[email protected]>
|
| 8 |
|
| 9 |
|
| 10 | #ifndef NET_9P_H
|
| 11 | #define NET_9P_H
|
| 12 |
|
| 13 | |
| 14 | * enum p9_debug_flags - bits for mount time debug parameter
|
| 15 | * @P9_DEBUG_ERROR: more verbose error messages including original error string
|
| 16 | * @P9_DEBUG_9P: 9P protocol tracing
|
| 17 | * @P9_DEBUG_VFS: VFS API tracing
|
| 18 | * @P9_DEBUG_CONV: protocol conversion tracing
|
| 19 | * @P9_DEBUG_MUX: trace management of concurrent transactions
|
| 20 | * @P9_DEBUG_TRANS: transport tracing
|
| 21 | * @P9_DEBUG_SLABS: memory management tracing
|
| 22 | * @P9_DEBUG_FCALL: verbose dump of protocol messages
|
| 23 | * @P9_DEBUG_FID: fid allocation/deallocation tracking
|
| 24 | * @P9_DEBUG_PKT: packet marshalling/unmarshalling
|
| 25 | * @P9_DEBUG_FSC: FS-cache tracing
|
| 26 | * @P9_DEBUG_VPKT: Verbose packet debugging (full packet dump)
|
| 27 | * @P9_DEBUG_CACHE: cache operations tracing
|
| 28 | * @P9_DEBUG_MMAP: memory-mapped I/O tracing
|
| 29 | *
|
| 30 | * These flags are passed at mount time to turn on various levels of
|
| 31 | * verbosity and tracing which will be output to the system logs.
|
| 32 |
|
| 33 |
|
| 34 | enum p9_debug_flags {
|
| 35 | P9_DEBUG_ERROR = (1<<0),
|
| 36 | P9_DEBUG_9P = (1<<2),
|
| 37 | P9_DEBUG_VFS = (1<<3),
|
| 38 | P9_DEBUG_CONV = (1<<4),
|
| 39 | P9_DEBUG_MUX = (1<<5),
|
| 40 | P9_DEBUG_TRANS = (1<<6),
|
| 41 | P9_DEBUG_SLABS = (1<<7),
|
| 42 | P9_DEBUG_FCALL = (1<<8),
|
| 43 | P9_DEBUG_FID = (1<<9),
|
| 44 | P9_DEBUG_PKT = (1<<10),
|
| 45 | P9_DEBUG_FSC = (1<<11),
|
| 46 | P9_DEBUG_VPKT = (1<<12),
|
| 47 | P9_DEBUG_CACHE = (1<<13),
|
| 48 | P9_DEBUG_MMAP = (1<<14),
|
| 49 | };
|
| 50 |
|
| 51 | #ifdef CONFIG_NET_9P_DEBUG
|
| 52 | extern unsigned int p9_debug_level;
|
| 53 | __printf(3, 4)
|
| 54 | void _p9_debug(enum p9_debug_flags level, const char *func,
|
| 55 | const char *fmt, ...);
|
| 56 | #define p9_debug(level, fmt, ...) \
|
| 57 | _p9_debug(level, __func__, fmt, ##__VA_ARGS__)
|
| 58 | #else
|
| 59 | #define p9_debug(level, fmt, ...) \
|
| 60 | no_printk(fmt, ##__VA_ARGS__)
|
| 61 | #endif
|
| 62 |
|
| 63 | |
| 64 | * enum p9_msg_t - 9P message types
|
| 65 | * @P9_TLERROR: not used
|
| 66 | * @P9_RLERROR: response for any failed request for 9P2000.L
|
| 67 | * @P9_TSTATFS: file system status request
|
| 68 | * @P9_RSTATFS: file system status response
|
| 69 | * @P9_TSYMLINK: make symlink request
|
| 70 | * @P9_RSYMLINK: make symlink response
|
| 71 | * @P9_TMKNOD: create a special file object request
|
| 72 | * @P9_RMKNOD: create a special file object response
|
| 73 | * @P9_TLOPEN: open a file for I/O (9P2000.L)
|
| 74 | * @P9_RLOPEN: response with qid and iounit (9P2000.L)
|
| 75 | * @P9_TLCREATE: prepare a handle for I/O on an new file for 9P2000.L
|
| 76 | * @P9_RLCREATE: response with file access information for 9P2000.L
|
| 77 | * @P9_TRENAME: rename request
|
| 78 | * @P9_RRENAME: rename response
|
| 79 | * @P9_TREADLINK: read symbolic link target (9P2000.L)
|
| 80 | * @P9_RREADLINK: response with symbolic link target (9P2000.L)
|
| 81 | * @P9_TGETATTR: get file attributes request (9P2000.L)
|
| 82 | * @P9_RGETATTR: get file attributes response (9P2000.L)
|
| 83 | * @P9_TSETATTR: set file attributes request (9P2000.L)
|
| 84 | * @P9_RSETATTR: set file attributes response (9P2000.L)
|
| 85 | * @P9_TXATTRWALK: prepare to read/list extended attributes (9P2000.L)
|
| 86 | * @P9_RXATTRWALK: response with extended attribute size (9P2000.L)
|
| 87 | * @P9_TXATTRCREATE: prepare to set extended attribute (9P2000.L)
|
| 88 | * @P9_RXATTRCREATE: set extended attribute response (9P2000.L)
|
| 89 | * @P9_TREADDIR: read directory entries request (9P2000.L)
|
| 90 | * @P9_RREADDIR: read directory entries response (9P2000.L)
|
| 91 | * @P9_TFSYNC: flush cached file data to storage request (9P2000.L)
|
| 92 | * @P9_RFSYNC: flush cached file data to storage response (9P2000.L)
|
| 93 | * @P9_TLOCK: acquire or release a POSIX record lock (9P2000.L)
|
| 94 | * @P9_RLOCK: POSIX record lock response (9P2000.L)
|
| 95 | * @P9_TGETLOCK: test for existence of POSIX record lock (9P2000.L)
|
| 96 | * @P9_RGETLOCK: POSIX record lock test response (9P2000.L)
|
| 97 | * @P9_TLINK: create a hard link (9P2000.L)
|
| 98 | * @P9_RLINK: hard link response (9P2000.L)
|
| 99 | * @P9_TRENAMEAT: safely rename across directories (9P2000.L)
|
| 100 | * @P9_RRENAMEAT: rename response (9P2000.L)
|
| 101 | * @P9_TUNLINKAT: unlink a file or directory (9P2000.L)
|
| 102 | * @P9_RUNLINKAT: unlink response (9P2000.L)
|
| 103 | * @P9_TMKDIR: create a directory request (9P2000.L)
|
| 104 | * @P9_RMKDIR: create a directory response (9P2000.L)
|
| 105 | * @P9_TVERSION: negotiate protocol version and message size
|
| 106 | * @P9_RVERSION: version handshake response
|
| 107 | * @P9_TAUTH: request to establish authentication channel
|
| 108 | * @P9_RAUTH: response with authentication information
|
| 109 | * @P9_TATTACH: establish user access to file service
|
| 110 | * @P9_RATTACH: response with top level handle to file hierarchy
|
| 111 | * @P9_TERROR: not used
|
| 112 | * @P9_RERROR: response for any failed request
|
| 113 | * @P9_TFLUSH: request to abort a previous request
|
| 114 | * @P9_RFLUSH: response when previous request has been cancelled
|
| 115 | * @P9_TWALK: descend a directory hierarchy
|
| 116 | * @P9_RWALK: response with new handle for position within hierarchy
|
| 117 | * @P9_TOPEN: prepare a handle for I/O on an existing file
|
| 118 | * @P9_ROPEN: response with file access information
|
| 119 | * @P9_TCREATE: prepare a handle for I/O on a new file
|
| 120 | * @P9_RCREATE: response with file access information
|
| 121 | * @P9_TREAD: request to transfer data from a file or directory
|
| 122 | * @P9_RREAD: response with data requested
|
| 123 | * @P9_TWRITE: reuqest to transfer data to a file
|
| 124 | * @P9_RWRITE: response with out much data was transferred to file
|
| 125 | * @P9_TCLUNK: forget about a handle to an entity within the file system
|
| 126 | * @P9_RCLUNK: response when server has forgotten about the handle
|
| 127 | * @P9_TREMOVE: request to remove an entity from the hierarchy
|
| 128 | * @P9_RREMOVE: response when server has removed the entity
|
| 129 | * @P9_TSTAT: request file entity attributes
|
| 130 | * @P9_RSTAT: response with file entity attributes
|
| 131 | * @P9_TWSTAT: request to update file entity attributes
|
| 132 | * @P9_RWSTAT: response when file entity attributes are updated
|
| 133 | *
|
| 134 | * There are 14 basic operations in 9P2000, paired as
|
| 135 | * requests and responses. The one special case is ERROR
|
| 136 | * as there is no @P9_TERROR request for clients to transmit to
|
| 137 | * the server, but the server may respond to any other request
|
| 138 | * with an @P9_RERROR.
|
| 139 | *
|
| 140 | * See Also: http://plan9.bell-labs.com/sys/man/5/INDEX.html
|
| 141 |
|
| 142 |
|
| 143 | enum p9_msg_t {
|
| 144 | P9_TLERROR = 6,
|
| 145 | P9_RLERROR,
|
| 146 | P9_TSTATFS = 8,
|
| 147 | P9_RSTATFS,
|
| 148 | P9_TLOPEN = 12,
|
| 149 | P9_RLOPEN,
|
| 150 | P9_TLCREATE = 14,
|
| 151 | P9_RLCREATE,
|
| 152 | P9_TSYMLINK = 16,
|
| 153 | P9_RSYMLINK,
|
| 154 | P9_TMKNOD = 18,
|
| 155 | P9_RMKNOD,
|
| 156 | P9_TRENAME = 20,
|
| 157 | P9_RRENAME,
|
| 158 | P9_TREADLINK = 22,
|
| 159 | P9_RREADLINK,
|
| 160 | P9_TGETATTR = 24,
|
| 161 | P9_RGETATTR,
|
| 162 | P9_TSETATTR = 26,
|
| 163 | P9_RSETATTR,
|
| 164 | P9_TXATTRWALK = 30,
|
| 165 | P9_RXATTRWALK,
|
| 166 | P9_TXATTRCREATE = 32,
|
| 167 | P9_RXATTRCREATE,
|
| 168 | P9_TREADDIR = 40,
|
| 169 | P9_RREADDIR,
|
| 170 | P9_TFSYNC = 50,
|
| 171 | P9_RFSYNC,
|
| 172 | P9_TLOCK = 52,
|
| 173 | P9_RLOCK,
|
| 174 | P9_TGETLOCK = 54,
|
| 175 | P9_RGETLOCK,
|
| 176 | P9_TLINK = 70,
|
| 177 | P9_RLINK,
|
| 178 | P9_TMKDIR = 72,
|
| 179 | P9_RMKDIR,
|
| 180 | P9_TRENAMEAT = 74,
|
| 181 | P9_RRENAMEAT,
|
| 182 | P9_TUNLINKAT = 76,
|
| 183 | P9_RUNLINKAT,
|
| 184 | P9_TVERSION = 100,
|
| 185 | P9_RVERSION,
|
| 186 | P9_TAUTH = 102,
|
| 187 | P9_RAUTH,
|
| 188 | P9_TATTACH = 104,
|
| 189 | P9_RATTACH,
|
| 190 | P9_TERROR = 106,
|
| 191 | P9_RERROR,
|
| 192 | P9_TFLUSH = 108,
|
| 193 | P9_RFLUSH,
|
| 194 | P9_TWALK = 110,
|
| 195 | P9_RWALK,
|
| 196 | P9_TOPEN = 112,
|
| 197 | P9_ROPEN,
|
| 198 | P9_TCREATE = 114,
|
| 199 | P9_RCREATE,
|
| 200 | P9_TREAD = 116,
|
| 201 | P9_RREAD,
|
| 202 | P9_TWRITE = 118,
|
| 203 | P9_RWRITE,
|
| 204 | P9_TCLUNK = 120,
|
| 205 | P9_RCLUNK,
|
| 206 | P9_TREMOVE = 122,
|
| 207 | P9_RREMOVE,
|
| 208 | P9_TSTAT = 124,
|
| 209 | P9_RSTAT,
|
| 210 | P9_TWSTAT = 126,
|
| 211 | P9_RWSTAT,
|
| 212 | };
|
| 213 |
|
| 214 | |
| 215 | * enum p9_open_mode_t - 9P open modes
|
| 216 | * @P9_OREAD: open file for reading only
|
| 217 | * @P9_OWRITE: open file for writing only
|
| 218 | * @P9_ORDWR: open file for reading or writing
|
| 219 | * @P9_OEXEC: open file for execution
|
| 220 | * @P9_OTRUNC: truncate file to zero-length before opening it
|
| 221 | * @P9_OREXEC: close the file when an exec(2) system call is made
|
| 222 | * @P9_ORCLOSE: remove the file when the file is closed
|
| 223 | * @P9_OAPPEND: open the file and seek to the end
|
| 224 | * @P9_OEXCL: only create a file, do not open it
|
| 225 | * @P9L_MODE_MASK: mask for protocol mode bits (client-side only)
|
| 226 | * @P9L_DIRECT: disable client-side caching for this file
|
| 227 | * @P9L_NOWRITECACHE: disable write caching for this file
|
| 228 | * @P9L_LOOSE: enable loose cache consistency
|
| 229 | *
|
| 230 | * 9P open modes differ slightly from Posix standard modes.
|
| 231 | * In particular, there are extra modes which specify different
|
| 232 | * semantic behaviors than may be available on standard Posix
|
| 233 | * systems. For example, @P9_OREXEC and @P9_ORCLOSE are modes that
|
| 234 | * most likely will not be issued from the Linux VFS client, but may
|
| 235 | * be supported by servers.
|
| 236 | *
|
| 237 | * See Also: http://plan9.bell-labs.com/magic/man2html/2/open
|
| 238 |
|
| 239 |
|
| 240 | enum p9_open_mode_t {
|
| 241 | P9_OREAD = 0x00,
|
| 242 | P9_OWRITE = 0x01,
|
| 243 | P9_ORDWR = 0x02,
|
| 244 | P9_OEXEC = 0x03,
|
| 245 | P9_OTRUNC = 0x10,
|
| 246 | P9_OREXEC = 0x20,
|
| 247 | P9_ORCLOSE = 0x40,
|
| 248 | P9_OAPPEND = 0x80,
|
| 249 | P9_OEXCL = 0x1000,
|
| 250 | P9L_MODE_MASK = 0x1FFF,
|
| 251 | P9L_DIRECT = 0x2000,
|
| 252 | P9L_NOWRITECACHE = 0x4000,
|
| 253 | P9L_LOOSE = 0x8000,
|
| 254 | };
|
| 255 |
|
| 256 | |
| 257 | * enum p9_perm_t - 9P permissions
|
| 258 | * @P9_DMDIR: mode bit for directories
|
| 259 | * @P9_DMAPPEND: mode bit for is append-only
|
| 260 | * @P9_DMEXCL: mode bit for excluse use (only one open handle allowed)
|
| 261 | * @P9_DMMOUNT: mode bit for mount points
|
| 262 | * @P9_DMAUTH: mode bit for authentication file
|
| 263 | * @P9_DMTMP: mode bit for non-backed-up files
|
| 264 | * @P9_DMSYMLINK: mode bit for symbolic links (9P2000.u)
|
| 265 | * @P9_DMLINK: mode bit for hard-link (9P2000.u)
|
| 266 | * @P9_DMDEVICE: mode bit for device files (9P2000.u)
|
| 267 | * @P9_DMNAMEDPIPE: mode bit for named pipe (9P2000.u)
|
| 268 | * @P9_DMSOCKET: mode bit for socket (9P2000.u)
|
| 269 | * @P9_DMSETUID: mode bit for setuid (9P2000.u)
|
| 270 | * @P9_DMSETGID: mode bit for setgid (9P2000.u)
|
| 271 | * @P9_DMSETVTX: mode bit for sticky bit (9P2000.u)
|
| 272 | *
|
| 273 | * 9P permissions differ slightly from Posix standard modes.
|
| 274 | *
|
| 275 | * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
|
| 276 |
|
| 277 | enum p9_perm_t {
|
| 278 | P9_DMDIR = 0x80000000,
|
| 279 | P9_DMAPPEND = 0x40000000,
|
| 280 | P9_DMEXCL = 0x20000000,
|
| 281 | P9_DMMOUNT = 0x10000000,
|
| 282 | P9_DMAUTH = 0x08000000,
|
| 283 | P9_DMTMP = 0x04000000,
|
| 284 |
|
| 285 | P9_DMSYMLINK = 0x02000000,
|
| 286 | P9_DMLINK = 0x01000000,
|
| 287 | P9_DMDEVICE = 0x00800000,
|
| 288 | P9_DMNAMEDPIPE = 0x00200000,
|
| 289 | P9_DMSOCKET = 0x00100000,
|
| 290 | P9_DMSETUID = 0x00080000,
|
| 291 | P9_DMSETGID = 0x00040000,
|
| 292 | P9_DMSETVTX = 0x00010000,
|
| 293 | };
|
| 294 |
|
| 295 |
|
| 296 | #define P9_DOTL_RDONLY 00000000
|
| 297 | #define P9_DOTL_WRONLY 00000001
|
| 298 | #define P9_DOTL_RDWR 00000002
|
| 299 | #define P9_DOTL_NOACCESS 00000003
|
| 300 | #define P9_DOTL_CREATE 00000100
|
| 301 | #define P9_DOTL_EXCL 00000200
|
| 302 | #define P9_DOTL_NOCTTY 00000400
|
| 303 | #define P9_DOTL_TRUNC 00001000
|
| 304 | #define P9_DOTL_APPEND 00002000
|
| 305 | #define P9_DOTL_NONBLOCK 00004000
|
| 306 | #define P9_DOTL_DSYNC 00010000
|
| 307 | #define P9_DOTL_FASYNC 00020000
|
| 308 | #define P9_DOTL_DIRECT 00040000
|
| 309 | #define P9_DOTL_LARGEFILE 00100000
|
| 310 | #define P9_DOTL_DIRECTORY 00200000
|
| 311 | #define P9_DOTL_NOFOLLOW 00400000
|
| 312 | #define P9_DOTL_NOATIME 01000000
|
| 313 | #define P9_DOTL_CLOEXEC 02000000
|
| 314 | #define P9_DOTL_SYNC 04000000
|
| 315 |
|
| 316 |
|
| 317 | #define P9_DOTL_AT_REMOVEDIR 0x200
|
| 318 |
|
| 319 |
|
| 320 | #define P9_LOCK_TYPE_RDLCK 0
|
| 321 | #define P9_LOCK_TYPE_WRLCK 1
|
| 322 | #define P9_LOCK_TYPE_UNLCK 2
|
| 323 |
|
| 324 | |
| 325 | * enum p9_qid_t - QID types
|
| 326 | * @P9_QTDIR: directory
|
| 327 | * @P9_QTAPPEND: append-only
|
| 328 | * @P9_QTEXCL: excluse use (only one open handle allowed)
|
| 329 | * @P9_QTMOUNT: mount points
|
| 330 | * @P9_QTAUTH: authentication file
|
| 331 | * @P9_QTTMP: non-backed-up files
|
| 332 | * @P9_QTSYMLINK: symbolic links (9P2000.u)
|
| 333 | * @P9_QTLINK: hard-link (9P2000.u)
|
| 334 | * @P9_QTFILE: normal files
|
| 335 | *
|
| 336 | * QID types are a subset of permissions - they are primarily
|
| 337 | * used to differentiate semantics for a file system entity via
|
| 338 | * a jump-table. Their value is also the most significant 16 bits
|
| 339 | * of the permission_t
|
| 340 | *
|
| 341 | * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
|
| 342 |
|
| 343 | enum p9_qid_t {
|
| 344 | P9_QTDIR = 0x80,
|
| 345 | P9_QTAPPEND = 0x40,
|
| 346 | P9_QTEXCL = 0x20,
|
| 347 | P9_QTMOUNT = 0x10,
|
| 348 | P9_QTAUTH = 0x08,
|
| 349 | P9_QTTMP = 0x04,
|
| 350 | P9_QTSYMLINK = 0x02,
|
| 351 | P9_QTLINK = 0x01,
|
| 352 | P9_QTFILE = 0x00,
|
| 353 | };
|
| 354 |
|
| 355 |
|
| 356 | #define P9_NOTAG ((u16)(~0))
|
| 357 | #define P9_NOFID ((u32)(~0))
|
| 358 | #define P9_MAXWELEM 16
|
| 359 |
|
| 360 |
|
| 361 | #define P9_HDRSZ 7
|
| 362 |
|
| 363 |
|
| 364 | #define P9_IOHDRSZ 24
|
| 365 |
|
| 366 |
|
| 367 | #define P9_READDIRHDRSZ 24
|
| 368 |
|
| 369 |
|
| 370 | #define P9_ZC_HDR_SZ 4096
|
| 371 |
|
| 372 |
|
| 373 | #define P9_ERRMAX 128
|
| 374 |
|
| 375 | |
| 376 | * struct p9_qid - file system entity information
|
| 377 | * @type: 8-bit type &p9_qid_t
|
| 378 | * @version: 16-bit monotonically incrementing version number
|
| 379 | * @path: 64-bit per-server-unique ID for a file system element
|
| 380 | *
|
| 381 | * qids are identifiers used by 9P servers to track file system
|
| 382 | * entities. The type is used to differentiate semantics for operations
|
| 383 | * on the entity (ie. read means something different on a directory than
|
| 384 | * on a file). The path provides a server unique index for an entity
|
| 385 | * (roughly analogous to an inode number), while the version is updated
|
| 386 | * every time a file is modified and can be used to maintain cache
|
| 387 | * coherency between clients and serves.
|
| 388 | * Servers will often differentiate purely synthetic entities by setting
|
| 389 | * their version to 0, signaling that they should never be cached and
|
| 390 | * should be accessed synchronously.
|
| 391 | *
|
| 392 | * See Also://plan9.bell-labs.com/magic/man2html/2/stat
|
| 393 |
|
| 394 |
|
| 395 | struct p9_qid {
|
| 396 | u8 type;
|
| 397 | u32 version;
|
| 398 | u64 path;
|
| 399 | };
|
| 400 |
|
| 401 | |
| 402 | * struct p9_wstat - file system metadata information
|
| 403 | * @size: length prefix for this stat structure instance
|
| 404 | * @type: the type of the server (equivalent to a major number)
|
| 405 | * @dev: the sub-type of the server (equivalent to a minor number)
|
| 406 | * @qid: unique id from the server of type &p9_qid
|
| 407 | * @mode: Plan 9 format permissions of type &p9_perm_t
|
| 408 | * @atime: Last access/read time
|
| 409 | * @mtime: Last modify/write time
|
| 410 | * @length: file length
|
| 411 | * @name: last element of path (aka filename)
|
| 412 | * @uid: owner name
|
| 413 | * @gid: group owner
|
| 414 | * @muid: last modifier
|
| 415 | * @extension: area used to encode extended UNIX support
|
| 416 | * @n_uid: numeric user id of owner (part of 9p2000.u extension)
|
| 417 | * @n_gid: numeric group id (part of 9p2000.u extension)
|
| 418 | * @n_muid: numeric user id of laster modifier (part of 9p2000.u extension)
|
| 419 | *
|
| 420 | * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
|
| 421 |
|
| 422 |
|
| 423 | struct p9_wstat {
|
| 424 | u16 size;
|
| 425 | u16 type;
|
| 426 | u32 dev;
|
| 427 | struct p9_qid qid;
|
| 428 | u32 mode;
|
| 429 | u32 atime;
|
| 430 | u32 mtime;
|
| 431 | u64 length;
|
| 432 | const char *name;
|
| 433 | const char *uid;
|
| 434 | const char *gid;
|
| 435 | const char *muid;
|
| 436 | char *extension;
|
| 437 | kuid_t n_uid;
|
| 438 | kgid_t n_gid;
|
| 439 | kuid_t n_muid;
|
| 440 | };
|
| 441 |
|
| 442 | struct p9_stat_dotl {
|
| 443 | u64 st_result_mask;
|
| 444 | struct p9_qid qid;
|
| 445 | u32 st_mode;
|
| 446 | kuid_t st_uid;
|
| 447 | kgid_t st_gid;
|
| 448 | u64 st_nlink;
|
| 449 | u64 st_rdev;
|
| 450 | u64 st_size;
|
| 451 | u64 st_blksize;
|
| 452 | u64 st_blocks;
|
| 453 | u64 st_atime_sec;
|
| 454 | u64 st_atime_nsec;
|
| 455 | u64 st_mtime_sec;
|
| 456 | u64 st_mtime_nsec;
|
| 457 | u64 st_ctime_sec;
|
| 458 | u64 st_ctime_nsec;
|
| 459 | u64 st_btime_sec;
|
| 460 | u64 st_btime_nsec;
|
| 461 | u64 st_gen;
|
| 462 | u64 st_data_version;
|
| 463 | };
|
| 464 |
|
| 465 | #define P9_STATS_MODE 0x00000001ULL
|
| 466 | #define P9_STATS_NLINK 0x00000002ULL
|
| 467 | #define P9_STATS_UID 0x00000004ULL
|
| 468 | #define P9_STATS_GID 0x00000008ULL
|
| 469 | #define P9_STATS_RDEV 0x00000010ULL
|
| 470 | #define P9_STATS_ATIME 0x00000020ULL
|
| 471 | #define P9_STATS_MTIME 0x00000040ULL
|
| 472 | #define P9_STATS_CTIME 0x00000080ULL
|
| 473 | #define P9_STATS_INO 0x00000100ULL
|
| 474 | #define P9_STATS_SIZE 0x00000200ULL
|
| 475 | #define P9_STATS_BLOCKS 0x00000400ULL
|
| 476 |
|
| 477 | #define P9_STATS_BTIME 0x00000800ULL
|
| 478 | #define P9_STATS_GEN 0x00001000ULL
|
| 479 | #define P9_STATS_DATA_VERSION 0x00002000ULL
|
| 480 |
|
| 481 | #define P9_STATS_BASIC 0x000007ffULL
|
| 482 | #define P9_STATS_ALL 0x00003fffULL
|
| 483 |
|
| 484 | |
| 485 | * struct p9_iattr_dotl - P9 inode attribute for setattr
|
| 486 | * @valid: bitfield specifying which fields are valid
|
| 487 | * same as in struct iattr
|
| 488 | * @mode: File permission bits
|
| 489 | * @uid: user id of owner
|
| 490 | * @gid: group id
|
| 491 | * @size: File size
|
| 492 | * @atime_sec: Last access time, seconds
|
| 493 | * @atime_nsec: Last access time, nanoseconds
|
| 494 | * @mtime_sec: Last modification time, seconds
|
| 495 | * @mtime_nsec: Last modification time, nanoseconds
|
| 496 |
|
| 497 |
|
| 498 | struct p9_iattr_dotl {
|
| 499 | u32 valid;
|
| 500 | u32 mode;
|
| 501 | kuid_t uid;
|
| 502 | kgid_t gid;
|
| 503 | u64 size;
|
| 504 | u64 atime_sec;
|
| 505 | u64 atime_nsec;
|
| 506 | u64 mtime_sec;
|
| 507 | u64 mtime_nsec;
|
| 508 | };
|
| 509 |
|
| 510 | #define P9_LOCK_SUCCESS 0
|
| 511 | #define P9_LOCK_BLOCKED 1
|
| 512 | #define P9_LOCK_ERROR 2
|
| 513 | #define P9_LOCK_GRACE 3
|
| 514 |
|
| 515 | #define P9_LOCK_FLAGS_BLOCK 1
|
| 516 | #define P9_LOCK_FLAGS_RECLAIM 2
|
| 517 |
|
| 518 | |
| 519 | * @type - type of lock
|
| 520 | * @flags - lock flags
|
| 521 | * @start - starting offset of the lock
|
| 522 | * @length - number of bytes
|
| 523 | * @proc_id - process id which wants to take lock
|
| 524 | * @client_id - client id
|
| 525 |
|
| 526 |
|
| 527 | struct p9_flock {
|
| 528 | u8 type;
|
| 529 | u32 flags;
|
| 530 | u64 start;
|
| 531 | u64 length;
|
| 532 | u32 proc_id;
|
| 533 | char *client_id;
|
| 534 | };
|
| 535 |
|
| 536 | |
| 537 | * @type - type of lock
|
| 538 | * @start - starting offset of the lock
|
| 539 | * @length - number of bytes
|
| 540 | * @proc_id - process id which wants to take lock
|
| 541 | * @client_id - client id
|
| 542 |
|
| 543 |
|
| 544 | struct p9_getlock {
|
| 545 | u8 type;
|
| 546 | u64 start;
|
| 547 | u64 length;
|
| 548 | u32 proc_id;
|
| 549 | char *client_id;
|
| 550 | };
|
| 551 |
|
| 552 | struct p9_rstatfs {
|
| 553 | u32 type;
|
| 554 | u32 bsize;
|
| 555 | u64 blocks;
|
| 556 | u64 bfree;
|
| 557 | u64 bavail;
|
| 558 | u64 files;
|
| 559 | u64 ffree;
|
| 560 | u64 fsid;
|
| 561 | u32 namelen;
|
| 562 | };
|
| 563 |
|
| 564 | |
| 565 | * struct p9_fcall - primary packet structure
|
| 566 | * @size: prefixed length of the structure
|
| 567 | * @id: protocol operating identifier of type &p9_msg_t
|
| 568 | * @tag: transaction id of the request
|
| 569 | * @offset: used by marshalling routines to track current position in buffer
|
| 570 | * @capacity: used by marshalling routines to track total malloc'd capacity
|
| 571 | * @sdata: payload
|
| 572 | * @zc: whether zero-copy is used
|
| 573 | *
|
| 574 | * &p9_fcall represents the structure for all 9P RPC
|
| 575 | * transactions. Requests are packaged into fcalls, and reponses
|
| 576 | * must be extracted from them.
|
| 577 | *
|
| 578 | * See Also: http://plan9.bell-labs.com/magic/man2html/2/fcall
|
| 579 |
|
| 580 |
|
| 581 | struct p9_fcall {
|
| 582 | u32 size;
|
| 583 | u8 id;
|
| 584 | u16 tag;
|
| 585 |
|
| 586 | size_t offset;
|
| 587 | size_t capacity;
|
| 588 |
|
| 589 | struct kmem_cache *cache;
|
| 590 | u8 *sdata;
|
| 591 | bool zc;
|
| 592 | };
|
| 593 |
|
| 594 | int p9_errstr2errno(char *errstr, int len);
|
| 595 |
|
| 596 | int p9_error_init(void);
|
| 597 | #endif
|