Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16951
b: refs/heads/master
c: 4a30131
h: refs/heads/master
i:
  16949: 5ed7b04
  16947: b07f034
  16943: b987a78
v: v3
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Jan 9, 2006
1 parent 97e4d64 commit ca3a45e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 788540141f4549637e89aadca6e25cf25eb53383
refs/heads/master: 4a30131e7dbb17e5fec6958bfac9da9aff1fa29b
24 changes: 8 additions & 16 deletions trunk/fs/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,12 @@ EXPORT_SYMBOL(inode_change_ok);
int inode_setattr(struct inode * inode, struct iattr * attr)
{
unsigned int ia_valid = attr->ia_valid;
int error = 0;

if (ia_valid & ATTR_SIZE) {
if (attr->ia_size != i_size_read(inode)) {
error = vmtruncate(inode, attr->ia_size);
if (error || (ia_valid == ATTR_SIZE))
goto out;
} else {
/*
* We skipped the truncate but must still update
* timestamps
*/
ia_valid |= ATTR_MTIME|ATTR_CTIME;
}

if (ia_valid & ATTR_SIZE &&
attr->ia_size != i_size_read(inode)) {
int error = vmtruncate(inode, attr->ia_size);
if (error)
return error;
}

if (ia_valid & ATTR_UID)
Expand All @@ -104,8 +96,8 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
inode->i_mode = mode;
}
mark_inode_dirty(inode);
out:
return error;

return 0;
}
EXPORT_SYMBOL(inode_setattr);

Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
goto close_fail;
if (!file->f_op->write)
goto close_fail;
if (do_truncate(file->f_dentry, 0, file) != 0)
if (do_truncate(file->f_dentry, 0, 0, file) != 0)
goto close_fail;

retval = binfmt->core_dump(signr, regs, file);
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
if (!error) {
DQUOT_INIT(inode);

error = do_truncate(dentry, 0, NULL);
error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL);
}
put_write_access(inode);
if (error)
Expand Down
9 changes: 5 additions & 4 deletions trunk/fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ asmlinkage long sys_fstatfs64(unsigned int fd, size_t sz, struct statfs64 __user
return error;
}

int do_truncate(struct dentry *dentry, loff_t length, struct file *filp)
int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
struct file *filp)
{
int err;
struct iattr newattrs;
Expand All @@ -204,7 +205,7 @@ int do_truncate(struct dentry *dentry, loff_t length, struct file *filp)
return -EINVAL;

newattrs.ia_size = length;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
newattrs.ia_valid = ATTR_SIZE | time_attrs;
if (filp) {
newattrs.ia_file = filp;
newattrs.ia_valid |= ATTR_FILE;
Expand Down Expand Up @@ -266,7 +267,7 @@ static inline long do_sys_truncate(const char __user * path, loff_t length)
error = locks_verify_truncate(inode, NULL, length);
if (!error) {
DQUOT_INIT(inode);
error = do_truncate(nd.dentry, length, NULL);
error = do_truncate(nd.dentry, length, 0, NULL);
}
put_write_access(inode);

Expand Down Expand Up @@ -318,7 +319,7 @@ static inline long do_sys_ftruncate(unsigned int fd, loff_t length, int small)

error = locks_verify_truncate(inode, file, length);
if (!error)
error = do_truncate(dentry, length, file);
error = do_truncate(dentry, length, 0, file);
out_putf:
fput(file);
out:
Expand Down
3 changes: 2 additions & 1 deletion trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,8 @@ static inline int break_lease(struct inode *inode, unsigned int mode)

/* fs/open.c */

extern int do_truncate(struct dentry *, loff_t start, struct file *filp);
extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
struct file *filp);
extern long do_sys_open(const char __user *filename, int flags, int mode);
extern struct file *filp_open(const char *, int, int);
extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
Expand Down

0 comments on commit ca3a45e

Please sign in to comment.