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