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