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;
46 struct hook_symlink_msg msg = {
52 if (!cache_inode || !cache_inode->i_op->readlink)
55 cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
61 SMFS_PRE_HOOK(dentry->d_inode, HOOK_READLINK, &msg);
63 rc = cache_inode->i_op->readlink(cache_dentry, buffer, buflen);
65 SMFS_POST_HOOK(dentry->d_inode, HOOK_READLINK, &msg, rc);
68 post_smfs_dentry(cache_dentry);
72 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
74 struct inode *cache_inode = I2CI(dentry->d_inode);
75 struct dentry *cache_dentry;
79 if (!cache_inode || !cache_inode->i_op->follow_link)
82 cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
84 rc = cache_inode->i_op->follow_link(cache_dentry, nd);
86 post_smfs_dentry(cache_dentry);
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,
100 struct file_operations smfs_sym_fops = {