3 Index: linux-2.6.3/fs/namei.c
4 ===================================================================
5 --- linux-2.6.3.orig/fs/namei.c 2004-03-31 18:22:06.000000000 -0500
6 +++ linux-2.6.3/fs/namei.c 2004-03-31 18:23:05.000000000 -0500
11 - error = do_truncate(dentry, 0);
12 + error = do_truncate(dentry, 0, 1);
14 put_write_access(inode);
18 struct dentry * dentry;
20 + intent_init(&nd.intent, IT_LOOKUP);
24 @@ -1537,6 +1538,15 @@
25 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
29 + if (nd.dentry->d_inode->i_op->mknod_raw) {
30 + struct inode_operations *op = nd.dentry->d_inode->i_op;
31 + error = op->mknod_raw(&nd, mode, dev);
32 + /* the file system wants to use normal vfs path now */
33 + if (error != -EOPNOTSUPP)
37 dentry = lookup_create(&nd, 0);
38 error = PTR_ERR(dentry);
43 up(&nd.dentry->d_inode->i_sem);
48 @@ -1604,10 +1615,18 @@
50 struct dentry *dentry;
52 + intent_init(&nd.intent, IT_LOOKUP);
54 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
57 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
58 + struct inode_operations *op = nd.dentry->d_inode->i_op;
59 + error = op->mkdir_raw(&nd, mode);
60 + /* the file system wants to use normal vfs path now */
61 + if (error != -EOPNOTSUPP)
64 dentry = lookup_create(&nd, 1);
65 error = PTR_ERR(dentry);
66 if (!IS_ERR(dentry)) {
70 up(&nd.dentry->d_inode->i_sem);
77 struct dentry *dentry;
79 + intent_init(&nd.intent, IT_LOOKUP);
81 name = getname(pathname);
83 @@ -1717,6 +1738,16 @@
88 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
89 + struct inode_operations *op = nd.dentry->d_inode->i_op;
91 + error = op->rmdir_raw(&nd);
92 + /* the file system wants to use normal vfs path now */
93 + if (error != -EOPNOTSUPP)
97 down(&nd.dentry->d_inode->i_sem);
98 dentry = lookup_hash(&nd.last, nd.dentry);
99 error = PTR_ERR(dentry);
100 @@ -1775,6 +1806,7 @@
101 struct dentry *dentry;
103 struct inode *inode = NULL;
104 + intent_init(&nd.intent, IT_LOOKUP);
106 name = getname(pathname);
108 @@ -1786,6 +1818,13 @@
110 if (nd.last_type != LAST_NORM)
112 + if (nd.dentry->d_inode->i_op->unlink_raw) {
113 + struct inode_operations *op = nd.dentry->d_inode->i_op;
114 + error = op->unlink_raw(&nd);
115 + /* the file system wants to use normal vfs path now */
116 + if (error != -EOPNOTSUPP)
119 down(&nd.dentry->d_inode->i_sem);
120 dentry = lookup_hash(&nd.last, nd.dentry);
121 error = PTR_ERR(dentry);
122 @@ -1853,10 +1892,18 @@
124 struct dentry *dentry;
126 + intent_init(&nd.intent, IT_LOOKUP);
128 error = path_lookup(to, LOOKUP_PARENT, &nd);
131 + if (nd.dentry->d_inode->i_op->symlink_raw) {
132 + struct inode_operations *op = nd.dentry->d_inode->i_op;
133 + error = op->symlink_raw(&nd, from);
134 + /* the file system wants to use normal vfs path now */
135 + if (error != -EOPNOTSUPP)
138 dentry = lookup_create(&nd, 0);
139 error = PTR_ERR(dentry);
140 if (!IS_ERR(dentry)) {
141 @@ -1864,6 +1911,7 @@
144 up(&nd.dentry->d_inode->i_sem);
149 @@ -1927,6 +1975,8 @@
150 struct nameidata nd, old_nd;
153 + intent_init(&nd.intent, IT_LOOKUP);
154 + intent_init(&old_nd.intent, IT_LOOKUP);
156 to = getname(newname);
158 @@ -1941,6 +1991,13 @@
160 if (old_nd.mnt != nd.mnt)
162 + if (nd.dentry->d_inode->i_op->link_raw) {
163 + struct inode_operations *op = nd.dentry->d_inode->i_op;
164 + error = op->link_raw(&old_nd, &nd);
165 + /* the file system wants to use normal vfs path now */
166 + if (error != -EOPNOTSUPP)
169 new_dentry = lookup_create(&nd, 0);
170 error = PTR_ERR(new_dentry);
171 if (!IS_ERR(new_dentry)) {
172 @@ -1991,7 +2048,7 @@
175 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
176 - struct inode *new_dir, struct dentry *new_dentry)
177 + struct inode *new_dir, struct dentry *new_dentry)
180 struct inode *target;
181 @@ -2036,7 +2093,7 @@
184 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
185 - struct inode *new_dir, struct dentry *new_dentry)
186 + struct inode *new_dir, struct dentry *new_dentry)
188 struct inode *target;
190 @@ -2113,6 +2170,8 @@
191 struct dentry * old_dentry, *new_dentry;
192 struct dentry * trap;
193 struct nameidata oldnd, newnd;
194 + intent_init(&oldnd.intent, IT_LOOKUP);
195 + intent_init(&newnd.intent, IT_LOOKUP);
197 error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
199 @@ -2135,6 +2194,13 @@
200 if (newnd.last_type != LAST_NORM)
203 + if (old_dir->d_inode->i_op->rename_raw) {
204 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
205 + /* the file system wants to use normal vfs path now */
206 + if (error != -EOPNOTSUPP)
210 trap = lock_rename(new_dir, old_dir);
212 old_dentry = lookup_hash(&oldnd.last, old_dir);
213 @@ -2166,8 +2232,7 @@
214 if (new_dentry == trap)
217 - error = vfs_rename(old_dir->d_inode, old_dentry,
218 - new_dir->d_inode, new_dentry);
219 + error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry);
223 Index: linux-2.6.3/fs/open.c
224 ===================================================================
225 --- linux-2.6.3.orig/fs/open.c 2004-03-31 18:22:06.000000000 -0500
226 +++ linux-2.6.3/fs/open.c 2004-03-31 20:18:47.000000000 -0500
231 -int do_truncate(struct dentry *dentry, loff_t length)
232 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
235 + struct inode_operations *op = dentry->d_inode->i_op;
236 struct iattr newattrs;
238 /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
240 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
241 down(&dentry->d_inode->i_sem);
242 down_write(&dentry->d_inode->i_alloc_sem);
243 - err = notify_change(dentry, &newattrs);
244 + if (called_from_open)
245 + newattrs.ia_valid |= ATTR_FROM_OPEN;
246 + if (op->setattr_raw) {
247 + newattrs.ia_valid |= ATTR_RAW;
248 + newattrs.ia_ctime = CURRENT_TIME;
249 + err = op->setattr_raw(dentry->d_inode, &newattrs);
251 + err = notify_change(dentry, &newattrs);
252 up_write(&dentry->d_inode->i_alloc_sem);
253 up(&dentry->d_inode->i_sem);
256 error = locks_verify_truncate(inode, NULL, length);
259 - error = do_truncate(nd.dentry, length);
260 + error = do_truncate(nd.dentry, length, 0);
262 put_write_access(inode);
266 error = locks_verify_truncate(inode, file, length);
268 - error = do_truncate(dentry, length);
269 + error = do_truncate(dentry, length, 0);
274 (error = permission(inode,MAY_WRITE,&nd)) != 0)
277 - down(&inode->i_sem);
278 - error = notify_change(nd.dentry, &newattrs);
280 + if (inode->i_op->setattr_raw) {
281 + struct inode_operations *op = nd.dentry->d_inode->i_op;
283 + newattrs.ia_valid |= ATTR_RAW;
284 + error = op->setattr_raw(inode, &newattrs);
285 + /* the file system wants to use normal vfs path now */
286 + if (error != -EOPNOTSUPP)
289 + down(&inode->i_sem);
290 + error = notify_change(nd.dentry, &newattrs);
297 (error = permission(inode,MAY_WRITE,&nd)) != 0)
300 - down(&inode->i_sem);
301 - error = notify_change(nd.dentry, &newattrs);
303 + if (inode->i_op->setattr_raw) {
304 + struct inode_operations *op = nd.dentry->d_inode->i_op;
306 + newattrs.ia_valid |= ATTR_RAW;
307 + error = op->setattr_raw(inode, &newattrs);
308 + /* the file system wants to use normal vfs path now */
309 + if (error != -EOPNOTSUPP)
312 + down(&inode->i_sem);
313 + error = notify_change(nd.dentry, &newattrs);
319 @@ -585,27 +613,31 @@
323 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
324 +int chmod_common(struct dentry *dentry, mode_t mode)
326 - struct inode * inode;
327 - struct dentry * dentry;
328 - struct file * file;
330 + struct inode *inode = dentry->d_inode;
331 struct iattr newattrs;
336 + if (IS_RDONLY(inode))
339 - dentry = file->f_dentry;
340 - inode = dentry->d_inode;
341 + if (inode->i_op->setattr_raw) {
342 + newattrs.ia_mode = mode;
343 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
344 + newattrs.ia_valid |= ATTR_RAW;
345 + down(&inode->i_sem);
346 + err = inode->i_op->setattr_raw(inode, &newattrs);
348 + /* the file system wants to use normal vfs path now */
349 + if (err != -EOPNOTSUPP)
354 - if (IS_RDONLY(inode))
357 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
362 if (mode == (mode_t) -1)
363 mode = inode->i_mode;
365 err = notify_change(dentry, &newattrs);
374 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
376 + struct file * file;
383 + err = chmod_common(file->f_dentry, mode);
388 @@ -623,32 +670,14 @@
389 asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
392 - struct inode * inode;
394 - struct iattr newattrs;
396 error = user_path_walk(filename, &nd);
399 - inode = nd.dentry->d_inode;
402 - if (IS_RDONLY(inode))
406 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
409 - down(&inode->i_sem);
410 - if (mode == (mode_t) -1)
411 - mode = inode->i_mode;
412 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
413 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
414 - error = notify_change(nd.dentry, &newattrs);
416 + error = chmod_common(nd.dentry, mode);
423 if (IS_RDONLY(inode))
426 + if (inode->i_op->setattr_raw) {
427 + struct inode_operations *op = dentry->d_inode->i_op;
429 + newattrs.ia_uid = user;
430 + newattrs.ia_gid = group;
431 + newattrs.ia_valid = ATTR_UID | ATTR_GID;
432 + newattrs.ia_valid |= ATTR_RAW;
433 + down(&inode->i_sem);
434 + error = op->setattr_raw(inode, &newattrs);
436 + /* the file system wants to use normal vfs path now */
437 + if (error != -EOPNOTSUPP)
440 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
442 newattrs.ia_valid = ATTR_CTIME;
444 newattrs.ia_valid |= ATTR_GID;
445 newattrs.ia_gid = group;
447 + down(&inode->i_sem);
448 if (!S_ISDIR(inode->i_mode))
449 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
450 - down(&inode->i_sem);
452 error = notify_change(dentry, &newattrs);
455 Index: linux-2.6.3/fs/exec.c
456 ===================================================================
457 --- linux-2.6.3.orig/fs/exec.c 2004-03-31 18:22:06.000000000 -0500
458 +++ linux-2.6.3/fs/exec.c 2004-03-31 18:23:05.000000000 -0500
459 @@ -1408,7 +1408,7 @@
461 if (!file->f_op->write)
463 - if (do_truncate(file->f_dentry, 0) != 0)
464 + if (do_truncate(file->f_dentry, 0, 0) != 0)
467 retval = binfmt->core_dump(signr, regs, file);
468 Index: linux-2.6.3/include/linux/fs.h
469 ===================================================================
470 --- linux-2.6.3.orig/include/linux/fs.h 2004-03-31 18:22:06.000000000 -0500
471 +++ linux-2.6.3/include/linux/fs.h 2004-03-31 18:23:05.000000000 -0500
472 @@ -843,13 +843,20 @@
473 int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
474 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
475 int (*link) (struct dentry *,struct inode *,struct dentry *);
476 + int (*link_raw) (struct nameidata *,struct nameidata *);
477 int (*unlink) (struct inode *,struct dentry *);
478 + int (*unlink_raw) (struct nameidata *);
479 int (*symlink) (struct inode *,struct dentry *,const char *);
480 + int (*symlink_raw) (struct nameidata *,const char *);
481 int (*mkdir) (struct inode *,struct dentry *,int);
482 + int (*mkdir_raw) (struct nameidata *,int);
483 int (*rmdir) (struct inode *,struct dentry *);
484 + int (*rmdir_raw) (struct nameidata *);
485 int (*mknod) (struct inode *,struct dentry *,int,dev_t);
486 + int (*mknod_raw) (struct nameidata *,int,dev_t);
487 int (*rename) (struct inode *, struct dentry *,
488 struct inode *, struct dentry *);
489 + int (*rename_raw) (struct nameidata *, struct nameidata *);
490 int (*readlink) (struct dentry *, char __user *,int);
491 int (*follow_link) (struct dentry *, struct nameidata *);
492 void (*truncate) (struct inode *);
493 @@ -1133,7 +1140,7 @@
497 -extern int do_truncate(struct dentry *, loff_t start);
498 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
499 extern struct file *filp_open(const char *, int, int);
500 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
501 extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
502 Index: linux-2.6.3/net/unix/af_unix.c
503 ===================================================================
504 --- linux-2.6.3.orig/net/unix/af_unix.c 2004-02-17 22:58:33.000000000 -0500
505 +++ linux-2.6.3/net/unix/af_unix.c 2004-03-31 18:23:05.000000000 -0500
509 if (sunname->sun_path[0]) {
510 + intent_init(&nd.intent, IT_LOOKUP);
511 err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);