diff options
author | Jan Kara <jack@suse.cz> | 2007-05-08 03:35:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:21 -0400 |
commit | 60448b1d6db4e82946ff9a2ac88df341f5fa87a2 (patch) | |
tree | d0623c3dc26be55aa17319e1e9e8d0fbeea98ac4 /fs/udf/truncate.c | |
parent | 277866a0e3a4f97e859f7a621f5b4f5359c9526c (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/truncate.c')
-rw-r--r-- | fs/udf/truncate.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index 0abd66ce36e..ebd0f37f8b1 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c | |||
@@ -125,9 +125,10 @@ void udf_discard_prealloc(struct inode * inode) | |||
125 | void udf_truncate_extents(struct inode * inode) | 125 | void udf_truncate_extents(struct inode * inode) |
126 | { | 126 | { |
127 | kernel_lb_addr bloc, eloc, neloc = { 0, 0 }; | 127 | kernel_lb_addr bloc, eloc, neloc = { 0, 0 }; |
128 | uint32_t extoffset, elen, offset, nelen = 0, lelen = 0, lenalloc; | 128 | uint32_t extoffset, elen, nelen = 0, lelen = 0, lenalloc; |
129 | int8_t etype; | 129 | int8_t etype; |
130 | int first_block = inode->i_size >> inode->i_sb->s_blocksize_bits; | 130 | sector_t first_block = inode->i_size >> inode->i_sb->s_blocksize_bits, offset; |
131 | loff_t byte_offset; | ||
131 | struct buffer_head *bh = NULL; | 132 | struct buffer_head *bh = NULL; |
132 | int adsize; | 133 | int adsize; |
133 | 134 | ||
@@ -139,14 +140,14 @@ void udf_truncate_extents(struct inode * inode) | |||
139 | adsize = 0; | 140 | adsize = 0; |
140 | 141 | ||
141 | etype = inode_bmap(inode, first_block, &bloc, &extoffset, &eloc, &elen, &offset, &bh); | 142 | etype = inode_bmap(inode, first_block, &bloc, &extoffset, &eloc, &elen, &offset, &bh); |
142 | offset += (inode->i_size & (inode->i_sb->s_blocksize - 1)); | 143 | byte_offset = (offset << inode->i_sb->s_blocksize_bits) + (inode->i_size & (inode->i_sb->s_blocksize-1)); |
143 | if (etype != -1) | 144 | if (etype != -1) |
144 | { | 145 | { |
145 | extoffset -= adsize; | 146 | extoffset -= adsize; |
146 | extent_trunc(inode, bloc, extoffset, eloc, etype, elen, bh, offset); | 147 | extent_trunc(inode, bloc, extoffset, eloc, etype, elen, bh, byte_offset); |
147 | extoffset += adsize; | 148 | extoffset += adsize; |
148 | 149 | ||
149 | if (offset) | 150 | if (byte_offset) |
150 | lenalloc = extoffset; | 151 | lenalloc = extoffset; |
151 | else | 152 | else |
152 | lenalloc = extoffset - adsize; | 153 | lenalloc = extoffset - adsize; |
@@ -237,7 +238,7 @@ void udf_truncate_extents(struct inode * inode) | |||
237 | } | 238 | } |
238 | else if (inode->i_size) | 239 | else if (inode->i_size) |
239 | { | 240 | { |
240 | if (offset) | 241 | if (byte_offset) |
241 | { | 242 | { |
242 | /* | 243 | /* |
243 | * OK, there is not extent covering inode->i_size and | 244 | * OK, there is not extent covering inode->i_size and |
@@ -248,7 +249,7 @@ void udf_truncate_extents(struct inode * inode) | |||
248 | (bh && extoffset == sizeof(struct allocExtDesc))) { | 249 | (bh && extoffset == sizeof(struct allocExtDesc))) { |
249 | /* File has no extents at all! */ | 250 | /* File has no extents at all! */ |
250 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); | 251 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); |
251 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | offset; | 252 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | byte_offset; |
252 | udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1); | 253 | udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1); |
253 | } | 254 | } |
254 | else { | 255 | else { |
@@ -257,7 +258,7 @@ void udf_truncate_extents(struct inode * inode) | |||
257 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | 258 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
258 | { | 259 | { |
259 | extoffset -= adsize; | 260 | extoffset -= adsize; |
260 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | (elen + offset); | 261 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | (elen + byte_offset); |
261 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 0); | 262 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 0); |
262 | } | 263 | } |
263 | else if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 264 | else if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
@@ -265,7 +266,7 @@ void udf_truncate_extents(struct inode * inode) | |||
265 | kernel_lb_addr neloc = { 0, 0 }; | 266 | kernel_lb_addr neloc = { 0, 0 }; |
266 | extoffset -= adsize; | 267 | extoffset -= adsize; |
267 | nelen = EXT_NOT_RECORDED_NOT_ALLOCATED | | 268 | nelen = EXT_NOT_RECORDED_NOT_ALLOCATED | |
268 | ((elen + offset + inode->i_sb->s_blocksize - 1) & | 269 | ((elen + byte_offset + inode->i_sb->s_blocksize - 1) & |
269 | ~(inode->i_sb->s_blocksize - 1)); | 270 | ~(inode->i_sb->s_blocksize - 1)); |
270 | udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 1); | 271 | udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 1); |
271 | udf_add_aext(inode, &bloc, &extoffset, eloc, (etype << 30) | elen, &bh, 1); | 272 | udf_add_aext(inode, &bloc, &extoffset, eloc, (etype << 30) | elen, &bh, 1); |
@@ -281,7 +282,7 @@ void udf_truncate_extents(struct inode * inode) | |||
281 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 1); | 282 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 1); |
282 | } | 283 | } |
283 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); | 284 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); |
284 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | offset; | 285 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | byte_offset; |
285 | udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1); | 286 | udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1); |
286 | } | 287 | } |
287 | } | 288 | } |