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