diff options
Diffstat (limited to 'include/linux/posix_acl.h')
| -rw-r--r-- | include/linux/posix_acl.h | 74 | 
1 files changed, 74 insertions, 0 deletions
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h index 4bc241290c24..065a3652a3ea 100644 --- a/include/linux/posix_acl.h +++ b/include/linux/posix_acl.h  | |||
| @@ -83,4 +83,78 @@ extern int posix_acl_chmod_masq(struct posix_acl *, mode_t); | |||
| 83 | extern struct posix_acl *get_posix_acl(struct inode *, int); | 83 | extern struct posix_acl *get_posix_acl(struct inode *, int); | 
| 84 | extern int set_posix_acl(struct inode *, int, struct posix_acl *); | 84 | extern int set_posix_acl(struct inode *, int, struct posix_acl *); | 
| 85 | 85 | ||
| 86 | #ifdef CONFIG_FS_POSIX_ACL | ||
| 87 | static inline struct posix_acl *get_cached_acl(struct inode *inode, int type) | ||
| 88 | { | ||
| 89 | struct posix_acl **p, *acl; | ||
| 90 | switch (type) { | ||
| 91 | case ACL_TYPE_ACCESS: | ||
| 92 | p = &inode->i_acl; | ||
| 93 | break; | ||
| 94 | case ACL_TYPE_DEFAULT: | ||
| 95 | p = &inode->i_default_acl; | ||
| 96 | break; | ||
| 97 | default: | ||
| 98 | return ERR_PTR(-EINVAL); | ||
| 99 | } | ||
| 100 | acl = ACCESS_ONCE(*p); | ||
| 101 | if (acl) { | ||
| 102 | spin_lock(&inode->i_lock); | ||
| 103 | acl = *p; | ||
| 104 | if (acl != ACL_NOT_CACHED) | ||
| 105 | acl = posix_acl_dup(acl); | ||
| 106 | spin_unlock(&inode->i_lock); | ||
| 107 | } | ||
| 108 | return acl; | ||
| 109 | } | ||
| 110 | |||
| 111 | static inline void set_cached_acl(struct inode *inode, | ||
| 112 | int type, | ||
| 113 | struct posix_acl *acl) | ||
| 114 | { | ||
| 115 | struct posix_acl *old = NULL; | ||
| 116 | spin_lock(&inode->i_lock); | ||
| 117 | switch (type) { | ||
| 118 | case ACL_TYPE_ACCESS: | ||
| 119 | old = inode->i_acl; | ||
| 120 | inode->i_acl = posix_acl_dup(acl); | ||
| 121 | break; | ||
| 122 | case ACL_TYPE_DEFAULT: | ||
| 123 | old = inode->i_default_acl; | ||
| 124 | inode->i_default_acl = posix_acl_dup(acl); | ||
| 125 | break; | ||
| 126 | } | ||
| 127 | spin_unlock(&inode->i_lock); | ||
| 128 | if (old != ACL_NOT_CACHED) | ||
| 129 | posix_acl_release(old); | ||
| 130 | } | ||
| 131 | |||
| 132 | static inline void forget_cached_acl(struct inode *inode, int type) | ||
| 133 | { | ||
| 134 | struct posix_acl *old = NULL; | ||
| 135 | spin_lock(&inode->i_lock); | ||
| 136 | switch (type) { | ||
| 137 | case ACL_TYPE_ACCESS: | ||
| 138 | old = inode->i_acl; | ||
| 139 | inode->i_acl = ACL_NOT_CACHED; | ||
| 140 | break; | ||
| 141 | case ACL_TYPE_DEFAULT: | ||
| 142 | old = inode->i_default_acl; | ||
| 143 | inode->i_default_acl = ACL_NOT_CACHED; | ||
| 144 | break; | ||
| 145 | } | ||
| 146 | spin_unlock(&inode->i_lock); | ||
| 147 | if (old != ACL_NOT_CACHED) | ||
| 148 | posix_acl_release(old); | ||
| 149 | } | ||
| 150 | #endif | ||
| 151 | |||
| 152 | static inline void cache_no_acl(struct inode *inode) | ||
| 153 | { | ||
| 154 | #ifdef CONFIG_FS_POSIX_ACL | ||
| 155 | inode->i_acl = NULL; | ||
| 156 | inode->i_default_acl = NULL; | ||
| 157 | #endif | ||
| 158 | } | ||
| 159 | |||
| 86 | #endif /* __LINUX_POSIX_ACL_H */ | 160 | #endif /* __LINUX_POSIX_ACL_H */ | 
