1 Index: linux-2.6.3-20/fs/exec.c
2 ===================================================================
3 --- linux-2.6.3-20.orig/fs/exec.c 2004-03-05 02:07:04.000000000 -0800
4 +++ linux-2.6.3-20/fs/exec.c 2004-03-08 14:23:40.000000000 -0800
9 + intent_init(&nd.intent, IT_OPEN);
11 - nd.intent.open.flags = FMODE_READ;
12 + error = user_path_walk_it(library, &nd);
14 + nd.intent.it_flags = O_RDONLY;
15 error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
22 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
23 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
24 error = PTR_ERR(file);
31 - nd.intent.open.flags = FMODE_READ;
32 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
33 + intent_init(&nd.intent, IT_OPEN);
34 + nd.intent.it_flags = O_RDONLY;
35 + err = path_lookup(name, LOOKUP_FOLLOW, &nd);
43 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
44 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
46 err = deny_write_access(file);
48 Index: linux-2.6.3-20/fs/namei.c
49 ===================================================================
50 --- linux-2.6.3-20.orig/fs/namei.c 2004-03-05 02:07:04.000000000 -0800
51 +++ linux-2.6.3-20/fs/namei.c 2004-03-08 14:32:24.000000000 -0800
56 +void intent_release(struct lookup_intent *it)
60 + if (it->it_magic != INTENT_MAGIC)
62 + if (it->it_op_release)
63 + it->it_op_release(it);
66 void path_release(struct nameidata *nd)
68 + intent_release(&nd->intent);
74 struct dentry * result;
75 struct inode *dir = parent->d_inode;
82 * First re-do the cached lookup just in case it was created
84 if (result->d_op && result->d_op->d_revalidate) {
85 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
87 - result = ERR_PTR(-ENOENT);
89 + result = ERR_PTR(-ESTALE);
90 + if (!IS_ERR(result))
96 return PTR_ERR(dentry);
99 +static int revalidate_special(struct nameidata *nd)
101 + struct dentry *dentry = nd->dentry;
102 + int err, counter = 0;
104 + if (!dentry->d_op || !dentry->d_op->d_revalidate)
107 + if (!dentry->d_op->d_revalidate(dentry, nd)) {
108 + struct dentry *new;
109 + if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC,nd)))
111 + new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
112 + d_invalidate(dentry);
114 + nd->dentry = dentry = new;
117 + goto revalidate_again;
118 + printk("excessive revalidate_it loops\n");
129 if (inode->i_op->follow_link) {
131 + nd->flags |= LOOKUP_LINK_NOTLAST;
132 err = do_follow_link(next.dentry, nd);
133 + nd->flags &= ~LOOKUP_LINK_NOTLAST;
138 inode = nd->dentry->d_inode;
141 + nd->flags |= LOOKUP_LAST;
142 + err = revalidate_special(nd);
143 + nd->flags &= ~LOOKUP_LAST;
148 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
153 + nd->flags |= LOOKUP_LAST;
154 err = do_lookup(nd, &this, &next);
155 + nd->flags &= ~LOOKUP_LAST;
158 follow_mount(&next.mnt, &next.dentry);
163 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
164 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
168 @@ -955,11 +1006,16 @@
170 this.hash = end_name_hash(hash);
172 - return lookup_hash(&this, base);
173 + return __lookup_hash(&this, base, nd);
175 return ERR_PTR(-EACCES);
178 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
180 + return lookup_one_len_it(name, base, len, NULL);
187 * that namei follows links, while lnamei does not.
190 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
191 +int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
193 char *tmp = getname(name);
194 int err = PTR_ERR(tmp);
195 @@ -983,6 +1039,12 @@
199 +int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
201 + intent_init(&nd->intent, IT_LOOKUP);
202 + return __user_walk_it(name, flags, nd);
206 * It's inline, so penalty for filesystems that don't use sticky bit is
208 @@ -1255,8 +1317,8 @@
209 acc_mode |= MAY_APPEND;
211 /* Fill in the open() intent data */
212 - nd->intent.open.flags = flag;
213 - nd->intent.open.create_mode = mode;
214 + nd->intent.it_flags = flag;
215 + nd->intent.it_create_mode = mode;
218 * The simplest case - just a plain lookup.
219 @@ -1271,6 +1333,7 @@
221 * Create - we need to know the parent.
223 + nd->intent.it_op |= IT_CREAT;
224 error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
227 @@ -1287,7 +1350,9 @@
229 nd->flags &= ~LOOKUP_PARENT;
230 down(&dir->d_inode->i_sem);
231 + nd->flags |= LOOKUP_LAST;
232 dentry = __lookup_hash(&nd->last, nd->dentry, nd);
233 + nd->flags &= ~LOOKUP_LAST;
236 error = PTR_ERR(dentry);
237 @@ -1392,7 +1457,9 @@
240 down(&dir->d_inode->i_sem);
241 + nd->flags |= LOOKUP_LAST;
242 dentry = __lookup_hash(&nd->last, nd->dentry, nd);
243 + nd->flags &= ~LOOKUP_LAST;
244 putname(nd->last.name);
247 @@ -2154,7 +2221,9 @@
248 __vfs_follow_link(struct nameidata *nd, const char *link)
251 + struct lookup_intent it = nd->intent;
257 @@ -2164,6 +2233,10 @@
258 /* weird __emul_prefix() stuff did it */
262 + intent_init(&nd->intent, it.it_op);
263 + nd->intent.it_flags = it.it_flags;
264 + nd->intent.it_create_mode = it.it_create_mode;
265 res = link_path_walk(link, nd);
267 if (current->link_count || res || nd->last_type!=LAST_NORM)
268 Index: linux-2.6.3-20/fs/namespace.c
269 ===================================================================
270 --- linux-2.6.3-20.orig/fs/namespace.c 2004-03-05 02:07:04.000000000 -0800
271 +++ linux-2.6.3-20/fs/namespace.c 2004-03-08 14:23:40.000000000 -0800
276 + intent_init(&nd.intent, IT_LOOKUP);
278 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
279 flags &= ~MS_MGC_MSK;
280 Index: linux-2.6.3-20/fs/open.c
281 ===================================================================
282 --- linux-2.6.3-20.orig/fs/open.c 2004-03-05 02:07:04.000000000 -0800
283 +++ linux-2.6.3-20/fs/open.c 2004-03-08 14:23:40.000000000 -0800
286 struct inode * inode;
289 + intent_init(&nd.intent, IT_GETATTR);
291 if (length < 0) /* sorry, but loff_t says... */
294 int old_fsuid, old_fsgid;
295 kernel_cap_t old_cap;
297 + intent_init(&nd.intent, IT_GETATTR);
299 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
302 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
303 && !special_file(nd.dentry->d_inode->i_mode))
313 + intent_init(&nd.intent, IT_GETATTR);
315 error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
321 + intent_init(&nd.intent, IT_GETATTR);
323 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
327 if (IS_RDONLY(inode))
332 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
335 * for the internal routines (ie open_namei()/follow_link() etc). 00 is
338 -struct file *filp_open(const char * filename, int flags, int mode)
340 - int namei_flags, error;
341 - struct nameidata nd;
343 - namei_flags = flags;
344 - if ((namei_flags+1) & O_ACCMODE)
346 - if (namei_flags & O_TRUNC)
349 - error = open_namei(filename, namei_flags, mode, &nd);
351 - return dentry_open(nd.dentry, nd.mnt, flags);
353 - return ERR_PTR(error);
356 -EXPORT_SYMBOL(filp_open);
358 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
359 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags,
360 + struct lookup_intent *it)
367 f->f_mode = (flags+1) & O_ACCMODE;
369 inode = dentry->d_inode;
370 if (f->f_mode & FMODE_WRITE) {
371 error = get_write_access(inode);
373 error = f->f_op->open(inode,f);
376 + intent_release(it);
378 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
384 + intent_release(it);
387 return ERR_PTR(error);
390 EXPORT_SYMBOL(dentry_open);
392 +struct file *filp_open(const char * filename, int flags, int mode)
394 + int namei_flags, error;
395 + struct file * temp_filp;
396 + struct nameidata nd;
397 + intent_init(&nd.intent, IT_OPEN);
399 + namei_flags = flags;
400 + if ((namei_flags+1) & O_ACCMODE)
402 + if (namei_flags & O_TRUNC)
405 + error = open_namei(filename, namei_flags, mode, &nd);
407 + temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
410 + return ERR_PTR(error);
414 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
416 + struct lookup_intent it;
417 + intent_init(&it, IT_LOOKUP);
419 + return dentry_open_it(dentry, mnt, flags, &it);
423 * Find an empty file descriptor entry, and mark it busy.
425 Index: linux-2.6.3-20/fs/stat.c
426 ===================================================================
427 --- linux-2.6.3-20.orig/fs/stat.c 2004-03-05 02:07:04.000000000 -0800
428 +++ linux-2.6.3-20/fs/stat.c 2004-03-08 14:23:40.000000000 -0800
431 EXPORT_SYMBOL(generic_fillattr);
433 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
434 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
436 struct inode *inode = dentry->d_inode;
442 + if (inode->i_op->getattr_it)
443 + return inode->i_op->getattr_it(mnt, dentry, it, stat);
444 if (inode->i_op->getattr)
445 return inode->i_op->getattr(mnt, dentry, stat);
449 EXPORT_SYMBOL(vfs_getattr);
451 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
453 + return vfs_getattr_it(mnt, dentry, NULL, stat);
456 int vfs_stat(char __user *name, struct kstat *stat)
460 + intent_init(&nd.intent, IT_GETATTR);
462 - error = user_path_walk(name, &nd);
463 + error = user_path_walk_it(name, &nd);
465 - error = vfs_getattr(nd.mnt, nd.dentry, stat);
466 + error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
474 + intent_init(&nd.intent, IT_GETATTR);
476 - error = user_path_walk_link(name, &nd);
477 + error = user_path_walk_link_it(name, &nd);
479 - error = vfs_getattr(nd.mnt, nd.dentry, stat);
480 + error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
486 struct file *f = fget(fd);
488 + struct nameidata nd;
489 + intent_init(&nd.intent, IT_GETATTR);
492 - error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
493 + error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
494 + intent_release(&nd.intent);
498 Index: linux-2.6.3-20/fs/nfs/dir.c
499 ===================================================================
500 --- linux-2.6.3-20.orig/fs/nfs/dir.c 2004-03-05 02:07:03.000000000 -0800
501 +++ linux-2.6.3-20/fs/nfs/dir.c 2004-03-08 14:23:40.000000000 -0800
504 if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE))
506 - return (nd->intent.open.flags & O_EXCL) != 0;
507 + return (nd->intent.it_flags & O_EXCL) != 0;
510 static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
512 attr.ia_valid = ATTR_MODE;
514 if (nd && (nd->flags & LOOKUP_CREATE))
515 - open_flags = nd->intent.open.flags;
516 + open_flags = nd->intent.it_flags;
519 * The 0 argument passed into the create function should one day
520 Index: linux-2.6.3-20/fs/inode.c
521 ===================================================================
522 --- linux-2.6.3-20.orig/fs/inode.c 2004-03-05 02:07:04.000000000 -0800
523 +++ linux-2.6.3-20/fs/inode.c 2004-03-08 14:23:40.000000000 -0800
525 inodes_stat.nr_unused--;
528 +EXPORT_SYMBOL(__iget);
530 * clear_inode - clear an inode
531 * @inode: inode to clear
532 Index: linux-2.6.3-20/fs/super.c
533 ===================================================================
534 --- linux-2.6.3-20.orig/fs/super.c 2004-03-05 02:07:04.000000000 -0800
535 +++ linux-2.6.3-20/fs/super.c 2004-03-08 14:23:40.000000000 -0800
537 return (struct vfsmount *)sb;
540 +EXPORT_SYMBOL(do_kern_mount);
542 struct vfsmount *kern_mount(struct file_system_type *type)
544 return do_kern_mount(type->name, 0, type->name, NULL);
545 Index: linux-2.6.3-20/include/linux/dcache.h
546 ===================================================================
547 --- linux-2.6.3-20.orig/include/linux/dcache.h 2004-03-05 02:07:17.000000000 -0800
548 +++ linux-2.6.3-20/include/linux/dcache.h 2004-03-08 14:23:40.000000000 -0800
552 #include <asm/atomic.h>
553 +#include <linux/string.h>
554 #include <linux/list.h>
555 #include <linux/spinlock.h>
556 #include <linux/cache.h>
561 +#include <linux/namei.h>
563 struct dentry_stat_t {
566 Index: linux-2.6.3-20/include/linux/fs.h
567 ===================================================================
568 --- linux-2.6.3-20.orig/include/linux/fs.h 2004-03-05 02:07:17.000000000 -0800
569 +++ linux-2.6.3-20/include/linux/fs.h 2004-03-08 14:23:41.000000000 -0800
571 #define ATTR_ATTR_FLAG 1024
572 #define ATTR_KILL_SUID 2048
573 #define ATTR_KILL_SGID 4096
574 +#define ATTR_RAW 8192 /* file system, not vfs will massage attrs */
575 +#define ATTR_FROM_OPEN 16384 /* called from open path, ie O_TRUNC */
578 * This is the Inode Attributes structure, used for notify_change(). It
580 struct block_device *i_bdev;
583 + void *i_filterdata;
585 unsigned long i_dnotify_mask; /* Directory notify events */
586 struct dnotify_struct *i_dnotify; /* for directory notifications */
588 spinlock_t f_ep_lock;
589 #endif /* #ifdef CONFIG_EPOLL */
590 struct address_space *f_mapping;
591 + struct lookup_intent *f_it;
593 extern spinlock_t files_lock;
594 #define file_list_lock() spin_lock(&files_lock);
596 void (*truncate) (struct inode *);
597 int (*permission) (struct inode *, int, struct nameidata *);
598 int (*setattr) (struct dentry *, struct iattr *);
599 + int (*setattr_raw) (struct inode *, struct iattr *);
600 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
601 + int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
602 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
603 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
604 ssize_t (*listxattr) (struct dentry *, char *, size_t);
605 @@ -1062,6 +1068,7 @@
606 extern int unregister_filesystem(struct file_system_type *);
607 extern struct vfsmount *kern_mount(struct file_system_type *);
608 extern int may_umount(struct vfsmount *);
609 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
610 extern long do_mount(char *, char *, char *, unsigned long, void *);
612 extern int vfs_statfs(struct super_block *, struct kstatfs *);
613 @@ -1126,6 +1133,7 @@
614 extern int do_truncate(struct dentry *, loff_t start);
615 extern struct file *filp_open(const char *, int, int);
616 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
617 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
618 extern int filp_close(struct file *, fl_owner_t id);
619 extern char * getname(const char __user *);
621 Index: linux-2.6.3-20/include/linux/namei.h
622 ===================================================================
623 --- linux-2.6.3-20.orig/include/linux/namei.h 2004-03-05 02:07:18.000000000 -0800
624 +++ linux-2.6.3-20/include/linux/namei.h 2004-03-08 14:23:41.000000000 -0800
626 #define _LINUX_NAMEI_H
628 #include <linux/linkage.h>
629 +#include <linux/string.h>
634 -struct open_intent {
637 +/* intent opcodes */
639 +#define IT_CREAT (1<<1)
640 +#define IT_READDIR (1<<2)
641 +#define IT_GETATTR (1<<3)
642 +#define IT_LOOKUP (1<<4)
643 +#define IT_UNLINK (1<<5)
644 +#define IT_TRUNC (1<<6)
645 +#define IT_GETXATTR (1<<7)
647 +struct lustre_intent_data {
648 + int it_disposition;
650 + __u64 it_lock_handle;
655 +#define INTENT_MAGIC 0x19620323
656 +struct lookup_intent {
658 + void (*it_op_release)(struct lookup_intent *);
661 + int it_create_mode;
663 + struct lustre_intent_data lustre;
667 +static inline void intent_init(struct lookup_intent *it, int op)
669 + memset(it, 0, sizeof(*it));
670 + it->it_magic = INTENT_MAGIC;
675 struct dentry *dentry;
676 struct vfsmount *mnt;
683 - struct open_intent open;
685 + struct lookup_intent intent;
690 #define LOOKUP_CONTINUE 4
691 #define LOOKUP_PARENT 16
692 #define LOOKUP_NOALT 32
693 +#define LOOKUP_LAST (1<<6)
694 +#define LOOKUP_LINK_NOTLAST (1<<7)
700 #define LOOKUP_ACCESS (0x0400)
702 extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
703 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
704 +#define user_path_walk_it(name,nd) \
705 + __user_walk_it(name, LOOKUP_FOLLOW, nd)
706 +#define user_path_walk_link_it(name,nd) \
707 + __user_walk_it(name, 0, nd)
708 +extern void intent_release(struct lookup_intent *);
709 #define user_path_walk(name,nd) \
710 __user_walk(name, LOOKUP_FOLLOW, nd)
711 #define user_path_walk_link(name,nd) \
714 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
715 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
717 extern int follow_down(struct vfsmount **, struct dentry **);
718 extern int follow_up(struct vfsmount **, struct dentry **);
720 Index: linux-2.6.3-20/kernel/exit.c
721 ===================================================================
722 --- linux-2.6.3-20.orig/kernel/exit.c 2004-03-05 02:07:17.000000000 -0800
723 +++ linux-2.6.3-20/kernel/exit.c 2004-03-08 14:23:41.000000000 -0800
725 write_unlock_irq(&tasklist_lock);
728 +EXPORT_SYMBOL(reparent_to_init);
730 void __set_special_pids(pid_t session, pid_t pgrp)
732 struct task_struct *curr = current;
737 +EXPORT_SYMBOL(exit_files);
739 static inline void __put_fs_struct(struct fs_struct *fs)
741 /* No need to hold fs->lock if we are killing it */