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 #include <asm/uaccess.h>
20 #include <linux/errno.h>
22 #include <linux/ext2_fs.h>
23 #include <linux/sched.h>
25 #include <linux/stat.h>
27 static int ext2_readlink (struct dentry
*, char *, int);
28 static struct dentry
*ext2_follow_link(struct dentry
*, struct dentry
*, unsigned int);
31 * symlinks can't do much...
33 struct inode_operations ext2_symlink_inode_operations
= {
34 NULL
, /* no file-operations */
44 ext2_readlink
, /* readlink */
45 ext2_follow_link
, /* follow_link */
51 NULL
, /* permission */
56 static struct dentry
* ext2_follow_link(struct dentry
* dentry
,
60 struct inode
*inode
= dentry
->d_inode
;
61 struct buffer_head
* bh
= NULL
;
65 link
= (char *) inode
->u
.ext2_i
.i_data
;
66 if (inode
->i_blocks
) {
67 if (!(bh
= ext2_bread (inode
, 0, 0, &error
))) {
74 base
= lookup_dentry(link
, base
, follow
);
80 static int ext2_readlink (struct dentry
* dentry
, char * buffer
, int buflen
)
82 struct inode
*inode
= dentry
->d_inode
;
83 struct buffer_head
* bh
= NULL
;
87 if (buflen
> inode
->i_sb
->s_blocksize
- 1)
88 buflen
= inode
->i_sb
->s_blocksize
- 1;
90 link
= (char *) inode
->u
.ext2_i
.i_data
;
91 if (inode
->i_blocks
) {
93 bh
= ext2_bread (inode
, 0, 0, &err
);
95 if(err
< 0) /* indicate type of error */
103 while (i
< buflen
&& link
[i
])
105 if (copy_to_user(buffer
, link
, i
))