]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
btrfs-util: move btrfs_defrag_fd() from fd-util.[ch]
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 24 Oct 2022 20:35:04 +0000 (05:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Oct 2022 07:25:46 +0000 (16:25 +0900)
After d71ece3f0b85c7a3decc50143b68ac07fc5831ae, the function is not used
in libbasic or libsystemd anymore. Let's move it to more appropriate
place.

src/basic/fd-util.c
src/basic/fd-util.h
src/shared/btrfs-util.c
src/shared/btrfs-util.h

index 6c85a34896c97173a6739f0e6f67c35e33321c7d..cee20a9a815c2e54bc6f46e25541ca386c361d7f 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <linux/btrfs.h>
 #if WANT_LINUX_FS_H
 #include <linux/fs.h>
 #endif
@@ -779,20 +778,6 @@ int read_nr_open(void) {
         return 1024 * 1024;
 }
 
-/* This is here because it's fd-related and is called from sd-journal code. Other btrfs-related utilities are
- * in src/shared, but libsystemd must not link to libsystemd-shared, see docs/ARCHITECTURE.md. */
-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 fd_get_diskseq(int fd, uint64_t *ret) {
         uint64_t diskseq;
 
index 8543d0d5eaa4d13f17160a5f4a2a8501f7e18b81..d9896e27e8d5c0fc2876f3a4548485ab9b621416 100644 (file)
@@ -108,7 +108,6 @@ static inline int make_null_stdio(void) {
 
 int fd_reopen(int fd, int flags);
 int read_nr_open(void);
-int btrfs_defrag_fd(int fd);
 int fd_get_diskseq(int fd, uint64_t *ret);
 
 /* The maximum length a buffer for a /proc/self/fd/<fd> path needs */
index 5e3bcbb6e4164ea1f8d4d7bce27007000123d52b..58ba286a2404c0145faab813e44f1b61d8afdc07 100644 (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;
 
index b67a4c10fe83424f44389fe1774267a778b3bcd6..5f568f23528d3f84957b205ef867eceaa8017cc9 100644 (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);