1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/smfs/symlink.c
5 * Lustre filesystem abstraction routines
7 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
9 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
25 #define DEBUG_SUBSYSTEM S_SM
27 #include <linux/kmod.h>
28 #include <linux/init.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>
39 #include "smfs_internal.h"
41 static int smfs_readlink(struct dentry *dentry, char *buffer, int buflen)
43 struct inode *cache_inode = I2CI(dentry->d_inode);
44 struct dentry *cache_dentry;
51 cache_dentry = pre_smfs_dentry(NULL, cache_inode, 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);
58 post_smfs_dentry(cache_dentry);
62 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
64 struct inode *cache_inode = I2CI(dentry->d_inode);
65 struct dentry *cache_dentry;
72 cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
74 GOTO(exit, rc = -ENOMEM);
76 if (cache_inode->i_op && cache_inode->i_op->follow_link)
77 rc = cache_inode->i_op->follow_link(cache_dentry, nd);
79 post_smfs_dentry(cache_dentry);
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 */
92 struct file_operations smfs_sym_fops = {