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