Whamcloud - gitweb
smash the HEAD with the contents of b_cmd. HEAD_PRE_CMD_SMASH and
[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 #include <linux/lustre_idl.h>
14
15 #include "smfs_internal.h" 
16
17 static int smfs_readlink(struct dentry * dentry, char * buffer, int buflen)
18 {
19         struct inode *cache_inode = I2CI(dentry->d_inode);
20         struct inode *cache_dir = NULL;
21         struct dentry *cache_dentry;
22         struct dentry parent;
23         int    rc = 0;
24
25         if (!cache_inode)
26                 RETURN(-ENOENT);
27         if (dentry->d_parent && dentry->d_parent->d_inode){
28                 cache_dir = I2CI(dentry->d_parent->d_inode);
29                 prepare_parent_dentry(&parent, cache_dir);
30         }       
31         cache_dentry = d_alloc(&parent, &dentry->d_name);
32         d_add(cache_dentry, cache_inode);
33         igrab(cache_inode);
34                 
35         if (cache_inode->i_op && cache_inode->i_op->readlink)   
36                 rc = cache_inode->i_op->readlink(cache_dentry, buffer, buflen);
37         
38         d_unalloc(cache_dentry);
39         return rc;
40 }
41
42 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
43 {
44         struct inode *cache_inode = I2CI(dentry->d_inode);
45         struct inode *cache_dir = NULL;
46         struct dentry *cache_dentry;
47         struct dentry parent;
48         int rc = 0;
49         if (!cache_inode)
50                 RETURN(-ENOENT);
51
52         if (dentry->d_parent && dentry->d_parent->d_inode){
53                 cache_dir = I2CI(dentry->d_parent->d_inode);
54                 prepare_parent_dentry(&parent, cache_dir);
55         }       
56
57         cache_dentry = d_alloc(&parent, &dentry->d_name);
58
59         d_add(cache_dentry, cache_inode);
60         igrab(cache_inode);
61         
62         if (cache_inode->i_op && cache_inode->i_op->follow_link)        
63                 rc = cache_inode->i_op->follow_link(cache_dentry, nd);
64         
65         d_unalloc(cache_dentry);
66         return rc;
67 }
68 struct inode_operations smfs_sym_iops = {
69         readlink:       smfs_readlink,
70         follow_link:    smfs_follow_link,
71         setxattr:       smfs_setxattr,          /* BKL held */
72         getxattr:       smfs_getxattr,          /* BKL held */
73         listxattr:      smfs_listxattr,         /* BKL held */
74         removexattr:    smfs_removexattr,       /* BKL held */
75 };
76
77 struct file_operations smfs_sym_fops = {
78 };