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