1 #ifndef _QEMU_VIRTIO_9P_H
2 #define _QEMU_VIRTIO_9P_H
9 #include "fsdev/file-op-9p.h"
11 /* The feature bitmap for virtio 9P */
12 /* The mount point is specified in a config variable */
13 #define VIRTIO_9P_MOUNT_TAG 0
96 enum p9_proto_version
{
97 V9FS_PROTO_2000U
= 0x01,
98 V9FS_PROTO_2000L
= 0x02,
101 #define P9_NOTAG (u16)(~0)
102 #define P9_NOFID (u32)(~0)
103 #define P9_MAXWELEM 16
104 static inline const char *rpath(FsContext
*ctx
, const char *path
, char *buffer
)
106 snprintf(buffer
, PATH_MAX
, "%s/%s", ctx
->fs_root
, path
);
111 * ample room for Twrite/Rread header
112 * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
114 #define P9_IOHDRSZ 24
116 typedef struct V9fsPDU V9fsPDU
;
124 VirtQueueElement elem
;
126 QLIST_ENTRY(V9fsPDU
) next
;
131 * 1) change user needs to set groups and stuff
134 /* from Linux's linux/virtio_9p.h */
136 /* The ID for virtio console */
137 #define VIRTIO_ID_9P 9
139 #define MAX_TAG_LEN 32
141 #define BUG_ON(cond) assert(!(cond))
143 typedef struct V9fsFidState V9fsFidState
;
145 typedef struct V9fsString
151 typedef struct V9fsQID
158 typedef struct V9fsStat
173 V9fsString extension
;
186 typedef struct V9fsXattr
209 typedef struct V9fsState
213 V9fsPDU pdus
[MAX_REQ
];
214 QLIST_HEAD(, V9fsPDU
) free_list
;
215 V9fsFidState
*fid_list
;
221 enum p9_proto_version proto_version
;
225 typedef struct V9fsCreateState
{
234 V9fsString extension
;
239 typedef struct V9fsLcreateState
{
250 typedef struct V9fsStatState
{
258 typedef struct V9fsStatDotl
{
259 uint64_t st_result_mask
;
269 uint64_t st_atime_sec
;
270 uint64_t st_atime_nsec
;
271 uint64_t st_mtime_sec
;
272 uint64_t st_mtime_nsec
;
273 uint64_t st_ctime_sec
;
274 uint64_t st_ctime_nsec
;
275 uint64_t st_btime_sec
;
276 uint64_t st_btime_nsec
;
278 uint64_t st_data_version
;
281 typedef struct V9fsWalkState
{
288 V9fsFidState
*newfidp
;
294 typedef struct V9fsOpenState
{
304 typedef struct V9fsReadState
{
311 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
323 typedef struct V9fsWriteState
{
331 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
336 typedef struct V9fsWstatState
346 typedef struct V9fsSymlinkState
358 typedef struct V9fsIattr
371 struct virtio_9p_config
373 /* number of characters in tag */
375 /* Variable size tag name */
377 } __attribute__((packed
));
379 typedef struct V9fsMkState
{
388 #define P9_LOCK_SUCCESS 0
389 #define P9_LOCK_BLOCKED 1
390 #define P9_LOCK_ERROR 2
391 #define P9_LOCK_GRACE 3
393 #define P9_LOCK_FLAGS_BLOCK 1
394 #define P9_LOCK_FLAGS_RECLAIM 2
396 typedef struct V9fsFlock
400 uint64_t start
; /* absolute offset */
403 V9fsString client_id
;
406 typedef struct V9fsLockState
416 typedef struct V9fsGetlock
419 uint64_t start
; /* absolute offset */
422 V9fsString client_id
;
425 typedef struct V9fsGetlockState
434 size_t pdu_packunpack(void *addr
, struct iovec
*sg
, int sg_count
,
435 size_t offset
, size_t size
, int pack
);
437 static inline size_t do_pdu_unpack(void *dst
, struct iovec
*sg
, int sg_count
,
438 size_t offset
, size_t size
)
440 return pdu_packunpack(dst
, sg
, sg_count
, offset
, size
, 0);
443 extern void handle_9p_output(VirtIODevice
*vdev
, VirtQueue
*vq
);