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 V9fsStatState {
247 typedef struct V9fsStatDotl {
248 uint64_t st_result_mask;
258 uint64_t st_atime_sec;
259 uint64_t st_atime_nsec;
260 uint64_t st_mtime_sec;
261 uint64_t st_mtime_nsec;
262 uint64_t st_ctime_sec;
263 uint64_t st_ctime_nsec;
264 uint64_t st_btime_sec;
265 uint64_t st_btime_nsec;
267 uint64_t st_data_version;
270 typedef struct V9fsOpenState {
280 typedef struct V9fsReadState {
287 struct iovec iov[128]; /* FIXME: bad, bad, bad */
299 typedef struct V9fsWriteState {
307 struct iovec iov[128]; /* FIXME: bad, bad, bad */
312 typedef struct V9fsWstatState
322 typedef struct V9fsSymlinkState
334 typedef struct V9fsIattr
347 struct virtio_9p_config
349 /* number of characters in tag */
351 /* Variable size tag name */
353 } __attribute__((packed));
355 typedef struct V9fsMkState {
364 #define P9_LOCK_SUCCESS 0
365 #define P9_LOCK_BLOCKED 1
366 #define P9_LOCK_ERROR 2
367 #define P9_LOCK_GRACE 3
369 #define P9_LOCK_FLAGS_BLOCK 1
370 #define P9_LOCK_FLAGS_RECLAIM 2
372 typedef struct V9fsFlock
376 uint64_t start; /* absolute offset */
379 V9fsString client_id;
382 typedef struct V9fsGetlock
385 uint64_t start; /* absolute offset */
388 V9fsString client_id;
391 size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
392 size_t offset, size_t size, int pack);
394 static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
395 size_t offset, size_t size)
397 return pdu_packunpack(dst, sg, sg_count, offset, size, 0);
400 extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq);