patch-2.1.45 linux/fs/sysv/symlink.c

Next file: linux/fs/sysv/truncate.c
Previous file: linux/fs/sysv/namei.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.44/linux/fs/sysv/symlink.c linux/fs/sysv/symlink.c
@@ -21,6 +21,7 @@
 #include <asm/uaccess.h>
 
 static int sysv_readlink(struct inode *, char *, int);
+static struct dentry *sysv_follow_link(struct inode *, struct dentry *);
 
 /*
  * symlinks can't do much...
@@ -37,6 +38,7 @@
 	NULL,			/* mknod */
 	NULL,			/* rename */
 	sysv_readlink,		/* readlink */
+	sysv_follow_link,	/* follow_link */
 	NULL,			/* readpage */
 	NULL,			/* writepage */
 	NULL,			/* bmap */
@@ -44,6 +46,21 @@
 	NULL			/* permission */
 };
 
+static struct dentry *sysv_follow_link(struct inode * inode, struct dentry * base)
+{
+	struct buffer_head * bh;
+
+	bh = sysv_file_bread(inode, 0, 0);
+	if (!bh) {
+		dput(base);
+		return ERR_PTR(-EIO);
+	}
+	UPDATE_ATIME(inode);
+	base = lookup_dentry(bh->b_data, base, 1);
+	brelse(bh);
+	return base;
+}
+
 static int sysv_readlink(struct inode * inode, char * buffer, int buflen)
 {
 	struct buffer_head * bh;
@@ -54,7 +71,6 @@
 	if (buflen > inode->i_sb->sv_block_size_1)
 		buflen = inode->i_sb->sv_block_size_1;
 	bh = sysv_file_bread(inode, 0, 0);
-	iput(inode);
 	if (!bh)
 		return 0;
 	bh_data = bh->b_data;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov