fs: take the ACL checks to common code
Replace the ->check_acl method with a ->get_acl method that simply reads an
ACL from disk after having a cache miss. This means we can replace the ACL
checking boilerplate code with a single implementation in namei.c.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
diff --git a/fs/namei.c b/fs/namei.c
index 120efc7..ec2e565 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -196,20 +196,22 @@
acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
/*
- * A filesystem can force a ACL callback by just never
- * filling the ACL cache. But normally you'd fill the
- * cache either at inode instantiation time, or on the
- * first ->check_acl call.
+ * A filesystem can force a ACL callback by just never filling the
+ * ACL cache. But normally you'd fill the cache either at inode
+ * instantiation time, or on the first ->get_acl call.
*
- * If the filesystem doesn't have a check_acl() function
- * at all, we'll just create the negative cache entry.
+ * If the filesystem doesn't have a get_acl() function at all, we'll
+ * just create the negative cache entry.
*/
if (acl == ACL_NOT_CACHED) {
- if (inode->i_op->check_acl)
- return inode->i_op->check_acl(inode, mask);
-
- set_cached_acl(inode, ACL_TYPE_ACCESS, NULL);
- return -EAGAIN;
+ if (inode->i_op->get_acl) {
+ acl = inode->i_op->get_acl(inode, ACL_TYPE_ACCESS);
+ if (IS_ERR(acl))
+ return PTR_ERR(acl);
+ } else {
+ set_cached_acl(inode, ACL_TYPE_ACCESS, NULL);
+ return -EAGAIN;
+ }
}
if (acl) {