diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-21 20:24:00 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-24 09:42:08 +0200 |
commit | 65ddc2c5ffd5b9d7798dfd4743423f08b4be6c2b (patch) | |
tree | 632093ab24eb7eb219d6390f4bf3fcc70efa4691 /src/shared/sleep-config.c | |
parent | basic,shared: move make_mount_point_inode_*() to shared/ (diff) | |
download | systemd-65ddc2c5ffd5b9d7798dfd4743423f08b4be6c2b.tar.xz systemd-65ddc2c5ffd5b9d7798dfd4743423f08b4be6c2b.zip |
basic: drop one btrfs-related function and move another
This will become useful later, it is the first step to moving btrfs-util.[ch]
out of src/basic/.
Diffstat (limited to 'src/shared/sleep-config.c')
-rw-r--r-- | src/shared/sleep-config.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 645b7e242e..dbaecb3a0f 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -6,6 +6,7 @@ #include <errno.h> #include <fcntl.h> #include <linux/fs.h> +#include <linux/magic.h> #include <stdbool.h> #include <stddef.h> #include <sys/ioctl.h> @@ -28,6 +29,7 @@ #include "parse-util.h" #include "path-util.h" #include "sleep-config.h" +#include "stat-util.h" #include "stdio-util.h" #include "string-table.h" #include "string-util.h" @@ -232,7 +234,7 @@ static int calculate_swap_file_offset(const SwapEntry *swap, uint64_t *ret_offse _cleanup_close_ int fd = -1; _cleanup_free_ struct fiemap *fiemap = NULL; struct stat sb; - int r, btrfs; + int r; assert(swap); assert(swap->device); @@ -245,10 +247,10 @@ static int calculate_swap_file_offset(const SwapEntry *swap, uint64_t *ret_offse if (fstat(fd, &sb) < 0) return log_debug_errno(errno, "Failed to stat %s: %m", swap->device); - btrfs = btrfs_is_filesystem(fd); - if (btrfs < 0) - return log_debug_errno(btrfs, "Error checking %s for Btrfs filesystem: %m", swap->device); - if (btrfs > 0) { + r = fd_is_fs_type(fd, BTRFS_SUPER_MAGIC); + if (r < 0) + return log_debug_errno(r, "Error checking %s for Btrfs filesystem: %m", swap->device); + if (r > 0) { log_debug("%s: detection of swap file offset on Btrfs is not supported", swap->device); *ret_offset = UINT64_MAX; return 0; |