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
101 enum p9_proto_version
{
102 V9FS_PROTO_2000U
= 0x01,
103 V9FS_PROTO_2000L
= 0x02,
106 #define P9_NOTAG (u16)(~0)
107 #define P9_NOFID (u32)(~0)
108 #define P9_MAXWELEM 16
110 #define FID_REFERENCED 0x1
111 #define FID_NON_RECLAIMABLE 0x2
112 static inline const char *rpath(FsContext
*ctx
, const char *path
, char *buffer
)
114 snprintf(buffer
, PATH_MAX
, "%s/%s", ctx
->fs_root
, path
);
119 * ample room for Twrite/Rread header
120 * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
122 #define P9_IOHDRSZ 24
124 typedef struct V9fsPDU V9fsPDU
;
132 VirtQueueElement elem
;
134 QLIST_ENTRY(V9fsPDU
) next
;
139 * 1) change user needs to set groups and stuff
142 /* from Linux's linux/virtio_9p.h */
144 /* The ID for virtio console */
145 #define VIRTIO_ID_9P 9
147 #define MAX_TAG_LEN 32
149 #define BUG_ON(cond) assert(!(cond))
151 typedef struct V9fsFidState V9fsFidState
;
153 typedef struct V9fsString
159 typedef struct V9fsQID
166 typedef struct V9fsStat
181 V9fsString extension
;
194 typedef struct V9fsXattr
223 V9fsFidState
*rclm_lst
;
226 typedef struct V9fsState
230 V9fsPDU pdus
[MAX_REQ
];
231 QLIST_HEAD(, V9fsPDU
) free_list
;
232 V9fsFidState
*fid_list
;
238 enum p9_proto_version proto_version
;
242 typedef struct V9fsStatState
{
250 typedef struct V9fsStatDotl
{
251 uint64_t st_result_mask
;
261 uint64_t st_atime_sec
;
262 uint64_t st_atime_nsec
;
263 uint64_t st_mtime_sec
;
264 uint64_t st_mtime_nsec
;
265 uint64_t st_ctime_sec
;
266 uint64_t st_ctime_nsec
;
267 uint64_t st_btime_sec
;
268 uint64_t st_btime_nsec
;
270 uint64_t st_data_version
;
273 typedef struct V9fsOpenState
{
283 typedef struct V9fsReadState
{
290 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
302 typedef struct V9fsWriteState
{
310 struct iovec iov
[128]; /* FIXME: bad, bad, bad */
315 typedef struct V9fsIattr
328 struct virtio_9p_config
330 /* number of characters in tag */
332 /* Variable size tag name */
336 typedef struct V9fsMkState
{
345 #define P9_LOCK_SUCCESS 0
346 #define P9_LOCK_BLOCKED 1
347 #define P9_LOCK_ERROR 2
348 #define P9_LOCK_GRACE 3
350 #define P9_LOCK_FLAGS_BLOCK 1
351 #define P9_LOCK_FLAGS_RECLAIM 2
353 typedef struct V9fsFlock
357 uint64_t start
; /* absolute offset */
360 V9fsString client_id
;
363 typedef struct V9fsGetlock
366 uint64_t start
; /* absolute offset */
369 V9fsString client_id
;
372 extern int open_fd_hw
;
373 extern int total_open_fd
;
375 size_t pdu_packunpack(void *addr
, struct iovec
*sg
, int sg_count
,
376 size_t offset
, size_t size
, int pack
);
378 static inline size_t do_pdu_unpack(void *dst
, struct iovec
*sg
, int sg_count
,
379 size_t offset
, size_t size
)
381 return pdu_packunpack(dst
, sg
, sg_count
, offset
, size
, 0);
384 extern void handle_9p_output(VirtIODevice
*vdev
, VirtQueue
*vq
);
385 extern void virtio_9p_set_fd_limit(void);
386 extern void v9fs_reclaim_fd(V9fsState
*s
);