Whamcloud - gitweb
New files for vanilla 2.6.6 linux kernel. also a new ldiskfs for 2.6.6
[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  *  Copyright (C) 2004 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #define DEBUG_SUBSYSTEM S_SM
24
25 #include <linux/kmod.h>
26 #include <linux/init.h>
27 #include <linux/fs.h>
28 #include <linux/slab.h>
29 #include <linux/string.h>
30 #include <linux/obd_class.h>
31 #include <linux/obd_support.h>
32 #include <linux/lustre_lib.h>
33 #include <linux/lustre_idl.h>
34 #include <linux/lustre_smfs.h>
35
36 #include "smfs_internal.h"
37
38 static int smfs_readlink(struct dentry *dentry, char *buffer, int buflen)
39 {
40         struct inode *cache_inode = I2CI(dentry->d_inode);
41         struct dentry *cache_dentry;
42         int rc = 0;
43         ENTRY;
44
45         if (!cache_inode)
46                 RETURN(-ENOENT);
47
48         cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
49         if (!cache_dentry)
50                 GOTO(exit, rc = -ENOMEM);
51         if (cache_inode->i_op && cache_inode->i_op->readlink)
52                 rc = cache_inode->i_op->readlink(cache_dentry, buffer, buflen);
53         GOTO(exit, rc);
54 exit:
55         post_smfs_dentry(cache_dentry);
56         return rc;
57 }
58
59 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60 {
61         struct inode *cache_inode = I2CI(dentry->d_inode);
62         struct dentry *cache_dentry;
63         int rc = 0;
64         ENTRY;
65
66         if (!cache_inode)
67                 RETURN(-ENOENT);
68
69         cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
70         if (!cache_dentry)
71                 GOTO(exit, rc = -ENOMEM);
72
73         if (cache_inode->i_op && cache_inode->i_op->follow_link)
74                 rc = cache_inode->i_op->follow_link(cache_dentry, nd);
75 exit:
76         post_smfs_dentry(cache_dentry);
77         return rc;
78 }
79
80 struct inode_operations smfs_sym_iops = {
81         readlink:        smfs_readlink,
82         follow_link:        smfs_follow_link,
83         setxattr:       smfs_setxattr,          /* BKL held */
84         getxattr:       smfs_getxattr,          /* BKL held */
85         listxattr:      smfs_listxattr,         /* BKL held */
86         removexattr:    smfs_removexattr,       /* BKL held */
87 };
88
89 struct file_operations smfs_sym_fops = {
90 };