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;
123 VirtQueueElement elem;
124 QLIST_ENTRY(V9fsPDU) next;
129 * 1) change user needs to set groups and stuff
132 /* from Linux's linux/virtio_9p.h */
134 /* The ID for virtio console */
135 #define VIRTIO_ID_9P 9
137 #define MAX_TAG_LEN 32
139 #define BUG_ON(cond) assert(!(cond))
141 typedef struct V9fsFidState V9fsFidState;
143 typedef struct V9fsString
149 typedef struct V9fsQID
156 typedef struct V9fsStat
171 V9fsString extension;
184 typedef struct V9fsXattr
207 typedef struct V9fsState
211 V9fsPDU pdus[MAX_REQ];
212 QLIST_HEAD(, V9fsPDU) free_list;
213 V9fsFidState *fid_list;
219 enum p9_proto_version proto_version;
223 typedef struct V9fsCreateState {
232 V9fsString extension;
237 typedef struct V9fsLcreateState {
248 typedef struct V9fsStatState {
256 typedef struct V9fsStatDotl {
257 uint64_t st_result_mask;
267 uint64_t st_atime_sec;
268 uint64_t st_atime_nsec;
269 uint64_t st_mtime_sec;
270 uint64_t st_mtime_nsec;
271 uint64_t st_ctime_sec;
272 uint64_t st_ctime_nsec;
273 uint64_t st_btime_sec;
274 uint64_t st_btime_nsec;
276 uint64_t st_data_version;
279 typedef struct V9fsStatStateDotl {
282 V9fsStatDotl v9stat_dotl;
287 typedef struct V9fsWalkState {
294 V9fsFidState *newfidp;
300 typedef struct V9fsOpenState {
310 typedef struct V9fsReadState {
317 struct iovec iov[128]; /* FIXME: bad, bad, bad */
329 typedef struct V9fsWriteState {
337 struct iovec iov[128]; /* FIXME: bad, bad, bad */
342 typedef struct V9fsRemoveState {
348 typedef struct V9fsWstatState
358 typedef struct V9fsSymlinkState
370 typedef struct V9fsIattr
383 typedef struct V9fsSetattrState
391 struct virtio_9p_config
393 /* number of characters in tag */
395 /* Variable size tag name */
397 } __attribute__((packed));
399 typedef struct V9fsStatfs
412 typedef struct V9fsStatfsState {
421 typedef struct V9fsMkState {
430 typedef struct V9fsRenameState {
438 typedef struct V9fsXattrState
442 V9fsFidState *file_fidp;
443 V9fsFidState *xattr_fidp;
450 #define P9_LOCK_SUCCESS 0
451 #define P9_LOCK_BLOCKED 1
452 #define P9_LOCK_ERROR 2
453 #define P9_LOCK_GRACE 3
455 #define P9_LOCK_FLAGS_BLOCK 1
456 #define P9_LOCK_FLAGS_RECLAIM 2
458 typedef struct V9fsFlock
462 uint64_t start; /* absolute offset */
465 V9fsString client_id;
468 typedef struct V9fsLockState
478 typedef struct V9fsGetlock
481 uint64_t start; /* absolute offset */
484 V9fsString client_id;
487 typedef struct V9fsGetlockState
496 typedef struct V9fsReadLinkState
503 size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
504 size_t offset, size_t size, int pack);
506 static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
507 size_t offset, size_t size)
509 return pdu_packunpack(dst, sg, sg_count, offset, size, 0);
512 extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq);