Whamcloud - gitweb
Update smfs: fix bugs of smfs_create
[fs/lustre-release.git] / lustre / smfs / symlink.c
1 /*
2  *  smfs/symlink.c
3  *
4  *
5  */
6 #define DEBUG_SUBSYSTEM S_SNAP
7
8 #include <linux/kmod.h>
9 #include <linux/init.h>
10 #include <linux/fs.h>
11 #include <linux/slab.h>
12 #include <linux/string.h>
13
14 #include "smfs_internal.h" 
15
16 static int smfs_readlink(struct dentry * dentry, char * buffer, int buflen)
17 {
18         struct inode *cache_inode = I2CI(dentry->d_inode);
19         struct dentry cache_dentry;
20         int    rc = 0;
21
22         if (!cache_inode)
23                 RETURN(-ENOENT);
24         
25         smfs_prepare_dentry(&cache_dentry, NULL, &dentry->d_name);
26         d_add(&cache_dentry, cache_inode);
27                 
28         if (cache_inode->i_op && cache_inode->i_op->readlink)   
29                 rc = cache_inode->i_op->readlink(&cache_dentry, buffer, buflen);
30         
31         smfs_clear_dentry(&cache_dentry);
32         return rc;
33 }
34
35 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
36 {
37         struct inode *cache_inode = I2CI(dentry->d_inode);
38         struct dentry cache_dentry;
39         int rc = 0;
40         if (!cache_inode)
41                 RETURN(-ENOENT);
42         
43         smfs_prepare_dentry(&cache_dentry, NULL, &dentry->d_name);
44         d_add(&cache_dentry, cache_inode);
45
46         if (cache_inode->i_op && cache_inode->i_op->follow_link)        
47                 rc = cache_inode->i_op->follow_link(&cache_dentry, nd);
48         
49         smfs_clear_dentry(&cache_dentry);
50         return rc;
51
52 }
53 struct inode_operations smfs_sym_iops = {
54         readlink:       smfs_readlink,
55         follow_link:    smfs_follow_link,
56         setxattr:       smfs_setxattr,          /* BKL held */
57         getxattr:       smfs_getxattr,          /* BKL held */
58         listxattr:      smfs_listxattr,         /* BKL held */
59         removexattr:    smfs_removexattr,       /* BKL held */
60 };
61
62 struct file_operations smfs_sym_fops = {
63 };