@@ -69,17 +69,6 @@ static int extract_subvolume_name(const char *path, const char **subvolume) {
6969 return 0 ;
7070}
7171
72- int btrfs_is_filesystem (int fd ) {
73- struct statfs sfs ;
74-
75- assert (fd >= 0 );
76-
77- if (fstatfs (fd , & sfs ) < 0 )
78- return - errno ;
79-
80- return F_TYPE_EQUAL (sfs .f_type , BTRFS_SUPER_MAGIC );
81- }
82-
8372int btrfs_is_subvol_fd (int fd ) {
8473 struct stat st ;
8574
@@ -93,7 +82,7 @@ int btrfs_is_subvol_fd(int fd) {
9382 if (!btrfs_might_be_subvol (& st ))
9483 return 0 ;
9584
96- return btrfs_is_filesystem (fd );
85+ return fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
9786}
9887
9988int btrfs_is_subvol (const char * path ) {
@@ -286,7 +275,7 @@ int btrfs_get_block_device_fd(int fd, dev_t *dev) {
286275 assert (fd >= 0 );
287276 assert (dev );
288277
289- r = btrfs_is_filesystem (fd );
278+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
290279 if (r < 0 )
291280 return r ;
292281 if (!r )
@@ -361,7 +350,7 @@ int btrfs_subvol_get_id_fd(int fd, uint64_t *ret) {
361350 assert (fd >= 0 );
362351 assert (ret );
363352
364- r = btrfs_is_filesystem (fd );
353+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
365354 if (r < 0 )
366355 return r ;
367356 if (!r )
@@ -481,7 +470,7 @@ int btrfs_subvol_get_info_fd(int fd, uint64_t subvol_id, BtrfsSubvolInfo *ret) {
481470 if (r < 0 )
482471 return r ;
483472 } else {
484- r = btrfs_is_filesystem (fd );
473+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
485474 if (r < 0 )
486475 return r ;
487476 if (!r )
@@ -575,7 +564,7 @@ int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
575564 if (r < 0 )
576565 return r ;
577566 } else {
578- r = btrfs_is_filesystem (fd );
567+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
579568 if (r < 0 )
580569 return r ;
581570 if (!r )
@@ -762,21 +751,6 @@ int btrfs_subvol_get_subtree_quota(const char *path, uint64_t subvol_id, BtrfsQu
762751 return btrfs_subvol_get_subtree_quota_fd (fd , subvol_id , ret );
763752}
764753
765- int btrfs_defrag_fd (int fd ) {
766- int r ;
767-
768- assert (fd >= 0 );
769-
770- r = fd_verify_regular (fd );
771- if (r < 0 )
772- return r ;
773-
774- if (ioctl (fd , BTRFS_IOC_DEFRAG , NULL ) < 0 )
775- return - errno ;
776-
777- return 0 ;
778- }
779-
780754int btrfs_defrag (const char * p ) {
781755 _cleanup_close_ int fd = -1 ;
782756
@@ -795,7 +769,7 @@ int btrfs_quota_enable_fd(int fd, bool b) {
795769
796770 assert (fd >= 0 );
797771
798- r = btrfs_is_filesystem (fd );
772+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
799773 if (r < 0 )
800774 return r ;
801775 if (!r )
@@ -832,7 +806,7 @@ int btrfs_qgroup_set_limit_fd(int fd, uint64_t qgroupid, uint64_t referenced_max
832806 if (r < 0 )
833807 return r ;
834808 } else {
835- r = btrfs_is_filesystem (fd );
809+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
836810 if (r < 0 )
837811 return r ;
838812 if (!r )
@@ -924,7 +898,7 @@ static int qgroup_create_or_destroy(int fd, bool b, uint64_t qgroupid) {
924898 };
925899 int r ;
926900
927- r = btrfs_is_filesystem (fd );
901+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
928902 if (r < 0 )
929903 return r ;
930904 if (r == 0 )
@@ -1042,7 +1016,7 @@ static int qgroup_assign_or_unassign(int fd, bool b, uint64_t child, uint64_t pa
10421016 };
10431017 int r ;
10441018
1045- r = btrfs_is_filesystem (fd );
1019+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
10461020 if (r < 0 )
10471021 return r ;
10481022 if (r == 0 )
@@ -1269,7 +1243,7 @@ int btrfs_qgroup_copy_limits(int fd, uint64_t old_qgroupid, uint64_t new_qgroupi
12691243
12701244 int r ;
12711245
1272- r = btrfs_is_filesystem (fd );
1246+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
12731247 if (r < 0 )
12741248 return r ;
12751249 if (!r )
@@ -1738,7 +1712,7 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) {
17381712 if (r < 0 )
17391713 return r ;
17401714 } else {
1741- r = btrfs_is_filesystem (fd );
1715+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
17421716 if (r < 0 )
17431717 return r ;
17441718 if (!r )
@@ -1979,7 +1953,7 @@ int btrfs_subvol_get_parent(int fd, uint64_t subvol_id, uint64_t *ret) {
19791953 if (r < 0 )
19801954 return r ;
19811955 } else {
1982- r = btrfs_is_filesystem (fd );
1956+ r = fd_is_fs_type (fd , BTRFS_SUPER_MAGIC );
19831957 if (r < 0 )
19841958 return r ;
19851959 if (!r )
0 commit comments