Whamcloud - gitweb
b=6274
[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         ENTRY;
47
48         if (!cache_inode || !cache_inode->i_op->readlink)
49                 RETURN(-ENOENT);
50
51         cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
52         if (cache_dentry)
53                 rc = cache_inode->i_op->readlink(cache_dentry, buffer, 
54                                                  buflen);
55         
56         post_smfs_dentry(cache_dentry);
57         return rc;
58 }
59
60 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
61 {
62         struct inode *cache_inode = I2CI(dentry->d_inode);
63         struct dentry *cache_dentry;
64         int rc = -ENOMEM;
65         ENTRY;
66
67         if (!cache_inode || !cache_inode->i_op->follow_link)
68                 RETURN(-ENOENT);
69
70         cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
71         if (cache_dentry)
72                 rc = cache_inode->i_op->follow_link(cache_dentry, nd);
73
74         post_smfs_dentry(cache_dentry);
75         RETURN(rc);
76 }
77
78 struct inode_operations smfs_sym_iops = {
79         .readlink        = smfs_readlink,
80         .follow_link     = smfs_follow_link,
81         .setxattr        = smfs_setxattr,          /* BKL held */
82         .getxattr        = smfs_getxattr,          /* BKL held */
83         .listxattr       = smfs_listxattr,         /* BKL held */
84         .removexattr     = smfs_removexattr,       /* BKL held */
85 };
86
87 struct file_operations smfs_sym_fops = {
88 };