From 435332115e8ffb00718cc513d75a3769ebc64fc3 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Wed, 14 Nov 2001 04:41:19 +0000 Subject: [PATCH] convert over from struct acl and other ACL related types/macros to an xfs_acl_t variant so we can tell what is XFS-specific and what is not. will help our transition to a common EA/ACL codebase while keeping our existing ondisk format intact. --- include/xfs_cred.h | 30 ++++++++--------- repair/attr_repair.c | 78 ++++++++++++++++++++------------------------ repair/attr_repair.h | 2 +- 3 files changed, 50 insertions(+), 60 deletions(-) diff --git a/include/xfs_cred.h b/include/xfs_cred.h index 6858393a4..435797477 100644 --- a/include/xfs_cred.h +++ b/include/xfs_cred.h @@ -42,26 +42,24 @@ /* * Access Control Lists */ -typedef ushort acl_perm_t; -typedef int acl_type_t; -typedef int acl_tag_t; +typedef ushort xfs_acl_perm_t; +typedef int xfs_acl_type_t; +typedef int xfs_acl_tag_t; +typedef uid_t xfs_acl_id_t; -#define ACL_MAX_ENTRIES 25 -#define ACL_NOT_PRESENT -1 +#define XFS_ACL_MAX_ENTRIES 25 +#define XFS_ACL_NOT_PRESENT -1 -typedef struct acl_entry { - acl_tag_t ae_tag; - uid_t ae_id; - acl_perm_t ae_perm; -} acl_entry_s; +typedef struct xfs_acl_entry { + xfs_acl_tag_t ae_tag; + xfs_acl_id_t ae_id; + xfs_acl_perm_t ae_perm; +} xfs_acl_entry_t; -typedef struct acl { +typedef struct xfs_acl { int acl_cnt; - acl_entry_s acl_entry[ACL_MAX_ENTRIES]; -} acl_s; - -typedef struct acl_entry * acl_entry_t; -typedef struct acl * acl_t; + xfs_acl_entry_t acl_entry[XFS_ACL_MAX_ENTRIES]; +} xfs_acl_t; /* * Capabilities diff --git a/repair/attr_repair.c b/repair/attr_repair.c index 1cad070d2..903b6115b 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -38,8 +38,8 @@ #include "dinode.h" #include "bmap.h" -static int acl_valid(struct acl *aclp); -static int mac_valid(mac_t lp); +static int xfs_acl_valid(xfs_acl_t *aclp); +static int xfs_mac_valid(mac_t lp); /* @@ -51,9 +51,9 @@ static int mac_valid(mac_t lp); * If that leaves the shortform down to 0 attributes, it's okay and * will appear to just have a null attribute fork. Some checks are done * for validity of the value field based on what the security needs are. - * Calls will be made out to mac_valid or acl_valid libc libraries if - * the security attributes exist. They will be cleared if invalid. No - * other values will be checked. The DMF folks do not have current + * Calls will be made to xfs_mac_valid or xfs_acl_valid routines if the + * security attributes exist. They will be cleared if invalid. + * No other values will be checked. The DMF folks do not have current * requirements, but may in the future. * * For leaf block attributes, it requires more processing. One sticky @@ -99,7 +99,7 @@ valuecheck(char *namevalue, char *value, int namelen, int valuelen) { /* for proper alignment issues, get the structs and bcopy the values */ mac_label macl; - struct acl thisacl; + xfs_acl_t thisacl; void *valuep; int clearit = 0; @@ -107,13 +107,13 @@ valuecheck(char *namevalue, char *value, int namelen, int valuelen) (strncmp(namevalue, SGI_ACL_DEFAULT, SGI_ACL_DEFAULT_SIZE) == 0)) { if (value == NULL) { - bzero(&thisacl, sizeof(struct acl)); + bzero(&thisacl, sizeof(xfs_acl_t)); bcopy(namevalue+namelen, &thisacl, valuelen); valuep = &thisacl; } else valuep = value; - if (acl_valid((struct acl *) valuep) != 0) { /* 0 means valid */ + if (xfs_acl_valid((xfs_acl_t *) valuep) != 0) { /* 0 is valid */ clearit = 1; do_warn("entry contains illegal value in attribute named SGI_ACL_FILE or SGI_ACL_DEFAULT\n"); } @@ -125,7 +125,7 @@ valuecheck(char *namevalue, char *value, int namelen, int valuelen) } else valuep = value; - if (mac_valid((mac_label *) valuep) != 1) { /* 1 means valid */ + if (xfs_mac_valid((mac_label *) valuep) != 1) { /* 1 is valid */ /* *if sysconf says MAC enabled, * temp = mac_from_text("msenhigh/mintlow", NULL) @@ -883,20 +883,17 @@ process_longform_attr( static void -xfs_acl_get_endian(struct acl *aclp) +xfs_acl_get_endian(xfs_acl_t *aclp) { - struct acl_entry *ace, *end; - - /* do the endian conversion */ - INT_SET(aclp->acl_cnt, ARCH_CONVERT, aclp->acl_cnt); - - /* loop thru ACEs of ACL */ - end = &aclp->acl_entry[0]+aclp->acl_cnt; - for (ace=&aclp->acl_entry[0]; ace < end; ace++) { - INT_SET(ace->ae_tag, ARCH_CONVERT, ace->ae_tag); - INT_SET(ace->ae_id, ARCH_CONVERT, ace->ae_id); - INT_SET(ace->ae_perm, ARCH_CONVERT, ace->ae_perm); - } + xfs_acl_entry_t *ace, *end; + + INT_SET(aclp->acl_cnt, ARCH_CONVERT, aclp->acl_cnt); + end = &aclp->acl_entry[0]+aclp->acl_cnt; + for (ace = &aclp->acl_entry[0]; ace < end; ace++) { + INT_SET(ace->ae_tag, ARCH_CONVERT, ace->ae_tag); + INT_SET(ace->ae_id, ARCH_CONVERT, ace->ae_id); + INT_SET(ace->ae_perm, ARCH_CONVERT, ace->ae_perm); + } } /* @@ -940,9 +937,9 @@ process_attributes( * Validate an ACL */ static int -acl_valid (struct acl *aclp) +xfs_acl_valid(xfs_acl_t *aclp) { - struct acl_entry *entry, *e; + xfs_acl_entry_t *entry, *e; int user = 0, group = 0, other = 0, mask = 0, mask_required = 0; int i, j; @@ -951,16 +948,12 @@ acl_valid (struct acl *aclp) xfs_acl_get_endian(aclp); - if (aclp->acl_cnt > ACL_MAX_ENTRIES) + if (aclp->acl_cnt > XFS_ACL_MAX_ENTRIES) goto acl_invalid; - for (i = 0; i < aclp->acl_cnt; i++) - { - + for (i = 0; i < aclp->acl_cnt; i++) { entry = &aclp->acl_entry[i]; - - switch (entry->ae_tag) - { + switch (entry->ae_tag) { case ACL_USER_OBJ: if (user++) goto acl_invalid; @@ -969,16 +962,16 @@ acl_valid (struct acl *aclp) if (group++) goto acl_invalid; break; - case ACL_OTHER_OBJ: + case ACL_OTHER: if (other++) goto acl_invalid; break; case ACL_USER: case ACL_GROUP: - for (j = i + 1; j < aclp->acl_cnt; j++) - { + for (j = i + 1; j < aclp->acl_cnt; j++) { e = &aclp->acl_entry[j]; - if (e->ae_id == entry->ae_id && e->ae_tag == entry->ae_tag) + if (e->ae_id == entry->ae_id && + e->ae_tag == entry->ae_tag) goto acl_invalid; } mask_required++; @@ -1007,21 +1000,20 @@ acl_invalid: static int __check_setvalue(const unsigned short *list, unsigned short count) { - unsigned short i; + unsigned short i; - for (i = 1; i < count ; i++) - if (list[i] <= list[i-1]) - return -1; - return 0; + for (i = 1; i < count ; i++) + if (list[i] <= list[i-1]) + return -1; + return 0; } - /* - * mac_valid(lp) + * xfs_mac_valid(lp) * check the validity of a mac label */ static int -mac_valid(mac_t lp) +xfs_mac_valid(mac_t lp) { if (lp == NULL) return (0); diff --git a/repair/attr_repair.h b/repair/attr_repair.h index 13e77ba1a..727ec4cbd 100644 --- a/repair/attr_repair.h +++ b/repair/attr_repair.h @@ -37,7 +37,7 @@ #define ACL_GROUP_OBJ 0x04 /* group */ #define ACL_GROUP 0x08 /* additional groups */ #define ACL_MASK 0x10 /* mask entry */ -#define ACL_OTHER_OBJ 0x20 /* other entry */ +#define ACL_OTHER 0x20 /* other entry */ struct blkmap; extern int process_attributes (xfs_mount_t *, xfs_ino_t, xfs_dinode_t *, -- 2.47.2