Use sector_t and loff_t for file offsets in UDF filesystem. Otherwise
an overflow may occur for long files. Also make inode_bmap() return offset in
the extent in number of blocks instead of number of bytes - for most callers
this is more convenient.
Signed-off-by: Jan Kara <[EMAIL PROTECTED]>
diff -rupX /home/jack/.kerndiffexclude linux-2.6.20/fs/udf/dir.c
linux-2.6.20-1-udf_bmap_sector_t/fs/udf/dir.c
--- linux-2.6.20/fs/udf/dir.c 2007-02-07 12:03:24.0 +0100
+++ linux-2.6.20-1-udf_bmap_sector_t/fs/udf/dir.c 2007-02-19
17:03:07.0 +0100
@@ -113,7 +113,8 @@ do_udf_readdir(struct inode * dir, struc
loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
struct buffer_head * bh = NULL, * tmp, * bha[16];
kernel_lb_addr bloc, eloc;
- uint32_t extoffset, elen, offset;
+ uint32_t extoffset, elen;
+ sector_t offset;
int i, num;
unsigned int dt_type;
@@ -129,7 +130,6 @@ do_udf_readdir(struct inode * dir, struc
else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
&bloc, &extoffset, &eloc, &elen, &offset, &bh) ==
(EXT_RECORDED_ALLOCATED >> 30))
{
- offset >>= dir->i_sb->s_blocksize_bits;
block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
if ((++offset << dir->i_sb->s_blocksize_bits) < elen)
{
diff -rupX /home/jack/.kerndiffexclude linux-2.6.20/fs/udf/directory.c
linux-2.6.20-1-udf_bmap_sector_t/fs/udf/directory.c
--- linux-2.6.20/fs/udf/directory.c 2007-02-19 15:37:14.0 +0100
+++ linux-2.6.20-1-udf_bmap_sector_t/fs/udf/directory.c 2007-02-21
17:58:54.0 +0100
@@ -77,7 +77,7 @@ udf_fileident_read(struct inode *dir, lo
struct fileIdentDesc *cfi,
kernel_lb_addr *bloc, uint32_t *extoffset,
kernel_lb_addr *eloc, uint32_t *elen,
- uint32_t *offset, struct buffer_head **bh)
+ sector_t *offset, struct buffer_head **bh)
{
struct fileIdentDesc *fi;
int i, num, block;
diff -rupX /home/jack/.kerndiffexclude linux-2.6.20/fs/udf/inode.c
linux-2.6.20-1-udf_bmap_sector_t/fs/udf/inode.c
--- linux-2.6.20/fs/udf/inode.c 2007-02-19 14:13:12.0 +0100
+++ linux-2.6.20-1-udf_bmap_sector_t/fs/udf/inode.c 2007-02-19
17:04:27.0 +0100
@@ -49,7 +49,7 @@ MODULE_LICENSE("GPL");
static mode_t udf_convert_permissions(struct fileEntry *);
static int udf_update_inode(struct inode *, int);
static void udf_fill_inode(struct inode *, struct buffer_head *);
-static struct buffer_head *inode_getblk(struct inode *, long, int *,
+static struct buffer_head *inode_getblk(struct inode *, sector_t, int *,
long *, int *);
static int8_t udf_insert_aext(struct inode *, kernel_lb_addr, int,
kernel_lb_addr, uint32_t, struct buffer_head *);
@@ -354,7 +354,7 @@ udf_getblk(struct inode *inode, long blo
return NULL;
}
-static struct buffer_head * inode_getblk(struct inode * inode, long block,
+static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
int *err, long *phys, int *new)
{
struct buffer_head *pbh = NULL, *cbh = NULL, *nbh = NULL, *result =
NULL;
@@ -364,14 +364,15 @@ static struct buffer_head * inode_getblk
uint32_t elen = 0;
kernel_lb_addr eloc, pbloc, cbloc, nbloc;
int c = 1;
- uint64_t lbcount = 0, b_off = 0;
- uint32_t newblocknum, newblock, offset = 0;
+ loff_t lbcount = 0, b_off = 0;
+ uint32_t newblocknum, newblock;
+ sector_t offset = 0;
int8_t etype;
int goal = 0, pgoal = UDF_I_LOCATION(inode).logicalBlockNum;
char lastblock = 0;
pextoffset = cextoffset = nextoffset =
udf_file_entry_alloc_offset(inode);
- b_off = (uint64_t)block << inode->i_sb->s_blocksize_bits;
+ b_off = (loff_t)block << inode->i_sb->s_blocksize_bits;
pbloc = cbloc = nbloc = UDF_I_LOCATION(inode);
/* find the extent which contains the block we are looking for.
@@ -1948,10 +1949,10 @@ int8_t udf_delete_aext(struct inode *ino
return (elen >> 30);
}
-int8_t inode_bmap(struct inode *inode, int block, kernel_lb_addr *bloc,
uint32_t *extoffset,
- kernel_lb_addr *eloc, uint32_t *elen, uint32_t *offset, struct
buffer_head **bh)
+int8_t inode_bmap(struct inode *inode, sector_t block, kernel_lb_addr *bloc,
uint32_t *extoffset,
+ kernel_lb_addr *eloc, uint32_t *elen, sector_t *offset, struct
buffer_head **bh)
{
- uint64_t lbcount = 0, bcount = (uint64_t)block <<
inode->i_sb->s_blocksize_bits;
+ loff_t lbcount = 0, bcount = (loff_t)block <<
inode->i_sb->s_blocksize_bits;
int8_t etype;
if (block < 0)
@@ -1968,29 +1969,30 @@ int8_t inode_bmap(struct inode *inode, i
{
if ((etype = udf_next_aext(inode, bloc, extoffset, eloc, elen,
bh, 1)) == -1)
{
- *offset = bcount - lbcount;
+