1 Index: linux-2.6.6/fs/namei.c
2 ===================================================================
3 --- linux-2.6.6.orig/fs/namei.c 2004-05-30 23:17:06.267030976 +0300
4 +++ linux-2.6.6/fs/namei.c 2004-05-30 23:23:15.642877312 +0300
9 - error = do_truncate(dentry, 0);
10 + error = do_truncate(dentry, 0, 1);
12 put_write_access(inode);
14 Index: linux-2.6.6/fs/open.c
15 ===================================================================
16 --- linux-2.6.6.orig/fs/open.c 2004-05-30 20:05:26.857206992 +0300
17 +++ linux-2.6.6/fs/open.c 2004-05-30 23:24:38.908219056 +0300
22 -int do_truncate(struct dentry *dentry, loff_t length)
23 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
26 struct iattr newattrs;
28 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
29 down(&dentry->d_inode->i_sem);
30 down_write(&dentry->d_inode->i_alloc_sem);
31 + if (called_from_open)
32 + newattrs.ia_valid |= ATTR_FROM_OPEN;
33 err = notify_change(dentry, &newattrs);
34 up_write(&dentry->d_inode->i_alloc_sem);
35 up(&dentry->d_inode->i_sem);
37 error = locks_verify_truncate(inode, NULL, length);
40 - error = do_truncate(nd.dentry, length);
41 + error = do_truncate(nd.dentry, length, 0);
43 put_write_access(inode);
47 error = locks_verify_truncate(inode, file, length);
49 - error = do_truncate(dentry, length);
50 + error = do_truncate(dentry, length, 0);
54 Index: linux-2.6.6/fs/exec.c
55 ===================================================================
56 --- linux-2.6.6.orig/fs/exec.c 2004-05-30 20:05:26.862206232 +0300
57 +++ linux-2.6.6/fs/exec.c 2004-05-30 23:23:15.648876400 +0300
60 if (!file->f_op->write)
62 - if (do_truncate(file->f_dentry, 0) != 0)
63 + if (do_truncate(file->f_dentry, 0, 0) != 0)
66 retval = binfmt->core_dump(signr, regs, file);
67 Index: linux-2.6.6/include/linux/fs.h
68 ===================================================================
69 --- linux-2.6.6.orig/include/linux/fs.h 2004-05-30 23:20:11.979798344 +0300
70 +++ linux-2.6.6/include/linux/fs.h 2004-05-30 23:25:29.167578472 +0300
72 #define ATTR_ATTR_FLAG 1024
73 #define ATTR_KILL_SUID 2048
74 #define ATTR_KILL_SGID 4096
75 +#define ATTR_FROM_OPEN 16384 /* called from open path, ie O_TRUNC */
78 * This is the Inode Attributes structure, used for notify_change(). It
83 -extern int do_truncate(struct dentry *, loff_t start);
84 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
85 extern struct file *filp_open(const char *, int, int);
86 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
87 extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);