0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/dcache.h>
0012 #include <linux/namei.h>
0013 #include <linux/mount.h>
0014 #include <linux/fs_stack.h>
0015 #include <linux/slab.h>
0016 #include "ecryptfs_kernel.h"
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags)
0032 {
0033 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
0034 int rc = 1;
0035
0036 if (flags & LOOKUP_RCU)
0037 return -ECHILD;
0038
0039 if (lower_dentry->d_flags & DCACHE_OP_REVALIDATE)
0040 rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags);
0041
0042 if (d_really_is_positive(dentry)) {
0043 struct inode *inode = d_inode(dentry);
0044
0045 fsstack_copy_attr_all(inode, ecryptfs_inode_to_lower(inode));
0046 if (!inode->i_nlink)
0047 return 0;
0048 }
0049 return rc;
0050 }
0051
0052 struct kmem_cache *ecryptfs_dentry_info_cache;
0053
0054 static void ecryptfs_dentry_free_rcu(struct rcu_head *head)
0055 {
0056 kmem_cache_free(ecryptfs_dentry_info_cache,
0057 container_of(head, struct ecryptfs_dentry_info, rcu));
0058 }
0059
0060
0061
0062
0063
0064
0065
0066 static void ecryptfs_d_release(struct dentry *dentry)
0067 {
0068 struct ecryptfs_dentry_info *p = dentry->d_fsdata;
0069 if (p) {
0070 path_put(&p->lower_path);
0071 call_rcu(&p->rcu, ecryptfs_dentry_free_rcu);
0072 }
0073 }
0074
0075 const struct dentry_operations ecryptfs_dops = {
0076 .d_revalidate = ecryptfs_d_revalidate,
0077 .d_release = ecryptfs_d_release,
0078 };