diff options
Diffstat (limited to 'fs/udf')
-rw-r--r-- | fs/udf/super.c | 2 | ||||
-rw-r--r-- | fs/udf/truncate.c | 64 |
2 files changed, 40 insertions, 26 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index 7de172efa084..fcce1a21a51b 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -1659,7 +1659,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1659 | iput(inode); | 1659 | iput(inode); |
1660 | goto error_out; | 1660 | goto error_out; |
1661 | } | 1661 | } |
1662 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 1662 | sb->s_maxbytes = 1<<30; |
1663 | return 0; | 1663 | return 0; |
1664 | 1664 | ||
1665 | error_out: | 1665 | error_out: |
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index e1b0e8cfecb4..0abd66ce36ea 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c | |||
@@ -239,37 +239,51 @@ void udf_truncate_extents(struct inode * inode) | |||
239 | { | 239 | { |
240 | if (offset) | 240 | if (offset) |
241 | { | 241 | { |
242 | extoffset -= adsize; | 242 | /* |
243 | etype = udf_next_aext(inode, &bloc, &extoffset, &eloc, &elen, &bh, 1); | 243 | * OK, there is not extent covering inode->i_size and |
244 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | 244 | * no extent above inode->i_size => truncate is |
245 | { | 245 | * extending the file by 'offset'. |
246 | extoffset -= adsize; | 246 | */ |
247 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | (elen + offset); | 247 | if ((!bh && extoffset == udf_file_entry_alloc_offset(inode)) || |
248 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 0); | 248 | (bh && extoffset == sizeof(struct allocExtDesc))) { |
249 | /* File has no extents at all! */ | ||
250 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); | ||
251 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | offset; | ||
252 | udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1); | ||
249 | } | 253 | } |
250 | else if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 254 | else { |
251 | { | ||
252 | kernel_lb_addr neloc = { 0, 0 }; | ||
253 | extoffset -= adsize; | 255 | extoffset -= adsize; |
254 | nelen = EXT_NOT_RECORDED_NOT_ALLOCATED | | 256 | etype = udf_next_aext(inode, &bloc, &extoffset, &eloc, &elen, &bh, 1); |
255 | ((elen + offset + inode->i_sb->s_blocksize - 1) & | 257 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
256 | ~(inode->i_sb->s_blocksize - 1)); | 258 | { |
257 | udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 1); | 259 | extoffset -= adsize; |
258 | udf_add_aext(inode, &bloc, &extoffset, eloc, (etype << 30) | elen, &bh, 1); | 260 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | (elen + offset); |
259 | } | 261 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 0); |
260 | else | 262 | } |
261 | { | 263 | else if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
262 | if (elen & (inode->i_sb->s_blocksize - 1)) | ||
263 | { | 264 | { |
265 | kernel_lb_addr neloc = { 0, 0 }; | ||
264 | extoffset -= adsize; | 266 | extoffset -= adsize; |
265 | elen = EXT_RECORDED_ALLOCATED | | 267 | nelen = EXT_NOT_RECORDED_NOT_ALLOCATED | |
266 | ((elen + inode->i_sb->s_blocksize - 1) & | 268 | ((elen + offset + inode->i_sb->s_blocksize - 1) & |
267 | ~(inode->i_sb->s_blocksize - 1)); | 269 | ~(inode->i_sb->s_blocksize - 1)); |
268 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 1); | 270 | udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 1); |
271 | udf_add_aext(inode, &bloc, &extoffset, eloc, (etype << 30) | elen, &bh, 1); | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | if (elen & (inode->i_sb->s_blocksize - 1)) | ||
276 | { | ||
277 | extoffset -= adsize; | ||
278 | elen = EXT_RECORDED_ALLOCATED | | ||
279 | ((elen + inode->i_sb->s_blocksize - 1) & | ||
280 | ~(inode->i_sb->s_blocksize - 1)); | ||
281 | udf_write_aext(inode, bloc, &extoffset, eloc, elen, bh, 1); | ||
282 | } | ||
283 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); | ||
284 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | offset; | ||
285 | udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1); | ||
269 | } | 286 | } |
270 | memset(&eloc, 0x00, sizeof(kernel_lb_addr)); | ||
271 | elen = EXT_NOT_RECORDED_NOT_ALLOCATED | offset; | ||
272 | udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 1); | ||
273 | } | 287 | } |
274 | } | 288 | } |
275 | } | 289 | } |