Add some (optional) information that the file driver can provide for
image files, namely the extent size.
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
qapi/block-core.json | 26 ++++++++++++++++++++++++--
block/file-posix.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
+++ b/block/file-posix.c
@@ -3068,6 +3068,34 @@ static int raw_get_info(BlockDriverState *bs,
BlockDriverInfo *bdi)
return 0;
}
+static ImageInfoSpecific *raw_get_specific_info(BlockDriverState *bs,
+ Error **errp)
+{
+ BDRVRawState *s = bs->opaque;
+ ImageInfoSpecificFile *file_info = g_new0(ImageInfoSpecificFile, 1);
+ ImageInfoSpecific *spec_info = g_new(ImageInfoSpecific, 1);
+
+ *spec_info = (ImageInfoSpecific){
+ .type = IMAGE_INFO_SPECIFIC_KIND_FILE,
+ .u.file.data = file_info,
+ };
+
+#ifdef FS_IOC_FSGETXATTR
+ {
+ struct fsxattr attr;
+ int ret;
+
+ ret = ioctl(s->fd, FS_IOC_FSGETXATTR, &attr);
+ if (!ret && attr.fsx_extsize != 0) {
+ file_info->has_extent_size = true;
+ file_info->extent_size = attr.fsx_extsize;
+ }
+ }
+#endif