Whamcloud - gitweb
Convert to Automake.
[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  *  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/obdfs.h>
30
31 static int obdfs_fast_readlink(struct dentry *dentry, char *buffer, int buflen)
32 {
33         char *s = obdfs_i2info(dentry->d_inode)->oi_inline;
34         return vfs_readlink(dentry, buffer, buflen, s);
35 }
36
37 static int obdfs_fast_follow_link(struct dentry *dentry, struct nameidata *nd)
38 {
39         char *s = obdfs_i2info(dentry->d_inode)->oi_inline;
40         return vfs_follow_link(nd, s); 
41 }
42
43 struct inode_operations obdfs_fast_symlink_inode_operations = {
44         readlink:       obdfs_fast_readlink,
45         follow_link:    obdfs_fast_follow_link,
46 };
47
48 static int obdfs_readlink(struct dentry *dentry, char *buffer, int buflen)
49 {
50         struct page *page = NULL;
51         int res;
52
53         ENTRY;
54         OIDEBUG(dentry->d_inode);
55         page = obdfs_getpage(dentry->d_inode, 0, 0, 0);
56         /* PDEBUG(page, "readlink"); */
57         if (!page) {
58                 EXIT;
59                 return 0;
60         }
61         res = vfs_readlink(dentry, buffer, buflen, (char *)page_address(page));
62         page_cache_release(page);
63         EXIT;
64         return res;
65 } /* obdfs_readlink */
66
67 static int obdfs_follow_link(struct dentry * dentry,
68                              struct nameidata *nd)
69 {
70         struct page *page = NULL;
71         int res;
72
73         ENTRY;
74         OIDEBUG(dentry->d_inode);
75         page = obdfs_getpage(dentry->d_inode, 0, 0, 0);
76         /* PDEBUG(page, "follow_link"); */
77         if (!page) {
78                 dput(nd->dentry);
79                 EXIT;
80                 return -EIO;
81         }
82         res = vfs_follow_link(nd, (char *)page_address(page));
83         page_cache_release(page);
84         EXIT;
85         return res;
86 }
87
88 struct inode_operations obdfs_symlink_inode_operations = {
89         readlink:       obdfs_readlink,
90         follow_link:    obdfs_follow_link,
91 };