qemu: virtio-9p: Implement statfs support in qemu server
PATCH 1/1 qemu: virtio-9p: Implement statfs support in qemu server
Implement statfs support in qemu 9p server. statfs gets file system statistics such as type of file system, optimal transfer block size etc.
statfs - get file system statistics
size[4] Tstatfs tag[2] fid[4]
size[4] Rstatfs tag[2] type[4] bsize[4] blocks[8] bfree[8] bavail[8]
files[8] ffree[8] fsid[8] namelen[4]Signed-off-by Sripathi Kodi <[email protected]>
Signed-off-by M. Mohan Kumar <[email protected]>
--- hw/file-op-9p.h | 2 + hw/virtio-9p-local.c | 6 ++++ hw/virtio-9p.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-9p.h | 24 +++++++++++++++++++ 4 files changed, 95 insertions(+), 0 deletions(-)
hw/file-op-9p.h +2 -0
@@ -18,6 +18,7 @@#include <utime.h> #include <sys/stat.h> #include <sys/uio.h> +#include <sys/vfs.h> typedef struct FsContext {
@@ -55,6 +56,7 @@ typedef struct FileOperationsint (*rename)(FsContext *,const char *,const char *);int (*truncate)(FsContext *,const char *,off_t );int (*fsync)(FsContext *,int ); +int (*statfs)(FsContext *s,const char *path,struct statfs *stbuf); void *opaque; } FileOperations;#endif
hw/virtio-9p-local.c +6 -0
@@ -262,6 +262,11 @@ static int local_fsync(FsContext *ctx, int fd)return fsync (fd); } +static int local_statfs (FsContext *s,const char *path,struct statfs *stbuf) +{ +return statfs (rpath (s, path), stbuf); +} +FileOperations local_ops = { .lstat = local_lstat, .setuid = local_setuid,
@@ -291,4 +296,5 @@ FileOperations local_ops = { .utime = local_utime, .remove = local_remove, .fsync = local_fsync, + .statfs = local_statfs, };
hw/virtio-9p.c +63 -0
72 lines not on this page · raw message
hw/virtio-9p.h +24 -0
@@ -13,6 +13,8 @@#define VIRTIO_9P_MOUNT_TAG 0enum { +P9_TSTATFS =8 , +P9_RSTATFS ,P9_TVERSION =100 ,P9_RVERSION ,P9_TAUTH =102 ,
@@ -160,6 +162,28 @@ struct virtio_9p_configuint8_t tag[0 ]; } __attribute__((packed)); +typedef struct V9fsStatfs +{ +uint32_t f_type; +uint32_t f_bsize; +uint64_t f_blocks; +uint64_t f_bfree; +uint64_t f_bavail; +uint64_t f_files; +uint64_t f_ffree; +uint64_t fsid_val; +uint32_t f_namelen; +}V9fsStatfs ; + +typedef struct V9fsStatfsState { +V9fsPDU *pdu; +size_t offset; +int32_t fid; +V9fsStatfs v9statfs; +V9fsFidState *fidp; +struct statfs stbuf; +}V9fsStatfsState ; +extern size_t pdu_packunpack (void *addr,struct iovec *sg,int sg_count,size_t offset,size_t size,int pack);
Signature · 1 line
1.6.6.1