patch-2.1.43 linux/fs/ext2/symlink.c

Next file: linux/fs/fat/dir.c
Previous file: linux/fs/ext2/super.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.42/linux/fs/ext2/symlink.c linux/fs/ext2/symlink.c
@@ -25,8 +25,6 @@
 #include <linux/stat.h>
 
 static int ext2_readlink (struct inode *, char *, int);
-static int ext2_follow_link (struct inode *, struct inode *, int, int,
-			       struct inode **);
 
 /*
  * symlinks can't do much...
@@ -43,7 +41,6 @@
 	NULL,			/* mknod */
 	NULL,			/* rename */
 	ext2_readlink,		/* readlink */
-	ext2_follow_link,	/* follow_link */
 	NULL,			/* readpage */
 	NULL,			/* writepage */
 	NULL,			/* bmap */
@@ -52,70 +49,20 @@
 	NULL			/* smap */
 };
 
-static int ext2_follow_link(struct inode * dir, struct inode * inode,
-			    int flag, int mode, struct inode ** res_inode)
-{
-	int error;
-	struct buffer_head * bh = NULL;
-	char * link;
-
-	*res_inode = NULL;
-	if (!dir) {
-		dir = current->fs->root;
-		dir->i_count++;
-	}
-	if (!inode) {
-		iput (dir);
-		return -ENOENT;
-	}
-	if (!S_ISLNK(inode->i_mode)) {
-		iput (dir);
-		*res_inode = inode;
-		return 0;
-	}
-	if (current->link_count > 5) {
-		iput (dir);
-		iput (inode);
-		return -ELOOP;
-	}
-	if (inode->i_blocks) {
-		if (!(bh = ext2_bread (inode, 0, 0, &error))) {
-			iput (dir);
-			iput (inode);
-			return -EIO;
-		}
-		link = bh->b_data;
-	} else
-		link = (char *) inode->u.ext2_i.i_data;
-	if (DO_UPDATE_ATIME(inode)) {
-		inode->i_atime = CURRENT_TIME;
-		inode->i_dirt = 1;
-	}
-	current->link_count++;
-	error = open_namei (link, flag, mode, res_inode, dir);
-	current->link_count--;
-	iput (inode);
-	if (bh)
-		brelse (bh);
-	return error;
-}
-
 static int ext2_readlink (struct inode * inode, char * buffer, int buflen)
 {
 	struct buffer_head * bh = NULL;
 	char * link;
 	int i, err;
 
-	if (!S_ISLNK(inode->i_mode)) {
-		iput (inode);
-		return -EINVAL;
-	}
 	if (buflen > inode->i_sb->s_blocksize - 1)
 		buflen = inode->i_sb->s_blocksize - 1;
 	if (inode->i_blocks) {
 		bh = ext2_bread (inode, 0, 0, &err);
 		if (!bh) {
 			iput (inode);
+			if(err < 0) /* indicate type of error */
+				return err;
 			return 0;
 		}
 		link = bh->b_data;

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