xref: /qemu/hw/9pfs/virtio-9p.h (revision 7834cf77be7e3e301177c6ab98a3d7f1bf73f28f)
19f107513SAnthony Liguori #ifndef _QEMU_VIRTIO_9P_H
29f107513SAnthony Liguori #define _QEMU_VIRTIO_9P_H
39f107513SAnthony Liguori 
49f107513SAnthony Liguori #include <sys/types.h>
59f107513SAnthony Liguori #include <dirent.h>
69f107513SAnthony Liguori #include <sys/time.h>
79f107513SAnthony Liguori #include <utime.h>
87a462745SAneesh Kumar K.V #include <sys/resource.h>
9ff06030fSVenkateswararao Jujjuri (JV) #include "hw/virtio.h"
10353ac78dSAneesh Kumar K.V #include "fsdev/file-op-9p.h"
119f107513SAnthony Liguori 
129f107513SAnthony Liguori /* The feature bitmap for virtio 9P */
139f107513SAnthony Liguori /* The mount point is specified in a config variable */
149f107513SAnthony Liguori #define VIRTIO_9P_MOUNT_TAG 0
159f107513SAnthony Liguori 
169f107513SAnthony Liguori enum {
178f4d1ca5SArun R Bharadwaj     P9_TLERROR = 6,
188f4d1ca5SArun R Bharadwaj     P9_RLERROR,
19be940c87SM. Mohan Kumar     P9_TSTATFS = 8,
20be940c87SM. Mohan Kumar     P9_RSTATFS,
21771e9d4cSM. Mohan Kumar     P9_TLOPEN = 12,
22771e9d4cSM. Mohan Kumar     P9_RLOPEN,
23c1568af5SVenkateswararao Jujjuri (JV)     P9_TLCREATE = 14,
24c1568af5SVenkateswararao Jujjuri (JV)     P9_RLCREATE,
2508c60fc9SVenkateswararao Jujjuri (JV)     P9_TSYMLINK = 16,
2608c60fc9SVenkateswararao Jujjuri (JV)     P9_RSYMLINK,
275268ceccSM. Mohan Kumar     P9_TMKNOD = 18,
285268ceccSM. Mohan Kumar     P9_RMKNOD,
29c7b4b0b3SM. Mohan Kumar     P9_TRENAME = 20,
30c7b4b0b3SM. Mohan Kumar     P9_RRENAME,
31df0973a4SM. Mohan Kumar     P9_TREADLINK = 22,
32df0973a4SM. Mohan Kumar     P9_RREADLINK,
3300ede4c2SSripathi Kodi     P9_TGETATTR = 24,
3400ede4c2SSripathi Kodi     P9_RGETATTR,
35c79ce737SSripathi Kodi     P9_TSETATTR = 26,
36c79ce737SSripathi Kodi     P9_RSETATTR,
37fa32ef88SAneesh Kumar K.V     P9_TXATTRWALK = 30,
38fa32ef88SAneesh Kumar K.V     P9_RXATTRWALK,
3910b468bdSAneesh Kumar K.V     P9_TXATTRCREATE = 32,
4010b468bdSAneesh Kumar K.V     P9_RXATTRCREATE,
41c18e2f94SSripathi Kodi     P9_TREADDIR = 40,
42c18e2f94SSripathi Kodi     P9_RREADDIR,
43b41e95d3SVenkateswararao Jujjuri (JV)     P9_TFSYNC = 50,
44b41e95d3SVenkateswararao Jujjuri (JV)     P9_RFSYNC,
4582cc3ee8SM. Mohan Kumar     P9_TLOCK = 52,
4682cc3ee8SM. Mohan Kumar     P9_RLOCK,
478f354003SM. Mohan Kumar     P9_TGETLOCK = 54,
488f354003SM. Mohan Kumar     P9_RGETLOCK,
49b2c224beSVenkateswararao Jujjuri (JV)     P9_TLINK = 70,
50b2c224beSVenkateswararao Jujjuri (JV)     P9_RLINK,
51b67592eaSM. Mohan Kumar     P9_TMKDIR = 72,
52b67592eaSM. Mohan Kumar     P9_RMKDIR,
5389bf6593SAneesh Kumar K.V     P9_TRENAMEAT = 74,
5489bf6593SAneesh Kumar K.V     P9_RRENAMEAT,
55*7834cf77SAneesh Kumar K.V     P9_TUNLINKAT = 76,
56*7834cf77SAneesh Kumar K.V     P9_RUNLINKAT,
579f107513SAnthony Liguori     P9_TVERSION = 100,
589f107513SAnthony Liguori     P9_RVERSION,
599f107513SAnthony Liguori     P9_TAUTH = 102,
609f107513SAnthony Liguori     P9_RAUTH,
619f107513SAnthony Liguori     P9_TATTACH = 104,
629f107513SAnthony Liguori     P9_RATTACH,
639f107513SAnthony Liguori     P9_TERROR = 106,
649f107513SAnthony Liguori     P9_RERROR,
659f107513SAnthony Liguori     P9_TFLUSH = 108,
669f107513SAnthony Liguori     P9_RFLUSH,
679f107513SAnthony Liguori     P9_TWALK = 110,
689f107513SAnthony Liguori     P9_RWALK,
699f107513SAnthony Liguori     P9_TOPEN = 112,
709f107513SAnthony Liguori     P9_ROPEN,
719f107513SAnthony Liguori     P9_TCREATE = 114,
729f107513SAnthony Liguori     P9_RCREATE,
739f107513SAnthony Liguori     P9_TREAD = 116,
749f107513SAnthony Liguori     P9_RREAD,
759f107513SAnthony Liguori     P9_TWRITE = 118,
769f107513SAnthony Liguori     P9_RWRITE,
779f107513SAnthony Liguori     P9_TCLUNK = 120,
789f107513SAnthony Liguori     P9_RCLUNK,
799f107513SAnthony Liguori     P9_TREMOVE = 122,
809f107513SAnthony Liguori     P9_RREMOVE,
819f107513SAnthony Liguori     P9_TSTAT = 124,
829f107513SAnthony Liguori     P9_RSTAT,
839f107513SAnthony Liguori     P9_TWSTAT = 126,
849f107513SAnthony Liguori     P9_RWSTAT,
859f107513SAnthony Liguori };
869f107513SAnthony Liguori 
879f107513SAnthony Liguori 
889f107513SAnthony Liguori /* qid.types */
899f107513SAnthony Liguori enum {
909f107513SAnthony Liguori     P9_QTDIR = 0x80,
919f107513SAnthony Liguori     P9_QTAPPEND = 0x40,
929f107513SAnthony Liguori     P9_QTEXCL = 0x20,
939f107513SAnthony Liguori     P9_QTMOUNT = 0x10,
949f107513SAnthony Liguori     P9_QTAUTH = 0x08,
959f107513SAnthony Liguori     P9_QTTMP = 0x04,
969f107513SAnthony Liguori     P9_QTSYMLINK = 0x02,
979f107513SAnthony Liguori     P9_QTLINK = 0x01,
989f107513SAnthony Liguori     P9_QTFILE = 0x00,
999f107513SAnthony Liguori };
1009f107513SAnthony Liguori 
10184151514SM. Mohan Kumar enum p9_proto_version {
10284151514SM. Mohan Kumar     V9FS_PROTO_2000U = 0x01,
10384151514SM. Mohan Kumar     V9FS_PROTO_2000L = 0x02,
10484151514SM. Mohan Kumar };
10584151514SM. Mohan Kumar 
1069f107513SAnthony Liguori #define P9_NOTAG    (u16)(~0)
1079f107513SAnthony Liguori #define P9_NOFID    (u32)(~0)
1089f107513SAnthony Liguori #define P9_MAXWELEM 16
1097a462745SAneesh Kumar K.V 
1107a462745SAneesh Kumar K.V #define FID_REFERENCED          0x1
1117a462745SAneesh Kumar K.V #define FID_NON_RECLAIMABLE     0x2
112faa44e3dSVenkateswararao Jujjuri (JV) static inline const char *rpath(FsContext *ctx, const char *path, char *buffer)
113faa44e3dSVenkateswararao Jujjuri (JV) {
114faa44e3dSVenkateswararao Jujjuri (JV)     snprintf(buffer, PATH_MAX, "%s/%s", ctx->fs_root, path);
115faa44e3dSVenkateswararao Jujjuri (JV)     return buffer;
116faa44e3dSVenkateswararao Jujjuri (JV) }
1179f107513SAnthony Liguori 
1185e94c103SM. Mohan Kumar /*
1195e94c103SM. Mohan Kumar  * ample room for Twrite/Rread header
1205e94c103SM. Mohan Kumar  * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
1215e94c103SM. Mohan Kumar  */
1225e94c103SM. Mohan Kumar #define P9_IOHDRSZ 24
1235e94c103SM. Mohan Kumar 
1249f107513SAnthony Liguori typedef struct V9fsPDU V9fsPDU;
125ff06030fSVenkateswararao Jujjuri (JV) struct V9fsState;
1269f107513SAnthony Liguori 
1279f107513SAnthony Liguori struct V9fsPDU
1289f107513SAnthony Liguori {
1299f107513SAnthony Liguori     uint32_t size;
1309f107513SAnthony Liguori     uint16_t tag;
1319f107513SAnthony Liguori     uint8_t id;
1329f107513SAnthony Liguori     VirtQueueElement elem;
133ff06030fSVenkateswararao Jujjuri (JV)     struct V9fsState *s;
1349f107513SAnthony Liguori     QLIST_ENTRY(V9fsPDU) next;
1359f107513SAnthony Liguori };
1369f107513SAnthony Liguori 
1379f107513SAnthony Liguori 
1389f107513SAnthony Liguori /* FIXME
1399f107513SAnthony Liguori  * 1) change user needs to set groups and stuff
1409f107513SAnthony Liguori  */
1419f107513SAnthony Liguori 
1429f107513SAnthony Liguori /* from Linux's linux/virtio_9p.h */
1439f107513SAnthony Liguori 
1449f107513SAnthony Liguori /* The ID for virtio console */
1459f107513SAnthony Liguori #define VIRTIO_ID_9P    9
1469f107513SAnthony Liguori #define MAX_REQ         128
1479f107513SAnthony Liguori #define MAX_TAG_LEN     32
1489f107513SAnthony Liguori 
1499f107513SAnthony Liguori #define BUG_ON(cond) assert(!(cond))
1509f107513SAnthony Liguori 
1519f107513SAnthony Liguori typedef struct V9fsFidState V9fsFidState;
1529f107513SAnthony Liguori 
1539f107513SAnthony Liguori typedef struct V9fsString
1549f107513SAnthony Liguori {
1559f107513SAnthony Liguori     int16_t size;
1569f107513SAnthony Liguori     char *data;
1579f107513SAnthony Liguori } V9fsString;
1589f107513SAnthony Liguori 
1599f107513SAnthony Liguori typedef struct V9fsQID
1609f107513SAnthony Liguori {
1619f107513SAnthony Liguori     int8_t type;
1629f107513SAnthony Liguori     int32_t version;
1639f107513SAnthony Liguori     int64_t path;
1649f107513SAnthony Liguori } V9fsQID;
1659f107513SAnthony Liguori 
1669f107513SAnthony Liguori typedef struct V9fsStat
1679f107513SAnthony Liguori {
1689f107513SAnthony Liguori     int16_t size;
1699f107513SAnthony Liguori     int16_t type;
1709f107513SAnthony Liguori     int32_t dev;
1719f107513SAnthony Liguori     V9fsQID qid;
1729f107513SAnthony Liguori     int32_t mode;
1739f107513SAnthony Liguori     int32_t atime;
1749f107513SAnthony Liguori     int32_t mtime;
1759f107513SAnthony Liguori     int64_t length;
1769f107513SAnthony Liguori     V9fsString name;
1779f107513SAnthony Liguori     V9fsString uid;
1789f107513SAnthony Liguori     V9fsString gid;
1799f107513SAnthony Liguori     V9fsString muid;
1809f107513SAnthony Liguori     /* 9p2000.u */
1819f107513SAnthony Liguori     V9fsString extension;
1829f107513SAnthony Liguori    int32_t n_uid;
1839f107513SAnthony Liguori     int32_t n_gid;
1849f107513SAnthony Liguori     int32_t n_muid;
1859f107513SAnthony Liguori } V9fsStat;
1869f107513SAnthony Liguori 
187d62dbb51SAneesh Kumar K.V enum {
188d62dbb51SAneesh Kumar K.V     P9_FID_NONE = 0,
189d62dbb51SAneesh Kumar K.V     P9_FID_FILE,
190d62dbb51SAneesh Kumar K.V     P9_FID_DIR,
191d62dbb51SAneesh Kumar K.V     P9_FID_XATTR,
192d62dbb51SAneesh Kumar K.V };
193d62dbb51SAneesh Kumar K.V 
194d62dbb51SAneesh Kumar K.V typedef struct V9fsXattr
195d62dbb51SAneesh Kumar K.V {
196d62dbb51SAneesh Kumar K.V     int64_t copied_len;
197d62dbb51SAneesh Kumar K.V     int64_t len;
198d62dbb51SAneesh Kumar K.V     void *value;
199d62dbb51SAneesh Kumar K.V     V9fsString name;
200d62dbb51SAneesh Kumar K.V     int flags;
201d62dbb51SAneesh Kumar K.V } V9fsXattr;
202d62dbb51SAneesh Kumar K.V 
2039f107513SAnthony Liguori struct V9fsFidState
2049f107513SAnthony Liguori {
205d62dbb51SAneesh Kumar K.V     int fid_type;
2069f107513SAnthony Liguori     int32_t fid;
2079f107513SAnthony Liguori     V9fsString path;
208d62dbb51SAneesh Kumar K.V     union {
2099f107513SAnthony Liguori         int fd;
2109f107513SAnthony Liguori         DIR *dir;
211d62dbb51SAneesh Kumar K.V         V9fsXattr xattr;
212d62dbb51SAneesh Kumar K.V     } fs;
2137a462745SAneesh Kumar K.V     union {
2147a462745SAneesh Kumar K.V         int fd;
2157a462745SAneesh Kumar K.V         DIR *dir;
2167a462745SAneesh Kumar K.V     } fs_reclaim;
2177a462745SAneesh Kumar K.V     int flags;
2187a462745SAneesh Kumar K.V     int open_flags;
2199f107513SAnthony Liguori     uid_t uid;
22084dfb926SAneesh Kumar K.V     int ref;
22184dfb926SAneesh Kumar K.V     int clunked;
2229f107513SAnthony Liguori     V9fsFidState *next;
2237a462745SAneesh Kumar K.V     V9fsFidState *rclm_lst;
2249f107513SAnthony Liguori };
2259f107513SAnthony Liguori 
2269f107513SAnthony Liguori typedef struct V9fsState
2279f107513SAnthony Liguori {
2289f107513SAnthony Liguori     VirtIODevice vdev;
2299f107513SAnthony Liguori     VirtQueue *vq;
2309f107513SAnthony Liguori     V9fsPDU pdus[MAX_REQ];
2319f107513SAnthony Liguori     QLIST_HEAD(, V9fsPDU) free_list;
2329f107513SAnthony Liguori     V9fsFidState *fid_list;
2339f107513SAnthony Liguori     FileOperations *ops;
2349f107513SAnthony Liguori     FsContext ctx;
2359f107513SAnthony Liguori     uint16_t tag_len;
2369f107513SAnthony Liguori     uint8_t *tag;
2379f107513SAnthony Liguori     size_t config_size;
23884151514SM. Mohan Kumar     enum p9_proto_version proto_version;
2395e94c103SM. Mohan Kumar     int32_t msize;
2409f107513SAnthony Liguori } V9fsState;
2419f107513SAnthony Liguori 
242fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsStatState {
243fac4f111SVenkateswararao Jujjuri (JV)     V9fsPDU *pdu;
244fac4f111SVenkateswararao Jujjuri (JV)     size_t offset;
245fac4f111SVenkateswararao Jujjuri (JV)     V9fsStat v9stat;
246fac4f111SVenkateswararao Jujjuri (JV)     V9fsFidState *fidp;
247fac4f111SVenkateswararao Jujjuri (JV)     struct stat stbuf;
248fac4f111SVenkateswararao Jujjuri (JV) } V9fsStatState;
249fac4f111SVenkateswararao Jujjuri (JV) 
25000ede4c2SSripathi Kodi typedef struct V9fsStatDotl {
25100ede4c2SSripathi Kodi     uint64_t st_result_mask;
25200ede4c2SSripathi Kodi     V9fsQID qid;
25300ede4c2SSripathi Kodi     uint32_t st_mode;
25400ede4c2SSripathi Kodi     uint32_t st_uid;
25500ede4c2SSripathi Kodi     uint32_t st_gid;
25600ede4c2SSripathi Kodi     uint64_t st_nlink;
25700ede4c2SSripathi Kodi     uint64_t st_rdev;
25800ede4c2SSripathi Kodi     uint64_t st_size;
25900ede4c2SSripathi Kodi     uint64_t st_blksize;
26000ede4c2SSripathi Kodi     uint64_t st_blocks;
26100ede4c2SSripathi Kodi     uint64_t st_atime_sec;
26200ede4c2SSripathi Kodi     uint64_t st_atime_nsec;
26300ede4c2SSripathi Kodi     uint64_t st_mtime_sec;
26400ede4c2SSripathi Kodi     uint64_t st_mtime_nsec;
26500ede4c2SSripathi Kodi     uint64_t st_ctime_sec;
26600ede4c2SSripathi Kodi     uint64_t st_ctime_nsec;
26700ede4c2SSripathi Kodi     uint64_t st_btime_sec;
26800ede4c2SSripathi Kodi     uint64_t st_btime_nsec;
26900ede4c2SSripathi Kodi     uint64_t st_gen;
27000ede4c2SSripathi Kodi     uint64_t st_data_version;
27100ede4c2SSripathi Kodi } V9fsStatDotl;
27200ede4c2SSripathi Kodi 
273fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsOpenState {
274fac4f111SVenkateswararao Jujjuri (JV)     V9fsPDU *pdu;
275fac4f111SVenkateswararao Jujjuri (JV)     size_t offset;
276771e9d4cSM. Mohan Kumar     int32_t mode;
277fac4f111SVenkateswararao Jujjuri (JV)     V9fsFidState *fidp;
278fac4f111SVenkateswararao Jujjuri (JV)     V9fsQID qid;
279fac4f111SVenkateswararao Jujjuri (JV)     struct stat stbuf;
2805e94c103SM. Mohan Kumar     int iounit;
281fac4f111SVenkateswararao Jujjuri (JV) } V9fsOpenState;
282fac4f111SVenkateswararao Jujjuri (JV) 
283fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsReadState {
284fac4f111SVenkateswararao Jujjuri (JV)     V9fsPDU *pdu;
285fac4f111SVenkateswararao Jujjuri (JV)     size_t offset;
286fac4f111SVenkateswararao Jujjuri (JV)     int32_t count;
287fac4f111SVenkateswararao Jujjuri (JV)     int32_t total;
288fac4f111SVenkateswararao Jujjuri (JV)     int64_t off;
289fac4f111SVenkateswararao Jujjuri (JV)     V9fsFidState *fidp;
290fac4f111SVenkateswararao Jujjuri (JV)     struct iovec iov[128]; /* FIXME: bad, bad, bad */
291fac4f111SVenkateswararao Jujjuri (JV)     struct iovec *sg;
292fac4f111SVenkateswararao Jujjuri (JV)     off_t dir_pos;
293fac4f111SVenkateswararao Jujjuri (JV)     struct dirent *dent;
294fac4f111SVenkateswararao Jujjuri (JV)     struct stat stbuf;
295fac4f111SVenkateswararao Jujjuri (JV)     V9fsString name;
296fac4f111SVenkateswararao Jujjuri (JV)     V9fsStat v9stat;
297fac4f111SVenkateswararao Jujjuri (JV)     int32_t len;
298fac4f111SVenkateswararao Jujjuri (JV)     int32_t cnt;
299fac4f111SVenkateswararao Jujjuri (JV)     int32_t max_count;
300fac4f111SVenkateswararao Jujjuri (JV) } V9fsReadState;
301fac4f111SVenkateswararao Jujjuri (JV) 
302fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsWriteState {
303fac4f111SVenkateswararao Jujjuri (JV)     V9fsPDU *pdu;
304fac4f111SVenkateswararao Jujjuri (JV)     size_t offset;
305fac4f111SVenkateswararao Jujjuri (JV)     int32_t len;
306fac4f111SVenkateswararao Jujjuri (JV)     int32_t count;
307fac4f111SVenkateswararao Jujjuri (JV)     int32_t total;
308fac4f111SVenkateswararao Jujjuri (JV)     int64_t off;
309fac4f111SVenkateswararao Jujjuri (JV)     V9fsFidState *fidp;
310fac4f111SVenkateswararao Jujjuri (JV)     struct iovec iov[128]; /* FIXME: bad, bad, bad */
311fac4f111SVenkateswararao Jujjuri (JV)     struct iovec *sg;
312fac4f111SVenkateswararao Jujjuri (JV)     int cnt;
313fac4f111SVenkateswararao Jujjuri (JV) } V9fsWriteState;
314fac4f111SVenkateswararao Jujjuri (JV) 
315c79ce737SSripathi Kodi typedef struct V9fsIattr
316c79ce737SSripathi Kodi {
317c79ce737SSripathi Kodi     int32_t valid;
318c79ce737SSripathi Kodi     int32_t mode;
319c79ce737SSripathi Kodi     int32_t uid;
320c79ce737SSripathi Kodi     int32_t gid;
321c79ce737SSripathi Kodi     int64_t size;
322c79ce737SSripathi Kodi     int64_t atime_sec;
323c79ce737SSripathi Kodi     int64_t atime_nsec;
324c79ce737SSripathi Kodi     int64_t mtime_sec;
325c79ce737SSripathi Kodi     int64_t mtime_nsec;
326c79ce737SSripathi Kodi } V9fsIattr;
327c79ce737SSripathi Kodi 
3289f107513SAnthony Liguori struct virtio_9p_config
3299f107513SAnthony Liguori {
3309f107513SAnthony Liguori     /* number of characters in tag */
3319f107513SAnthony Liguori     uint16_t tag_len;
3329f107513SAnthony Liguori     /* Variable size tag name */
3339f107513SAnthony Liguori     uint8_t tag[0];
334541dc0d4SStefan Weil } QEMU_PACKED;
3359f107513SAnthony Liguori 
3365268ceccSM. Mohan Kumar typedef struct V9fsMkState {
3375268ceccSM. Mohan Kumar     V9fsPDU *pdu;
3385268ceccSM. Mohan Kumar     size_t offset;
3395268ceccSM. Mohan Kumar     V9fsQID qid;
3405268ceccSM. Mohan Kumar     struct stat stbuf;
3415268ceccSM. Mohan Kumar     V9fsString name;
3425268ceccSM. Mohan Kumar     V9fsString fullname;
3435268ceccSM. Mohan Kumar } V9fsMkState;
3445268ceccSM. Mohan Kumar 
34582cc3ee8SM. Mohan Kumar #define P9_LOCK_SUCCESS 0
34682cc3ee8SM. Mohan Kumar #define P9_LOCK_BLOCKED 1
34782cc3ee8SM. Mohan Kumar #define P9_LOCK_ERROR 2
34882cc3ee8SM. Mohan Kumar #define P9_LOCK_GRACE 3
34982cc3ee8SM. Mohan Kumar 
35082cc3ee8SM. Mohan Kumar #define P9_LOCK_FLAGS_BLOCK 1
35182cc3ee8SM. Mohan Kumar #define P9_LOCK_FLAGS_RECLAIM 2
35282cc3ee8SM. Mohan Kumar 
35382cc3ee8SM. Mohan Kumar typedef struct V9fsFlock
35482cc3ee8SM. Mohan Kumar {
35582cc3ee8SM. Mohan Kumar     uint8_t type;
35682cc3ee8SM. Mohan Kumar     uint32_t flags;
35782cc3ee8SM. Mohan Kumar     uint64_t start; /* absolute offset */
35882cc3ee8SM. Mohan Kumar     uint64_t length;
35982cc3ee8SM. Mohan Kumar     uint32_t proc_id;
36082cc3ee8SM. Mohan Kumar     V9fsString client_id;
36182cc3ee8SM. Mohan Kumar } V9fsFlock;
36282cc3ee8SM. Mohan Kumar 
3638f354003SM. Mohan Kumar typedef struct V9fsGetlock
3648f354003SM. Mohan Kumar {
3658f354003SM. Mohan Kumar     uint8_t type;
3668f354003SM. Mohan Kumar     uint64_t start; /* absolute offset */
3678f354003SM. Mohan Kumar     uint64_t length;
3688f354003SM. Mohan Kumar     uint32_t proc_id;
3698f354003SM. Mohan Kumar     V9fsString client_id;
3708f354003SM. Mohan Kumar } V9fsGetlock;
3718f354003SM. Mohan Kumar 
3727a462745SAneesh Kumar K.V extern int open_fd_hw;
3737a462745SAneesh Kumar K.V extern int total_open_fd;
3747a462745SAneesh Kumar K.V 
37564b85a8fSBlue Swirl size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
3769f107513SAnthony Liguori                       size_t offset, size_t size, int pack);
3779f107513SAnthony Liguori 
3789f107513SAnthony Liguori static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count,
3799f107513SAnthony Liguori                         size_t offset, size_t size)
3809f107513SAnthony Liguori {
3819f107513SAnthony Liguori     return pdu_packunpack(dst, sg, sg_count, offset, size, 0);
3829f107513SAnthony Liguori }
3839f107513SAnthony Liguori 
384f4f61d27SAneesh Kumar K.V extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq);
3857a462745SAneesh Kumar K.V extern void virtio_9p_set_fd_limit(void);
3867a462745SAneesh Kumar K.V extern void v9fs_reclaim_fd(V9fsState *s);
3879f107513SAnthony Liguori #endif
388