From c05c70c77ca797549e45c971bc3c02bb3ec79e6e Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 22 Aug 2017 20:34:36 +0200 Subject: [PATCH] btrfs-progs: convert: move acl helper to common source file There were 2 copies of ext2_acl_count and acl_ea_size. Signed-off-by: David Sterba --- convert/source-ext2.c | 21 --------------------- convert/source-fs.c | 17 +++++++++++++++++ convert/source-fs.h | 2 ++ convert/source-reiserfs.h | 16 ---------------- 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/convert/source-ext2.c b/convert/source-ext2.c index 24744e22..cdaf6698 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -424,27 +424,6 @@ static int ext2_xattr_check_entry(struct ext2_ext_attr_entry *entry, return 0; } -static inline int ext2_acl_count(size_t size) -{ - ssize_t s; - size -= sizeof(ext2_acl_header); - s = size - 4 * sizeof(ext2_acl_entry_short); - if (s < 0) { - if (size % sizeof(ext2_acl_entry_short)) - return -1; - return size / sizeof(ext2_acl_entry_short); - } else { - if (s % sizeof(ext2_acl_entry)) - return -1; - return s / sizeof(ext2_acl_entry) + 4; - } -} - -static inline size_t acl_ea_size(int count) -{ - return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry); -} - static int ext2_acl_to_xattr(void *dst, const void *src, size_t dst_size, size_t src_size) { diff --git a/convert/source-fs.c b/convert/source-fs.c index 4755efb2..d6dfc077 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -28,6 +28,23 @@ const struct simple_range btrfs_reserved_ranges[3] = { { BTRFS_SB_MIRROR_OFFSET(2), SZ_64K } }; +int ext2_acl_count(size_t size) +{ + ssize_t s; + + size -= sizeof(ext2_acl_header); + s = size - 4 * sizeof(ext2_acl_entry_short); + if (s < 0) { + if (size % sizeof(ext2_acl_entry_short)) + return -1; + return size / sizeof(ext2_acl_entry_short); + } else { + if (s % sizeof(ext2_acl_entry)) + return -1; + return s / sizeof(ext2_acl_entry) + 4; + } +} + static u64 intersect_with_reserved(u64 bytenr, u64 num_bytes) { int i; diff --git a/convert/source-fs.h b/convert/source-fs.h index a2b21982..bc693162 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -102,6 +102,8 @@ static inline size_t acl_ea_size(int count) return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry); } +int ext2_acl_count(size_t size); + struct btrfs_convert_operations { const char name[SOURCE_FS_NAME_LEN]; int (*open_fs)(struct btrfs_convert_context *cctx, const char *devname); diff --git a/convert/source-reiserfs.h b/convert/source-reiserfs.h index 10b0ceb6..0fa476a9 100644 --- a/convert/source-reiserfs.h +++ b/convert/source-reiserfs.h @@ -29,22 +29,6 @@ #define REISERFS_ACL_VERSION 0x0001 -static inline int ext2_acl_count(size_t size) -{ - ssize_t s; - size -= sizeof(ext2_acl_header); - s = size - 4 * sizeof(ext2_acl_entry_short); - if (s < 0) { - if (size % sizeof(ext2_acl_entry_short)) - return -1; - return size / sizeof(ext2_acl_entry_short); - } else { - if (s % sizeof(ext2_acl_entry)) - return -1; - return s / sizeof(ext2_acl_entry) + 4; - } -} - static inline dev_t new_decode_dev(u32 dev) { unsigned major = (dev & 0xfff00) >> 8;