Whamcloud - gitweb
bonsai test; please ignore
[fs/lustre-release.git] / lustre / smfs / symlink.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/smfs/symlink.c
5  *  Lustre filesystem abstraction routines
6  *
7  *  Copyright (C) 2002, 2003 Cluster File Systems, Inc.
8  *
9  *   This file is part of Lustre, http://www.lustre.org.
10  *
11  *   Lustre is free software; you can redistribute it and/or
12  *   modify it under the terms of version 2 of the GNU General Public
13  *   License as published by the Free Software Foundation.
14  *
15  *   Lustre is distributed in the hope that it will be useful,
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *   GNU General Public License for more details.
19  *
20  *   You should have received a copy of the GNU General Public License
21  *   along with Lustre; if not, write to the Free Software
22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24
25 #define DEBUG_SUBSYSTEM S_SM
26
27 #include <linux/kmod.h>
28 #include <linux/init.h>
29 #include <linux/fs.h>
30 #include <linux/slab.h>
31 #include <linux/string.h>
32 #include <linux/obd_class.h>
33 #include <linux/obd_support.h>
34 #include <linux/lustre_lib.h>
35 #include <linux/lustre_idl.h>
36 #include <linux/lustre_fsfilt.h>
37 #include <linux/lustre_smfs.h>
38
39 #include "smfs_internal.h"
40
41 static int smfs_readlink(struct dentry *dentry, char *buffer, int buflen)
42 {
43         struct inode *cache_inode = I2CI(dentry->d_inode);
44         struct dentry *cache_dentry;
45         int rc = -ENOMEM;
46         struct hook_symlink_msg msg = {
47                 .dentry = dentry,
48         };
49         
50         ENTRY;
51
52         if (!cache_inode || !cache_inode->i_op->readlink)
53                 RETURN(-ENOENT);
54         
55         cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
56         if (!cache_dentry) {
57                 rc = -ENOMEM;
58                 goto exit;
59         }
60
61         SMFS_PRE_HOOK(dentry->d_inode, HOOK_READLINK, &msg);
62         
63         rc = cache_inode->i_op->readlink(cache_dentry, buffer, buflen);
64
65         SMFS_POST_HOOK(dentry->d_inode, HOOK_READLINK, &msg, rc); 
66        
67 exit:
68         post_smfs_dentry(cache_dentry);
69         RETURN(rc);
70 }
71
72 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
73 {
74         struct inode *cache_inode = I2CI(dentry->d_inode);
75         struct dentry *cache_dentry;
76         int rc = -ENOMEM;
77         ENTRY;
78
79         if (!cache_inode || !cache_inode->i_op->follow_link)
80                 RETURN(-ENOENT);
81
82         cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
83         if (cache_dentry)
84                 rc = cache_inode->i_op->follow_link(cache_dentry, nd);
85
86         post_smfs_dentry(cache_dentry);
87         RETURN(rc);
88 }
89
90 struct inode_operations smfs_sym_iops = {
91         .readlink        = smfs_readlink,
92         .follow_link     = smfs_follow_link,
93         .setxattr        = smfs_setxattr,
94         .getxattr        = smfs_getxattr,
95         .listxattr       = smfs_listxattr,
96         .removexattr     = smfs_removexattr,
97         .permission      = smfs_permission,
98 };
99
100 struct file_operations smfs_sym_fops = {
101 };