1 #ifndef _QEMU_VIRTIO_9P_H
2 #define _QEMU_VIRTIO_9P_H
8 #include <sys/resource.h>
10 #include "fsdev/file-op-9p.h"
12 /* The feature bitmap for virtio 9P */
13 /* The mount point is specified in a config variable */
14 #define VIRTIO_9P_MOUNT_TAG 0
99 enum p9_proto_version
{
100 V9FS_PROTO_2000U
= 0x01,
101 V9FS_PROTO_2000L
= 0x02,
104 #define P9_NOTAG (u16)(~0)
105 #define P9_NOFID (u32)(~0)
106 #define P9_MAXWELEM 16
108 #define FID_REFERENCED 0x1
109 #define FID_NON_RECLAIMABLE 0x2
110 static inline const char *rpath(FsContext
*ctx
, const char *path
, char *buffer
)
112 snprintf(buffer
, PATH_MAX
, "%s/%s", ctx
->fs_root
, path
);
117 * ample room for Twrite/Rread header
118 * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
120 #define P9_IOHDRSZ 24
122 typedef struct V9fsPDU V9fsPDU
;
130 VirtQueueElement elem
;
132 QLIST_ENTRY(V9fsPDU
) next
;
137 * 1) change user needs to set groups and stuff
140 /* from Linux's linux/virtio_9p.h */
142 /* The ID for virtio console */
143 #define VIRTIO_ID_9P 9
145 #define MAX_TAG_LEN 32
147 #define BUG_ON(cond) assert(!(cond))
149 typedef struct V9fsFidState V9fsFidState
;
151 typedef struct V9fsString
157 typedef struct V9fsQID
164 typedef struct V9fsStat
179 V9fsString extension
;
192 typedef struct V9fsXattr
221 V9fsFidState
*rclm_lst
;
224 typedef struct V9fsState
228 V9fsPDU pdus
[MAX_REQ
];
229 QLIST_HEAD(, V9fsPDU
) free_list
;
230 V9fsFidState
*fid_list
;
236 enum p9_proto_version proto_version
;
240 typedef struct V9fsStatState
{
248 typedef struct V9fsStatDotl
{
249 uint64_t st_result_mask
;
259 uint64_t st_atime_sec
;
260 uint64_t st_atime_nsec
;
261 uint64_t st_mtime_sec
;
262 uint64_t st_mtime_nsec
;
263 uint64_t st_ctime_sec
;
264 uint64_t st_ctime_nsec
;
265 uint64_t st_btime_sec
;
266 uint64_t st_btime_nsec
;
268 uint64_t st_data_version
;
271 typedef struct V9fsOpenState
{
281 typedef struct V9fsReadState
{
288 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
300 typedef struct V9fsWriteState
{
308 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
313 typedef struct V9fsIattr
326 struct virtio_9p_config
328 /* number of characters in tag */
330 /* Variable size tag name */
334 typedef struct V9fsMkState
{
343 #define P9_LOCK_SUCCESS 0
344 #define P9_LOCK_BLOCKED 1
345 #define P9_LOCK_ERROR 2
346 #define P9_LOCK_GRACE 3
348 #define P9_LOCK_FLAGS_BLOCK 1
349 #define P9_LOCK_FLAGS_RECLAIM 2
351 typedef struct V9fsFlock
355 uint64_t start
; /* absolute offset */
358 V9fsString client_id
;
361 typedef struct V9fsGetlock
364 uint64_t start
; /* absolute offset */
367 V9fsString client_id
;
370 extern int open_fd_hw
;
371 extern int total_open_fd
;
373 size_t pdu_packunpack(void *addr
, struct iovec
*sg
, int sg_count
,
374 size_t offset
, size_t size
, int pack
);
376 static inline size_t do_pdu_unpack(void *dst
, struct iovec
*sg
, int sg_count
,
377 size_t offset
, size_t size
)
379 return pdu_packunpack(dst
, sg
, sg_count
, offset
, size
, 0);
382 extern void handle_9p_output(VirtIODevice
*vdev
, VirtQueue
*vq
);
383 extern void virtio_9p_set_fd_limit(void);
384 extern void v9fs_reclaim_fd(V9fsState
*s
);