1 #ifndef _QEMU_VIRTIO_9P_H
2 #define _QEMU_VIRTIO_9P_H
9 #include "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
106 * ample room for Twrite/Rread header
107 * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
109 #define P9_IOHDRSZ 24
111 typedef struct V9fsPDU V9fsPDU
;
118 VirtQueueElement elem
;
119 QLIST_ENTRY(V9fsPDU
) next
;
124 * 1) change user needs to set groups and stuff
127 /* from Linux's linux/virtio_9p.h */
129 /* The ID for virtio console */
130 #define VIRTIO_ID_9P 9
132 #define MAX_TAG_LEN 32
134 #define BUG_ON(cond) assert(!(cond))
136 typedef struct V9fsFidState V9fsFidState
;
138 typedef struct V9fsString
144 typedef struct V9fsQID
151 typedef struct V9fsStat
166 V9fsString extension
;
179 typedef struct V9fsXattr
202 typedef struct V9fsState
206 V9fsPDU pdus
[MAX_REQ
];
207 QLIST_HEAD(, V9fsPDU
) free_list
;
208 V9fsFidState
*fid_list
;
214 enum p9_proto_version proto_version
;
218 typedef struct V9fsCreateState
{
227 V9fsString extension
;
232 typedef struct V9fsLcreateState
{
243 typedef struct V9fsStatState
{
251 typedef struct V9fsStatDotl
{
252 uint64_t st_result_mask
;
262 uint64_t st_atime_sec
;
263 uint64_t st_atime_nsec
;
264 uint64_t st_mtime_sec
;
265 uint64_t st_mtime_nsec
;
266 uint64_t st_ctime_sec
;
267 uint64_t st_ctime_nsec
;
268 uint64_t st_btime_sec
;
269 uint64_t st_btime_nsec
;
271 uint64_t st_data_version
;
274 typedef struct V9fsStatStateDotl
{
277 V9fsStatDotl v9stat_dotl
;
282 typedef struct V9fsWalkState
{
289 V9fsFidState
*newfidp
;
295 typedef struct V9fsOpenState
{
305 typedef struct V9fsReadState
{
312 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
324 typedef struct V9fsWriteState
{
332 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
337 typedef struct V9fsRemoveState
{
343 typedef struct V9fsWstatState
353 typedef struct V9fsSymlinkState
365 typedef struct V9fsIattr
378 typedef struct V9fsSetattrState
386 struct virtio_9p_config
388 /* number of characters in tag */
390 /* Variable size tag name */
392 } __attribute__((packed
));
394 typedef struct V9fsStatfs
407 typedef struct V9fsStatfsState
{
416 typedef struct V9fsMkState
{
425 typedef struct V9fsRenameState
{
433 typedef struct V9fsXattrState
437 V9fsFidState
*file_fidp
;
438 V9fsFidState
*xattr_fidp
;
445 #define P9_LOCK_SUCCESS 0
446 #define P9_LOCK_BLOCKED 1
447 #define P9_LOCK_ERROR 2
448 #define P9_LOCK_GRACE 3
450 #define P9_LOCK_FLAGS_BLOCK 1
451 #define P9_LOCK_FLAGS_RECLAIM 2
453 typedef struct V9fsFlock
457 uint64_t start
; /* absolute offset */
460 V9fsString client_id
;
463 typedef struct V9fsLockState
473 typedef struct V9fsGetlock
476 uint64_t start
; /* absolute offset */
479 V9fsString client_id
;
482 typedef struct V9fsGetlockState
491 typedef struct V9fsReadLinkState
498 size_t pdu_packunpack(void *addr
, struct iovec
*sg
, int sg_count
,
499 size_t offset
, size_t size
, int pack
);
501 static inline size_t do_pdu_unpack(void *dst
, struct iovec
*sg
, int sg_count
,
502 size_t offset
, size_t size
)
504 return pdu_packunpack(dst
, sg
, sg_count
, offset
, size
, 0);