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 <dsterba@suse.com>
This commit is contained in:
David Sterba 2017-08-22 20:34:36 +02:00
parent 385bbf35e2
commit c05c70c77c
4 changed files with 19 additions and 37 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -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);

View File

@ -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;