2 * linux/fs/ext2/symlink.c
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)
11 * linux/fs/minix/symlink.c
13 * Copyright (C) 1991, 1992 Linus Torvalds
15 * ext2 symlink handling code
18 * Copyright (C) 1999 Seagate Technology Inc. (author: braam@stelias.com)
21 #include <asm/uaccess.h>
23 #include <linux/errno.h>
25 #include <linux/ext2_fs.h>
26 #include <linux/sched.h>
28 #include <linux/stat.h>
30 static int obdfs_readlink (struct dentry *, char *, int);
31 static struct dentry *obdfs_follow_link(struct dentry *, struct dentry *, unsigned int);
33 static struct dentry * ext2_follow_link(struct dentry * dentry,
37 struct inode *inode = dentry->d_inode;
38 struct page *page = NULL;
42 link = (char *) inode->u.ext2_i.i_data;
43 if (inode->i_blocks) {
44 if (!(page = obdfs_getpage(inode, 0, 0, &error))) {
51 base = lookup_dentry(link, base, follow);
57 static int ext2_readlink (struct dentry * dentry, char * buffer, int buflen)
59 struct inode *inode = dentry->d_inode;
60 struct buffer_head * bh = NULL;
64 if (buflen > inode->i_sb->s_blocksize - 1)
65 buflen = inode->i_sb->s_blocksize - 1;
67 link = (char *) inode->u.ext2_i.i_data;
68 if (inode->i_blocks) {
70 bh = ext2_bread (inode, 0, 0, &err);
72 if(err < 0) /* indicate type of error */
80 while (i < buflen && link[i])
82 if (copy_to_user(buffer, link, i))