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