posix_acl: xattr representation cleanups
authorAndreas Gruenbacher <agruenba@redhat.com>
Tue, 27 Sep 2016 11:03:22 +0000 (13:03 +0200)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 28 Sep 2016 01:52:00 +0000 (21:52 -0400)
Remove the unnecessary typedefs and the zero-length a_entries array in
struct posix_acl_xattr_header.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/staging/lustre/lustre/include/lustre_acl.h
drivers/staging/lustre/lustre/ptlrpc/wiretest.c
fs/btrfs/send.c
fs/cifs/cifssmb.c
fs/posix_acl.c
include/linux/posix_acl_xattr.h

index fecabe139b1f1743b104cf2f0ea6b20336ee5672..9786f6caaadeaf70d3e250ad3e41ed658007d963 100644 (file)
@@ -38,8 +38,8 @@
 #include <linux/posix_acl_xattr.h>
 
 #define LUSTRE_POSIX_ACL_MAX_ENTRIES   32
-#define LUSTRE_POSIX_ACL_MAX_SIZE                                      \
-       (sizeof(posix_acl_xattr_header) +                               \
-        LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(posix_acl_xattr_entry))
+#define LUSTRE_POSIX_ACL_MAX_SIZE                                              \
+       (sizeof(struct posix_acl_xattr_header) +                                \
+        LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(struct posix_acl_xattr_entry))
 
 #endif
index 6cc2b2edf3fc5bda048d4d5fe46d4fa4e8062132..bcdf0f34008335e5482bfc8943c00a22f361a22c 100644 (file)
@@ -3745,32 +3745,28 @@ void lustre_assert_wire_constants(void)
        CLASSERT(FIEMAP_EXTENT_NET == 0x80000000);
 
        /* Checks for type posix_acl_xattr_entry */
-       LASSERTF((int)sizeof(posix_acl_xattr_entry) == 8, "found %lld\n",
-                (long long)(int)sizeof(posix_acl_xattr_entry));
-       LASSERTF((int)offsetof(posix_acl_xattr_entry, e_tag) == 0, "found %lld\n",
-                (long long)(int)offsetof(posix_acl_xattr_entry, e_tag));
-       LASSERTF((int)sizeof(((posix_acl_xattr_entry *)0)->e_tag) == 2, "found %lld\n",
-                (long long)(int)sizeof(((posix_acl_xattr_entry *)0)->e_tag));
-       LASSERTF((int)offsetof(posix_acl_xattr_entry, e_perm) == 2, "found %lld\n",
-                (long long)(int)offsetof(posix_acl_xattr_entry, e_perm));
-       LASSERTF((int)sizeof(((posix_acl_xattr_entry *)0)->e_perm) == 2, "found %lld\n",
-                (long long)(int)sizeof(((posix_acl_xattr_entry *)0)->e_perm));
-       LASSERTF((int)offsetof(posix_acl_xattr_entry, e_id) == 4, "found %lld\n",
-                (long long)(int)offsetof(posix_acl_xattr_entry, e_id));
-       LASSERTF((int)sizeof(((posix_acl_xattr_entry *)0)->e_id) == 4, "found %lld\n",
-                (long long)(int)sizeof(((posix_acl_xattr_entry *)0)->e_id));
+       LASSERTF((int)sizeof(struct posix_acl_xattr_entry) == 8, "found %lld\n",
+                (long long)(int)sizeof(struct posix_acl_xattr_entry));
+       LASSERTF((int)offsetof(struct posix_acl_xattr_entry, e_tag) == 0, "found %lld\n",
+                (long long)(int)offsetof(struct posix_acl_xattr_entry, e_tag));
+       LASSERTF((int)sizeof(((struct posix_acl_xattr_entry *)0)->e_tag) == 2, "found %lld\n",
+                (long long)(int)sizeof(((struct posix_acl_xattr_entry *)0)->e_tag));
+       LASSERTF((int)offsetof(struct posix_acl_xattr_entry, e_perm) == 2, "found %lld\n",
+                (long long)(int)offsetof(struct posix_acl_xattr_entry, e_perm));
+       LASSERTF((int)sizeof(((struct posix_acl_xattr_entry *)0)->e_perm) == 2, "found %lld\n",
+                (long long)(int)sizeof(((struct posix_acl_xattr_entry *)0)->e_perm));
+       LASSERTF((int)offsetof(struct posix_acl_xattr_entry, e_id) == 4, "found %lld\n",
+                (long long)(int)offsetof(struct posix_acl_xattr_entry, e_id));
+       LASSERTF((int)sizeof(((struct posix_acl_xattr_entry *)0)->e_id) == 4, "found %lld\n",
+                (long long)(int)sizeof(((struct posix_acl_xattr_entry *)0)->e_id));
 
        /* Checks for type posix_acl_xattr_header */
