From 385bbf35e245bfa71c83d6c41e563ce4ed22663e Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 22 Aug 2017 20:30:43 +0200 Subject: [PATCH] btrfs-progs: convert: move duplicated acl code to common header The ACL types and macros are same for both source filesystem. Signed-off-by: David Sterba --- convert/source-ext2.h | 42 ---------------------------------- convert/source-fs.h | 47 ++++++++++++++++++++++++++++++++++++++ convert/source-reiserfs.h | 48 --------------------------------------- 3 files changed, 47 insertions(+), 90 deletions(-) diff --git a/convert/source-ext2.h b/convert/source-ext2.h index 20a278ed..80833b21 100644 --- a/convert/source-ext2.h +++ b/convert/source-ext2.h @@ -66,48 +66,6 @@ struct dir_iterate_data { #define EXT2_ACL_VERSION 0x0001 -/* 23.2.5 acl_tag_t values */ - -#define ACL_UNDEFINED_TAG (0x00) -#define ACL_USER_OBJ (0x01) -#define ACL_USER (0x02) -#define ACL_GROUP_OBJ (0x04) -#define ACL_GROUP (0x08) -#define ACL_MASK (0x10) -#define ACL_OTHER (0x20) - -/* 23.2.7 ACL qualifier constants */ - -#define ACL_UNDEFINED_ID ((id_t)-1) - -typedef struct { - __le16 e_tag; - __le16 e_perm; - __le32 e_id; -} ext2_acl_entry; - -typedef struct { - __le16 e_tag; - __le16 e_perm; -} ext2_acl_entry_short; - -typedef struct { - __le32 a_version; -} ext2_acl_header; - -#define ACL_EA_VERSION 0x0002 - -typedef struct { - __le16 e_tag; - __le16 e_perm; - __le32 e_id; -} acl_ea_entry; - -typedef struct { - __le32 a_version; - acl_ea_entry a_entries[0]; -} acl_ea_header; - #endif /* BTRFSCONVERT_EXT2 */ #endif diff --git a/convert/source-fs.h b/convert/source-fs.h index 3a6fa46c..a2b21982 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -55,6 +55,53 @@ struct btrfs_convert_context; #define CONVERT_FLAG_COPY_LABEL (1U << 3) #define CONVERT_FLAG_SET_LABEL (1U << 4) +/* 23.2.5 acl_tag_t values */ + +#define ACL_UNDEFINED_TAG (0x00) +#define ACL_USER_OBJ (0x01) +#define ACL_USER (0x02) +#define ACL_GROUP_OBJ (0x04) +#define ACL_GROUP (0x08) +#define ACL_MASK (0x10) +#define ACL_OTHER (0x20) + +/* 23.2.7 ACL qualifier constants */ + +#define ACL_UNDEFINED_ID ((id_t)-1) + +#define ACL_EA_VERSION 0x0002 + +typedef struct { + __le16 e_tag; + __le16 e_perm; + __le32 e_id; +} acl_ea_entry; + +typedef struct { + __le32 a_version; + acl_ea_entry a_entries[0]; +} acl_ea_header; + +typedef struct { + __le16 e_tag; + __le16 e_perm; + __le32 e_id; +} ext2_acl_entry; + +typedef struct { + __le16 e_tag; + __le16 e_perm; +} ext2_acl_entry_short; + +typedef struct { + __le32 a_version; +} ext2_acl_header; + +static inline size_t acl_ea_size(int count) +{ + return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry); +} + 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 c960c2b6..10b0ceb6 100644 --- a/convert/source-reiserfs.h +++ b/convert/source-reiserfs.h @@ -29,48 +29,6 @@ #define REISERFS_ACL_VERSION 0x0001 -/* 23.2.5 acl_tag_t values */ - -#define ACL_UNDEFINED_TAG (0x00) -#define ACL_USER_OBJ (0x01) -#define ACL_USER (0x02) -#define ACL_GROUP_OBJ (0x04) -#define ACL_GROUP (0x08) -#define ACL_MASK (0x10) -#define ACL_OTHER (0x20) - -/* 23.2.7 ACL qualifier constants */ - -#define ACL_UNDEFINED_ID ((id_t)-1) - -typedef struct { - __le16 e_tag; - __le16 e_perm; - __le32 e_id; -} ext2_acl_entry; - -typedef struct { - __le16 e_tag; - __le16 e_perm; -} ext2_acl_entry_short; - -typedef struct { - __le32 a_version; -} ext2_acl_header; - -#define ACL_EA_VERSION 0x0002 - -typedef struct { - __le16 e_tag; - __le16 e_perm; - __le32 e_id; -} acl_ea_entry; - -typedef struct { - __le32 a_version; - acl_ea_entry a_entries[0]; -} acl_ea_header; - static inline int ext2_acl_count(size_t size) { ssize_t s; @@ -87,12 +45,6 @@ static inline int ext2_acl_count(size_t size) } } - -static inline size_t acl_ea_size(int count) -{ - return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry); -} - static inline dev_t new_decode_dev(u32 dev) { unsigned major = (dev & 0xfff00) >> 8;