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