Skip to content

Commit c05c70c

Browse files
committed
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>
1 parent 385bbf3 commit c05c70c

File tree

4 files changed

+19
-37
lines changed

4 files changed

+19
-37
lines changed

convert/source-ext2.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -424,27 +424,6 @@ static int ext2_xattr_check_entry(struct ext2_ext_attr_entry *entry,
424424
return 0;
425425
}
426426

427-
static inline int ext2_acl_count(size_t size)
428-
{
429-
ssize_t s;
430-
size -= sizeof(ext2_acl_header);
431-
s = size - 4 * sizeof(ext2_acl_entry_short);
432-
if (s < 0) {
433-
if (size % sizeof(ext2_acl_entry_short))
434-
return -1;
435-
return size / sizeof(ext2_acl_entry_short);
436-
} else {
437-
if (s % sizeof(ext2_acl_entry))
438-
return -1;
439-
return s / sizeof(ext2_acl_entry) + 4;
440-
}
441-
}
442-
443-
static inline size_t acl_ea_size(int count)
444-
{
445-
return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry);
446-
}
447-
448427
static int ext2_acl_to_xattr(void *dst, const void *src,
449428
size_t dst_size, size_t src_size)
450429
{

convert/source-fs.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ const struct simple_range btrfs_reserved_ranges[3] = {
2828
{ BTRFS_SB_MIRROR_OFFSET(2), SZ_64K }
2929
};
3030

31+
int ext2_acl_count(size_t size)
32+
{
33+
ssize_t s;
34+
35+
size -= sizeof(ext2_acl_header);
36+
s = size - 4 * sizeof(ext2_acl_entry_short);
37+
if (s < 0) {
38+
if (size % sizeof(ext2_acl_entry_short))
39+
return -1;
40+
return size / sizeof(ext2_acl_entry_short);
41+
} else {
42+
if (s % sizeof(ext2_acl_entry))
43+
return -1;
44+
return s / sizeof(ext2_acl_entry) + 4;
45+
}
46+
}
47+
3148
static u64 intersect_with_reserved(u64 bytenr, u64 num_bytes)
3249
{
3350
int i;

convert/source-fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ static inline size_t acl_ea_size(int count)
102102
return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry);
103103
}
104104

105+
int ext2_acl_count(size_t size);
106+
105107
struct btrfs_convert_operations {
106108
const char name[SOURCE_FS_NAME_LEN];
107109
int (*open_fs)(struct btrfs_convert_context *cctx, const char *devname);

convert/source-reiserfs.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,6 @@
2929

3030
#define REISERFS_ACL_VERSION 0x0001
3131

32-
static inline int ext2_acl_count(size_t size)
33-
{
34-
ssize_t s;
35-
size -= sizeof(ext2_acl_header);
36-
s = size - 4 * sizeof(ext2_acl_entry_short);
37-
if (s < 0) {
38-
if (size % sizeof(ext2_acl_entry_short))
39-
return -1;
40-
return size / sizeof(ext2_acl_entry_short);
41-
} else {
42-
if (s % sizeof(ext2_acl_entry))
43-
return -1;
44-
return s / sizeof(ext2_acl_entry) + 4;
45-
}
46-
}
47-
4832
static inline dev_t new_decode_dev(u32 dev)
4933
{
5034
unsigned major = (dev & 0xfff00) >> 8;

0 commit comments

Comments
 (0)