btrfs-util: move btrfs_defrag_fd() from fd-util.[ch]

After d71ece3f0b, the function is not used
in libbasic or libsystemd anymore. Let's move it to more appropriate
place.
This commit is contained in:
Yu Watanabe
2022-10-25 16:25:46 +09:00
parent 876d7e0b4f
commit 4117366a28
4 changed files with 13 additions and 16 deletions
+12
View File
@@ -739,6 +739,18 @@ int btrfs_subvol_get_subtree_quota(const char *path, uint64_t subvol_id, BtrfsQu
return btrfs_subvol_get_subtree_quota_fd(fd, subvol_id, ret);
}
int btrfs_defrag_fd(int fd) {
int r;
assert(fd >= 0);
r = fd_verify_regular(fd);
if (r < 0)
return r;
return RET_NERRNO(ioctl(fd, BTRFS_IOC_DEFRAG, NULL));
}
int btrfs_defrag(const char *p) {
_cleanup_close_ int fd = -1;
+1
View File
@@ -52,6 +52,7 @@ int btrfs_clone_range(int infd, uint64_t in_offset, int ofd, uint64_t out_offset
int btrfs_get_block_device_fd(int fd, dev_t *dev);
int btrfs_get_block_device(const char *path, dev_t *dev);
int btrfs_defrag_fd(int fd);
int btrfs_defrag(const char *p);
int btrfs_quota_enable_fd(int fd, bool b);