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
97 enum p9_proto_version
{
98 V9FS_PROTO_2000U
= 0x01,
99 V9FS_PROTO_2000L
= 0x02,
102 #define P9_NOTAG (u16)(~0)
103 #define P9_NOFID (u32)(~0)
104 #define P9_MAXWELEM 16
106 #define FID_REFERENCED 0x1
107 #define FID_NON_RECLAIMABLE 0x2
108 static inline const char *rpath(FsContext
*ctx
, const char *path
, char *buffer
)
110 snprintf(buffer
, PATH_MAX
, "%s/%s", ctx
->fs_root
, path
);
115 * ample room for Twrite/Rread header
116 * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
118 #define P9_IOHDRSZ 24
120 typedef struct V9fsPDU V9fsPDU
;
128 VirtQueueElement elem
;
130 QLIST_ENTRY(V9fsPDU
) next
;
135 * 1) change user needs to set groups and stuff
138 /* from Linux's linux/virtio_9p.h */
140 /* The ID for virtio console */
141 #define VIRTIO_ID_9P 9
143 #define MAX_TAG_LEN 32
145 #define BUG_ON(cond) assert(!(cond))
147 typedef struct V9fsFidState V9fsFidState
;
149 typedef struct V9fsString
155 typedef struct V9fsQID
162 typedef struct V9fsStat
177 V9fsString extension
;
190 typedef struct V9fsXattr
219 V9fsFidState
*rclm_lst
;
222 typedef struct V9fsState
226 V9fsPDU pdus
[MAX_REQ
];
227 QLIST_HEAD(, V9fsPDU
) free_list
;
228 V9fsFidState
*fid_list
;
234 enum p9_proto_version proto_version
;
238 typedef struct V9fsStatState
{
246 typedef struct V9fsStatDotl
{
247 uint64_t st_result_mask
;
257 uint64_t st_atime_sec
;
258 uint64_t st_atime_nsec
;
259 uint64_t st_mtime_sec
;
260 uint64_t st_mtime_nsec
;
261 uint64_t st_ctime_sec
;
262 uint64_t st_ctime_nsec
;
263 uint64_t st_btime_sec
;
264 uint64_t st_btime_nsec
;
266 uint64_t st_data_version
;
269 typedef struct V9fsOpenState
{
279 typedef struct V9fsReadState
{
286 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
298 typedef struct V9fsWriteState
{
306 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
311 typedef struct V9fsIattr
324 struct virtio_9p_config
326 /* number of characters in tag */
328 /* Variable size tag name */
332 typedef struct V9fsMkState
{
341 #define P9_LOCK_SUCCESS 0
342 #define P9_LOCK_BLOCKED 1
343 #define P9_LOCK_ERROR 2
344 #define P9_LOCK_GRACE 3
346 #define P9_LOCK_FLAGS_BLOCK 1
347 #define P9_LOCK_FLAGS_RECLAIM 2
349 typedef struct V9fsFlock
353 uint64_t start
; /* absolute offset */
356 V9fsString client_id
;
359 typedef struct V9fsGetlock
362 uint64_t start
; /* absolute offset */
365 V9fsString client_id
;
368 extern int open_fd_hw
;
369 extern int total_open_fd
;
371 size_t pdu_packunpack(void *addr
, struct iovec
*sg
, int sg_count
,
372 size_t offset
, size_t size
, int pack
);
374 static inline size_t do_pdu_unpack(void *dst
, struct iovec
*sg
, int sg_count
,
375 size_t offset
, size_t size
)
377 return pdu_packunpack(dst
, sg
, sg_count
, offset
, size
, 0);
380 extern void handle_9p_output(VirtIODevice
*vdev
, VirtQueue
*vq
);
381 extern void virtio_9p_set_fd_limit(void);
382 extern void v9fs_reclaim_fd(V9fsState
*s
);