diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/fd-util.c | 15 | ||||
-rw-r--r-- | src/basic/fd-util.h | 1 | ||||
-rw-r--r-- | src/shared/btrfs-util.c | 12 | ||||
-rw-r--r-- | src/shared/btrfs-util.h | 1 |
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); |