@@ -25,13 +25,13 @@ typedef struct {
static inline size_t ext2_acl_size(int count)
{
- if (count <= 4) {
+ if (count <= ACL_MAX_SHORT_ENTRY) {
return sizeof(ext2_acl_header) +
count * sizeof(ext2_acl_entry_short);
} else {
return sizeof(ext2_acl_header) +
- 4 * sizeof(ext2_acl_entry_short) +
- (count - 4) * sizeof(ext2_acl_entry);
+ ACL_MAX_SHORT_ENTRY * sizeof(ext2_acl_entry_short) +
+ (count - ACL_MAX_SHORT_ENTRY) * sizeof(ext2_acl_entry);
}
}
@@ -39,7 +39,7 @@ 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);
+ s = size - ACL_MAX_SHORT_ENTRY * sizeof(ext2_acl_entry_short);
if (s < 0) {
if (size % sizeof(ext2_acl_entry_short))
return -1;
@@ -47,7 +47,7 @@ static inline int ext2_acl_count(size_t size)
} else {
if (s % sizeof(ext2_acl_entry))
return -1;
- return s / sizeof(ext2_acl_entry) + 4;
+ return s / sizeof(ext2_acl_entry) + ACL_MAX_SHORT_ENTRY;
}
}
@@ -25,13 +25,13 @@ typedef struct {
static inline size_t ext3_acl_size(int count)
{
- if (count <= 4) {
+ if (count <= ACL_MAX_SHORT_ENTRY) {
return sizeof(ext3_acl_header) +
count * sizeof(ext3_acl_entry_short);
} else {
return sizeof(ext3_acl_header) +
- 4 * sizeof(ext3_acl_entry_short) +
- (count - 4) * sizeof(ext3_acl_entry);
+ ACL_MAX_SHORT_ENTRY * sizeof(ext3_acl_entry_short) +
+ (count - ACL_MAX_SHORT_ENTRY) * sizeof(ext3_acl_entry);
}
}
@@ -39,7 +39,7 @@ static inline int ext3_acl_count(size_t size)
{
ssize_t s;
size -= sizeof(ext3_acl_header);
- s = size - 4 * sizeof(ext3_acl_entry_short);
+ s = size - ACL_MAX_SHORT_ENTRY * sizeof(ext3_acl_entry_short);
if (s < 0) {
if (size % sizeof(ext3_acl_entry_short))
return -1;
@@ -47,7 +47,7 @@ static inline int ext3_acl_count(size_t size)
} else {
if (s % sizeof(ext3_acl_entry))
return -1;
- return s / sizeof(ext3_acl_entry) + 4;
+ return s / sizeof(ext3_acl_entry) + ACL_MAX_SHORT_ENTRY;
}
}
@@ -25,13 +25,13 @@ typedef struct {
static inline size_t ext4_acl_size(int count)
{
- if (count <= 4) {
+ if (count <= ACL_MAX_SHORT_ENTRY) {
return sizeof(ext4_acl_header) +
count * sizeof(ext4_acl_entry_short);
} else {
return sizeof(ext4_acl_header) +
- 4 * sizeof(ext4_acl_entry_short) +
- (count - 4) * sizeof(ext4_acl_entry);
+ ACL_MAX_SHORT_ENTRY * sizeof(ext4_acl_entry_short) +
+ (count - ACL_MAX_SHORT_ENTRY) * sizeof(ext4_acl_entry);
}
}
@@ -39,7 +39,7 @@ static inline int ext4_acl_count(size_t size)
{
ssize_t s;
size -= sizeof(ext4_acl_header);
- s = size - 4 * sizeof(ext4_acl_entry_short);
+ s = size - ACL_MAX_SHORT_ENTRY * sizeof(ext4_acl_entry_short);
if (s < 0) {
if (size % sizeof(ext4_acl_entry_short))
return -1;
@@ -47,7 +47,7 @@ static inline int ext4_acl_count(size_t size)
} else {
if (s % sizeof(ext4_acl_entry))
return -1;
- return s / sizeof(ext4_acl_entry) + 4;
+ return s / sizeof(ext4_acl_entry) + ACL_MAX_SHORT_ENTRY;
}
}
@@ -22,13 +22,15 @@
static inline size_t f2fs_acl_size(int count)
{
- if (count <= 4) {
+ if (count <= ACL_MAX_SHORT_ENTRY) {
return sizeof(struct f2fs_acl_header) +
count * sizeof(struct f2fs_acl_entry_short);
} else {
return sizeof(struct f2fs_acl_header) +
- 4 * sizeof(struct f2fs_acl_entry_short) +
- (count - 4) * sizeof(struct f2fs_acl_entry);
+ ACL_MAX_SHORT_ENTRY
+ * sizeof(struct f2fs_acl_entry_short) +
+ (count - ACL_MAX_SHORT_ENTRY)
+ * sizeof(struct f2fs_acl_entry);
}
}
@@ -36,7 +38,7 @@ static inline int f2fs_acl_count(size_t size)
{
ssize_t s;
size -= sizeof(struct f2fs_acl_header);
- s = size - 4 * sizeof(struct f2fs_acl_entry_short);
+ s = size - ACL_MAX_SHORT_ENTRY * sizeof(struct f2fs_acl_entry_short);
if (s < 0) {
if (size % sizeof(struct f2fs_acl_entry_short))
return -1;
@@ -44,7 +46,7 @@ static inline int f2fs_acl_count(size_t size)
} else {
if (s % sizeof(struct f2fs_acl_entry))
return -1;
- return s / sizeof(struct f2fs_acl_entry) + 4;
+ return s / sizeof(struct f2fs_acl_entry) + ACL_MAX_SHORT_ENTRY;
}
}
@@ -25,13 +25,15 @@
static size_t jffs2_acl_size(int count)
{
- if (count <= 4) {
+ if (count <= ACL_MAX_SHORT_ENTRY) {
return sizeof(struct jffs2_acl_header)
+ count * sizeof(struct jffs2_acl_entry_short);
} else {
return sizeof(struct jffs2_acl_header)
- + 4 * sizeof(struct jffs2_acl_entry_short)
- + (count - 4) * sizeof(struct jffs2_acl_entry);
+ + ACL_MAX_SHORT_ENTRY
+ * sizeof(struct jffs2_acl_entry_short)
+ + (count - ACL_MAX_SHORT_ENTRY)
+ * sizeof(struct jffs2_acl_entry);
}
}
@@ -40,15 +42,16 @@ static int jffs2_acl_count(size_t size)
size_t s;
size -= sizeof(struct jffs2_acl_header);
- if (size < 4 * sizeof(struct jffs2_acl_entry_short)) {
+ if (size < ACL_MAX_SHORT_ENTRY * sizeof(struct jffs2_acl_entry_short)) {
if (size % sizeof(struct jffs2_acl_entry_short))
return -1;
return size / sizeof(struct jffs2_acl_entry_short);
} else {
- s = size - 4 * sizeof(struct jffs2_acl_entry_short);
+ s = size - ACL_MAX_SHORT_ENTRY
+ * sizeof(struct jffs2_acl_entry_short);
if (s % sizeof(struct jffs2_acl_entry))
return -1;
- return s / sizeof(struct jffs2_acl_entry) + 4;
+ return s / sizeof(struct jffs2_acl_entry) + ACL_MAX_SHORT_ENTRY;
}
}
@@ -72,6 +72,14 @@ posix_acl_clone(const struct posix_acl *acl, gfp_t flags)
/*
* Check if an acl is valid. Returns 0 if it is, or -E... otherwise.
+ *
+ * make sure ACL format is the following:
+ *
+ * ACL_USER_OBJ ACL_USER*[1] ACL_GROUP_OBJ ACL_GROUP*[1] ACL_MASK[2] ACL_OTHER
+ *
+ * [1] Where * is the regexp sense of "0 or more times"
+ * [2] Only if there is at least one ACL_USER or ACL_GROUP tag;
+ * otherwise skip ACL_MASK.
*/
int
posix_acl_valid(const struct posix_acl *acl)
@@ -20,13 +20,13 @@ typedef struct {
static inline size_t reiserfs_acl_size(int count)
{
- if (count <= 4) {
+ if (count <= ACL_MAX_SHORT_ENTRY) {
return sizeof(reiserfs_acl_header) +
count * sizeof(reiserfs_acl_entry_short);
} else {
return sizeof(reiserfs_acl_header) +
- 4 * sizeof(reiserfs_acl_entry_short) +
- (count - 4) * sizeof(reiserfs_acl_entry);
+ ACL_MAX_SHORT_ENTRY * sizeof(reiserfs_acl_entry_short) +
+ (count - ACL_MAX_SHORT_ENTRY) * sizeof(reiserfs_acl_entry);
}
}
@@ -34,7 +34,7 @@ static inline int reiserfs_acl_count(size_t size)
{
ssize_t s;
size -= sizeof(reiserfs_acl_header);
- s = size - 4 * sizeof(reiserfs_acl_entry_short);
+ s = size - ACL_MAX_SHORT_ENTRY * sizeof(reiserfs_acl_entry_short);
if (s < 0) {
if (size % sizeof(reiserfs_acl_entry_short))
return -1;
@@ -42,7 +42,7 @@ static inline int reiserfs_acl_count(size_t size)
} else {
if (s % sizeof(reiserfs_acl_entry))
return -1;
- return s / sizeof(reiserfs_acl_entry) + 4;
+ return s / sizeof(reiserfs_acl_entry) + ACL_MAX_SHORT_ENTRY;
}
}
@@ -26,6 +26,14 @@
#define ACL_MASK (0x10)
#define ACL_OTHER (0x20)
+/*
+ * posix_acl_valid() makes sure that if there are <= 4 ACL entries, then
+ * all of them are short. Otherwise exactly 4 entries are short ones and
+ * other have full length. See comment before that function for exact ACL
+ * format.
+ */
+#define ACL_MAX_SHORT_ENTRY (4)
+
/* permissions in the e_perm field */
#define ACL_READ (0x04)
#define ACL_WRITE (0x02)