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 V9fsStatState
{
233 typedef struct V9fsStatDotl
{
234 uint64_t st_result_mask
;
244 uint64_t st_atime_sec
;
245 uint64_t st_atime_nsec
;
246 uint64_t st_mtime_sec
;
247 uint64_t st_mtime_nsec
;
248 uint64_t st_ctime_sec
;
249 uint64_t st_ctime_nsec
;
250 uint64_t st_btime_sec
;
251 uint64_t st_btime_nsec
;
253 uint64_t st_data_version
;
256 typedef struct V9fsOpenState
{
266 typedef struct V9fsReadState
{
273 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
285 typedef struct V9fsWriteState
{
293 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
298 typedef struct V9fsWstatState
308 typedef struct V9fsIattr
321 struct virtio_9p_config
323 /* number of characters in tag */
325 /* Variable size tag name */
327 } __attribute__((packed
));
329 typedef struct V9fsMkState
{
338 #define P9_LOCK_SUCCESS 0
339 #define P9_LOCK_BLOCKED 1
340 #define P9_LOCK_ERROR 2
341 #define P9_LOCK_GRACE 3
343 #define P9_LOCK_FLAGS_BLOCK 1
344 #define P9_LOCK_FLAGS_RECLAIM 2
346 typedef struct V9fsFlock
350 uint64_t start
; /* absolute offset */
353 V9fsString client_id
;
356 typedef struct V9fsGetlock
359 uint64_t start
; /* absolute offset */
362 V9fsString client_id
;
365 size_t pdu_packunpack(void *addr
, struct iovec
*sg
, int sg_count
,
366 size_t offset
, size_t size
, int pack
);
368 static inline size_t do_pdu_unpack(void *dst
, struct iovec
*sg
, int sg_count
,
369 size_t offset
, size_t size
)
371 return pdu_packunpack(dst
, sg
, sg_count
, offset
, size
, 0);
374 extern void handle_9p_output(VirtIODevice
*vdev
, VirtQueue
*vq
);