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