summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 46c3a431..c139eb2e 100644
--- a/utils.c
+++ b/utils.c
@@ -2344,3 +2344,23 @@ int find_mount_root(const char *path, char **mount_root)
free(longest_match);
return ret;
}
+
+int test_minimum_size(const char *file, u32 leafsize)
+{
+ int fd;
+ struct stat statbuf;
+
+ fd = open(file, O_RDONLY);
+ if (fd < 0)
+ return -errno;
+ if (stat(file, &statbuf) < 0) {
+ close(fd);
+ return -errno;
+ }
+ if (btrfs_device_size(fd, &statbuf) < btrfs_min_dev_size(leafsize)) {
+ close(fd);
+ return 1;
+ }
+ close(fd);
+ return 0;
+}