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