Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
9p.h
Go to the documentation of this file.
1 /*
2  * include/net/9p/9p.h
3  *
4  * 9P protocol definitions.
5  *
6  * Copyright (C) 2005 by Latchesar Ionkov <[email protected]>
7  * Copyright (C) 2004 by Eric Van Hensbergen <[email protected]>
8  * Copyright (C) 2002 by Ron Minnich <[email protected]>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2
12  * as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to:
21  * Free Software Foundation
22  * 51 Franklin Street, Fifth Floor
23  * Boston, MA 02111-1301 USA
24  *
25  */
26 
27 #ifndef NET_9P_H
28 #define NET_9P_H
29 
50  P9_DEBUG_ERROR = (1<<0),
51  P9_DEBUG_9P = (1<<2),
52  P9_DEBUG_VFS = (1<<3),
53  P9_DEBUG_CONV = (1<<4),
54  P9_DEBUG_MUX = (1<<5),
55  P9_DEBUG_TRANS = (1<<6),
56  P9_DEBUG_SLABS = (1<<7),
57  P9_DEBUG_FCALL = (1<<8),
58  P9_DEBUG_FID = (1<<9),
59  P9_DEBUG_PKT = (1<<10),
60  P9_DEBUG_FSC = (1<<11),
61  P9_DEBUG_VPKT = (1<<12),
62 };
63 
64 #ifdef CONFIG_NET_9P_DEBUG
65 extern unsigned int p9_debug_level;
66 __printf(3, 4)
67 void _p9_debug(enum p9_debug_flags level, const char *func,
68  const char *fmt, ...);
69 #define p9_debug(level, fmt, ...) \
70  _p9_debug(level, __func__, fmt, ##__VA_ARGS__)
71 #else
72 #define p9_debug(level, fmt, ...) \
73  no_printk(fmt, ##__VA_ARGS__)
74 #endif
75 
130 enum p9_msg_t {
135  P9_TLOPEN = 12,
141  P9_TMKNOD = 18,
157  P9_TFSYNC = 50,
159  P9_TLOCK = 52,
163  P9_TLINK = 70,
165  P9_TMKDIR = 72,
171  P9_TVERSION = 100,
173  P9_TAUTH = 102,
175  P9_TATTACH = 104,
177  P9_TERROR = 106,
179  P9_TFLUSH = 108,
181  P9_TWALK = 110,
183  P9_TOPEN = 112,
185  P9_TCREATE = 114,
187  P9_TREAD = 116,
189  P9_TWRITE = 118,
191  P9_TCLUNK = 120,
193  P9_TREMOVE = 122,
195  P9_TSTAT = 124,
197  P9_TWSTAT = 126,
199 };
200 
224  P9_OREAD = 0x00,
225  P9_OWRITE = 0x01,
226  P9_ORDWR = 0x02,
227  P9_OEXEC = 0x03,
228  P9_OTRUNC = 0x10,
229  P9_OREXEC = 0x20,
230  P9_ORCLOSE = 0x40,
231  P9_OAPPEND = 0x80,
232  P9_OEXCL = 0x1000,
233 };
234 
256 enum p9_perm_t {
257  P9_DMDIR = 0x80000000,
258  P9_DMAPPEND = 0x40000000,
259  P9_DMEXCL = 0x20000000,
260  P9_DMMOUNT = 0x10000000,
261  P9_DMAUTH = 0x08000000,
262  P9_DMTMP = 0x04000000,
263 /* 9P2000.u extensions */
264  P9_DMSYMLINK = 0x02000000,
265  P9_DMLINK = 0x01000000,
266  P9_DMDEVICE = 0x00800000,
267  P9_DMNAMEDPIPE = 0x00200000,
268  P9_DMSOCKET = 0x00100000,
269  P9_DMSETUID = 0x00080000,
270  P9_DMSETGID = 0x00040000,
271  P9_DMSETVTX = 0x00010000,
272 };
273 
274 /* 9p2000.L open flags */
275 #define P9_DOTL_RDONLY 00000000
276 #define P9_DOTL_WRONLY 00000001
277 #define P9_DOTL_RDWR 00000002
278 #define P9_DOTL_NOACCESS 00000003
279 #define P9_DOTL_CREATE 00000100
280 #define P9_DOTL_EXCL 00000200
281 #define P9_DOTL_NOCTTY 00000400
282 #define P9_DOTL_TRUNC 00001000
283 #define P9_DOTL_APPEND 00002000
284 #define P9_DOTL_NONBLOCK 00004000
285 #define P9_DOTL_DSYNC 00010000
286 #define P9_DOTL_FASYNC 00020000
287 #define P9_DOTL_DIRECT 00040000
288 #define P9_DOTL_LARGEFILE 00100000
289 #define P9_DOTL_DIRECTORY 00200000
290 #define P9_DOTL_NOFOLLOW 00400000
291 #define P9_DOTL_NOATIME 01000000
292 #define P9_DOTL_CLOEXEC 02000000
293 #define P9_DOTL_SYNC 04000000
294 
295 /* 9p2000.L at flags */
296 #define P9_DOTL_AT_REMOVEDIR 0x200
297 
298 /* 9p2000.L lock type */
299 #define P9_LOCK_TYPE_RDLCK 0
300 #define P9_LOCK_TYPE_WRLCK 1
301 #define P9_LOCK_TYPE_UNLCK 2
302 
322 enum p9_qid_t {
323  P9_QTDIR = 0x80,
324  P9_QTAPPEND = 0x40,
325  P9_QTEXCL = 0x20,
326  P9_QTMOUNT = 0x10,
327  P9_QTAUTH = 0x08,
328  P9_QTTMP = 0x04,
329  P9_QTSYMLINK = 0x02,
330  P9_QTLINK = 0x01,
331  P9_QTFILE = 0x00,
332 };
333 
334 /* 9P Magic Numbers */
335 #define P9_NOTAG (u16)(~0)
336 #define P9_NOFID (u32)(~0)
337 #define P9_MAXWELEM 16
338 
339 /* ample room for Twrite/Rread header */
340 #define P9_IOHDRSZ 24
341 
342 /* Room for readdir header */
343 #define P9_READDIRHDRSZ 24
344 
345 /* size of header for zero copy read/write */
346 #define P9_ZC_HDR_SZ 4096
347 
368 struct p9_qid {
372 };
373 
396 struct p9_wstat {
400  struct p9_qid qid;
405  char *name;
406  char *uid;
407  char *gid;
408  char *muid;
409  char *extension; /* 9p2000.u extensions */
410  u32 n_uid; /* 9p2000.u extensions */
411  u32 n_gid; /* 9p2000.u extensions */
412  u32 n_muid; /* 9p2000.u extensions */
413 };
414 
415 struct p9_stat_dotl {
417  struct p9_qid qid;
436 };
437 
438 #define P9_STATS_MODE 0x00000001ULL
439 #define P9_STATS_NLINK 0x00000002ULL
440 #define P9_STATS_UID 0x00000004ULL
441 #define P9_STATS_GID 0x00000008ULL
442 #define P9_STATS_RDEV 0x00000010ULL
443 #define P9_STATS_ATIME 0x00000020ULL
444 #define P9_STATS_MTIME 0x00000040ULL
445 #define P9_STATS_CTIME 0x00000080ULL
446 #define P9_STATS_INO 0x00000100ULL
447 #define P9_STATS_SIZE 0x00000200ULL
448 #define P9_STATS_BLOCKS 0x00000400ULL
449 
450 #define P9_STATS_BTIME 0x00000800ULL
451 #define P9_STATS_GEN 0x00001000ULL
452 #define P9_STATS_DATA_VERSION 0x00002000ULL
453 
454 #define P9_STATS_BASIC 0x000007ffULL /* Mask for fields up to BLOCKS */
455 #define P9_STATS_ALL 0x00003fffULL /* Mask for All fields above */
456 
481 };
482 
483 #define P9_LOCK_SUCCESS 0
484 #define P9_LOCK_BLOCKED 1
485 #define P9_LOCK_ERROR 2
486 #define P9_LOCK_GRACE 3
487 
488 #define P9_LOCK_FLAGS_BLOCK 1
489 #define P9_LOCK_FLAGS_RECLAIM 2
490 
491 /* struct p9_flock: POSIX lock structure
492  * @type - type of lock
493  * @flags - lock flags
494  * @start - starting offset of the lock
495  * @length - number of bytes
496  * @proc_id - process id which wants to take lock
497  * @client_id - client id
498  */
499 
500 struct p9_flock {
506  char *client_id;
507 };
508 
509 /* struct p9_getlock: getlock structure
510  * @type - type of lock
511  * @start - starting offset of the lock
512  * @length - number of bytes
513  * @proc_id - process id which wants to take lock
514  * @client_id - client id
515  */
516 
517 struct p9_getlock {
522  char *client_id;
523 };
524 
525 struct p9_rstatfs {
535 };
536 
553 struct p9_fcall {
557 
558  size_t offset;
559  size_t capacity;
560 
562 };
563 
564 struct p9_idpool;
565 
566 int p9_errstr2errno(char *errstr, int len);
567 
568 struct p9_idpool *p9_idpool_create(void);
569 void p9_idpool_destroy(struct p9_idpool *);
570 int p9_idpool_get(struct p9_idpool *p);
571 void p9_idpool_put(int id, struct p9_idpool *p);
572 int p9_idpool_check(int id, struct p9_idpool *p);
573 
574 int p9_error_init(void);
575 int p9_trans_fd_init(void);
576 void p9_trans_fd_exit(void);
577 #endif /* NET_9P_H */