1 fs/exec.c | 18 +++++++---
2 fs/namei.c | 86 +++++++++++++++++++++++++++++++++++++++++++++----
5 fs/open.c | 62 +++++++++++++++++++++++------------
6 fs/stat.c | 24 ++++++++++---
7 include/linux/dcache.h | 3 +
8 include/linux/fs.h | 8 ++++
9 include/linux/namei.h | 56 ++++++++++++++++++++++++++-----
10 kernel/ksyms.c | 8 ++++
11 10 files changed, 222 insertions(+), 49 deletions(-)
13 .old..........pc/vfs_intent-2.6.3-suse/fs/exec.c
14 .new.........fs/exec.c
15 Index: linux-2.6.3-20/fs/exec.c
16 ===================================================================
17 --- linux-2.6.3-20.orig/fs/exec.c 2004-03-05 02:07:04.000000000 -0800
18 +++ linux-2.6.3-20/fs/exec.c 2004-03-08 14:23:40.000000000 -0800
23 + intent_init(&nd.intent, IT_OPEN);
25 - nd.intent.open.flags = FMODE_READ;
26 + error = user_path_walk_it(library, &nd);
28 + nd.intent.it_flags = O_RDONLY;
29 error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
36 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
37 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
38 error = PTR_ERR(file);
45 - nd.intent.open.flags = FMODE_READ;
46 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
47 + intent_init(&nd.intent, IT_OPEN);
48 + nd.intent.it_flags = O_RDONLY;
49 + err = path_lookup(name, LOOKUP_FOLLOW, &nd);
57 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
58 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
60 err = deny_write_access(file);
62 .old..........pc/vfs_intent-2.6.3-suse/fs/namei.c
63 .new.........fs/namei.c
64 Index: linux-2.6.3-20/fs/namei.c
65 ===================================================================
66 --- linux-2.6.3-20.orig/fs/namei.c 2004-03-05 02:07:04.000000000 -0800
67 +++ linux-2.6.3-20/fs/namei.c 2004-03-08 14:32:24.000000000 -0800
72 +void intent_release(struct lookup_intent *it)
76 + if (it->it_magic != INTENT_MAGIC)
78 + if (it->it_op_release)
79 + it->it_op_release(it);
82 void path_release(struct nameidata *nd)
84 + intent_release(&nd->intent);
90 struct dentry * result;
91 struct inode *dir = parent->d_inode;
98 * First re-do the cached lookup just in case it was created
100 if (result->d_op && result->d_op->d_revalidate) {
101 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
103 - result = ERR_PTR(-ENOENT);
105 + result = ERR_PTR(-ESTALE);
106 + if (!IS_ERR(result))
112 return PTR_ERR(dentry);
115 +static int revalidate_special(struct nameidata *nd)
117 + struct dentry *dentry = nd->dentry;
118 + int err, counter = 0;
120 + if (!dentry->d_op || !dentry->d_op->d_revalidate)
123 + if (!dentry->d_op->d_revalidate(dentry, nd)) {
124 + struct dentry *new;
125 + if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC,nd)))
127 + new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
128 + d_invalidate(dentry);
130 + nd->dentry = dentry = new;
133 + goto revalidate_again;
134 + printk("excessive revalidate_it loops\n");
145 if (inode->i_op->follow_link) {
147 + nd->flags |= LOOKUP_LINK_NOTLAST;
148 err = do_follow_link(next.dentry, nd);
149 + nd->flags &= ~LOOKUP_LINK_NOTLAST;
154 inode = nd->dentry->d_inode;
157 + nd->flags |= LOOKUP_LAST;
158 + err = revalidate_special(nd);
159 + nd->flags &= ~LOOKUP_LAST;
164 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
169 + nd->flags |= LOOKUP_LAST;
170 err = do_lookup(nd, &this, &next);
171 + nd->flags &= ~LOOKUP_LAST;
174 follow_mount(&next.mnt, &next.dentry);
179 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
180 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
184 @@ -955,11 +1006,16 @@
186 this.hash = end_name_hash(hash);
188 - return lookup_hash(&this, base);
189 + return __lookup_hash(&this, base, nd);
191 return ERR_PTR(-EACCES);
194 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
196 + return lookup_one_len_it(name, base, len, NULL);
203 * that namei follows links, while lnamei does not.
206 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
207 +int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
209 char *tmp = getname(name);
210 int err = PTR_ERR(tmp);
211 @@ -983,6 +1039,12 @@
215 +int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
217 + intent_init(&nd->intent, IT_LOOKUP);
218 + return __user_walk_it(name, flags, nd);
222 * It's inline, so penalty for filesystems that don't use sticky bit is
224 @@ -1255,8 +1317,8 @@
225 acc_mode |= MAY_APPEND;
227 /* Fill in the open() intent data */
228 - nd->intent.open.flags = flag;
229 - nd->intent.open.create_mode = mode;
230 + nd->intent.it_flags = flag;
231 + nd->intent.it_create_mode = mode;
234 * The simplest case - just a plain lookup.
235 @@ -1271,6 +1333,7 @@
237 * Create - we need to know the parent.
239 + nd->intent.it_op |= IT_CREAT;
240 error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
243 @@ -1287,7 +1350,9 @@
245 nd->flags &= ~LOOKUP_PARENT;
246 down(&dir->d_inode->i_sem);
247 + nd->flags |= LOOKUP_LAST;
248 dentry = __lookup_hash(&nd->last, nd->dentry, nd);
249 + nd->flags &= ~LOOKUP_LAST;
252 error = PTR_ERR(dentry);
253 @@ -1392,7 +1457,9 @@
256 down(&dir->d_inode->i_sem);
257 + nd->flags |= LOOKUP_LAST;
258 dentry = __lookup_hash(&nd->last, nd->dentry, nd);
259 + nd->flags &= ~LOOKUP_LAST;
260 putname(nd->last.name);
263 @@ -2154,7 +2221,9 @@
264 __vfs_follow_link(struct nameidata *nd, const char *link)
267 + struct lookup_intent it = nd->intent;
273 @@ -2164,6 +2233,10 @@
274 /* weird __emul_prefix() stuff did it */
278 + intent_init(&nd->intent, it.it_op);
279 + nd->intent.it_flags = it.it_flags;
280 + nd->intent.it_create_mode = it.it_create_mode;
281 res = link_path_walk(link, nd);
283 if (current->link_count || res || nd->last_type!=LAST_NORM)
284 .old..........pc/vfs_intent-2.6.3-suse/fs/namespace.c
285 .new.........fs/namespace.c
286 Index: linux-2.6.3-20/fs/namespace.c
287 ===================================================================
288 --- linux-2.6.3-20.orig/fs/namespace.c 2004-03-05 02:07:04.000000000 -0800
289 +++ linux-2.6.3-20/fs/namespace.c 2004-03-08 14:23:40.000000000 -0800
294 + intent_init(&nd.intent, IT_LOOKUP);
296 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
297 flags &= ~MS_MGC_MSK;
298 .old..........pc/vfs_intent-2.6.3-suse/fs/open.c
299 .new.........fs/open.c
300 Index: linux-2.6.3-20/fs/open.c
301 ===================================================================
302 --- linux-2.6.3-20.orig/fs/open.c 2004-03-05 02:07:04.000000000 -0800
303 +++ linux-2.6.3-20/fs/open.c 2004-03-08 14:23:40.000000000 -0800
306 struct inode * inode;
309 + intent_init(&nd.intent, IT_GETATTR);
311 if (length < 0) /* sorry, but loff_t says... */
314 int old_fsuid, old_fsgid;
315 kernel_cap_t old_cap;
317 + intent_init(&nd.intent, IT_GETATTR);
319 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
322 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
323 && !special_file(nd.dentry->d_inode->i_mode))
333 + intent_init(&nd.intent, IT_GETATTR);
335 error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
341 + intent_init(&nd.intent, IT_GETATTR);
343 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
347 if (IS_RDONLY(inode))
352 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
355 * for the internal routines (ie open_namei()/follow_link() etc). 00 is
358 -struct file *filp_open(const char * filename, int flags, int mode)
360 - int namei_flags, error;
361 - struct nameidata nd;
363 - namei_flags = flags;
364 - if ((namei_flags+1) & O_ACCMODE)
366 - if (namei_flags & O_TRUNC)
369 - error = open_namei(filename, namei_flags, mode, &nd);
371 - return dentry_open(nd.dentry, nd.mnt, flags);
373 - return ERR_PTR(error);
376 -EXPORT_SYMBOL(filp_open);
378 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
379 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags,
380 + struct lookup_intent *it)
387 f->f_mode = (flags+1) & O_ACCMODE;
389 inode = dentry->d_inode;
390 if (f->f_mode & FMODE_WRITE) {
391 error = get_write_access(inode);
393 error = f->f_op->open(inode,f);
396 + intent_release(it);
398 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
404 + intent_release(it);
407 return ERR_PTR(error);
410 EXPORT_SYMBOL(dentry_open);
412 +struct file *filp_open(const char * filename, int flags, int mode)
414 + int namei_flags, error;
415 + struct file * temp_filp;
416 + struct nameidata nd;
417 + intent_init(&nd.intent, IT_OPEN);
419 + namei_flags = flags;
420 + if ((namei_flags+1) & O_ACCMODE)
422 + if (namei_flags & O_TRUNC)
425 + error = open_namei(filename, namei_flags, mode, &nd);
427 + temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
430 + return ERR_PTR(error);
434 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
436 + struct lookup_intent it;
437 + intent_init(&it, IT_LOOKUP);
439 + return dentry_open_it(dentry, mnt, flags, &it);
443 * Find an empty file descriptor entry, and mark it busy.
445 .old..........pc/vfs_intent-2.6.3-suse/fs/stat.c
446 .new.........fs/stat.c
447 Index: linux-2.6.3-20/fs/stat.c
448 ===================================================================
449 --- linux-2.6.3-20.orig/fs/stat.c 2004-03-05 02:07:04.000000000 -0800
450 +++ linux-2.6.3-20/fs/stat.c 2004-03-08 14:23:40.000000000 -0800
453 EXPORT_SYMBOL(generic_fillattr);
455 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
456 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
458 struct inode *inode = dentry->d_inode;
464 + if (inode->i_op->getattr_it)
465 + return inode->i_op->getattr_it(mnt, dentry, it, stat);
466 if (inode->i_op->getattr)
467 return inode->i_op->getattr(mnt, dentry, stat);
471 EXPORT_SYMBOL(vfs_getattr);
473 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
475 + return vfs_getattr_it(mnt, dentry, NULL, stat);
478 int vfs_stat(char __user *name, struct kstat *stat)
482 + intent_init(&nd.intent, IT_GETATTR);
484 - error = user_path_walk(name, &nd);
485 + error = user_path_walk_it(name, &nd);
487 - error = vfs_getattr(nd.mnt, nd.dentry, stat);
488 + error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
496 + intent_init(&nd.intent, IT_GETATTR);
498 - error = user_path_walk_link(name, &nd);
499 + error = user_path_walk_link_it(name, &nd);
501 - error = vfs_getattr(nd.mnt, nd.dentry, stat);
502 + error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
508 struct file *f = fget(fd);
510 + struct nameidata nd;
511 + intent_init(&nd.intent, IT_GETATTR);
514 - error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
515 + error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
516 + intent_release(&nd.intent);
520 .old..........pc/vfs_intent-2.6.3-suse/fs/nfs/dir.c
521 .new.........fs/nfs/dir.c
522 Index: linux-2.6.3-20/fs/nfs/dir.c
523 ===================================================================
524 --- linux-2.6.3-20.orig/fs/nfs/dir.c 2004-03-05 02:07:03.000000000 -0800
525 +++ linux-2.6.3-20/fs/nfs/dir.c 2004-03-08 14:23:40.000000000 -0800
528 if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE))
530 - return (nd->intent.open.flags & O_EXCL) != 0;
531 + return (nd->intent.it_flags & O_EXCL) != 0;
534 static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
536 attr.ia_valid = ATTR_MODE;
538 if (nd && (nd->flags & LOOKUP_CREATE))
539 - open_flags = nd->intent.open.flags;
540 + open_flags = nd->intent.it_flags;
543 * The 0 argument passed into the create function should one day
544 .old..........pc/vfs_intent-2.6.3-suse/fs/inode.c
545 .new.........fs/inode.c
546 Index: linux-2.6.3-20/fs/inode.c
547 ===================================================================
548 --- linux-2.6.3-20.orig/fs/inode.c 2004-03-05 02:07:04.000000000 -0800
549 +++ linux-2.6.3-20/fs/inode.c 2004-03-08 14:23:40.000000000 -0800
551 inodes_stat.nr_unused--;
554 +EXPORT_SYMBOL(__iget);
556 * clear_inode - clear an inode
557 * @inode: inode to clear
558 .old..........pc/vfs_intent-2.6.3-suse/fs/super.c
559 .new.........fs/super.c
560 Index: linux-2.6.3-20/fs/super.c
561 ===================================================================
562 --- linux-2.6.3-20.orig/fs/super.c 2004-03-05 02:07:04.000000000 -0800
563 +++ linux-2.6.3-20/fs/super.c 2004-03-08 14:23:40.000000000 -0800
565 return (struct vfsmount *)sb;
568 +EXPORT_SYMBOL(do_kern_mount);
570 struct vfsmount *kern_mount(struct file_system_type *type)
572 return do_kern_mount(type->name, 0, type->name, NULL);
573 .old..........pc/vfs_intent-2.6.3-suse/include/linux/dcache.h
574 .new.........include/linux/dcache.h
575 Index: linux-2.6.3-20/include/linux/dcache.h
576 ===================================================================
577 --- linux-2.6.3-20.orig/include/linux/dcache.h 2004-03-05 02:07:17.000000000 -0800
578 +++ linux-2.6.3-20/include/linux/dcache.h 2004-03-08 14:23:40.000000000 -0800
582 #include <asm/atomic.h>
583 +#include <linux/string.h>
584 #include <linux/list.h>
585 #include <linux/spinlock.h>
586 #include <linux/cache.h>
591 +#include <linux/namei.h>
593 struct dentry_stat_t {
596 .old..........pc/vfs_intent-2.6.3-suse/include/linux/fs.h
597 .new.........include/linux/fs.h
598 Index: linux-2.6.3-20/include/linux/fs.h
599 ===================================================================
600 --- linux-2.6.3-20.orig/include/linux/fs.h 2004-03-05 02:07:17.000000000 -0800
601 +++ linux-2.6.3-20/include/linux/fs.h 2004-03-08 14:23:41.000000000 -0800
603 #define ATTR_ATTR_FLAG 1024
604 #define ATTR_KILL_SUID 2048
605 #define ATTR_KILL_SGID 4096
606 +#define ATTR_RAW 8192 /* file system, not vfs will massage attrs */
607 +#define ATTR_FROM_OPEN 16384 /* called from open path, ie O_TRUNC */
610 * This is the Inode Attributes structure, used for notify_change(). It
612 struct block_device *i_bdev;
615 + void *i_filterdata;
617 unsigned long i_dnotify_mask; /* Directory notify events */
618 struct dnotify_struct *i_dnotify; /* for directory notifications */
620 spinlock_t f_ep_lock;
621 #endif /* #ifdef CONFIG_EPOLL */
622 struct address_space *f_mapping;
623 + struct lookup_intent *f_it;
625 extern spinlock_t files_lock;
626 #define file_list_lock() spin_lock(&files_lock);
628 void (*truncate) (struct inode *);
629 int (*permission) (struct inode *, int, struct nameidata *);
630 int (*setattr) (struct dentry *, struct iattr *);
631 + int (*setattr_raw) (struct inode *, struct iattr *);
632 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
633 + int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
634 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
635 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
636 ssize_t (*listxattr) (struct dentry *, char *, size_t);
637 @@ -1062,6 +1068,7 @@
638 extern int unregister_filesystem(struct file_system_type *);
639 extern struct vfsmount *kern_mount(struct file_system_type *);
640 extern int may_umount(struct vfsmount *);
641 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
642 extern long do_mount(char *, char *, char *, unsigned long, void *);
644 extern int vfs_statfs(struct super_block *, struct kstatfs *);
645 @@ -1126,6 +1133,7 @@
646 extern int do_truncate(struct dentry *, loff_t start);
647 extern struct file *filp_open(const char *, int, int);
648 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
649 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
650 extern int filp_close(struct file *, fl_owner_t id);
651 extern char * getname(const char __user *);
653 .old..........pc/vfs_intent-2.6.3-suse/include/linux/namei.h
654 .new.........include/linux/namei.h
655 Index: linux-2.6.3-20/include/linux/namei.h
656 ===================================================================
657 --- linux-2.6.3-20.orig/include/linux/namei.h 2004-03-05 02:07:18.000000000 -0800
658 +++ linux-2.6.3-20/include/linux/namei.h 2004-03-08 14:23:41.000000000 -0800
660 #define _LINUX_NAMEI_H
662 #include <linux/linkage.h>
663 +#include <linux/string.h>
668 -struct open_intent {
671 +/* intent opcodes */
673 +#define IT_CREAT (1<<1)
674 +#define IT_READDIR (1<<2)
675 +#define IT_GETATTR (1<<3)
676 +#define IT_LOOKUP (1<<4)
677 +#define IT_UNLINK (1<<5)
678 +#define IT_TRUNC (1<<6)
679 +#define IT_GETXATTR (1<<7)
681 +struct lustre_intent_data {
682 + int it_disposition;
684 + __u64 it_lock_handle;
689 +#define INTENT_MAGIC 0x19620323
690 +struct lookup_intent {
692 + void (*it_op_release)(struct lookup_intent *);
695 + int it_create_mode;
697 + struct lustre_intent_data lustre;
701 +static inline void intent_init(struct lookup_intent *it, int op)
703 + memset(it, 0, sizeof(*it));
704 + it->it_magic = INTENT_MAGIC;
709 struct dentry *dentry;
710 struct vfsmount *mnt;
717 - struct open_intent open;
719 + struct lookup_intent intent;
724 #define LOOKUP_CONTINUE 4
725 #define LOOKUP_PARENT 16
726 #define LOOKUP_NOALT 32
727 +#define LOOKUP_LAST (1<<6)
728 +#define LOOKUP_LINK_NOTLAST (1<<7)
734 #define LOOKUP_ACCESS (0x0400)
736 extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
737 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
738 +#define user_path_walk_it(name,nd) \
739 + __user_walk_it(name, LOOKUP_FOLLOW, nd)
740 +#define user_path_walk_link_it(name,nd) \
741 + __user_walk_it(name, 0, nd)
742 +extern void intent_release(struct lookup_intent *);
743 #define user_path_walk(name,nd) \
744 __user_walk(name, LOOKUP_FOLLOW, nd)
745 #define user_path_walk_link(name,nd) \
748 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
749 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
751 extern int follow_down(struct vfsmount **, struct dentry **);
752 extern int follow_up(struct vfsmount **, struct dentry **);
754 .old..........pc/vfs_intent-2.6.3-suse/kernel/exit.c
755 .new.........kernel/exit.c
756 Index: linux-2.6.3-20/kernel/exit.c
757 ===================================================================
758 --- linux-2.6.3-20.orig/kernel/exit.c 2004-03-05 02:07:17.000000000 -0800
759 +++ linux-2.6.3-20/kernel/exit.c 2004-03-08 14:23:41.000000000 -0800
761 write_unlock_irq(&tasklist_lock);
764 +EXPORT_SYMBOL(reparent_to_init);
766 void __set_special_pids(pid_t session, pid_t pgrp)
768 struct task_struct *curr = current;
773 +EXPORT_SYMBOL(exit_files);
775 static inline void __put_fs_struct(struct fs_struct *fs)
777 /* No need to hold fs->lock if we are killing it */