diff options
Diffstat (limited to 'fs/fat/file.c')
| -rw-r--r-- | fs/fat/file.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/fs/fat/file.c b/fs/fat/file.c index 990dfae022e5..7257752b6d5d 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
| @@ -364,18 +364,6 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode) | |||
| 364 | return 0; | 364 | return 0; |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | int fat_setsize(struct inode *inode, loff_t offset) | ||
| 368 | { | ||
| 369 | int error; | ||
| 370 | |||
| 371 | error = simple_setsize(inode, offset); | ||
| 372 | if (error) | ||
| 373 | return error; | ||
| 374 | fat_truncate_blocks(inode, offset); | ||
| 375 | |||
| 376 | return error; | ||
| 377 | } | ||
| 378 | |||
| 379 | #define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET) | 367 | #define TIMES_SET_FLAGS (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET) |
| 380 | /* valid file mode bits */ | 368 | /* valid file mode bits */ |
| 381 | #define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO) | 369 | #define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO) |
| @@ -387,21 +375,6 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 387 | unsigned int ia_valid; | 375 | unsigned int ia_valid; |
| 388 | int error; | 376 | int error; |
| 389 | 377 | ||
| 390 | /* | ||
| 391 | * Expand the file. Since inode_setattr() updates ->i_size | ||
| 392 | * before calling the ->truncate(), but FAT needs to fill the | ||
| 393 | * hole before it. XXX: this is no longer true with new truncate | ||
| 394 | * sequence. | ||
| 395 | */ | ||
| 396 | if (attr->ia_valid & ATTR_SIZE) { | ||
| 397 | if (attr->ia_size > inode->i_size) { | ||
| 398 | error = fat_cont_expand(inode, attr->ia_size); | ||
| 399 | if (error || attr->ia_valid == ATTR_SIZE) | ||
| 400 | goto out; | ||
| 401 | attr->ia_valid &= ~ATTR_SIZE; | ||
| 402 | } | ||
| 403 | } | ||
| 404 | |||
| 405 | /* Check for setting the inode time. */ | 378 | /* Check for setting the inode time. */ |
| 406 | ia_valid = attr->ia_valid; | 379 | ia_valid = attr->ia_valid; |
| 407 | if (ia_valid & TIMES_SET_FLAGS) { | 380 | if (ia_valid & TIMES_SET_FLAGS) { |
| @@ -417,6 +390,21 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 417 | goto out; | 390 | goto out; |
| 418 | } | 391 | } |
| 419 | 392 | ||
| 393 | /* | ||
| 394 | * Expand the file. Since inode_setattr() updates ->i_size | ||
| 395 | * before calling the ->truncate(), but FAT needs to fill the | ||
| 396 | * hole before it. XXX: this is no longer true with new truncate | ||
| 397 | * sequence. | ||
| 398 | */ | ||
| 399 | if (attr->ia_valid & ATTR_SIZE) { | ||
| 400 | if (attr->ia_size > inode->i_size) { | ||
| 401 | error = fat_cont_expand(inode, attr->ia_size); | ||
| 402 | if (error || attr->ia_valid == ATTR_SIZE) | ||
| 403 | goto out; | ||
| 404 | attr->ia_valid &= ~ATTR_SIZE; | ||
| 405 | } | ||
| 406 | } | ||
| 407 | |||
| 420 | if (((attr->ia_valid & ATTR_UID) && | 408 | if (((attr->ia_valid & ATTR_UID) && |
| 421 | (attr->ia_uid != sbi->options.fs_uid)) || | 409 | (attr->ia_uid != sbi->options.fs_uid)) || |
| 422 | ((attr->ia_valid & ATTR_GID) && | 410 | ((attr->ia_valid & ATTR_GID) && |
| @@ -441,12 +429,11 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 441 | } | 429 | } |
| 442 | 430 | ||
| 443 | if (attr->ia_valid & ATTR_SIZE) { | 431 | if (attr->ia_valid & ATTR_SIZE) { |
| 444 | error = fat_setsize(inode, attr->ia_size); | 432 | truncate_setsize(inode, attr->ia_size); |
| 445 | if (error) | 433 | fat_truncate_blocks(inode, attr->ia_size); |
| 446 | goto out; | ||
| 447 | } | 434 | } |
| 448 | 435 | ||
| 449 | generic_setattr(inode, attr); | 436 | setattr_copy(inode, attr); |
| 450 | mark_inode_dirty(inode); | 437 | mark_inode_dirty(inode); |
| 451 | out: | 438 | out: |
| 452 | return error; | 439 | return error; |
