Whamcloud - gitweb
Small fixes to get lustre_light mount working over the request handling
[fs/lustre-release.git] / lustre / llite / 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  *  Copyright (C) 1999 Seagate Technology Inc. (author: braam@stelias.com)
22  */
23
24 #include <linux/fs.h>
25 #include <linux/mm.h>
26 #include <linux/stat.h>
27 #include <linux/locks.h>
28 #include <linux/obd_support.h> /* for ENTRY and EXIT only */
29 #include <linux/lustre_light.h>
30
31 static int ll_fast_readlink(struct dentry *dentry, char *buffer, int buflen)
32 {
33         char *s = ll_i2info(dentry->d_inode)->lli_inline;
34         return vfs_readlink(dentry, buffer, buflen, s);
35 }
36
37 static int ll_fast_follow_link(struct dentry *dentry, struct nameidata *nd)
38 {
39         char *s = ll_i2info(dentry->d_inode)->lli_inline;
40         return vfs_follow_link(nd, s); 
41 }
42
43 extern int ll_setattr(struct dentry *de, struct iattr *attr);
44 struct inode_operations ll_fast_symlink_inode_operations = {
45         readlink:       ll_fast_readlink,
46         follow_link:    ll_fast_follow_link,
47         setattr:        ll_setattr
48 };
49
50 static int ll_readlink(struct dentry *dentry, char *buffer, int buflen)
51 {
52         struct page *page = NULL;
53         int res;
54
55         ENTRY;
56         OIDEBUG(dentry->d_inode);
57         page = ll_getpage(dentry->d_inode, 0, 0, 0);
58         /* PDEBUG(page, "readlink"); */
59         if (!page) {
60                 EXIT;
61                 return 0;
62         }
63         res = vfs_readlink(dentry, buffer, buflen, (char *)page_address(page));
64         page_cache_release(page);
65         EXIT;
66         return res;
67 } /* ll_readlink */
68
69 static int ll_follow_link(struct dentry * dentry,
70                              struct nameidata *nd)
71 {
72         struct page *page = NULL;
73         int res;
74
75         ENTRY;
76         OIDEBUG(dentry->d_inode);
77         page = ll_getpage(dentry->d_inode, 0, 0, 0);
78         /* PDEBUG(page, "follow_link"); */
79         if (!page) {
80                 dput(nd->dentry);
81                 EXIT;
82                 return -EIO;
83         }
84         res = vfs_follow_link(nd, (char *)page_address(page));
85         page_cache_release(page);
86         EXIT;
87         return res;
88 }
89
90 struct inode_operations ll_symlink_inode_operations = {
91         readlink:       ll_readlink,
92         follow_link:    ll_follow_link,
93         setattr:        ll_setattr
94 };