Skip to content

Commit 0d89fda

Browse files
cmaiolinoAl Viro
authored andcommitted
fibmap: Use bmap instead of ->bmap method in ioctl_fibmap
Now we have the possibility of proper error return in bmap, use bmap() function in ioctl_fibmap() instead of calling ->bmap method directly. Signed-off-by: Carlos Maiolino <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 569d205 commit 0d89fda

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

fs/ioctl.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,29 @@ EXPORT_SYMBOL(vfs_ioctl);
5454

5555
static int ioctl_fibmap(struct file *filp, int __user *p)
5656
{
57-
struct address_space *mapping = filp->f_mapping;
58-
int res, block;
57+
struct inode *inode = file_inode(filp);
58+
int error, ur_block;
59+
sector_t block;
5960

60-
/* do we support this mess? */
61-
if (!mapping->a_ops->bmap)
62-
return -EINVAL;
6361
if (!capable(CAP_SYS_RAWIO))
6462
return -EPERM;
65-
res = get_user(block, p);
66-
if (res)
67-
return res;
68-
res = mapping->a_ops->bmap(mapping, block);
69-
return put_user(res, p);
63+
64+
error = get_user(ur_block, p);
65+
if (error)
66+
return error;
67+
68+
block = ur_block;
69+
error = bmap(inode, &block);
70+
71+
if (error)
72+
ur_block = 0;
73+
else
74+
ur_block = block;
75+
76+
if (put_user(ur_block, p))
77+
error = -EFAULT;
78+
79+
return error;
7080
}
7181

7282
/**

0 commit comments

Comments
 (0)