summaryrefslogtreecommitdiffstats
path: root/src/shared/resize-fs.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-12-05 10:15:49 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-12-05 10:15:49 +0100
commitd6f1e66076929f071830334800fc380bd4954806 (patch)
treecb69eb0a85260b74df4c1bc14ced1d3c95859c8b /src/shared/resize-fs.c
parentgrowfs: define main function through macro (diff)
downloadsystemd-d6f1e66076929f071830334800fc380bd4954806.tar.xz
systemd-d6f1e66076929f071830334800fc380bd4954806.zip
growfs: port over to resize_fs()
Diffstat (limited to 'src/shared/resize-fs.c')
-rw-r--r--src/shared/resize-fs.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/shared/resize-fs.c b/src/shared/resize-fs.c
index 9f33dd77d8..5ed26a6c92 100644
--- a/src/shared/resize-fs.c
+++ b/src/shared/resize-fs.c
@@ -13,7 +13,7 @@
#include "resize-fs.h"
#include "stat-util.h"
-int resize_fs(int fd, uint64_t sz) {
+int resize_fs(int fd, uint64_t sz, uint64_t *ret_size) {
struct statfs sfs;
int r;
@@ -38,6 +38,9 @@ int resize_fs(int fd, uint64_t sz) {
if (ioctl(fd, EXT4_IOC_RESIZE_FS, &u) < 0)
return -errno;
+ if (ret_size)
+ *ret_size = u * sfs.f_bsize;
+
} else if (is_fs_type(&sfs, BTRFS_SUPER_MAGIC)) {
struct btrfs_ioctl_vol_args args = {};
@@ -49,12 +52,17 @@ int resize_fs(int fd, uint64_t sz) {
if (sz < BTRFS_MINIMAL_SIZE)
return -ERANGE;
+ sz -= sz % sfs.f_bsize;
+
r = snprintf(args.name, sizeof(args.name), "%" PRIu64, sz);
assert((size_t) r < sizeof(args.name));
if (ioctl(fd, BTRFS_IOC_RESIZE, &args) < 0)
return -errno;
+ if (ret_size)
+ *ret_size = sz;
+
} else if (is_fs_type(&sfs, XFS_SB_MAGIC)) {
xfs_fsop_geom_t geo;
xfs_growfs_data_t d;
@@ -73,6 +81,9 @@ int resize_fs(int fd, uint64_t sz) {
if (ioctl(fd, XFS_IOC_FSGROWFSDATA, &d) < 0)
return -errno;
+ if (ret_size)
+ *ret_size = d.newblocks * geo.blocksize;
+
} else
return -EOPNOTSUPP;