patch-2.1.45 linux/fs/ioctl.c

Next file: linux/fs/isofs/dir.c
Previous file: linux/fs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.44/linux/fs/ioctl.c linux/fs/ioctl.c
@@ -20,28 +20,27 @@
 {
 	int error;
 	int block;
+	struct inode * inode = filp->f_dentry->d_inode;
 
 	switch (cmd) {
 		case FIBMAP:
-			if (filp->f_inode->i_op == NULL)
+			if (inode->i_op == NULL)
 				return -EBADF;
-		    	if (filp->f_inode->i_op->bmap == NULL)
+		    	if (inode->i_op->bmap == NULL)
 				return -EINVAL;
 			if ((error = get_user(block, (int *) arg)) != 0)
 				return error;
-			block = filp->f_inode->i_op->bmap(filp->f_inode,block);
+			block = inode->i_op->bmap(inode,block);
 			return put_user(block, (int *) arg);
 		case FIGETBSZ:
-			if (filp->f_inode->i_sb == NULL)
+			if (inode->i_sb == NULL)
 				return -EBADF;
-			return put_user(filp->f_inode->i_sb->s_blocksize,
-					(int *) arg);
+			return put_user(inode->i_sb->s_blocksize, (int *) arg);
 		case FIONREAD:
-			return put_user(filp->f_inode->i_size - filp->f_pos,
-					(int *) arg);
+			return put_user(inode->i_size - filp->f_pos, (int *) arg);
 	}
 	if (filp->f_op && filp->f_op->ioctl)
-		return filp->f_op->ioctl(filp->f_inode, filp, cmd, arg);
+		return filp->f_op->ioctl(inode, filp, cmd, arg);
 	return -ENOTTY;
 }
 
@@ -91,10 +90,10 @@
 			break;
 
 		default:
-			if (filp->f_inode && S_ISREG(filp->f_inode->i_mode))
+			if (filp->f_dentry && filp->f_dentry->d_inode && S_ISREG(filp->f_dentry->d_inode->i_mode))
 				error = file_ioctl(filp, cmd, arg);
 			else if (filp->f_op && filp->f_op->ioctl)
-				error = filp->f_op->ioctl(filp->f_inode, filp, cmd, arg);
+				error = filp->f_op->ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
 			else
 				error = -ENOTTY;
 	}

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