Whamcloud - gitweb
merge b_devel into HEAD, which will become 0.7.3
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_intent_2.6.0-test1.patch
1  fs/exec.c              |   18 +++++++---
2  fs/namei.c             |   81 +++++++++++++++++++++++++++++++++++++++++++++----
3  fs/namespace.c         |    2 +
4  fs/open.c              |   64 +++++++++++++++++++++++++-------------
5  fs/stat.c              |   28 ++++++++++++----
6  fs/sysfs/inode.c       |    2 -
7  include/linux/dcache.h |    3 +
8  include/linux/fs.h     |    7 ++++
9  include/linux/namei.h  |   59 ++++++++++++++++++++++++++++++++---
10  kernel/ksyms.c         |    8 ++++
11  net/sunrpc/rpc_pipe.c  |    6 +--
12  net/unix/af_unix.c     |    2 -
13  12 files changed, 228 insertions(+), 52 deletions(-)
14
15 --- linux-2.6.0-test1/fs/sysfs/inode.c~vfs_intent_2.6.0-test1   2003-07-13 21:37:23.000000000 -0600
16 +++ linux-2.6.0-test1-braam/fs/sysfs/inode.c    2003-07-16 17:32:36.000000000 -0600
17 @@ -81,7 +81,7 @@ struct dentry * sysfs_get_dentry(struct 
18         qstr.name = name;
19         qstr.len = strlen(name);
20         qstr.hash = full_name_hash(name,qstr.len);
21 -       return lookup_hash(&qstr,parent);
22 +       return lookup_hash(&qstr,parent, NULL);
23  }
24  
25  void sysfs_hash_and_remove(struct dentry * dir, const char * name)
26 --- linux-2.6.0-test1/fs/exec.c~vfs_intent_2.6.0-test1  2003-07-16 17:19:46.000000000 -0600
27 +++ linux-2.6.0-test1-braam/fs/exec.c   2003-07-16 18:42:40.000000000 -0600
28 @@ -116,8 +116,11 @@ asmlinkage long sys_uselib(const char __
29         struct file * file;
30         struct nameidata nd;
31         int error;
32 +        intent_init(&nd.intent, IT_OPEN);
33 +  
34 +       error = user_path_walk_it(library, &nd);
35  
36 -       nd.intent.open.flags = O_RDONLY;
37 +       nd.intent.intent.open.flags = O_RDONLY;
38         error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
39         if (error)
40                 goto out;
41 @@ -130,7 +133,7 @@ asmlinkage long sys_uselib(const char __
42         if (error)
43                 goto exit;
44  
45 -       file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
46 +       file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
47         error = PTR_ERR(file);
48         if (IS_ERR(file))
49                 goto out;
50 @@ -457,8 +460,13 @@ static inline void free_arg_pages(struct
51  struct file *open_exec(const char *name)
52  {
53         struct nameidata nd;
54 -       int err = path_lookup(name, LOOKUP_FOLLOW, &nd);
55 -       struct file *file = ERR_PTR(err);
56 +       int err;
57 +       struct file *file;
58 +         
59 +        intent_init(&nd.intent, IT_OPEN);
60 +        nd.intent.intent.open.flags = O_RDONLY;
61 +        err = path_lookup(name, LOOKUP_FOLLOW, &nd);
62 +        file = ERR_PTR(err);
63  
64         if (!err) {
65                 struct inode *inode = nd.dentry->d_inode;
66 @@ -470,7 +478,7 @@ struct file *open_exec(const char *name)
67                                 err = -EACCES;
68                         file = ERR_PTR(err);
69                         if (!err) {
70 -                               file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
71 +                               file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
72                                 if (!IS_ERR(file)) {
73                                         err = deny_write_access(file);
74                                         if (err) {
75 --- linux-2.6.0-test1/fs/namei.c~vfs_intent_2.6.0-test1 2003-07-16 17:19:46.000000000 -0600
76 +++ linux-2.6.0-test1-braam/fs/namei.c  2003-07-16 18:37:11.000000000 -0600
77 @@ -263,8 +263,19 @@ int deny_write_access(struct file * file
78         return 0;
79  }
80  
81 +void intent_release(struct lookup_intent *it)
82 +{
83 +        if (!it) 
84 +                return;
85 +        if (it->it_magic != INTENT_MAGIC)
86 +                return;
87 +        if (it->it_op_release)
88 +                it->it_op_release(it);
89 +}
90 +
91  void path_release(struct nameidata *nd)
92  {
93 +        intent_release(&nd->intent);
94         dput(nd->dentry);
95         mntput(nd->mnt);
96  }
97 @@ -554,6 +565,32 @@ fail:
98         return PTR_ERR(dentry);
99  }
100  
101 +
102 +static int revalidate_special(struct nameidata *nd)
103 +{
104 +        struct dentry *dentry = nd->dentry;
105 +        int err, counter = 0;
106 +
107 +        if (!dentry->d_op || !dentry->d_op->d_revalidate)
108 +                return 0;
109 + revalidate_again:
110 +        if (!dentry->d_op->d_revalidate(dentry, nd)) {
111 +                struct dentry *new;
112 +                if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC,nd)))
113 +                        return err;
114 +                new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
115 +                d_invalidate(dentry);
116 +                dput(dentry);
117 +                dentry = new;
118 +                counter++;
119 +                if (counter < 10)
120 +                        goto revalidate_again;
121 +                printk("excessive revalidate_it loops\n");
122 +                return -ESTALE;
123 +        }
124 +        return 0;
125 +}
126 +
127  /*
128   * Name resolution.
129   *
130 @@ -654,7 +691,9 @@ int link_path_walk(const char * name, st
131  
132                 if (inode->i_op->follow_link) {
133                         mntget(next.mnt);
134 +                        nd->flags |= LOOKUP_LINK_NOTLAST;
135                         err = do_follow_link(next.dentry, nd);
136 +                        nd->flags &= ~LOOKUP_LINK_NOTLAST;
137                         dput(next.dentry);
138                         mntput(next.mnt);
139                         if (err)
140 @@ -693,6 +732,11 @@ last_component:
141                                 inode = nd->dentry->d_inode;
142                                 /* fallthrough */
143                         case 1:
144 +                                nd->flags |= LOOKUP_LAST;
145 +                                err = revalidate_special(nd);
146 +                                nd->flags &= ~LOOKUP_LAST;
147 +                                if (err)
148 +                                        break;
149                                 goto return_base;
150                 }
151                 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
152 @@ -700,7 +744,9 @@ last_component:
153                         if (err < 0)
154                                 break;
155                 }
156 +                nd->flags |= LOOKUP_LAST;
157                 err = do_lookup(nd, &this, &next);
158 +                nd->flags &= ~LOOKUP_LAST;
159                 if (err)
160                         break;
161                 follow_mount(&next.mnt, &next.dentry);
162 @@ -743,7 +789,7 @@ out_dput:
163                 dput(next.dentry);
164                 break;
165         }
166 -       path_release(nd);
167 +        path_release(nd);
168  return_err:
169         return err;
170  }
171 @@ -912,7 +958,7 @@ struct dentry * lookup_hash(struct qstr 
172  }
173  
174  /* SMP-safe */
175 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
176 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
177  {
178         unsigned long hash;
179         struct qstr this;
180 @@ -932,11 +978,16 @@ struct dentry * lookup_one_len(const cha
181         }
182         this.hash = end_name_hash(hash);
183  
184 -       return lookup_hash(&this, base);
185 +       return __lookup_hash(&this, base, nd);
186  access:
187         return ERR_PTR(-EACCES);
188  }
189  
190 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
191 +{
192 +        return lookup_one_len_it(name, base, len, NULL);
193 +}
194 +
195  /*
196   *     namei()
197   *
198 @@ -948,10 +999,11 @@ access:
199   * that namei follows links, while lnamei does not.
200   * SMP-safe
201   */
202 -int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
203 +int __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
204  {
205         char *tmp = getname(name);
206         int err = PTR_ERR(tmp);
207
208  
209         if (!IS_ERR(tmp)) {
210                 err = path_lookup(tmp, flags, nd);
211 @@ -960,6 +1012,12 @@ int __user_walk(const char __user *name,
212         return err;
213  }
214  
215 +int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
216 +{
217 +        intent_init(&nd->intent, IT_LOOKUP);
218 +        return __user_walk_it(name, flags, nd);
219 +}
220 +
221  /*
222   * It's inline, so penalty for filesystems that don't use sticky bit is
223   * minimal.
224 @@ -1232,8 +1290,8 @@ int open_namei(const char * pathname, in
225                 acc_mode |= MAY_APPEND;
226  
227         /* Fill in the open() intent data */
228 -       nd->intent.open.flags = flag;
229 -       nd->intent.open.create_mode = mode;
230 +       nd->intent.intent.open.flags = flag;
231 +       nd->intent.intent.open.create_mode = mode;
232  
233         /*
234          * The simplest case - just a plain lookup.
235 @@ -1249,6 +1307,7 @@ int open_namei(const char * pathname, in
236         /*
237          * Create - we need to know the parent.
238          */
239 +        nd->intent.it_op |= IT_CREAT;
240         error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
241         if (error)
242                 return error;
243 @@ -1265,7 +1324,9 @@ int open_namei(const char * pathname, in
244         dir = nd->dentry;
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;
250  
251  do_last:
252         error = PTR_ERR(dentry);
253 @@ -1370,7 +1431,9 @@ do_link:
254         }
255         dir = nd->dentry;
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);
261         goto do_last;
262  }
263 @@ -2143,7 +2206,9 @@ static inline int
264  __vfs_follow_link(struct nameidata *nd, const char *link)
265  {
266         int res = 0;
267 +        struct lookup_intent it = nd->intent;
268         char *name;
269 +
270         if (IS_ERR(link))
271                 goto fail;
272  
273 @@ -2153,6 +2218,10 @@ __vfs_follow_link(struct nameidata *nd, 
274                         /* weird __emul_prefix() stuff did it */
275                         goto out;
276         }
277 +
278 +        intent_init(&nd->intent, it.it_op);
279 +        nd->intent.intent.open.flags = it.intent.open.flags;
280 +        nd->intent.intent.open.create_mode = it.intent.open.create_mode;
281         res = link_path_walk(link, nd);
282  out:
283         if (current->link_count || res || nd->last_type!=LAST_NORM)
284 --- linux-2.6.0-test1/fs/namespace.c~vfs_intent_2.6.0-test1     2003-07-16 17:19:46.000000000 -0600
285 +++ linux-2.6.0-test1-braam/fs/namespace.c      2003-07-16 18:44:38.000000000 -0600
286 @@ -738,6 +738,7 @@ long do_mount(char * dev_name, char * di
287         int retval = 0;
288         int mnt_flags = 0;
289  
290 +        intent_init(&nd.intent, IT_LOOKUP);
291         /* Discard magic */
292         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
293                 flags &= ~MS_MGC_MSK;
294 @@ -947,6 +948,7 @@ void set_fs_pwd(struct fs_struct *fs, st
295                 mntput(old_pwdmnt);
296         }
297  }
298 +EXPORT_SYMBOL(set_fs_pwd);
299  
300  static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
301  {
302 --- linux-2.6.0-test1/fs/open.c~vfs_intent_2.6.0-test1  2003-07-13 21:29:30.000000000 -0600
303 +++ linux-2.6.0-test1-braam/fs/open.c   2003-07-16 18:39:48.000000000 -0600
304 @@ -200,7 +200,7 @@ static inline long do_sys_truncate(const
305         struct nameidata nd;
306         struct inode * inode;
307         int error;
308 -
309 +       intent_init(&nd.intent, IT_GETATTR);
310         error = -EINVAL;
311         if (length < 0) /* sorry, but loff_t says... */
312                 goto out;
313 @@ -443,6 +443,7 @@ asmlinkage long sys_access(const char __
314         int old_fsuid, old_fsgid;
315         kernel_cap_t old_cap;
316         int res;
317 +       intent_init(&nd.intent, IT_GETATTR);
318  
319         if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
320                 return -EINVAL;
321 @@ -474,6 +475,7 @@ asmlinkage long sys_access(const char __
322                 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
323                    && !special_file(nd.dentry->d_inode->i_mode))
324                         res = -EROFS;
325 +                               
326                 path_release(&nd);
327         }
328  
329 @@ -488,6 +490,7 @@ asmlinkage long sys_chdir(const char __u
330  {
331         struct nameidata nd;
332         int error;
333 +       intent_init(&nd.intent, IT_GETATTR);
334  
335         error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
336         if (error)
337 @@ -539,6 +542,7 @@ asmlinkage long sys_chroot(const char __
338  {
339         struct nameidata nd;
340         int error;
341 +       intent_init(&nd.intent, IT_GETATTR);
342  
343         error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
344         if (error)
345 @@ -611,7 +615,7 @@ asmlinkage long sys_chmod(const char __u
346         error = -EROFS;
347         if (IS_RDONLY(inode))
348                 goto dput_and_out;
349 -
350 +       
351         error = -EPERM;
352         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
353                 goto dput_and_out;
354 @@ -719,25 +723,8 @@ asmlinkage long sys_fchown(unsigned int 
355   * for the internal routines (ie open_namei()/follow_link() etc). 00 is
356   * used by symlinks.
357   */
358 -struct file *filp_open(const char * filename, int flags, int mode)
359 -{
360 -       int namei_flags, error;
361 -       struct nameidata nd;
362 -
363 -       namei_flags = flags;
364 -       if ((namei_flags+1) & O_ACCMODE)
365 -               namei_flags++;
366 -       if (namei_flags & O_TRUNC)
367 -               namei_flags |= 2;
368 -
369 -       error = open_namei(filename, namei_flags, mode, &nd);
370 -       if (!error)
371 -               return dentry_open(nd.dentry, nd.mnt, flags);
372 -
373 -       return ERR_PTR(error);
374 -}
375 -
376 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
377 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, 
378 +                            struct lookup_intent *it)
379  {
380         struct file * f;
381         struct inode *inode;
382 @@ -749,6 +736,7 @@ struct file *dentry_open(struct dentry *
383                 goto cleanup_dentry;
384         f->f_flags = flags;
385         f->f_mode = (flags+1) & O_ACCMODE;
386 +        f->f_it = it;
387         inode = dentry->d_inode;
388         if (f->f_mode & FMODE_WRITE) {
389                 error = get_write_access(inode);
390 @@ -767,6 +755,7 @@ struct file *dentry_open(struct dentry *
391                 error = f->f_op->open(inode,f);
392                 if (error)
393                         goto cleanup_all;
394 +                intent_release(it);
395         }
396         f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
397  
398 @@ -778,7 +767,7 @@ struct file *dentry_open(struct dentry *
399                                 f = ERR_PTR(-EINVAL);
400                 }
401         }
402 -
403 +        
404         return f;
405  
406  cleanup_all:
407 @@ -791,11 +780,42 @@ cleanup_all:
408  cleanup_file:
409         put_filp(f);
410  cleanup_dentry:
411 +        intent_release(it);
412         dput(dentry);
413         mntput(mnt);
414         return ERR_PTR(error);
415  }
416  
417 +struct file *filp_open(const char * filename, int flags, int mode)
418 +{
419 +       int namei_flags, error;
420 +       struct file * temp_filp;
421 +        struct nameidata nd;
422 +       intent_init(&nd.intent, IT_OPEN);
423 +
424 +       namei_flags = flags;
425 +       if ((namei_flags+1) & O_ACCMODE)
426 +               namei_flags++;
427 +       if (namei_flags & O_TRUNC)
428 +               namei_flags |= 2;
429 +
430 +       error = open_namei(filename, namei_flags, mode, &nd);
431 +       if (!error) {
432 +               temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
433 +               return temp_filp;
434 +       }       
435 +       return ERR_PTR(error);
436 +}
437 +
438 +
439 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
440 +{
441 +        struct lookup_intent it;
442 +       intent_init(&it, IT_LOOKUP);
443 +
444 +        return dentry_open_it(dentry, mnt, flags, &it);
445 +}
446 +
447  /*
448   * Find an empty file descriptor entry, and mark it busy.
449   */
450 --- linux-2.6.0-test1/fs/stat.c~vfs_intent_2.6.0-test1  2003-07-13 21:31:21.000000000 -0600
451 +++ linux-2.6.0-test1-braam/fs/stat.c   2003-07-16 18:44:27.000000000 -0600
452 @@ -33,7 +33,7 @@ void generic_fillattr(struct inode *inod
453         stat->blksize = inode->i_blksize;
454  }
455  
456 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
457 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
458  {
459         struct inode *inode = dentry->d_inode;
460         int retval;
461 @@ -44,6 +44,8 @@ int vfs_getattr(struct vfsmount *mnt, st
462  
463         if (inode->i_op->getattr)
464                 return inode->i_op->getattr(mnt, dentry, stat);
465 +       if (inode->i_op->getattr_it)
466 +               return inode->i_op->getattr_it(mnt, dentry, it, stat);
467  
468         generic_fillattr(inode, stat);
469         if (!stat->blksize) {
470 @@ -56,15 +58,21 @@ int vfs_getattr(struct vfsmount *mnt, st
471         return 0;
472  }
473  
474 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
475 +{
476 +        return vfs_getattr_it(mnt, dentry, NULL, stat);
477 +}
478 +
479  int vfs_stat(char __user *name, struct kstat *stat)
480  {
481         struct nameidata nd;
482         int error;
483 +       intent_init(&nd.intent, IT_GETATTR);
484  
485 -       error = user_path_walk(name, &nd);
486 +       error = user_path_walk_it(name, &nd);
487         if (!error) {
488 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
489 -               path_release(&nd);
490 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
491 +                path_release(&nd);
492         }
493         return error;
494  }
495 @@ -73,11 +81,12 @@ int vfs_lstat(char __user *name, struct 
496  {
497         struct nameidata nd;
498         int error;
499 +       intent_init(&nd.intent, IT_GETATTR);
500  
501 -       error = user_path_walk_link(name, &nd);
502 +       error = user_path_walk_link_it(name, &nd);
503         if (!error) {
504 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
505 -               path_release(&nd);
506 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
507 +                path_release(&nd);
508         }
509         return error;
510  }
511 @@ -86,9 +95,12 @@ int vfs_fstat(unsigned int fd, struct ks
512  {
513         struct file *f = fget(fd);
514         int error = -EBADF;
515 +        struct nameidata nd;
516 +       intent_init(&nd.intent, IT_GETATTR);
517  
518         if (f) {
519 -               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
520 +               error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
521 +                intent_release(&nd.intent);
522                 fput(f);
523         }
524         return error;
525 --- linux-2.6.0-test1/include/linux/dcache.h~vfs_intent_2.6.0-test1     2003-07-13 21:39:22.000000000 -0600
526 +++ linux-2.6.0-test1-braam/include/linux/dcache.h      2003-07-16 17:49:49.000000000 -0600
527 @@ -4,6 +4,7 @@
528  #ifdef __KERNEL__
529  
530  #include <asm/atomic.h>
531 +#include <linux/string.h>
532  #include <linux/list.h>
533  #include <linux/spinlock.h>
534  #include <linux/cache.h>
535 @@ -35,6 +36,8 @@ struct qstr {
536         char name_str[0];
537  };
538  
539 +#include <linux/namei.h>
540 +
541  struct dentry_stat_t {
542         int nr_dentry;
543         int nr_unused;
544 --- linux-2.6.0-test1/include/linux/fs.h~vfs_intent_2.6.0-test1 2003-07-16 17:19:46.000000000 -0600
545 +++ linux-2.6.0-test1-braam/include/linux/fs.h  2003-07-16 17:32:36.000000000 -0600
546 @@ -237,6 +237,8 @@ typedef int (get_blocks_t)(struct inode 
547  #define ATTR_ATTR_FLAG 1024
548  #define ATTR_KILL_SUID 2048
549  #define ATTR_KILL_SGID 4096
550 +#define ATTR_RAW               8192    /* file system, not vfs will massage attrs */
551 +#define ATTR_FROM_OPEN         16384    /* called from open path, ie O_TRUNC */
552  
553  /*
554   * This is the Inode Attributes structure, used for notify_change().  It
555 @@ -511,6 +513,7 @@ struct file {
556         /* Used by fs/eventpoll.c to link all the hooks to this file */
557         struct list_head        f_ep_links;
558         spinlock_t              f_ep_lock;
559 +        struct lookup_intent    *f_it;
560  };
561  extern spinlock_t files_lock;
562  #define file_list_lock() spin_lock(&files_lock);
563 @@ -816,7 +819,9 @@ struct inode_operations {
564         void (*truncate) (struct inode *);
565         int (*permission) (struct inode *, int, struct nameidata *);
566         int (*setattr) (struct dentry *, struct iattr *);
567 +       int (*setattr_raw) (struct inode *, struct iattr *);
568         int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
569 +       int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
570         int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
571         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
572         ssize_t (*listxattr) (struct dentry *, char *, size_t);
573 @@ -1029,6 +1034,7 @@ extern int register_filesystem(struct fi
574  extern int unregister_filesystem(struct file_system_type *);
575  extern struct vfsmount *kern_mount(struct file_system_type *);
576  extern int may_umount(struct vfsmount *);
577 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
578  extern long do_mount(char *, char *, char *, unsigned long, void *);
579  
580  extern int vfs_statfs(struct super_block *, struct kstatfs *);
581 @@ -1096,6 +1102,7 @@ extern int do_truncate(struct dentry *, 
582  
583  extern struct file *filp_open(const char *, int, int);
584  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
585 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
586  extern int filp_close(struct file *, fl_owner_t id);
587  extern char * getname(const char __user *);
588  
589 --- linux-2.6.0-test1/include/linux/namei.h~vfs_intent_2.6.0-test1      2003-07-13 21:32:39.000000000 -0600
590 +++ linux-2.6.0-test1-braam/include/linux/namei.h       2003-07-16 18:38:10.000000000 -0600
591 @@ -2,25 +2,64 @@
592  #define _LINUX_NAMEI_H
593  
594  #include <linux/linkage.h>
595 +#include <linux/string.h>
596  
597  struct vfsmount;
598 +struct nameidata;
599 +
600 +/* intent opcodes */
601 +#define IT_OPEN     (1)
602 +#define IT_CREAT    (1<<1)
603 +#define IT_READDIR  (1<<2)
604 +#define IT_GETATTR  (1<<3)
605 +#define IT_LOOKUP   (1<<4)
606 +#define IT_UNLINK   (1<<5)
607 +#define IT_TRUNC    (1<<6)
608 +#define IT_GETXATTR (1<<7)
609  
610  struct open_intent {
611         int     flags;
612         int     create_mode;
613  };
614  
615 +struct lustre_intent_data {
616 +        int it_mode;
617 +        int it_flags;
618 +        int it_disposition;
619 +        int it_status;
620 +        struct iattr *it_iattr;
621 +        __u64 it_lock_handle[2];
622 +        int it_lock_mode;
623 +        void *it_data;
624 +};
625 +
626 +#define INTENT_MAGIC 0x19620323
627 +struct lookup_intent {
628 +        int it_magic;
629 +        void (*it_op_release)(struct lookup_intent *);
630 +        int it_op;
631 +       union {
632 +               struct open_intent open;
633 +       } intent;
634 +        union {
635 +                struct lustre_intent_data lustre;
636 +        } fsdata;
637 +};
638 +
639 +static inline void intent_init(struct lookup_intent *it, int op)
640 +{
641 +        memset(it, 0, sizeof(*it));
642 +        it->it_magic = INTENT_MAGIC;
643 +        it->it_op = op;
644 +}
645 +
646  struct nameidata {
647         struct dentry   *dentry;
648         struct vfsmount *mnt;
649         struct qstr     last;
650         unsigned int    flags;
651         int             last_type;
652 -
653 -       /* Intent data */
654 -       union {
655 -               struct open_intent open;
656 -       } intent;
657 +        struct lookup_intent intent;
658  };
659  
660  /*
661 @@ -41,6 +80,9 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
662  #define LOOKUP_CONTINUE                 4
663  #define LOOKUP_PARENT          16
664  #define LOOKUP_NOALT           32
665 +#define LOOKUP_LAST             (1<<6)
666 +#define LOOKUP_LINK_NOTLAST     (1<<7)
667 +
668  /*
669   * Intent data
670   */
671 @@ -49,6 +91,12 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
672  #define LOOKUP_ACCESS          (0x0400)
673  
674  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
675 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
676 +#define user_path_walk_it(name,nd) \
677 +       __user_walk_it(name, LOOKUP_FOLLOW, nd)
678 +#define user_path_walk_link_it(name,nd) \
679 +       __user_walk_it(name, 0, nd)
680 +extern void intent_release(struct lookup_intent *);
681  #define user_path_walk(name,nd) \
682         __user_walk(name, LOOKUP_FOLLOW, nd)
683  #define user_path_walk_link(name,nd) \
684 @@ -60,7 +108,6 @@ extern void path_release(struct nameidat
685  
686  extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
687  extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
688 -
689  extern int follow_down(struct vfsmount **, struct dentry **);
690  extern int follow_up(struct vfsmount **, struct dentry **);
691  
692 --- linux-2.6.0-test1/kernel/ksyms.c~vfs_intent_2.6.0-test1     2003-07-16 17:20:31.000000000 -0600
693 +++ linux-2.6.0-test1-braam/kernel/ksyms.c      2003-07-16 17:32:36.000000000 -0600
694 @@ -383,6 +383,7 @@ EXPORT_SYMBOL(unregister_filesystem);
695  EXPORT_SYMBOL(kern_mount);
696  EXPORT_SYMBOL(__mntput);
697  EXPORT_SYMBOL(may_umount);
698 +EXPORT_SYMBOL(reparent_to_init);
699  
700  /* executable format registration */
701  EXPORT_SYMBOL(register_binfmt);
702 @@ -412,6 +413,12 @@ EXPORT_SYMBOL(del_timer);
703  EXPORT_SYMBOL(request_irq);
704  EXPORT_SYMBOL(free_irq);
705  
706 +/* lustre */
707 +EXPORT_SYMBOL(do_kern_mount);
708 +EXPORT_SYMBOL(exit_files);
709 +//EXPORT_SYMBOL(kmem_cache_validate);
710 +
711 +
712  /* waitqueue handling */
713  EXPORT_SYMBOL(add_wait_queue);
714  EXPORT_SYMBOL(add_wait_queue_exclusive);
715 @@ -559,6 +566,7 @@ EXPORT_SYMBOL(sys_tz);
716  EXPORT_SYMBOL(file_fsync);
717  EXPORT_SYMBOL(fsync_buffers_list);
718  EXPORT_SYMBOL(clear_inode);
719 +EXPORT_SYMBOL(__iget);
720  EXPORT_SYMBOL(init_special_inode);
721  EXPORT_SYMBOL(new_inode);
722  EXPORT_SYMBOL(__insert_inode_hash);
723 --- linux-2.6.0-test1/net/unix/af_unix.c~vfs_intent_2.6.0-test1 2003-07-13 21:35:16.000000000 -0600
724 +++ linux-2.6.0-test1-braam/net/unix/af_unix.c  2003-07-16 17:32:36.000000000 -0600
725 @@ -702,7 +702,7 @@ static int unix_bind(struct socket *sock
726                 /*
727                  * Do the final lookup.
728                  */
729 -               dentry = lookup_hash(&nd.last, nd.dentry);
730 +               dentry = lookup_hash(&nd.last, nd.dentry, NULL);
731                 err = PTR_ERR(dentry);
732                 if (IS_ERR(dentry))
733                         goto out_mknod_unlock;
734 --- linux-2.6.0-test1/net/sunrpc/rpc_pipe.c~vfs_intent_2.6.0-test1      2003-07-13 21:32:34.000000000 -0600
735 +++ linux-2.6.0-test1-braam/net/sunrpc/rpc_pipe.c       2003-07-16 17:32:36.000000000 -0600
736 @@ -598,7 +598,7 @@ rpc_lookup_negative(char *path, struct n
737                 return ERR_PTR(error);
738         dir = nd->dentry->d_inode;
739         down(&dir->i_sem);
740 -       dentry = lookup_hash(&nd->last, nd->dentry);
741 +       dentry = lookup_hash(&nd->last, nd->dentry, NULL);
742         if (IS_ERR(dentry))
743                 goto out_err;
744         if (dentry->d_inode) {
745 @@ -660,7 +660,7 @@ rpc_rmdir(char *path)
746                 return error;
747         dir = nd.dentry->d_inode;
748         down(&dir->i_sem);
749 -       dentry = lookup_hash(&nd.last, nd.dentry);
750 +       dentry = lookup_hash(&nd.last, nd.dentry, NULL);
751         if (IS_ERR(dentry)) {
752                 error = PTR_ERR(dentry);
753                 goto out_release;
754 @@ -721,7 +721,7 @@ rpc_unlink(char *path)
755                 return error;
756         dir = nd.dentry->d_inode;
757         down(&dir->i_sem);
758 -       dentry = lookup_hash(&nd.last, nd.dentry);
759 +       dentry = lookup_hash(&nd.last, nd.dentry, NULL);
760         if (IS_ERR(dentry)) {
761                 error = PTR_ERR(dentry);
762                 goto out_release;
763
764 _