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
92 enum p9_proto_version
{
93 V9FS_PROTO_2000U
= 0x01,
94 V9FS_PROTO_2000L
= 0x02,
97 #define P9_NOTAG (u16)(~0)
98 #define P9_NOFID (u32)(~0)
99 #define P9_MAXWELEM 16
102 * ample room for Twrite/Rread header
103 * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
105 #define P9_IOHDRSZ 24
107 typedef struct V9fsPDU V9fsPDU
;
114 VirtQueueElement elem
;
115 QLIST_ENTRY(V9fsPDU
) next
;
120 * 1) change user needs to set groups and stuff
123 /* from Linux's linux/virtio_9p.h */
125 /* The ID for virtio console */
126 #define VIRTIO_ID_9P 9
128 #define MAX_TAG_LEN 32
130 #define BUG_ON(cond) assert(!(cond))
132 typedef struct V9fsFidState V9fsFidState
;
134 typedef struct V9fsString
140 typedef struct V9fsQID
147 typedef struct V9fsStat
162 V9fsString extension
;
175 typedef struct V9fsXattr
198 typedef struct V9fsState
202 V9fsPDU pdus
[MAX_REQ
];
203 QLIST_HEAD(, V9fsPDU
) free_list
;
204 V9fsFidState
*fid_list
;
210 enum p9_proto_version proto_version
;
214 typedef struct V9fsCreateState
{
223 V9fsString extension
;
228 typedef struct V9fsLcreateState
{
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 V9fsStatStateDotl
{
273 V9fsStatDotl v9stat_dotl
;
278 typedef struct V9fsWalkState
{
285 V9fsFidState
*newfidp
;
291 typedef struct V9fsOpenState
{
301 typedef struct V9fsReadState
{
308 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
320 typedef struct V9fsWriteState
{
328 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
333 typedef struct V9fsRemoveState
{
339 typedef struct V9fsWstatState
349 typedef struct V9fsSymlinkState
361 typedef struct V9fsIattr
374 typedef struct V9fsSetattrState
382 struct virtio_9p_config
384 /* number of characters in tag */
386 /* Variable size tag name */
388 } __attribute__((packed
));
390 typedef struct V9fsStatfs
403 typedef struct V9fsStatfsState
{
412 typedef struct V9fsMkState
{
421 typedef struct V9fsRenameState
{
429 typedef struct V9fsXattrState
433 V9fsFidState
*file_fidp
;
434 V9fsFidState
*xattr_fidp
;
441 #define P9_LOCK_SUCCESS 0
442 #define P9_LOCK_BLOCKED 1
443 #define P9_LOCK_ERROR 2
444 #define P9_LOCK_GRACE 3
446 #define P9_LOCK_FLAGS_BLOCK 1
447 #define P9_LOCK_FLAGS_RECLAIM 2
449 typedef struct V9fsFlock
453 uint64_t start
; /* absolute offset */
456 V9fsString client_id
;
459 typedef struct V9fsLockState
469 typedef struct V9fsGetlock
472 uint64_t start
; /* absolute offset */
475 V9fsString client_id
;
478 typedef struct V9fsGetlockState
488 extern size_t pdu_packunpack(void *addr
, struct iovec
*sg
, int sg_count
,
489 size_t offset
, size_t size
, int pack
);
491 static inline size_t do_pdu_unpack(void *dst
, struct iovec
*sg
, int sg_count
,
492 size_t offset
, size_t size
)
494 return pdu_packunpack(dst
, sg
, sg_count
, offset
, size
, 0);