From f5caa421d1bb826559ec7a6d98c1a6b6b1f0a629 Mon Sep 17 00:00:00 2001 From: Maxim Perevedentsev Date: Tue, 27 Oct 2015 18:20:45 +0300 Subject: [PATCH] Added xfs support to vfs_minimum_size. --- daemon/daemon.h | 1 + daemon/fs-min-size.c | 7 +++++++ daemon/xfs.c | 16 ++++++++++++++++ generator/actions.ml | 6 +++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index 4a969ddd5..1f0cd30c3 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -269,6 +269,7 @@ extern int copy_xattrs (const char *src, const char *dest); extern int xfs_set_uuid (const char *device, const char *uuid); extern int xfs_set_uuid_random (const char *device); extern int xfs_set_label (const char *device, const char *label); +extern int64_t xfs_minimum_size (const char *path); /*-- debug-bmap.c --*/ extern char *debug_bmap (const char *subcmd, size_t argc, char *const *const argv); diff --git a/daemon/fs-min-size.c b/daemon/fs-min-size.c index ca71c4d5e..ba0f73928 100644 --- a/daemon/fs-min-size.c +++ b/daemon/fs-min-size.c @@ -73,6 +73,13 @@ do_vfs_minimum_size (const mountable_t *mountable) r = btrfs_minimum_size (path); } + else if (STREQ (vfs_type, "xfs")) { + CLEANUP_FREE char *path = get_mount_point (mountable->device); + if (path == NULL) + return -1; + r = xfs_minimum_size (path); + } + else NOT_SUPPORTED (-1, "don't know how to get minimum size of '%s' filesystems", vfs_type); diff --git a/daemon/xfs.c b/daemon/xfs.c index f74890201..abc2736ac 100644 --- a/daemon/xfs.c +++ b/daemon/xfs.c @@ -660,3 +660,19 @@ do_xfs_repair (const char *device, return r; } + +int64_t +xfs_minimum_size (const char *path) +{ + CLEANUP_FREE guestfs_int_xfsinfo *info = do_xfs_info (path); + + if (info == NULL) + return -1; + + // XFS does not support shrinking. + if (INT64_MAX / info->xfs_blocksize < info->xfs_datablocks) { + reply_with_error ("filesystem size too big: overflow"); + return -1; + } + return info->xfs_blocksize * info->xfs_datablocks; +} diff --git a/generator/actions.ml b/generator/actions.ml index 8832410ac..d8af08d6f 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -12765,6 +12765,10 @@ To read the UUID on a filesystem, call C." }; [["mkfs"; "btrfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"]; ["mount"; "/dev/sda1"; "/"]; ["vfs_minimum_size"; "/dev/sda1"]]), []; + InitPartition, Always, TestRun ( + [["mkfs"; "xfs"; "/dev/sda1"; ""; "NOARG"; ""; ""; "NOARG"]; + ["mount"; "/dev/sda1"; "/"]; + ["vfs_minimum_size"; "/dev/sda1"]]), []; ]; shortdesc = "get minimum filesystem size"; longdesc = "\ @@ -12774,7 +12778,7 @@ This is the minimum possible size for filesystem shrinking. If getting minimum size of specified filesystem is not supported, this will fail and set errno as ENOTSUP. -See also L, L, L." }; +See also L, L, L, L." }; ]