aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/inode.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2007-05-08 03:35:13 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:21 -0400
commit60448b1d6db4e82946ff9a2ac88df341f5fa87a2 (patch)
treed0623c3dc26be55aa17319e1e9e8d0fbeea98ac4 /fs/udf/inode.c
parent277866a0e3a4f97e859f7a621f5b4f5359c9526c (diff)
udf: use sector_t and loff_t for file offsets
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 <jack@suse.cz> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf/inode.c')
-rw-r--r--fs/udf/inode.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index ae21a0e59e95..6b094250d805 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -49,7 +49,7 @@ MODULE_LICENSE("GPL");
49static mode_t udf_convert_permissions(struct fileEntry *); 49static mode_t udf_convert_permissions(struct fileEntry *);
50static int udf_update_inode(struct inode *, int); 50static int udf_update_inode(struct inode *, int);
51static void udf_fill_inode(struct inode *, struct buffer_head *); 51static void udf_fill_inode(struct inode *, struct buffer_head *);
52static struct buffer_head *inode_getblk(struct inode *, long, int *, 52static struct buffer_head *inode_getblk(struct inode *, sector_t, int *,
53 long *, int *); 53 long *, int *);
54static int8_t udf_insert_aext(struct inode *, kernel_lb_addr, int, 54static int8_t udf_insert_aext(struct inode *, kernel_lb_addr, int,
55 kernel_lb_addr, uint32_t, struct buffer_head *); 55 kernel_lb_addr, uint32_t, struct buffer_head *);
@@ -354,7 +354,7 @@ udf_getblk(struct inode *inode, long block, int create, int *err)
354 return NULL; 354 return NULL;
355} 355}
356 356
357static struct buffer_head * inode_getblk(struct inode * inode, long block, 357static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
358 int *err, long *phys, int *new) 358 int *err, long *phys, int *new)
359{ 359{
360 struct buffer_head *pbh = NULL, *cbh = NULL, *nbh = NULL, *result = NULL; 360 struct buffer_head *pbh = NULL, *cbh = NULL, *nbh = NULL, *result = NULL;
@@ -364,14 +364,15 @@ static struct buffer_head * inode_getblk(struct inode * inode, long block,
364 uint32_t elen = 0; 364 uint32_t elen = 0;
365 kernel_lb_addr eloc, pbloc, cbloc, nbloc; 365 kernel_lb_addr eloc, pbloc, cbloc, nbloc;
366 int c = 1; 366 int c = 1;
367 uint64_t lbcount = 0, b_off = 0; 367 loff_t lbcount = 0, b_off = 0;
368 uint32_t newblocknum, newblock, offset = 0; 368 uint32_t newblocknum, newblock;
369 sector_t offset = 0;
369 int8_t etype; 370 int8_t etype;
370 int goal = 0, pgoal = UDF_I_LOCATION(inode).logicalBlockNum; 371 int goal = 0, pgoal = UDF_I_LOCATION(inode).logicalBlockNum;
371 char lastblock = 0; 372 char lastblock = 0;
372 373
373 pextoffset = cextoffset = nextoffset = udf_file_entry_alloc_offset(inode); 374 pextoffset = cextoffset = nextoffset = udf_file_entry_alloc_offset(inode);
374 b_off = (uint64_t)block << inode->i_sb->s_blocksize_bits; 375 b_off = (loff_t)block << inode->i_sb->s_blocksize_bits;
375 pbloc = cbloc = nbloc = UDF_I_LOCATION(inode); 376 pbloc = cbloc = nbloc = UDF_I_LOCATION(inode);
376 377
377 /* find the extent which contains the block we are looking for. 378 /* find the extent which contains the block we are looking for.
@@ -1948,10 +1949,10 @@ int8_t udf_delete_aext(struct inode *inode, kernel_lb_addr nbloc, int nextoffset
1948 return (elen >> 30); 1949 return (elen >> 30);
1949} 1950}
1950 1951
1951int8_t inode_bmap(struct inode *inode, int block, kernel_lb_addr *bloc, uint32_t *extoffset, 1952int8_t inode_bmap(struct inode *inode, sector_t block, kernel_lb_addr *bloc, uint32_t *extoffset,
1952 kernel_lb_addr *eloc, uint32_t *elen, uint32_t *offset, struct buffer_head **bh) 1953 kernel_lb_addr *eloc, uint32_t *elen, sector_t *offset, struct buffer_head **bh)
1953{ 1954{
1954 uint64_t lbcount = 0, bcount = (uint64_t)block << inode->i_sb->s_blocksize_bits; 1955 loff_t lbcount = 0, bcount = (loff_t)block << inode->i_sb->s_blocksize_bits;
1955 int8_t etype; 1956 int8_t etype;
1956 1957
1957 if (block < 0) 1958 if (block < 0)
@@ -1968,29 +1969,30 @@ int8_t inode_bmap(struct inode *inode, int block, kernel_lb_addr *bloc, uint32_t
1968 { 1969 {
1969 if ((etype = udf_next_aext(inode, bloc, extoffset, eloc, elen, bh, 1)) == -1) 1970 if ((etype = udf_next_aext(inode, bloc, extoffset, eloc, elen, bh, 1)) == -1)
1970 { 1971 {
1971 *offset = bcount - lbcount; 1972 *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits;
1972 UDF_I_LENEXTENTS(inode) = lbcount; 1973 UDF_I_LENEXTENTS(inode) = lbcount;
1973 return -1; 1974 return -1;
1974 } 1975 }
1975 lbcount += *elen; 1976 lbcount += *elen;
1976 } while (lbcount <= bcount); 1977 } while (lbcount <= bcount);
1977 1978
1978 *offset = bcount + *elen - lbcount; 1979 *offset = (bcount + *elen - lbcount) >> inode->i_sb->s_blocksize_bits;
1979 1980
1980 return etype; 1981 return etype;
1981} 1982}
1982 1983
1983long udf_block_map(struct inode *inode, long block) 1984long udf_block_map(struct inode *inode, sector_t block)
1984{ 1985{
1985 kernel_lb_addr eloc, bloc; 1986 kernel_lb_addr eloc, bloc;
1986 uint32_t offset, extoffset, elen; 1987 uint32_t extoffset, elen;
1988 sector_t offset;
1987 struct buffer_head *bh = NULL; 1989 struct buffer_head *bh = NULL;
1988 int ret; 1990 int ret;
1989 1991
1990 lock_kernel(); 1992 lock_kernel();
1991 1993
1992 if (inode_bmap(inode, block, &bloc, &extoffset, &eloc, &elen, &offset, &bh) == (EXT_RECORDED_ALLOCATED >> 30)) 1994 if (inode_bmap(inode, block, &bloc, &extoffset, &eloc, &elen, &offset, &bh) == (EXT_RECORDED_ALLOCATED >> 30))
1993 ret = udf_get_lb_pblock(inode->i_sb, eloc, offset >> inode->i_sb->s_blocksize_bits); 1995 ret = udf_get_lb_pblock(inode->i_sb, eloc, offset);
1994 else 1996 else
1995 ret = 0; 1997 ret = 0;
1996 1998