| 1 | /* |
|---|
| 2 | File: linux/posix_acl_xattr.h |
|---|
| 3 | |
|---|
| 4 | Extended attribute system call representation of Access Control Lists. |
|---|
| 5 | |
|---|
| 6 | Copyright (C) 2000 by Andreas Gruenbacher <a.gruenbacher@computer.org> |
|---|
| 7 | Copyright (C) 2002 SGI - Silicon Graphics, Inc <linux-xfs@oss.sgi.com> |
|---|
| 8 | */ |
|---|
| 9 | #ifndef _POSIX_ACL_XATTR_H |
|---|
| 10 | #define _POSIX_ACL_XATTR_H |
|---|
| 11 | |
|---|
| 12 | #include <asm/types.h> |
|---|
| 13 | |
|---|
| 14 | #include <linux/posix_acl.h> |
|---|
| 15 | |
|---|
| 16 | /* Extended attribute names */ |
|---|
| 17 | #define POSIX_ACL_XATTR_ACCESS "system.posix_acl_access" |
|---|
| 18 | #define POSIX_ACL_XATTR_DEFAULT "system.posix_acl_default" |
|---|
| 19 | |
|---|
| 20 | /* Supported ACL a_version fields */ |
|---|
| 21 | #define POSIX_ACL_XATTR_VERSION 0x0002 |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | /* An undefined entry e_id value */ |
|---|
| 25 | #define ACL_UNDEFINED_ID (-1) |
|---|
| 26 | |
|---|
| 27 | typedef struct { |
|---|
| 28 | __u16 e_tag; |
|---|
| 29 | __u16 e_perm; |
|---|
| 30 | __u32 e_id; |
|---|
| 31 | } posix_acl_xattr_entry; |
|---|
| 32 | |
|---|
| 33 | typedef struct { |
|---|
| 34 | __u32 a_version; |
|---|
| 35 | posix_acl_xattr_entry a_entries[0]; |
|---|
| 36 | } posix_acl_xattr_header; |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | static inline size_t |
|---|
| 40 | posix_acl_xattr_size(int count) |
|---|
| 41 | { |
|---|
| 42 | return (sizeof(posix_acl_xattr_header) + |
|---|
| 43 | (count * sizeof(posix_acl_xattr_entry))); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | static inline int |
|---|
| 47 | posix_acl_xattr_count(size_t size) |
|---|
| 48 | { |
|---|
| 49 | if (size < sizeof(posix_acl_xattr_header)) |
|---|
| 50 | return -1; |
|---|
| 51 | size -= sizeof(posix_acl_xattr_header); |
|---|
| 52 | if (size % sizeof(posix_acl_xattr_entry)) |
|---|
| 53 | return -1; |
|---|
| 54 | return size / sizeof(posix_acl_xattr_entry); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | #endif /* _POSIX_ACL_XATTR_H */ |
|---|