-       LASSERTF((int)sizeof(posix_acl_xattr_header) == 4, "found %lld\n",
-                (long long)(int)sizeof(posix_acl_xattr_header));
-       LASSERTF((int)offsetof(posix_acl_xattr_header, a_version) == 0, "found %lld\n",
-                (long long)(int)offsetof(posix_acl_xattr_header, a_version));
-       LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_version) == 4, "found %lld\n",
-                (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_version));
-       LASSERTF((int)offsetof(posix_acl_xattr_header, a_entries) == 4, "found %lld\n",
-                (long long)(int)offsetof(posix_acl_xattr_header, a_entries));
-       LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_entries) == 0, "found %lld\n",
-                (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_entries));
+       LASSERTF((int)sizeof(struct posix_acl_xattr_header) == 4, "found %lld\n",
+                (long long)(int)sizeof(struct posix_acl_xattr_header));
+       LASSERTF((int)offsetof(struct posix_acl_xattr_header, a_version) == 0, "found %lld\n",
+                (long long)(int)offsetof(struct posix_acl_xattr_header, a_version));
+       LASSERTF((int)sizeof(((struct posix_acl_xattr_header *)0)->a_version) == 4, "found %lld\n",
+                (long long)(int)sizeof(((struct posix_acl_xattr_header *)0)->a_version));
 
        /* Checks for struct link_ea_header */
        LASSERTF((int)sizeof(struct link_ea_header) == 24, "found %lld\n",
index a87675ffd02b33a9766eb229eea2b3b4200b783e..1379e59277e27545a281eb9e6e6af632308a687a 100644 (file)
@@ -4329,7 +4329,7 @@ static int __process_new_xattr(int num, struct btrfs_key *di_key,
        int ret;
        struct send_ctx *sctx = ctx;
        struct fs_path *p;
-       posix_acl_xattr_header dummy_acl;
+       struct posix_acl_xattr_header dummy_acl;
 
        p = fs_path_alloc();
        if (!p)
index d47197ea4ab625843377b0c1abdb2e9399962af4..fb63e4c70cff6bbdb1451483b828dbc4920948c3 100644 (file)
@@ -3334,7 +3334,7 @@ CIFSSMB_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
 #ifdef CONFIG_CIFS_POSIX
 
 /*Convert an Access Control Entry from wire format to local POSIX xattr format*/
-static void cifs_convert_ace(posix_acl_xattr_entry *ace,
+static void cifs_convert_ace(struct posix_acl_xattr_entry *ace,
                             struct cifs_posix_ace *cifs_ace)
 {
        /* u8 cifs fields do not need le conversion */
@@ -3358,7 +3358,7 @@ static int cifs_copy_posix_acl(char *trgt, char *src, const int buflen,
        __u16 count;
        struct cifs_posix_ace *pACE;
        struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)src;
-       posix_acl_xattr_header *local_acl = (posix_acl_xattr_header *)trgt;
+       struct posix_acl_xattr_header *local_acl = (void *)trgt;
 
        if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION)
                return -EOPNOTSUPP;
@@ -3396,9 +3396,11 @@ static int cifs_copy_posix_acl(char *trgt, char *src, const int buflen,
        } else if (size > buflen) {
                return -ERANGE;
        } else /* buffer big enough */ {
+               struct posix_acl_xattr_entry *ace = (void *)(local_acl + 1);
+
                local_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
                for (i = 0; i < count ; i++) {
-                       cifs_convert_ace(&local_acl->a_entries[i], pACE);
+                       cifs_convert_ace(&ace[i], pACE);
                        pACE++;
                }
        }
@@ -3406,7 +3408,7 @@ static int cifs_copy_posix_acl(char *trgt, char *src, const int buflen,
 }
 
 static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace *cifs_ace,
-                                    const posix_acl_xattr_entry *local_ace)
+                                    const struct posix_acl_xattr_entry *local_ace)
 {
        __u16 rc = 0; /* 0 = ACL converted ok */
 
@@ -3431,7 +3433,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
 {
        __u16 rc = 0;
        struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data;
-       posix_acl_xattr_header *local_acl = (posix_acl_xattr_header *)pACL;
+       struct posix_acl_xattr_header *local_acl = (void *)pACL;
        int count;
        int i;
 
@@ -3459,7 +3461,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
        }
        for (i = 0; i < count; i++) {
                rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],
-                                       &local_acl->a_entries[i]);
+                       (struct posix_acl_xattr_entry *)(local_acl + 1));
                if (rc != 0) {
                        /* ACE not converted */
                        break;
index 59d47ab0791af5ce96200c18ecaeee53800cd35a..8cdcbb1dd092c77a2d7545a7a9ea42e2a4c6ea62 100644 (file)
@@ -633,15 +633,15 @@ static void posix_acl_fix_xattr_userns(
        struct user_namespace *to, struct user_namespace *from,
        void *value, size_t size)
 {
-       posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
-       posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
+       struct posix_acl_xattr_header *header = value;
+       struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
        int count;
        kuid_t uid;
        kgid_t gid;
 
        if (!value)
                return;
-       if (size < sizeof(posix_acl_xattr_header))
+       if (size < sizeof(struct posix_acl_xattr_header))
                return;
        if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
                return;
@@ -691,15 +691,15 @@ struct posix_acl *
 posix_acl_from_xattr(struct user_namespace *user_ns,
                     const void *value, size_t size)
 {
-       posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
-       posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
+       const struct posix_acl_xattr_header *header = value;
+       const struct posix_acl_xattr_entry *entry = (const void *)(header + 1), *end;
        int count;
        struct posix_acl *acl;
        struct posix_acl_entry *acl_e;
 
        if (!value)
                return NULL;
-       if (size < sizeof(posix_acl_xattr_header))
+       if (size < sizeof(struct posix_acl_xattr_header))
                 return ERR_PTR(-EINVAL);
        if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
                return ERR_PTR(-EOPNOTSUPP);
@@ -760,8 +760,8 @@ int
 posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
                   void *buffer, size_t size)
 {
-       posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer;
-       posix_acl_xattr_entry *ext_entry;
+       struct posix_acl_xattr_header *ext_acl = buffer;
+       struct posix_acl_xattr_entry *ext_entry;
        int real_size, n;
 
        real_size = posix_acl_xattr_size(acl->a_count);
@@ -770,7 +770,7 @@ posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
        if (real_size > size)
                return -ERANGE;
 
-       ext_entry = ext_acl->a_entries;
+       ext_entry = (void *)(ext_acl + 1);
        ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
 
        for (n=0; n < acl->a_count; n++, ext_entry++) {
index e5e8ec40278dd7f463d59298ce45eb3a86e99b16..d23d36842322f380fcffe84e746f7081a4434454 100644 (file)
 /* An undefined entry e_id value */
 #define ACL_UNDEFINED_ID       (-1)
 
-typedef struct {
+struct posix_acl_xattr_entry {
        __le16                  e_tag;
        __le16                  e_perm;
        __le32                  e_id;
-} posix_acl_xattr_entry;
+};
 
-typedef struct {
+struct posix_acl_xattr_header {
        __le32                  a_version;
-       posix_acl_xattr_entry   a_entries[0];
-} posix_acl_xattr_header;
+};
 
 
 static inline size_t
 posix_acl_xattr_size(int count)
 {
-       return (sizeof(posix_acl_xattr_header) +
-               (count * sizeof(posix_acl_xattr_entry)));
+       return (sizeof(struct posix_acl_xattr_header) +
+               (count * sizeof(struct posix_acl_xattr_entry)));
 }
 
 static inline int
 posix_acl_xattr_count(size_t size)
 {
-       if (size < sizeof(posix_acl_xattr_header))
+       if (size < sizeof(struct posix_acl_xattr_header))
                return -1;
-       size -= sizeof(posix_acl_xattr_header);
-       if (size % sizeof(posix_acl_xattr_entry))
+       size -= sizeof(struct posix_acl_xattr_header);
+       if (size % sizeof(struct posix_acl_xattr_entry))
                return -1;
-       return size / sizeof(posix_acl_xattr_entry);
+       return size / sizeof(struct posix_acl_xattr_entry);
 }
 
 #ifdef CONFIG_FS_POSIX_ACL