+static int
+cloner_check_fs_support(int src_fd, int dest_fd, unsigned int *fs_type)
+{
+ int ret;
+ struct statfs sfs;
+
+ ret = fstatfs(src_fd, &sfs);
+ if (ret != 0) {
+ printf("failed to stat source FS\n");
+ return errno;
+ }
+
+ if (sfs.f_type != BTRFS_SUPER_MAGIC) {
+ printf("unsupported source FS 0x%x\n",
+ (unsigned int)sfs.f_type);
+ return ENOTSUP;
+ }
+
+ *fs_type = (unsigned int)sfs.f_type;
+
+ ret = fstatfs(dest_fd, &sfs);
+ if (ret != 0) {
+ printf("failed to stat destination FS\n");
+ return errno;
+ }
+
+ if (sfs.f_type != *fs_type) {
+ printf("dest FS type 0x%x does not match source 0x%x\n",
+ (unsigned int)sfs.f_type, *fs_type);
+ return ENOTSUP;
+ }
+
+ return 0;
+}
+