Whamcloud - gitweb
3ae8a4d80b2c5ffea25f8fd950f23a3411d937d8
[fs/lustre-release.git] / lustre / obdfs / symlink.c
1 /*
2  *  linux/fs/ext2/symlink.c
3  *
4  * This code is issued under the GNU General Public License.
5  * See the file COPYING in this distribution
6  *
7  * Copyright (C) 1992, 1993, 1994, 1995
8  * Remy Card (card@masi.ibp.fr)
9  * Laboratoire MASI - Institut Blaise Pascal
10  * Universite Pierre et Marie Curie (Paris VI)
11  *
12  *  from
13  *
14  *  linux/fs/minix/symlink.c
15  *
16  *  Copyright (C) 1991, 1992  Linus Torvalds
17  *
18  *  ext2 symlink handling code
19  *
20  * Modified for OBDFS.
21  * Re-written Oct 2001.
22  *
23  *  Copyright (C) 2001 Cluster File Systems, Inc. (author: braam@clusterfs.com)
24  */
25
26 #include <linux/fs.h>
27 #include <linux/mm.h>
28 #include <linux/stat.h>
29 #include <linux/locks.h>
30
31 #define DEBUG_SUBSYSTEM S_OBDFS
32
33 #include <linux/obd_support.h> /* for ENTRY and EXIT only */
34 #include <linux/obdfs.h>
35
36 static int obdfs_fast_readlink(struct dentry *dentry, char *buffer, int buflen)
37 {
38         char *s = obdfs_i2info(dentry->d_inode)->oi_inline;
39         return vfs_readlink(dentry, buffer, buflen, s);
40 }
41
42 static int obdfs_fast_follow_link(struct dentry *dentry, struct nameidata *nd)
43 {
44         char *s = obdfs_i2info(dentry->d_inode)->oi_inline;
45         return vfs_follow_link(nd, s); 
46 }
47
48 extern int obdfs_setattr(struct dentry *de, struct iattr *attr);
49 struct inode_operations obdfs_fast_symlink_inode_operations = {
50         readlink:       obdfs_fast_readlink,
51         follow_link:    obdfs_fast_follow_link,
52         setattr:        obdfs_setattr
53 };
54
55 static int obdfs_readlink(struct dentry *dentry, char *buffer, int buflen)
56 {
57         struct page *page = NULL;
58         int res;
59
60         ENTRY;
61         OIDEBUG(dentry->d_inode);
62         page = obdfs_getpage(dentry->d_inode, 0, 0, 0);
63         /* PDEBUG(page, "readlink"); */
64         if (!page) {
65                 EXIT;
66                 return 0;
67         }
68         res = vfs_readlink(dentry, buffer, buflen, (char *)page_address(page));
69         page_cache_release(page);
70         EXIT;
71         return res;
72 } /* obdfs_readlink */
73
74 static int obdfs_follow_link(struct dentry * dentry,
75                              struct nameidata *nd)
76 {
77         struct page *page = NULL;
78         int res;
79
80         ENTRY;
81         OIDEBUG(dentry->d_inode);
82         page = obdfs_getpage(dentry->d_inode, 0, 0, 0);
83         /* PDEBUG(page, "follow_link"); */
84         if (!page) {
85                 dput(nd->dentry);
86                 EXIT;
87                 return -EIO;
88         }
89         res = vfs_follow_link(nd, (char *)page_address(page));
90         page_cache_release(page);
91         EXIT;
92         return res;
93 }
94
95 struct inode_operations obdfs_symlink_inode_operations = {
96         readlink:       obdfs_readlink,
97         follow_link:    obdfs_follow_link,
98         setattr:        obdfs_setattr
99 };