1 --- linux-2.6.12.6.orig/fs/exec.c
2 +++ linux-2.6.12.6/fs/exec.c
7 + intent_init(&nd.intent, IT_OPEN);
9 - nd.intent.open.flags = FMODE_READ;
10 - error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
11 + nd.intent.it_flags = FMODE_READ|FMODE_EXEC;
12 + error = __user_walk_it(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
20 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
21 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
22 error = PTR_ERR(file);
29 - nd.intent.open.flags = FMODE_READ;
30 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
31 + intent_init(&nd.intent, IT_OPEN);
32 + nd.intent.it_flags = FMODE_READ|FMODE_EXEC;
33 + err = path_lookup(name, LOOKUP_FOLLOW, &nd);
41 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
42 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
44 err = deny_write_access(file);
46 --- linux-2.6.12.6.orig/fs/namei.c
47 +++ linux-2.6.12.6/fs/namei.c
52 +void intent_release(struct lookup_intent *it)
56 + if (it->it_magic != INTENT_MAGIC)
58 + if (it->it_op_release)
59 + it->it_op_release(it);
62 void path_release(struct nameidata *nd)
64 + intent_release(&nd->intent);
70 struct dentry * result;
71 struct inode *dir = parent->d_inode;
78 * First re-do the cached lookup just in case it was created
79 * while we waited for the directory semaphore..
81 * Uhhuh! Nasty case: the cache was re-populated while
82 * we waited on the semaphore. Need to revalidate.
85 if (result->d_op && result->d_op->d_revalidate) {
86 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
88 - result = ERR_PTR(-ENOENT);
90 + result = ERR_PTR(-ESTALE);
91 + if (!IS_ERR(result))
108 /* weird __emul_prefix() stuff did it */
111 + intent_reset_fs_part(&nd->intent);
112 res = link_path_walk(link, nd);
114 if (nd->depth || res || nd->last_type!=LAST_NORM)
116 return PTR_ERR(dentry);
119 +static int revalidate_special(struct nameidata *nd)
121 + struct dentry *dentry = nd->dentry;
122 + int err, counter = 0;
125 + if (!dentry->d_op || !dentry->d_op->d_revalidate)
127 + if (!dentry->d_op->d_revalidate(dentry, nd)) {
128 + struct dentry *new;
129 + if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC, nd)))
131 + new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
133 + return PTR_ERR(new);
134 + d_invalidate(dentry);
136 + nd->dentry = dentry = new;
139 + goto revalidate_again;
140 + //printk("excessive revalidate_it loops\n");
148 * This is the basic name resolution function, turning a pathname into
152 if (inode->i_op->follow_link) {
153 + int save_flags = nd->flags;
154 + nd->flags |= LOOKUP_LINK_NOTLAST;
155 err = do_follow_link(&next, nd);
156 + if (!(save_flags & LOOKUP_LINK_NOTLAST))
157 + nd->flags &= ~LOOKUP_LINK_NOTLAST;
162 inode = nd->dentry->d_inode;
165 + nd->flags |= LOOKUP_LAST;
166 + err = revalidate_special(nd);
167 + nd->flags &= ~LOOKUP_LAST;
168 + if (!nd->dentry->d_inode)
174 + if (lookup_flags & LOOKUP_DIRECTORY) {
176 + if(!nd->dentry->d_inode->i_op ||
177 + !nd->dentry->d_inode->i_op->lookup) {
184 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
189 + nd->flags |= LOOKUP_LAST;
190 err = do_lookup(nd, &this, &next);
191 + nd->flags &= ~LOOKUP_LAST;
194 inode = next.dentry->d_inode;
195 @@ -1097,7 +1166,7 @@
199 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
200 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
204 @@ -1117,11 +1186,16 @@
206 this.hash = end_name_hash(hash);
208 - return lookup_hash(&this, base);
209 + return __lookup_hash(&this, base, nd);
211 return ERR_PTR(-EACCES);
214 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
216 + return lookup_one_len_it(name, base, len, NULL);
222 @@ -1133,7 +1207,7 @@
223 * that namei follows links, while lnamei does not.
226 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
227 +int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
229 char *tmp = getname(name);
230 int err = PTR_ERR(tmp);
231 @@ -1145,6 +1219,12 @@
235 +int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
237 + intent_init(&nd->intent, IT_LOOKUP);
238 + return __user_walk_it(name, flags, nd);
242 * It's inline, so penalty for filesystems that don't use sticky bit is
244 @@ -1426,8 +1506,8 @@
245 acc_mode |= MAY_APPEND;
247 /* Fill in the open() intent data */
248 - nd->intent.open.flags = flag;
249 - nd->intent.open.create_mode = mode;
250 + nd->intent.it_flags = flag;
251 + nd->intent.it_create_mode = mode;
254 * The simplest case - just a plain lookup.
255 @@ -1442,6 +1522,7 @@
257 * Create - we need to know the parent.
259 + nd->intent.it_op |= IT_CREAT;
260 error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
263 @@ -1458,7 +1539,9 @@
265 nd->flags &= ~LOOKUP_PARENT;
266 down(&dir->d_inode->i_sem);
267 + nd->flags |= LOOKUP_LAST;
268 path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
269 + nd->flags &= ~LOOKUP_LAST;
273 @@ -1564,7 +1647,9 @@
276 down(&dir->d_inode->i_sem);
277 + nd->flags |= LOOKUP_LAST;
278 path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
279 + nd->flags &= ~LOOKUP_LAST;
281 putname(nd->last.name);
283 --- linux-2.6.12.6.orig/fs/namespace.c
284 +++ linux-2.6.12.6/fs/namespace.c
286 INIT_LIST_HEAD(&mnt->mnt_mounts);
287 INIT_LIST_HEAD(&mnt->mnt_list);
288 INIT_LIST_HEAD(&mnt->mnt_fslink);
289 + INIT_LIST_HEAD(&mnt->mnt_lustre_list);
291 int size = strlen(name)+1;
292 char *newname = kmalloc(size, GFP_KERNEL);
295 static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
297 + memset(old_nd, 0, sizeof(*old_nd));
298 old_nd->dentry = mnt->mnt_mountpoint;
299 old_nd->mnt = mnt->mnt_parent;
300 mnt->mnt_parent = mnt;
303 struct super_block *sb = mnt->mnt_sb;
305 + spin_lock(&dcache_lock);
306 + list_del(&mnt->mnt_lustre_list);
307 + spin_unlock(&dcache_lock);
309 deactivate_super(sb);
315 + if (sb->s_op->umount_lustre)
316 + sb->s_op->umount_lustre(sb);
317 if( (flags&MNT_FORCE) && sb->s_op->umount_begin)
318 sb->s_op->umount_begin(sb);
322 if (!old_name || !*old_name)
324 + intent_init(&old_nd.intent, IT_LOOKUP);
325 err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
330 if (!old_name || !*old_name)
332 + intent_init(&old_nd.intent, IT_LOOKUP);
333 err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
336 @@ -1012,6 +1021,7 @@
340 + intent_init(&nd.intent, IT_LOOKUP);
342 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
343 flags &= ~MS_MGC_MSK;
344 --- linux-2.6.12.6.orig/fs/open.c
345 +++ linux-2.6.12.6/fs/open.c
346 @@ -215,12 +215,12 @@
348 struct inode * inode;
351 + intent_init(&nd.intent, IT_GETATTR);
353 if (length < 0) /* sorry, but loff_t says... */
356 - error = user_path_walk(path, &nd);
357 + error = user_path_walk_it(path, &nd);
360 inode = nd.dentry->d_inode;
362 int old_fsuid, old_fsgid;
363 kernel_cap_t old_cap;
365 + intent_init(&nd.intent, IT_GETATTR);
367 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
369 @@ -498,13 +499,14 @@
371 current->cap_effective = current->cap_permitted;
373 - res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
374 + res = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
376 res = permission(nd.dentry->d_inode, mode, &nd);
377 /* SuS v2 requires we report a read only fs too */
378 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
379 && !special_file(nd.dentry->d_inode->i_mode))
389 + intent_init(&nd.intent, IT_GETATTR);
391 - error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
392 + error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
400 + intent_init(&nd.intent, IT_GETATTR);
402 - error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
403 + error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
408 * for the internal routines (ie open_namei()/follow_link() etc). 00 is
411 -struct file *filp_open(const char * filename, int flags, int mode)
413 - int namei_flags, error;
414 - struct nameidata nd;
416 - namei_flags = flags;
417 - if ((namei_flags+1) & O_ACCMODE)
419 - if (namei_flags & O_TRUNC)
422 - error = open_namei(filename, namei_flags, mode, &nd);
424 - return dentry_open(nd.dentry, nd.mnt, flags);
426 - return ERR_PTR(error);
429 -EXPORT_SYMBOL(filp_open);
431 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
432 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags,
433 + struct lookup_intent *it)
440 f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
442 inode = dentry->d_inode;
443 if (f->f_mode & FMODE_WRITE) {
444 error = get_write_access(inode);
446 error = f->f_op->open(inode,f);
449 + intent_release(it);
451 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
457 + intent_release(it);
460 return ERR_PTR(error);
463 EXPORT_SYMBOL(dentry_open);
465 +struct file *filp_open(const char * filename, int flags, int mode)
467 + int namei_flags, error;
468 + struct file * temp_filp;
469 + struct nameidata nd;
470 + intent_init(&nd.intent, IT_OPEN);
472 + namei_flags = flags;
473 + if ((namei_flags+1) & O_ACCMODE)
475 + if (namei_flags & O_TRUNC)
478 + error = open_namei(filename, namei_flags, mode, &nd);
480 + temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
483 + return ERR_PTR(error);
487 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
489 + struct lookup_intent it;
490 + intent_init(&it, IT_LOOKUP);
492 + return dentry_open_it(dentry, mnt, flags, &it);
496 * Find an empty file descriptor entry, and mark it busy.
498 --- linux-2.6.12.6.orig/fs/stat.c
499 +++ linux-2.6.12.6/fs/stat.c
502 EXPORT_SYMBOL(generic_fillattr);
504 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
505 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
507 struct inode *inode = dentry->d_inode;
513 + if (inode->i_op->getattr_it)
514 + return inode->i_op->getattr_it(mnt, dentry, it, stat);
515 if (inode->i_op->getattr)
516 return inode->i_op->getattr(mnt, dentry, stat);
520 EXPORT_SYMBOL(vfs_getattr);
522 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
524 + return vfs_getattr_it(mnt, dentry, NULL, stat);
527 int vfs_stat(char __user *name, struct kstat *stat)
531 + intent_init(&nd.intent, IT_GETATTR);
533 - error = user_path_walk(name, &nd);
534 + error = user_path_walk_it(name, &nd);
536 - error = vfs_getattr(nd.mnt, nd.dentry, stat);
537 + error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
545 + intent_init(&nd.intent, IT_GETATTR);
547 - error = user_path_walk_link(name, &nd);
548 + error = user_path_walk_link_it(name, &nd);
550 - error = vfs_getattr(nd.mnt, nd.dentry, stat);
551 + error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
557 struct file *f = fget(fd);
559 + struct nameidata nd;
560 + intent_init(&nd.intent, IT_GETATTR);
563 - error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
564 + error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
565 + intent_release(&nd.intent);
569 --- linux-2.6.12.6.orig/fs/inode.c
570 +++ linux-2.6.12.6/fs/inode.c
572 inodes_stat.nr_unused--;
575 +EXPORT_SYMBOL(__iget);
577 * clear_inode - clear an inode
578 * @inode: inode to clear
579 --- linux-2.6.12.6.orig/include/linux/dcache.h
580 +++ linux-2.6.12.6/include/linux/dcache.h
584 #include <asm/atomic.h>
585 +#include <linux/string.h>
586 #include <linux/list.h>
587 #include <linux/spinlock.h>
588 #include <linux/cache.h>
590 const unsigned char *name;
593 +#include <linux/namei.h>
595 struct dentry_stat_t {
598 --- linux-2.6.12.6.orig/include/linux/fs.h
599 +++ linux-2.6.12.6/include/linux/fs.h
603 #define FMODE_WRITE 2
604 +#define FMODE_EXEC 4
606 /* Internal kernel extensions */
607 #define FMODE_LSEEK 4
609 #define ATTR_ATTR_FLAG 1024
610 #define ATTR_KILL_SUID 2048
611 #define ATTR_KILL_SGID 4096
612 +#define ATTR_RAW 8192 /* file system, not vfs will massage attrs */
613 +#define ATTR_FROM_OPEN 16384 /* called from open path, ie O_TRUNC */
616 * This is the Inode Attributes structure, used for notify_change(). It
618 struct block_device *i_bdev;
621 + void *i_filterdata;
626 spinlock_t f_ep_lock;
627 #endif /* #ifdef CONFIG_EPOLL */
628 struct address_space *f_mapping;
629 + struct lookup_intent *f_it;
631 extern spinlock_t files_lock;
632 #define file_list_lock() spin_lock(&files_lock);
634 void (*truncate) (struct inode *);
635 int (*permission) (struct inode *, int, struct nameidata *);
636 int (*setattr) (struct dentry *, struct iattr *);
637 + int (*setattr_raw) (struct inode *, struct iattr *);
638 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
639 + int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
640 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
641 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
642 ssize_t (*listxattr) (struct dentry *, char *, size_t);
643 @@ -1008,6 +1015,7 @@
644 int (*remount_fs) (struct super_block *, int *, char *);
645 void (*clear_inode) (struct inode *);
646 void (*umount_begin) (struct super_block *);
647 + void (*umount_lustre) (struct super_block *);
649 int (*show_options)(struct seq_file *, struct vfsmount *);
651 @@ -1210,6 +1218,7 @@
652 extern struct vfsmount *kern_mount(struct file_system_type *);
653 extern int may_umount_tree(struct vfsmount *);
654 extern int may_umount(struct vfsmount *);
655 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
656 extern long do_mount(char *, char *, char *, unsigned long, void *);
658 extern int vfs_statfs(struct super_block *, struct kstatfs *);
659 @@ -1262,6 +1271,7 @@
660 extern int do_truncate(struct dentry *, loff_t start);
661 extern struct file *filp_open(const char *, int, int);
662 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
663 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
664 extern int filp_close(struct file *, fl_owner_t id);
665 extern char * getname(const char __user *);
667 --- linux-2.6.12.6.orig/include/linux/namei.h
668 +++ linux-2.6.12.6/include/linux/namei.h
670 #define _LINUX_NAMEI_H
672 #include <linux/linkage.h>
673 +#include <linux/string.h>
678 -struct open_intent {
681 +/* intent opcodes */
683 +#define IT_CREAT (1<<1)
684 +#define IT_READDIR (1<<2)
685 +#define IT_GETATTR (1<<3)
686 +#define IT_LOOKUP (1<<4)
687 +#define IT_UNLINK (1<<5)
688 +#define IT_TRUNC (1<<6)
689 +#define IT_GETXATTR (1<<7)
691 +struct lustre_intent_data {
692 + int it_disposition;
694 + __u64 it_lock_handle;
699 +#define INTENT_MAGIC 0x19620323
700 +struct lookup_intent {
702 + void (*it_op_release)(struct lookup_intent *);
705 + int it_create_mode;
707 + struct lustre_intent_data lustre;
711 +static inline void intent_reset_fs_part(struct lookup_intent *it)
713 + memset(&it->d, 0, sizeof(it->d));
714 + it->it_magic = INTENT_MAGIC;
715 + it->it_op_release = NULL;
718 +static inline void intent_init(struct lookup_intent *it, int op)
720 + memset(it, 0, sizeof(*it));
721 + it->it_magic = INTENT_MAGIC;
725 enum { MAX_NESTED_LINKS = 5 };
730 char *saved_names[MAX_NESTED_LINKS + 1];
734 - struct open_intent open;
736 + struct lookup_intent intent;
741 #define LOOKUP_PARENT 16
742 #define LOOKUP_NOALT 32
743 #define LOOKUP_REVAL 64
744 +#define LOOKUP_LAST (0x1000)
745 +#define LOOKUP_LINK_NOTLAST (0x2000)
750 #define LOOKUP_ACCESS (0x0400)
752 extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
753 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
754 +#define user_path_walk_it(name,nd) \
755 + __user_walk_it(name, LOOKUP_FOLLOW, nd)
756 +#define user_path_walk_link_it(name,nd) \
757 + __user_walk_it(name, 0, nd)
758 +extern void intent_release(struct lookup_intent *);
759 #define user_path_walk(name,nd) \
760 __user_walk(name, LOOKUP_FOLLOW, nd)
761 #define user_path_walk_link(name,nd) \
764 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
765 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
767 extern int follow_down(struct vfsmount **, struct dentry **);
768 extern int follow_up(struct vfsmount **, struct dentry **);
770 --- linux-2.6.12.6.orig/include/linux/mount.h
771 +++ linux-2.6.12.6/include/linux/mount.h
773 struct list_head mnt_list;
774 struct list_head mnt_fslink; /* link in fs-specific expiry list */
775 struct namespace *mnt_namespace; /* containing namespace */
776 + struct list_head mnt_lustre_list; /* GNS mount list */
777 + unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */
780 static inline struct vfsmount *mntget(struct vfsmount *mnt)