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