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" 1102cb7f3aSAneesh Kumar K.V #include "qemu-thread.h" 1202cb7f3aSAneesh Kumar K.V #include "qemu-coroutine.h" 139f107513SAnthony Liguori 149f107513SAnthony Liguori /* The feature bitmap for virtio 9P */ 159f107513SAnthony Liguori /* The mount point is specified in a config variable */ 169f107513SAnthony Liguori #define VIRTIO_9P_MOUNT_TAG 0 179f107513SAnthony Liguori 189f107513SAnthony Liguori enum { 198f4d1ca5SArun R Bharadwaj P9_TLERROR = 6, 208f4d1ca5SArun R Bharadwaj P9_RLERROR, 21be940c87SM. Mohan Kumar P9_TSTATFS = 8, 22be940c87SM. Mohan Kumar P9_RSTATFS, 23771e9d4cSM. Mohan Kumar P9_TLOPEN = 12, 24771e9d4cSM. Mohan Kumar P9_RLOPEN, 25c1568af5SVenkateswararao Jujjuri (JV) P9_TLCREATE = 14, 26c1568af5SVenkateswararao Jujjuri (JV) P9_RLCREATE, 2708c60fc9SVenkateswararao Jujjuri (JV) P9_TSYMLINK = 16, 2808c60fc9SVenkateswararao Jujjuri (JV) P9_RSYMLINK, 295268ceccSM. Mohan Kumar P9_TMKNOD = 18, 305268ceccSM. Mohan Kumar P9_RMKNOD, 31c7b4b0b3SM. Mohan Kumar P9_TRENAME = 20, 32c7b4b0b3SM. Mohan Kumar P9_RRENAME, 33df0973a4SM. Mohan Kumar P9_TREADLINK = 22, 34df0973a4SM. Mohan Kumar P9_RREADLINK, 3500ede4c2SSripathi Kodi P9_TGETATTR = 24, 3600ede4c2SSripathi Kodi P9_RGETATTR, 37c79ce737SSripathi Kodi P9_TSETATTR = 26, 38c79ce737SSripathi Kodi P9_RSETATTR, 39fa32ef88SAneesh Kumar K.V P9_TXATTRWALK = 30, 40fa32ef88SAneesh Kumar K.V P9_RXATTRWALK, 4110b468bdSAneesh Kumar K.V P9_TXATTRCREATE = 32, 4210b468bdSAneesh Kumar K.V P9_RXATTRCREATE, 43c18e2f94SSripathi Kodi P9_TREADDIR = 40, 44c18e2f94SSripathi Kodi P9_RREADDIR, 45b41e95d3SVenkateswararao Jujjuri (JV) P9_TFSYNC = 50, 46b41e95d3SVenkateswararao Jujjuri (JV) P9_RFSYNC, 4782cc3ee8SM. Mohan Kumar P9_TLOCK = 52, 4882cc3ee8SM. Mohan Kumar P9_RLOCK, 498f354003SM. Mohan Kumar P9_TGETLOCK = 54, 508f354003SM. Mohan Kumar P9_RGETLOCK, 51b2c224beSVenkateswararao Jujjuri (JV) P9_TLINK = 70, 52b2c224beSVenkateswararao Jujjuri (JV) P9_RLINK, 53b67592eaSM. Mohan Kumar P9_TMKDIR = 72, 54b67592eaSM. Mohan Kumar P9_RMKDIR, 5589bf6593SAneesh Kumar K.V P9_TRENAMEAT = 74, 5689bf6593SAneesh Kumar K.V P9_RRENAMEAT, 577834cf77SAneesh Kumar K.V P9_TUNLINKAT = 76, 587834cf77SAneesh Kumar K.V P9_RUNLINKAT, 599f107513SAnthony Liguori P9_TVERSION = 100, 609f107513SAnthony Liguori P9_RVERSION, 619f107513SAnthony Liguori P9_TAUTH = 102, 629f107513SAnthony Liguori P9_RAUTH, 639f107513SAnthony Liguori P9_TATTACH = 104, 649f107513SAnthony Liguori P9_RATTACH, 659f107513SAnthony Liguori P9_TERROR = 106, 669f107513SAnthony Liguori P9_RERROR, 679f107513SAnthony Liguori P9_TFLUSH = 108, 689f107513SAnthony Liguori P9_RFLUSH, 699f107513SAnthony Liguori P9_TWALK = 110, 709f107513SAnthony Liguori P9_RWALK, 719f107513SAnthony Liguori P9_TOPEN = 112, 729f107513SAnthony Liguori P9_ROPEN, 739f107513SAnthony Liguori P9_TCREATE = 114, 749f107513SAnthony Liguori P9_RCREATE, 759f107513SAnthony Liguori P9_TREAD = 116, 769f107513SAnthony Liguori P9_RREAD, 779f107513SAnthony Liguori P9_TWRITE = 118, 789f107513SAnthony Liguori P9_RWRITE, 799f107513SAnthony Liguori P9_TCLUNK = 120, 809f107513SAnthony Liguori P9_RCLUNK, 819f107513SAnthony Liguori P9_TREMOVE = 122, 829f107513SAnthony Liguori P9_RREMOVE, 839f107513SAnthony Liguori P9_TSTAT = 124, 849f107513SAnthony Liguori P9_RSTAT, 859f107513SAnthony Liguori P9_TWSTAT = 126, 869f107513SAnthony Liguori P9_RWSTAT, 879f107513SAnthony Liguori }; 889f107513SAnthony Liguori 899f107513SAnthony Liguori 909f107513SAnthony Liguori /* qid.types */ 919f107513SAnthony Liguori enum { 929f107513SAnthony Liguori P9_QTDIR = 0x80, 939f107513SAnthony Liguori P9_QTAPPEND = 0x40, 949f107513SAnthony Liguori P9_QTEXCL = 0x20, 959f107513SAnthony Liguori P9_QTMOUNT = 0x10, 969f107513SAnthony Liguori P9_QTAUTH = 0x08, 979f107513SAnthony Liguori P9_QTTMP = 0x04, 989f107513SAnthony Liguori P9_QTSYMLINK = 0x02, 999f107513SAnthony Liguori P9_QTLINK = 0x01, 1009f107513SAnthony Liguori P9_QTFILE = 0x00, 1019f107513SAnthony Liguori }; 1029f107513SAnthony Liguori 10384151514SM. Mohan Kumar enum p9_proto_version { 10484151514SM. Mohan Kumar V9FS_PROTO_2000U = 0x01, 10584151514SM. Mohan Kumar V9FS_PROTO_2000L = 0x02, 10684151514SM. Mohan Kumar }; 10784151514SM. Mohan Kumar 1089f107513SAnthony Liguori #define P9_NOTAG (u16)(~0) 1099f107513SAnthony Liguori #define P9_NOFID (u32)(~0) 1109f107513SAnthony Liguori #define P9_MAXWELEM 16 1117a462745SAneesh Kumar K.V 1127a462745SAneesh Kumar K.V #define FID_REFERENCED 0x1 1137a462745SAneesh Kumar K.V #define FID_NON_RECLAIMABLE 0x2 114faa44e3dSVenkateswararao Jujjuri (JV) static inline const char *rpath(FsContext *ctx, const char *path, char *buffer) 115faa44e3dSVenkateswararao Jujjuri (JV) { 116faa44e3dSVenkateswararao Jujjuri (JV) snprintf(buffer, PATH_MAX, "%s/%s", ctx->fs_root, path); 117faa44e3dSVenkateswararao Jujjuri (JV) return buffer; 118faa44e3dSVenkateswararao Jujjuri (JV) } 1199f107513SAnthony Liguori 1205e94c103SM. Mohan Kumar /* 1215e94c103SM. Mohan Kumar * ample room for Twrite/Rread header 1225e94c103SM. Mohan Kumar * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4] 1235e94c103SM. Mohan Kumar */ 1245e94c103SM. Mohan Kumar #define P9_IOHDRSZ 24 1255e94c103SM. Mohan Kumar 1269f107513SAnthony Liguori typedef struct V9fsPDU V9fsPDU; 127ff06030fSVenkateswararao Jujjuri (JV) struct V9fsState; 1289f107513SAnthony Liguori 1299f107513SAnthony Liguori struct V9fsPDU 1309f107513SAnthony Liguori { 1319f107513SAnthony Liguori uint32_t size; 1329f107513SAnthony Liguori uint16_t tag; 1339f107513SAnthony Liguori uint8_t id; 134*bccacf6cSAneesh Kumar K.V uint8_t cancelled; 135*bccacf6cSAneesh Kumar K.V CoQueue complete; 1369f107513SAnthony Liguori VirtQueueElement elem; 137ff06030fSVenkateswararao Jujjuri (JV) struct V9fsState *s; 1389f107513SAnthony Liguori QLIST_ENTRY(V9fsPDU) next; 1399f107513SAnthony Liguori }; 1409f107513SAnthony Liguori 1419f107513SAnthony Liguori 1429f107513SAnthony Liguori /* FIXME 1439f107513SAnthony Liguori * 1) change user needs to set groups and stuff 1449f107513SAnthony Liguori */ 1459f107513SAnthony Liguori 1469f107513SAnthony Liguori /* from Linux's linux/virtio_9p.h */ 1479f107513SAnthony Liguori 1489f107513SAnthony Liguori /* The ID for virtio console */ 1499f107513SAnthony Liguori #define VIRTIO_ID_9P 9 1509f107513SAnthony Liguori #define MAX_REQ 128 1519f107513SAnthony Liguori #define MAX_TAG_LEN 32 1529f107513SAnthony Liguori 1539f107513SAnthony Liguori #define BUG_ON(cond) assert(!(cond)) 1549f107513SAnthony Liguori 1559f107513SAnthony Liguori typedef struct V9fsFidState V9fsFidState; 1569f107513SAnthony Liguori 1579f107513SAnthony Liguori typedef struct V9fsString 1589f107513SAnthony Liguori { 1599f107513SAnthony Liguori int16_t size; 1609f107513SAnthony Liguori char *data; 1619f107513SAnthony Liguori } V9fsString; 1629f107513SAnthony Liguori 1639f107513SAnthony Liguori typedef struct V9fsQID 1649f107513SAnthony Liguori { 1659f107513SAnthony Liguori int8_t type; 1669f107513SAnthony Liguori int32_t version; 1679f107513SAnthony Liguori int64_t path; 1689f107513SAnthony Liguori } V9fsQID; 1699f107513SAnthony Liguori 1709f107513SAnthony Liguori typedef struct V9fsStat 1719f107513SAnthony Liguori { 1729f107513SAnthony Liguori int16_t size; 1739f107513SAnthony Liguori int16_t type; 1749f107513SAnthony Liguori int32_t dev; 1759f107513SAnthony Liguori V9fsQID qid; 1769f107513SAnthony Liguori int32_t mode; 1779f107513SAnthony Liguori int32_t atime; 1789f107513SAnthony Liguori int32_t mtime; 1799f107513SAnthony Liguori int64_t length; 1809f107513SAnthony Liguori V9fsString name; 1819f107513SAnthony Liguori V9fsString uid; 1829f107513SAnthony Liguori V9fsString gid; 1839f107513SAnthony Liguori V9fsString muid; 1849f107513SAnthony Liguori /* 9p2000.u */ 1859f107513SAnthony Liguori V9fsString extension; 1869f107513SAnthony Liguori int32_t n_uid; 1879f107513SAnthony Liguori int32_t n_gid; 1889f107513SAnthony Liguori int32_t n_muid; 1899f107513SAnthony Liguori } V9fsStat; 1909f107513SAnthony Liguori 191d62dbb51SAneesh Kumar K.V enum { 192d62dbb51SAneesh Kumar K.V P9_FID_NONE = 0, 193d62dbb51SAneesh Kumar K.V P9_FID_FILE, 194d62dbb51SAneesh Kumar K.V P9_FID_DIR, 195d62dbb51SAneesh Kumar K.V P9_FID_XATTR, 196d62dbb51SAneesh Kumar K.V }; 197d62dbb51SAneesh Kumar K.V 198d62dbb51SAneesh Kumar K.V typedef struct V9fsXattr 199d62dbb51SAneesh Kumar K.V { 200d62dbb51SAneesh Kumar K.V int64_t copied_len; 201d62dbb51SAneesh Kumar K.V int64_t len; 202d62dbb51SAneesh Kumar K.V void *value; 203d62dbb51SAneesh Kumar K.V V9fsString name; 204d62dbb51SAneesh Kumar K.V int flags; 205d62dbb51SAneesh Kumar K.V } V9fsXattr; 206d62dbb51SAneesh Kumar K.V 2079f107513SAnthony Liguori struct V9fsFidState 2089f107513SAnthony Liguori { 209d62dbb51SAneesh Kumar K.V int fid_type; 2109f107513SAnthony Liguori int32_t fid; 2112289be19SAneesh Kumar K.V V9fsPath path; 212d62dbb51SAneesh Kumar K.V union { 2139f107513SAnthony Liguori int fd; 2149f107513SAnthony Liguori DIR *dir; 215d62dbb51SAneesh Kumar K.V V9fsXattr xattr; 216d62dbb51SAneesh Kumar K.V } fs; 2177a462745SAneesh Kumar K.V union { 2187a462745SAneesh Kumar K.V int fd; 2197a462745SAneesh Kumar K.V DIR *dir; 2207a462745SAneesh Kumar K.V } fs_reclaim; 2217a462745SAneesh Kumar K.V int flags; 2227a462745SAneesh Kumar K.V int open_flags; 2239f107513SAnthony Liguori uid_t uid; 22484dfb926SAneesh Kumar K.V int ref; 22584dfb926SAneesh Kumar K.V int clunked; 2269f107513SAnthony Liguori V9fsFidState *next; 2277a462745SAneesh Kumar K.V V9fsFidState *rclm_lst; 2289f107513SAnthony Liguori }; 2299f107513SAnthony Liguori 2309f107513SAnthony Liguori typedef struct V9fsState 2319f107513SAnthony Liguori { 2329f107513SAnthony Liguori VirtIODevice vdev; 2339f107513SAnthony Liguori VirtQueue *vq; 2349f107513SAnthony Liguori V9fsPDU pdus[MAX_REQ]; 2359f107513SAnthony Liguori QLIST_HEAD(, V9fsPDU) free_list; 236*bccacf6cSAneesh Kumar K.V QLIST_HEAD(, V9fsPDU) active_list; 2379f107513SAnthony Liguori V9fsFidState *fid_list; 2389f107513SAnthony Liguori FileOperations *ops; 2399f107513SAnthony Liguori FsContext ctx; 2409f107513SAnthony Liguori uint16_t tag_len; 2419f107513SAnthony Liguori uint8_t *tag; 2429f107513SAnthony Liguori size_t config_size; 24384151514SM. Mohan Kumar enum p9_proto_version proto_version; 2445e94c103SM. Mohan Kumar int32_t msize; 24502cb7f3aSAneesh Kumar K.V /* 24602cb7f3aSAneesh Kumar K.V * lock ensuring atomic path update 24702cb7f3aSAneesh Kumar K.V * on rename. 24802cb7f3aSAneesh Kumar K.V */ 24902cb7f3aSAneesh Kumar K.V CoRwlock rename_lock; 2509f107513SAnthony Liguori } V9fsState; 2519f107513SAnthony Liguori 252fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsStatState { 253fac4f111SVenkateswararao Jujjuri (JV) V9fsPDU *pdu; 254fac4f111SVenkateswararao Jujjuri (JV) size_t offset; 255fac4f111SVenkateswararao Jujjuri (JV) V9fsStat v9stat; 256fac4f111SVenkateswararao Jujjuri (JV) V9fsFidState *fidp; 257fac4f111SVenkateswararao Jujjuri (JV) struct stat stbuf; 258fac4f111SVenkateswararao Jujjuri (JV) } V9fsStatState; 259fac4f111SVenkateswararao Jujjuri (JV) 26000ede4c2SSripathi Kodi typedef struct V9fsStatDotl { 26100ede4c2SSripathi Kodi uint64_t st_result_mask; 26200ede4c2SSripathi Kodi V9fsQID qid; 26300ede4c2SSripathi Kodi uint32_t st_mode; 26400ede4c2SSripathi Kodi uint32_t st_uid; 26500ede4c2SSripathi Kodi uint32_t st_gid; 26600ede4c2SSripathi Kodi uint64_t st_nlink; 26700ede4c2SSripathi Kodi uint64_t st_rdev; 26800ede4c2SSripathi Kodi uint64_t st_size; 26900ede4c2SSripathi Kodi uint64_t st_blksize; 27000ede4c2SSripathi Kodi uint64_t st_blocks; 27100ede4c2SSripathi Kodi uint64_t st_atime_sec; 27200ede4c2SSripathi Kodi uint64_t st_atime_nsec; 27300ede4c2SSripathi Kodi uint64_t st_mtime_sec; 27400ede4c2SSripathi Kodi uint64_t st_mtime_nsec; 27500ede4c2SSripathi Kodi uint64_t st_ctime_sec; 27600ede4c2SSripathi Kodi uint64_t st_ctime_nsec; 27700ede4c2SSripathi Kodi uint64_t st_btime_sec; 27800ede4c2SSripathi Kodi uint64_t st_btime_nsec; 27900ede4c2SSripathi Kodi uint64_t st_gen; 28000ede4c2SSripathi Kodi uint64_t st_data_version; 28100ede4c2SSripathi Kodi } V9fsStatDotl; 28200ede4c2SSripathi Kodi 283fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsOpenState { 284fac4f111SVenkateswararao Jujjuri (JV) V9fsPDU *pdu; 285fac4f111SVenkateswararao Jujjuri (JV) size_t offset; 286771e9d4cSM. Mohan Kumar int32_t mode; 287fac4f111SVenkateswararao Jujjuri (JV) V9fsFidState *fidp; 288fac4f111SVenkateswararao Jujjuri (JV) V9fsQID qid; 289fac4f111SVenkateswararao Jujjuri (JV) struct stat stbuf; 2905e94c103SM. Mohan Kumar int iounit; 291fac4f111SVenkateswararao Jujjuri (JV) } V9fsOpenState; 292fac4f111SVenkateswararao Jujjuri (JV) 293fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsReadState { 294fac4f111SVenkateswararao Jujjuri (JV) V9fsPDU *pdu; 295fac4f111SVenkateswararao Jujjuri (JV) size_t offset; 296fac4f111SVenkateswararao Jujjuri (JV) int32_t count; 297fac4f111SVenkateswararao Jujjuri (JV) int32_t total; 298fac4f111SVenkateswararao Jujjuri (JV) int64_t off; 299fac4f111SVenkateswararao Jujjuri (JV) V9fsFidState *fidp; 300fac4f111SVenkateswararao Jujjuri (JV) struct iovec iov[128]; /* FIXME: bad, bad, bad */ 301fac4f111SVenkateswararao Jujjuri (JV) struct iovec *sg; 302fac4f111SVenkateswararao Jujjuri (JV) off_t dir_pos; 303fac4f111SVenkateswararao Jujjuri (JV) struct dirent *dent; 304fac4f111SVenkateswararao Jujjuri (JV) struct stat stbuf; 305fac4f111SVenkateswararao Jujjuri (JV) V9fsString name; 306fac4f111SVenkateswararao Jujjuri (JV) V9fsStat v9stat; 307fac4f111SVenkateswararao Jujjuri (JV) int32_t len; 308fac4f111SVenkateswararao Jujjuri (JV) int32_t cnt; 309fac4f111SVenkateswararao Jujjuri (JV) int32_t max_count; 310fac4f111SVenkateswararao Jujjuri (JV) } V9fsReadState; 311fac4f111SVenkateswararao Jujjuri (JV) 312fac4f111SVenkateswararao Jujjuri (JV) typedef struct V9fsWriteState { 313fac4f111SVenkateswararao Jujjuri (JV) V9fsPDU *pdu; 314fac4f111SVenkateswararao Jujjuri (JV) size_t offset; 315fac4f111SVenkateswararao Jujjuri (JV) int32_t len; 316fac4f111SVenkateswararao Jujjuri (JV) int32_t count; 317fac4f111SVenkateswararao Jujjuri (JV) int32_t total; 318fac4f111SVenkateswararao Jujjuri (JV) int64_t off; 319fac4f111SVenkateswararao Jujjuri (JV) V9fsFidState *fidp; 320fac4f111SVenkateswararao Jujjuri (JV) struct iovec iov[128]; /* FIXME: bad, bad, bad */ 321fac4f111SVenkateswararao Jujjuri (JV) struct iovec *sg; 322fac4f111SVenkateswararao Jujjuri (JV) int cnt; 323fac4f111SVenkateswararao Jujjuri (JV) } V9fsWriteState; 324fac4f111SVenkateswararao Jujjuri (JV) 325c79ce737SSripathi Kodi typedef struct V9fsIattr 326c79ce737SSripathi Kodi { 327c79ce737SSripathi Kodi int32_t valid; 328c79ce737SSripathi Kodi int32_t mode; 329c79ce737SSripathi Kodi int32_t uid; 330c79ce737SSripathi Kodi int32_t gid; 331c79ce737SSripathi Kodi int64_t size; 332c79ce737SSripathi Kodi int64_t atime_sec; 333c79ce737SSripathi Kodi int64_t atime_nsec; 334c79ce737SSripathi Kodi int64_t mtime_sec; 335c79ce737SSripathi Kodi int64_t mtime_nsec; 336c79ce737SSripathi Kodi } V9fsIattr; 337c79ce737SSripathi Kodi 3389f107513SAnthony Liguori struct virtio_9p_config 3399f107513SAnthony Liguori { 3409f107513SAnthony Liguori /* number of characters in tag */ 3419f107513SAnthony Liguori uint16_t tag_len; 3429f107513SAnthony Liguori /* Variable size tag name */ 3439f107513SAnthony Liguori uint8_t tag[0]; 344541dc0d4SStefan Weil } QEMU_PACKED; 3459f107513SAnthony Liguori 3465268ceccSM. Mohan Kumar typedef struct V9fsMkState { 3475268ceccSM. Mohan Kumar V9fsPDU *pdu; 3485268ceccSM. Mohan Kumar size_t offset; 3495268ceccSM. Mohan Kumar V9fsQID qid; 3505268ceccSM. Mohan Kumar struct stat stbuf; 3515268ceccSM. Mohan Kumar V9fsString name; 3525268ceccSM. Mohan Kumar V9fsString fullname; 3535268ceccSM. Mohan Kumar } V9fsMkState; 3545268ceccSM. Mohan Kumar 35582cc3ee8SM. Mohan Kumar #define P9_LOCK_SUCCESS 0 35682cc3ee8SM. Mohan Kumar #define P9_LOCK_BLOCKED 1 35782cc3ee8SM. Mohan Kumar #define P9_LOCK_ERROR 2 35882cc3ee8SM. Mohan Kumar #define P9_LOCK_GRACE 3 35982cc3ee8SM. Mohan Kumar 36082cc3ee8SM. Mohan Kumar #define P9_LOCK_FLAGS_BLOCK 1 36182cc3ee8SM. Mohan Kumar #define P9_LOCK_FLAGS_RECLAIM 2 36282cc3ee8SM. Mohan Kumar 36382cc3ee8SM. Mohan Kumar typedef struct V9fsFlock 36482cc3ee8SM. Mohan Kumar { 36582cc3ee8SM. Mohan Kumar uint8_t type; 36682cc3ee8SM. Mohan Kumar uint32_t flags; 36782cc3ee8SM. Mohan Kumar uint64_t start; /* absolute offset */ 36882cc3ee8SM. Mohan Kumar uint64_t length; 36982cc3ee8SM. Mohan Kumar uint32_t proc_id; 37082cc3ee8SM. Mohan Kumar V9fsString client_id; 37182cc3ee8SM. Mohan Kumar } V9fsFlock; 37282cc3ee8SM. Mohan Kumar 3738f354003SM. Mohan Kumar typedef struct V9fsGetlock 3748f354003SM. Mohan Kumar { 3758f354003SM. Mohan Kumar uint8_t type; 3768f354003SM. Mohan Kumar uint64_t start; /* absolute offset */ 3778f354003SM. Mohan Kumar uint64_t length; 3788f354003SM. Mohan Kumar uint32_t proc_id; 3798f354003SM. Mohan Kumar V9fsString client_id; 3808f354003SM. Mohan Kumar } V9fsGetlock; 3818f354003SM. Mohan Kumar 3827a462745SAneesh Kumar K.V extern int open_fd_hw; 3837a462745SAneesh Kumar K.V extern int total_open_fd; 3847a462745SAneesh Kumar K.V 38564b85a8fSBlue Swirl size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count, 3869f107513SAnthony Liguori size_t offset, size_t size, int pack); 3879f107513SAnthony Liguori 3889f107513SAnthony Liguori static inline size_t do_pdu_unpack(void *dst, struct iovec *sg, int sg_count, 3899f107513SAnthony Liguori size_t offset, size_t size) 3909f107513SAnthony Liguori { 3919f107513SAnthony Liguori return pdu_packunpack(dst, sg, sg_count, offset, size, 0); 3929f107513SAnthony Liguori } 3939f107513SAnthony Liguori 394532decb7SAneesh Kumar K.V static inline void v9fs_path_write_lock(V9fsState *s) 395532decb7SAneesh Kumar K.V { 396532decb7SAneesh Kumar K.V if (s->ctx.flags & PATHNAME_FSCONTEXT) { 397532decb7SAneesh Kumar K.V qemu_co_rwlock_wrlock(&s->rename_lock); 398532decb7SAneesh Kumar K.V } 399532decb7SAneesh Kumar K.V } 400532decb7SAneesh Kumar K.V 401532decb7SAneesh Kumar K.V static inline void v9fs_path_read_lock(V9fsState *s) 402532decb7SAneesh Kumar K.V { 403532decb7SAneesh Kumar K.V if (s->ctx.flags & PATHNAME_FSCONTEXT) { 404532decb7SAneesh Kumar K.V qemu_co_rwlock_rdlock(&s->rename_lock); 405532decb7SAneesh Kumar K.V } 406532decb7SAneesh Kumar K.V } 407532decb7SAneesh Kumar K.V 408532decb7SAneesh Kumar K.V static inline void v9fs_path_unlock(V9fsState *s) 409532decb7SAneesh Kumar K.V { 410532decb7SAneesh Kumar K.V if (s->ctx.flags & PATHNAME_FSCONTEXT) { 411532decb7SAneesh Kumar K.V qemu_co_rwlock_unlock(&s->rename_lock); 412532decb7SAneesh Kumar K.V } 413532decb7SAneesh Kumar K.V } 414532decb7SAneesh Kumar K.V 415*bccacf6cSAneesh Kumar K.V static inline uint8_t v9fs_request_cancelled(V9fsPDU *pdu) 416*bccacf6cSAneesh Kumar K.V { 417*bccacf6cSAneesh Kumar K.V return pdu->cancelled; 418*bccacf6cSAneesh Kumar K.V } 419*bccacf6cSAneesh Kumar K.V 420f4f61d27SAneesh Kumar K.V extern void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq); 4217a462745SAneesh Kumar K.V extern void virtio_9p_set_fd_limit(void); 422*bccacf6cSAneesh Kumar K.V extern void v9fs_reclaim_fd(V9fsPDU *pdu); 42370c18fc0SAneesh Kumar K.V extern void v9fs_string_init(V9fsString *str); 42470c18fc0SAneesh Kumar K.V extern void v9fs_string_free(V9fsString *str); 42570c18fc0SAneesh Kumar K.V extern void v9fs_string_null(V9fsString *str); 42670c18fc0SAneesh Kumar K.V extern void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...); 42770c18fc0SAneesh Kumar K.V extern void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs); 4282289be19SAneesh Kumar K.V extern void v9fs_path_init(V9fsPath *path); 4292289be19SAneesh Kumar K.V extern void v9fs_path_free(V9fsPath *path); 4302289be19SAneesh Kumar K.V extern void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs); 4312289be19SAneesh Kumar K.V extern int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, 4322289be19SAneesh Kumar K.V const char *name, V9fsPath *path); 4339f107513SAnthony Liguori #endif 434