summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-10-24 22:35:04 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-10-25 09:25:46 +0200
commit4117366a283657295264723e559d7ead79a7cfd3 (patch)
treeed1dd5bb0c262d0223fd62083e139e3cc97db8b6 /src
parentMerge pull request #25118 from bluca/rc2 (diff)
downloadsystemd-4117366a283657295264723e559d7ead79a7cfd3.tar.xz
systemd-4117366a283657295264723e559d7ead79a7cfd3.zip
btrfs-util: move btrfs_defrag_fd() from fd-util.[ch]
After d71ece3f0b85c7a3decc50143b68ac07fc5831ae, the function is not used in libbasic or libsystemd anymore. Let's move it to more appropriate place.
Diffstat (limited to 'src')
-rw-r--r--src/basic/fd-util.c15
-rw-r--r--src/basic/fd-util.h1
-rw-r--r--src/shared/btrfs-util.c12
-rw-r--r--src/shared/btrfs-util.h1
4 files changed, 13 insertions, 16 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index 6c85a34896..cee20a9a81 100644
--- a/src/basic/fd-util.c
+++ b/src/basic/fd-util.c
@@ -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;
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h
index 8543d0d5ea..d9896e27e8 100644
--- a/src/basic/fd-util.h
+++ b/src/basic/fd-util.h
@@ -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 */
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c
index 5e3bcbb6e4..58ba286a24 100644
--- a/src/shared/btrfs-util.c
+++ b/src/shared/btrfs-util.c
@@ -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;
diff --git a/src/shared/btrfs-util.h b/src/shared/btrfs-util.h
index b67a4c10fe..5f568f2352 100644
--- a/src/shared/btrfs-util.h
+++ b/src/shared/btrfs-util.h
@@ -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);