Whamcloud - gitweb
22029f1e92e471e0ad9625c7a055b821782a8ae8
[fs/lustre-release.git] / lustre / patches / patch-2.4.18-14
1 --- linux-2.4.18-17.8.0-uml-pristine/include/linux/lustre_version.h     Wed Dec 31 19:00:00 1969
2 +++ linux-2.4.18-17.8.0-uml/include/linux/lustre_version.h      Wed Nov  6 02:34:14 2002
3 @@ -0,0 +1 @@
4 +#define LUSTRE_KERNEL_VERSION 2
5 --- linux-2.4.18-17.8.0-uml-pristine/arch/ia64/mm/init.c        2002-10-19 11:44:08.000000000 -0600
6 +++ linux-2.4.18-17.8.0-uml/arch/ia64/mm/init.c 2002-10-19 11:44:51.000000000 -0600
7 @@ -37,6 +37,12 @@
8  
9  static unsigned long totalram_pages;
10  
11 +struct page *check_get_page(unsigned long kaddr)
12 +{
13 +#warning FIXME: Lustre team, is this solid?
14 +       return virt_to_page(kaddr);
15 +}
16 +
17  int
18  do_check_pgt_cache (int low, int high)
19  {
20 --- linux-2.4.18-17.8.0-uml-pristine/arch/i386/mm/init.c        2002-10-19 11:44:04.000000000 -0600
21 +++ linux-2.4.18-17.8.0-uml/arch/i386/mm/init.c 2002-10-19 11:44:51.000000000 -0600
22 @@ -43,6 +43,12 @@
23  static unsigned long totalram_pages;
24  static unsigned long totalhigh_pages;
25  
26 +struct page *check_get_page(unsigned long kaddr)
27 +{
28 +#warning FIXME: Lustre team, is this solid?
29 +       return virt_to_page(kaddr);
30 +}
31 +
32  int do_check_pgt_cache(int low, int high)
33  {
34         int freed = 0;
35 --- linux-2.4.18-17.8.0-uml-pristine/drivers/block/blkpg.c      2002-10-19 11:43:55.000000000 -0600
36 +++ linux-2.4.18-17.8.0-uml/drivers/block/blkpg.c       2002-10-19 11:44:51.000000000 -0600
37 @@ -297,3 +297,38 @@
38  }
39  
40  EXPORT_SYMBOL(blk_ioctl);
41 +
42 +#define NUM_DEV_NO_WRITE 16
43 +static int dev_no_write[NUM_DEV_NO_WRITE];
44 +
45 +/*
46 + * Debug code for turning block devices "read-only" (will discard writes
47 + * silently).  This is for filesystem crash/recovery testing.
48 + */
49 +void dev_set_rdonly(kdev_t dev, int no_write)
50 +{
51 +       if (dev) {
52 +               printk(KERN_WARNING "Turning device %s read-only\n",
53 +                      bdevname(dev));
54 +               dev_no_write[no_write] = 0xdead0000 + dev;
55 +       }
56 +}
57 +
58 +int dev_check_rdonly(kdev_t dev) {
59 +       int i;
60 +
61 +       for (i = 0; i < NUM_DEV_NO_WRITE; i++) {
62 +               if ((dev_no_write[i] & 0xffff0000) == 0xdead0000 &&
63 +                   dev == (dev_no_write[i] & 0xffff))
64 +                       return 1;
65 +       }
66 +       return 0;
67 +}
68 +
69 +void dev_clear_rdonly(int no_write) {
70 +       dev_no_write[no_write] = 0;
71 +}
72 +
73 +EXPORT_SYMBOL(dev_set_rdonly);
74 +EXPORT_SYMBOL(dev_check_rdonly);
75 +EXPORT_SYMBOL(dev_clear_rdonly);
76 --- linux-2.4.18-17.8.0-uml-pristine/drivers/block/loop.c       2002-10-19 11:43:55.000000000 -0600
77 +++ linux-2.4.18-17.8.0-uml/drivers/block/loop.c        2002-10-19 11:44:51.000000000 -0600
78 @@ -491,6 +491,11 @@
79         spin_unlock_irq(&lo->lo_lock);
80  
81         if (rw == WRITE) {
82 +#ifdef CONFIG_DEV_RDONLY
83 +               if (dev_check_rdonly(rbh->b_rdev))
84 +                       goto err;
85 +#endif
86 +
87                 if (lo->lo_flags & LO_FLAGS_READ_ONLY)
88                         goto err;
89         } else if (rw == READA) {
90 --- linux-2.4.18-17.8.0-uml-pristine/drivers/ide/ide-disk.c     2002-10-19 11:43:58.000000000 -0600
91 +++ linux-2.4.18-17.8.0-uml/drivers/ide/ide-disk.c      2002-10-19 11:44:51.000000000 -0600
92 @@ -557,6 +557,12 @@
93   */
94  static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block)
95  {
96 +#ifdef CONFIG_DEV_RDONLY
97 +       if (rq->cmd == WRITE && dev_check_rdonly(rq->rq_dev)) {
98 +               ide_end_request(1, HWGROUP(drive));
99 +               return ide_stopped;
100 +       }
101 +#endif
102         if (IDE_CONTROL_REG)
103                 OUT_BYTE(drive->ctl,IDE_CONTROL_REG);
104  
105 --- linux-2.4.18-17.8.0-uml-pristine/fs/ext3/Makefile   2002-10-19 11:43:53.000000000 -0600
106 +++ linux-2.4.18-17.8.0-uml/fs/ext3/Makefile    2002-10-19 11:44:51.000000000 -0600
107 @@ -9,6 +9,8 @@
108  
109  O_TARGET := ext3.o
110  
111 +export-objs := super.o
112 +
113  obj-y    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
114                 ioctl.o namei.o super.o symlink.o
115  obj-m    := $(O_TARGET)
116 --- linux-2.4.18-17.8.0-uml-pristine/fs/ext3/super.c    2002-10-19 11:43:53.000000000 -0600
117 +++ linux-2.4.18-17.8.0-uml/fs/ext3/super.c     2002-10-19 11:44:51.000000000 -0600
118 @@ -1746,7 +1746,7 @@
119         unregister_filesystem(&ext3_fs_type);
120  }
121  
122 -EXPORT_NO_SYMBOLS;
123 +EXPORT_SYMBOL(ext3_bread);
124  
125  MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
126  MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
127 --- linux-2.4.18-17.8.0-uml-pristine/include/linux/slab.h       2002-10-19 11:43:54.000000000 -0600
128 +++ linux-2.4.18-17.8.0-uml/include/linux/slab.h        2002-11-02 00:49:24.000000000 -0700
129 @@ -57,6 +57,7 @@
130  extern int kmem_cache_shrink(kmem_cache_t *);
131  extern void *kmem_cache_alloc(kmem_cache_t *, int);
132  extern void kmem_cache_free(kmem_cache_t *, void *);
133 +extern int kmem_cache_validate(kmem_cache_t *cachep, void *objp);
134  
135  extern void *kmalloc(size_t, int);
136  extern void kfree(const void *);
137 --- linux-2.4.18-17.8.0-uml-pristine/kernel/ksyms.c     2002-10-19 11:43:53.000000000 -0600
138 +++ linux-2.4.18-17.8.0-uml/kernel/ksyms.c      2002-11-02 01:09:34.000000000 -0700
139 @@ -292,6 +292,7 @@
140  EXPORT_SYMBOL(set_page_dirty);
141  EXPORT_SYMBOL(vfs_readlink);
142  EXPORT_SYMBOL(vfs_follow_link);
143 +EXPORT_SYMBOL(vfs_follow_link_it);
144  EXPORT_SYMBOL(page_readlink);
145  EXPORT_SYMBOL(page_follow_link);
146  EXPORT_SYMBOL(page_symlink_inode_operations);
147 @@ -306,6 +307,12 @@
148  EXPORT_SYMBOL_GPL(nr_free_pages);
149  EXPORT_SYMBOL_GPL(page_cache_size);
150  
151 +/* lustre */
152 +EXPORT_SYMBOL(panic_notifier_list);
153 +EXPORT_SYMBOL(pagecache_lock_cacheline);
154 +EXPORT_SYMBOL(do_kern_mount);
155 +EXPORT_SYMBOL(kmem_cache_validate);
156 +
157  /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */
158  EXPORT_SYMBOL(default_llseek);
159  EXPORT_SYMBOL(dentry_open);
160 --- linux-2.4.18-17.8.0-uml-pristine/include/linux/dcache.h     2002-10-19 11:43:54.000000000 -0600
161 +++ linux-2.4.18-17.8.0-uml/include/linux/dcache.h      2002-11-02 00:49:24.000000000 -0700
162 @@ -6,6 +6,34 @@
163  #include <asm/atomic.h>
164  #include <linux/mount.h>
165  
166 +#define IT_OPEN  (1)
167 +#define IT_CREAT  (1<<1)
168 +#define IT_MKDIR  (1<<2)
169 +#define IT_LINK  (1<<3)
170 +#define IT_LINK2  (1<<4)
171 +#define IT_SYMLINK  (1<<5)
172 +#define IT_UNLINK  (1<<6)
173 +#define IT_RMDIR  (1<<7)
174 +#define IT_RENAME  (1<<8)
175 +#define IT_RENAME2  (1<<9)
176 +#define IT_READDIR  (1<<10)
177 +#define IT_GETATTR  (1<<11)
178 +#define IT_SETATTR  (1<<12)
179 +#define IT_READLINK  (1<<13)
180 +#define IT_MKNOD  (1<<14)
181 +#define IT_LOOKUP  (1<<15)
182 +
183 +struct lookup_intent {
184 +       int it_op;
185 +       int it_mode;
186 +       int it_disposition;
187 +       int it_status;
188 +       struct iattr *it_iattr;
189 +       __u64 it_lock_handle[2];
190 +       int it_lock_mode;
191 +       void *it_data;
192 +};
193 +
194  /*
195   * linux/include/linux/dcache.h
196   *
197 @@ -78,6 +106,7 @@
198         unsigned long d_time;           /* used by d_revalidate */
199         struct dentry_operations  *d_op;
200         struct super_block * d_sb;      /* The root of the dentry tree */
201 +       struct lookup_intent *d_it;
202         unsigned long d_vfs_flags;
203         void * d_fsdata;                /* fs-specific data */
204         void * d_extra_attributes;      /* TUX-specific data */
205 @@ -91,6 +120,8 @@
206         int (*d_delete)(struct dentry *);
207         void (*d_release)(struct dentry *);
208         void (*d_iput)(struct dentry *, struct inode *);
209 +       int (*d_revalidate2)(struct dentry *, int, struct lookup_intent *);
210 +       void (*d_intent_release)(struct dentry *, struct lookup_intent *);
211  };
212  
213  /* the dentry parameter passed to d_hash and d_compare is the parent
214 --- linux-2.4.18-17.8.0-uml-pristine/include/linux/fs.h 2002-10-19 11:43:54.000000000 -0600
215 +++ linux-2.4.18-17.8.0-uml/include/linux/fs.h  2002-11-02 00:49:24.000000000 -0700
216 @@ -576,6 +576,7 @@
217  
218         /* needed for tty driver, and maybe others */
219         void                    *private_data;
220 +       struct lookup_intent    *f_intent;
221  
222         /* preallocated helper kiobuf to speedup O_DIRECT */
223         struct kiobuf           *f_iobuf;
224 @@ -836,7 +837,9 @@
225  extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
226  extern int vfs_rmdir(struct inode *, struct dentry *);
227  extern int vfs_unlink(struct inode *, struct dentry *);
228 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
229 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
230 +               struct inode *new_dir, struct dentry *new_dentry,
231 +               struct lookup_intent *it);
232  
233  /*
234   * File types
235 @@ -897,6 +900,7 @@
236  struct inode_operations {
237         int (*create) (struct inode *,struct dentry *,int);
238         struct dentry * (*lookup) (struct inode *,struct dentry *);
239 +       struct dentry * (*lookup2) (struct inode *,struct dentry *, struct lookup_intent *);
240         int (*link) (struct dentry *,struct inode *,struct dentry *);
241         int (*unlink) (struct inode *,struct dentry *);
242         int (*symlink) (struct inode *,struct dentry *,const char *);
243 @@ -907,6 +911,8 @@
244                         struct inode *, struct dentry *);
245         int (*readlink) (struct dentry *, char *,int);
246         int (*follow_link) (struct dentry *, struct nameidata *);
247 +       int (*follow_link2) (struct dentry *, struct nameidata *, 
248 +                            struct lookup_intent *it);
249         void (*truncate) (struct inode *);
250         int (*permission) (struct inode *, int);
251         int (*revalidate) (struct dentry *);
252 @@ -1046,6 +1052,7 @@
253  extern struct vfsmount *kern_mount(struct file_system_type *);
254  extern int may_umount(struct vfsmount *);
255  extern long do_mount(char *, char *, char *, unsigned long, void *);
256 +struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
257  extern void umount_tree(struct vfsmount *);
258  
259  #define kern_umount mntput
260 @@ -1380,6 +1387,7 @@
261  extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
262  
263  extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
264 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
265  extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
266  extern int FASTCALL(path_walk(const char *, struct nameidata *));
267  extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
268 @@ -1391,6 +1399,8 @@
269  extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
270  #define user_path_walk(name,nd)         __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
271  #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
272 +#define user_path_walk_it(name,nd,it)  __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
273 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
274  
275  extern void inode_init_once(struct inode *);
276  extern void iput(struct inode *);
277 @@ -1491,6 +1501,8 @@
278  
279  extern int vfs_readlink(struct dentry *, char *, int, const char *);
280  extern int vfs_follow_link(struct nameidata *, const char *);
281 +extern int vfs_follow_link_it(struct nameidata *, const char *, 
282 +                              struct lookup_intent *it);
283  extern int page_readlink(struct dentry *, char *, int);
284  extern int page_follow_link(struct dentry *, struct nameidata *);
285  extern struct inode_operations page_symlink_inode_operations;
286 --- linux-2.4.18-17.8.0-uml-pristine/fs/dcache.c        2002-10-19 11:43:53.000000000 -0600
287 +++ linux-2.4.18-17.8.0-uml/fs/dcache.c 2002-10-31 13:10:34.000000000 -0700
288 @@ -150,6 +150,8 @@
289  unhash_it:
290         list_del_init(&dentry->d_hash);
291  
292 +
293 +
294  kill_it: {
295                 struct dentry *parent;
296                 list_del(&dentry->d_child);
297 @@ -645,6 +647,7 @@
298         dentry->d_fsdata = NULL;
299         dentry->d_extra_attributes = NULL;
300         dentry->d_mounted = 0;
301 +       dentry->d_it = NULL;
302         INIT_LIST_HEAD(&dentry->d_hash);
303         INIT_LIST_HEAD(&dentry->d_lru);
304         INIT_LIST_HEAD(&dentry->d_subdirs);
305 --- linux-2.4.18-17.8.0-uml-pristine/fs/nfsd/vfs.c      2002-10-19 11:43:53.000000000 -0600
306 +++ linux-2.4.18-17.8.0-uml/fs/nfsd/vfs.c       2002-10-19 11:44:51.000000000 -0600
307 @@ -1298,7 +1298,7 @@
308                         err = nfserr_perm;
309         } else
310  #endif
311 -       err = vfs_rename(fdir, odentry, tdir, ndentry);
312 +       err = vfs_rename(fdir, odentry, tdir, ndentry, NULL);
313         unlock_kernel();
314         if (!err && EX_ISSYNC(tfhp->fh_export)) {
315                 nfsd_sync_dir(tdentry);
316 --- linux-2.4.18-17.8.0-uml-pristine/fs/namei.c 2002-10-19 11:43:53.000000000 -0600
317 +++ linux-2.4.18-17.8.0-uml/fs/namei.c  2002-11-02 01:02:26.000000000 -0700
318 @@ -1,3 +1,6 @@
319 +
320 +
321 +
322  /*
323   *  linux/fs/namei.c
324   *
325 @@ -94,6 +97,14 @@
326   * XEmacs seems to be relying on it...
327   */
328  
329 +void intent_release(struct dentry *de, struct lookup_intent *it)
330 +{
331 +       if (de->d_op && de->d_op->d_intent_release)
332 +               de->d_op->d_intent_release(de, it);
333 +       de->d_it = NULL;
334 +}
335 +
336 +
337  /* In order to reduce some races, while at the same time doing additional
338   * checking and hopefully speeding things up, we copy filenames to the
339   * kernel data space before using them..
340 @@ -260,10 +271,19 @@
341   * Internal lookup() using the new generic dcache.
342   * SMP-safe
343   */
344 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
345 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
346 +                                   int flags, struct lookup_intent *it)
347  {
348         struct dentry * dentry = d_lookup(parent, name);
349  
350 +       if (dentry && dentry->d_op && dentry->d_op->d_revalidate2) {
351 +               if (!dentry->d_op->d_revalidate2(dentry, flags, it) &&
352 +                   !d_invalidate(dentry)) {
353 +                       dput(dentry);
354 +                       dentry = NULL;
355 +               }
356 +               return dentry;
357 +       } else
358         if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
359                 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
360                         dput(dentry);
361 @@ -281,7 +301,8 @@
362   * make sure that nobody added the entry to the dcache in the meantime..
363   * SMP-safe
364   */
365 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
366 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
367 +                                 int flags, struct lookup_intent *it)
368  {
369         struct dentry * result;
370         struct inode *dir = parent->d_inode;
371 @@ -300,6 +321,9 @@
372                 result = ERR_PTR(-ENOMEM);
373                 if (dentry) {
374                         lock_kernel();
375 +                       if (dir->i_op->lookup2)
376 +                               result = dir->i_op->lookup2(dir, dentry, it);
377 +                       else
378                         result = dir->i_op->lookup(dir, dentry);
379                         unlock_kernel();
380                         if (result)
381 @@ -321,6 +345,12 @@
382                         dput(result);
383                         result = ERR_PTR(-ENOENT);
384                 }
385 +       } else if (result->d_op && result->d_op->d_revalidate2) {
386 +               if (!result->d_op->d_revalidate2(result, flags, it) &&
387 +                   !d_invalidate(result)) {
388 +                       dput(result);
389 +                       result = ERR_PTR(-ENOENT);
390 +               }
391         }
392         return result;
393  }
394 @@ -334,7 +364,8 @@
395   * Without that kind of total limit, nasty chains of consecutive
396   * symlinks can cause almost arbitrarily long lookups. 
397   */
398 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
399 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd, 
400 +                                 struct lookup_intent *it)
401  {
402         int err;
403         if (current->link_count >= max_recursive_link)
404 @@ -348,10 +379,14 @@
405         current->link_count++;
406         current->total_link_count++;
407         UPDATE_ATIME(dentry->d_inode);
408 -       err = dentry->d_inode->i_op->follow_link(dentry, nd);
409 +        if (dentry->d_inode->i_op->follow_link2)
410 +                err = dentry->d_inode->i_op->follow_link2(dentry, nd, it);
411 +        else 
412 +                err = dentry->d_inode->i_op->follow_link(dentry, nd);
413         current->link_count--;
414         return err;
415  loop:
416 +        intent_release(dentry, it);
417         path_release(nd);
418         return -ELOOP;
419  }
420 @@ -449,7 +484,8 @@
421   *
422   * We expect 'base' to be positive and a directory.
423   */
424 -int link_path_walk(const char * name, struct nameidata *nd)
425 +int link_path_walk_it(const char *name, struct nameidata *nd,
426 +                     struct lookup_intent *it)
427  {
428         struct dentry *dentry;
429         struct inode *inode;
430 @@ -526,12 +562,12 @@
431                                 break;
432                 }
433                 /* This does the actual lookups.. */
434 -               dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
435 +               dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
436                 if (!dentry) {
437                         err = -EWOULDBLOCKIO;
438                         if (atomic)
439                                 break;
440 -                       dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
441 +                       dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
442                         err = PTR_ERR(dentry);
443                         if (IS_ERR(dentry))
444                                 break;
445 @@ -548,8 +584,8 @@
446                 if (!inode->i_op)
447                         goto out_dput;
448  
449 -               if (inode->i_op->follow_link) {
450 -                       err = do_follow_link(dentry, nd);
451 +               if (inode->i_op->follow_link || inode->i_op->follow_link2) {
452 +                       err = do_follow_link(dentry, nd, it);
453                         dput(dentry);
454                         if (err)
455                                 goto return_err;
456 @@ -565,7 +601,7 @@
457                         nd->dentry = dentry;
458                 }
459                 err = -ENOTDIR; 
460 -               if (!inode->i_op->lookup)
461 +               if (!inode->i_op->lookup && !inode->i_op->lookup2)
462                         break;
463                 continue;
464                 /* here ends the main loop */
465 @@ -592,12 +628,12 @@
466                         if (err < 0)
467                                 break;
468                 }
469 -               dentry = cached_lookup(nd->dentry, &this, 0);
470 +               dentry = cached_lookup(nd->dentry, &this, 0, it);
471                 if (!dentry) {
472                         err = -EWOULDBLOCKIO;
473                         if (atomic)
474                                 break;
475 -                       dentry = real_lookup(nd->dentry, &this, 0);
476 +                       dentry = real_lookup(nd->dentry, &this, 0, it);
477                         err = PTR_ERR(dentry);
478                         if (IS_ERR(dentry))
479                                 break;
480 @@ -606,8 +642,10 @@
481                         ;
482                 inode = dentry->d_inode;
483                 if ((lookup_flags & LOOKUP_FOLLOW)
484 -                   && inode && inode->i_op && inode->i_op->follow_link) {
485 -                       err = do_follow_link(dentry, nd);
486 +                   && inode && inode->i_op && 
487 +                    (inode->i_op->follow_link || 
488 +                     inode->i_op->follow_link2)) {
489 +                       err = do_follow_link(dentry, nd, it);
490                         dput(dentry);
491                         if (err)
492                                 goto return_err;
493 @@ -621,7 +659,8 @@
494                         goto no_inode;
495                 if (lookup_flags & LOOKUP_DIRECTORY) {
496                         err = -ENOTDIR; 
497 -                       if (!inode->i_op || !inode->i_op->lookup)
498 +                       if (!inode->i_op || (!inode->i_op->lookup &&
499 +                                            !inode->i_op->lookup2))
500                                 break;
501                 }
502                 goto return_base;
503 @@ -663,10 +702,21 @@
504         return err;
505  }
506  
507 +int link_path_walk(const char * name, struct nameidata *nd)
508 +{
509 +       return link_path_walk_it(name, nd, NULL);
510 +}
511 +
512 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
513 +{
514 +       current->total_link_count = 0;
515 +       return link_path_walk_it(name, nd, it);
516 +}
517 +
518  int path_walk(const char * name, struct nameidata *nd)
519  {
520         current->total_link_count = 0;
521 -       return link_path_walk(name, nd);
522 +       return link_path_walk_it(name, nd, NULL);
523  }
524  
525  /* SMP-safe */
526 @@ -751,6 +801,17 @@
527  }
528  
529  /* SMP-safe */
530 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
531 +                  struct lookup_intent *it)
532 +{
533 +       int error = 0;
534 +       if (path_init(path, flags, nd))
535 +               error = path_walk_it(path, nd, it);
536 +       return error;
537 +}
538 +
539 +
540 +/* SMP-safe */
541  int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
542  {
543         int error = 0;
544 @@ -779,7 +840,8 @@
545   * needs parent already locked. Doesn't follow mounts.
546   * SMP-safe.
547   */
548 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
549 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
550 +                              struct lookup_intent *it)
551  {
552         struct dentry * dentry;
553         struct inode *inode;
554 @@ -802,13 +864,16 @@
555                         goto out;
556         }
557  
558 -       dentry = cached_lookup(base, name, 0);
559 +       dentry = cached_lookup(base, name, 0, it);
560         if (!dentry) {
561                 struct dentry *new = d_alloc(base, name);
562                 dentry = ERR_PTR(-ENOMEM);
563                 if (!new)
564                         goto out;
565                 lock_kernel();
566 +               if (inode->i_op->lookup2)
567 +                       dentry = inode->i_op->lookup2(inode, new, it);
568 +               else
569                 dentry = inode->i_op->lookup(inode, new);
570                 unlock_kernel();
571                 if (!dentry)
572 @@ -820,6 +885,12 @@
573         return dentry;
574  }
575  
576 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
577 +{
578 +       return lookup_hash_it(name, base, NULL);
579 +}
580 +
581 +
582  /* SMP-safe */
583  struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
584  {
585 @@ -841,7 +912,7 @@
586         }
587         this.hash = end_name_hash(hash);
588  
589 -       return lookup_hash(&this, base);
590 +       return lookup_hash_it(&this, base, NULL);
591  access:
592         return ERR_PTR(-EACCES);
593  }
594 @@ -872,6 +943,23 @@
595         return err;
596  }
597  
598 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
599 +                  struct lookup_intent *it)
600 +{
601 +       char *tmp;
602 +       int err;
603 +
604 +       tmp = getname(name);
605 +       err = PTR_ERR(tmp);
606 +       if (!IS_ERR(tmp)) {
607 +               err = 0;
608 +               if (path_init(tmp, flags, nd))
609 +                       err = path_walk_it(tmp, nd, it);
610 +               putname(tmp);
611 +       }
612 +       return err;
613 +}
614 +
615  /*
616   * It's inline, so penalty for filesystems that don't use sticky bit is
617   * minimal.
618 @@ -1010,7 +1098,8 @@
619   * for symlinks (where the permissions are checked later).
620   * SMP-safe
621   */
622 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
623 +int open_namei_it(const char *pathname, int flag, int mode,
624 +                 struct nameidata *nd, struct lookup_intent *it)
625  {
626         int acc_mode, error = 0;
627         struct inode *inode;
628 @@ -1024,7 +1113,7 @@
629          * The simplest case - just a plain lookup.
630          */
631         if (!(flag & O_CREAT)) {
632 -               error = path_lookup(pathname, lookup_flags(flag), nd);
633 +               error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
634                 if (error)
635                         return error;
636                 dentry = nd->dentry;
637 @@ -1034,6 +1123,10 @@
638         /*
639          * Create - we need to know the parent.
640          */
641 +       if (it) {
642 +               it->it_mode = mode;
643 +               it->it_op |= IT_CREAT;
644 +       }
645         error = path_lookup(pathname, LOOKUP_PARENT, nd);
646         if (error)
647                 return error;
648 @@ -1049,7 +1142,7 @@
649  
650         dir = nd->dentry;
651         down(&dir->d_inode->i_sem);
652 -       dentry = lookup_hash(&nd->last, nd->dentry);
653 +       dentry = lookup_hash_it(&nd->last, nd->dentry, it);
654  
655  do_last:
656         error = PTR_ERR(dentry);
657 @@ -1058,6 +1151,7 @@
658                 goto exit;
659         }
660  
661 +       it->it_mode = mode;
662         /* Negative dentry, just create the file */
663         if (!dentry->d_inode) {
664                 error = vfs_create(dir->d_inode, dentry,
665 @@ -1091,7 +1185,8 @@
666         error = -ENOENT;
667         if (!dentry->d_inode)
668                 goto exit_dput;
669 -       if (dentry->d_inode->i_op && dentry->d_inode->i_op->follow_link)
670 +       if (dentry->d_inode->i_op && (dentry->d_inode->i_op->follow_link || 
671 +                                      dentry->d_inode->i_op->follow_link2))
672                 goto do_link;
673  
674         dput(nd->dentry);
675 @@ -1177,8 +1272,10 @@
676         return 0;
677  
678  exit_dput:
679 +       intent_release(dentry, it);
680         dput(dentry);
681  exit:
682 +       intent_release(nd->dentry, it);
683         path_release(nd);
684         return error;
685  
686 @@ -1197,7 +1294,12 @@
687          * are done. Procfs-like symlinks just set LAST_BIND.
688          */
689         UPDATE_ATIME(dentry->d_inode);
690 -       error = dentry->d_inode->i_op->follow_link(dentry, nd);
691 +        if (dentry->d_inode->i_op->follow_link2) 
692 +                error = dentry->d_inode->i_op->follow_link2(dentry, nd, it);
693 +        else 
694 +                error = dentry->d_inode->i_op->follow_link(dentry, nd);
695 +       if (error)
696 +               intent_release(dentry, it);
697         dput(dentry);
698         if (error)
699                 return error;
700 @@ -1219,13 +1321,20 @@
701         }
702         dir = nd->dentry;
703         down(&dir->d_inode->i_sem);
704 -       dentry = lookup_hash(&nd->last, nd->dentry);
705 +       dentry = lookup_hash_it(&nd->last, nd->dentry, NULL);
706         putname(nd->last.name);
707         goto do_last;
708  }
709  
710 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
711 +{
712 +       return open_namei_it(pathname, flag, mode, nd, NULL);
713 +}
714 +
715 +
716  /* SMP-safe */
717 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
718 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
719 +                                   struct lookup_intent *it)
720  {
721         struct dentry *dentry;
722  
723 @@ -1233,7 +1342,7 @@
724         dentry = ERR_PTR(-EEXIST);
725         if (nd->last_type != LAST_NORM)
726                 goto fail;
727 -       dentry = lookup_hash(&nd->last, nd->dentry);
728 +       dentry = lookup_hash_it(&nd->last, nd->dentry, it);
729         if (IS_ERR(dentry))
730                 goto fail;
731         if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
732 @@ -1279,6 +1388,7 @@
733         char * tmp;
734         struct dentry * dentry;
735         struct nameidata nd;
736 +       struct lookup_intent it = { .it_op = IT_MKNOD, .it_mode = mode };
737  
738         if (S_ISDIR(mode))
739                 return -EPERM;
740 @@ -1289,7 +1399,7 @@
741         error = path_lookup(tmp, LOOKUP_PARENT, &nd);
742         if (error)
743                 goto out;
744 -       dentry = lookup_create(&nd, 0);
745 +       dentry = lookup_create(&nd, 0, &it);
746         error = PTR_ERR(dentry);
747  
748         mode &= ~current->fs->umask;
749 @@ -1307,6 +1417,7 @@
750                 default:
751                         error = -EINVAL;
752                 }
753 +               intent_release(dentry, &it);
754                 dput(dentry);
755         }
756         up(&nd.dentry->d_inode->i_sem);
757 @@ -1347,6 +1458,7 @@
758  {
759         int error = 0;
760         char * tmp;
761 +       struct lookup_intent it = { .it_op = IT_MKDIR, .it_mode = mode };
762  
763         tmp = getname(pathname);
764         error = PTR_ERR(tmp);
765 @@ -1357,11 +1469,12 @@
766                 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
767                 if (error)
768                         goto out;
769 -               dentry = lookup_create(&nd, 1);
770 +               dentry = lookup_create(&nd, 1, &it);
771                 error = PTR_ERR(dentry);
772                 if (!IS_ERR(dentry)) {
773                         error = vfs_mkdir(nd.dentry->d_inode, dentry,
774                                           mode & ~current->fs->umask);
775 +                       intent_release(dentry, &it);
776                         dput(dentry);
777                 }
778                 up(&nd.dentry->d_inode->i_sem);
779 @@ -1445,6 +1558,7 @@
780         char * name;
781         struct dentry *dentry;
782         struct nameidata nd;
783 +       struct lookup_intent it = { .it_op = IT_RMDIR };
784  
785         name = getname(pathname);
786         if(IS_ERR(name))
787 @@ -1466,10 +1580,11 @@
788                         goto exit1;
789         }
790         down(&nd.dentry->d_inode->i_sem);
791 -       dentry = lookup_hash(&nd.last, nd.dentry);
792 +       dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
793         error = PTR_ERR(dentry);
794         if (!IS_ERR(dentry)) {
795                 error = vfs_rmdir(nd.dentry->d_inode, dentry);
796 +               intent_release(dentry, &it);
797                 dput(dentry);
798         }
799         up(&nd.dentry->d_inode->i_sem);
800 @@ -1513,6 +1628,7 @@
801         char * name;
802         struct dentry *dentry;
803         struct nameidata nd;
804 +       struct lookup_intent it = { .it_op = IT_UNLINK };
805  
806         name = getname(pathname);
807         if(IS_ERR(name))
808 @@ -1525,7 +1641,7 @@
809         if (nd.last_type != LAST_NORM)
810                 goto exit1;
811         down(&nd.dentry->d_inode->i_sem);
812 -       dentry = lookup_hash(&nd.last, nd.dentry);
813 +       dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
814         error = PTR_ERR(dentry);
815         if (!IS_ERR(dentry)) {
816                 /* Why not before? Because we want correct error value */
817 @@ -1533,6 +1649,7 @@
818                         goto slashes;
819                 error = vfs_unlink(nd.dentry->d_inode, dentry);
820         exit2:
821 +               intent_release(dentry, &it);
822                 dput(dentry);
823         }
824         up(&nd.dentry->d_inode->i_sem);
825 @@ -1579,6 +1696,7 @@
826         int error = 0;
827         char * from;
828         char * to;
829 +       struct lookup_intent it = { .it_op = IT_SYMLINK };
830  
831         from = getname(oldname);
832         if(IS_ERR(from))
833 @@ -1592,10 +1710,12 @@
834                 error = path_lookup(to, LOOKUP_PARENT, &nd);
835                 if (error)
836                         goto out;
837 -               dentry = lookup_create(&nd, 0);
838 +               it.it_data = from;
839 +               dentry = lookup_create(&nd, 0, &it);
840                 error = PTR_ERR(dentry);
841                 if (!IS_ERR(dentry)) {
842                         error = vfs_symlink(nd.dentry->d_inode, dentry, from);
843 +                       intent_release(dentry, &it);
844                         dput(dentry);
845                 }
846                 up(&nd.dentry->d_inode->i_sem);
847 @@ -1660,6 +1780,7 @@
848  {
849         int error;
850         char * to;
851 +       struct lookup_intent it = { .it_op = IT_LINK };
852  
853         to = getname(newname);
854         error = PTR_ERR(to);
855 @@ -1667,7 +1788,7 @@
856                 struct dentry *new_dentry;
857                 struct nameidata nd, old_nd;
858  
859 -               error = __user_walk(oldname, LOOKUP_POSITIVE, &old_nd);
860 +               error = __user_walk_it(oldname, LOOKUP_POSITIVE, &old_nd, &it);
861                 if (error)
862                         goto exit;
863                 error = path_lookup(to, LOOKUP_PARENT, &nd);
864 @@ -1676,10 +1797,12 @@
865                 error = -EXDEV;
866                 if (old_nd.mnt != nd.mnt)
867                         goto out_release;
868 -               new_dentry = lookup_create(&nd, 0);
869 +               it.it_op = IT_LINK2;
870 +               new_dentry = lookup_create(&nd, 0, &it);
871                 error = PTR_ERR(new_dentry);
872                 if (!IS_ERR(new_dentry)) {
873                         error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
874 +                       intent_release(new_dentry, &it);
875                         dput(new_dentry);
876                 }
877                 up(&nd.dentry->d_inode->i_sem);
878 @@ -1720,7 +1843,8 @@
879   *        locking].
880   */
881  int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
882 -              struct inode *new_dir, struct dentry *new_dentry)
883 +                  struct inode *new_dir, struct dentry *new_dentry,
884 +                  struct lookup_intent *it)
885  {
886         int error;
887         struct inode *target;
888 @@ -1778,6 +1902,7 @@
889                 error = -EBUSY;
890         else 
891                 error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
892 +       intent_release(new_dentry, it);
893         if (target) {
894                 if (!error)
895                         target->i_flags |= S_DEAD;
896 @@ -1799,7 +1924,8 @@
897  }
898  
899  int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
900 -              struct inode *new_dir, struct dentry *new_dentry)
901 +                    struct inode *new_dir, struct dentry *new_dentry,
902 +                    struct lookup_intent *it)
903  {
904         int error;
905  
906 @@ -1830,6 +1956,7 @@
907                 error = -EBUSY;
908         else
909                 error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
910 +       intent_release(new_dentry, it);
911         double_up(&old_dir->i_zombie, &new_dir->i_zombie);
912         if (error)
913                 return error;
914 @@ -1841,13 +1968,14 @@
915  }
916  
917  int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
918 -              struct inode *new_dir, struct dentry *new_dentry)
919 +              struct inode *new_dir, struct dentry *new_dentry,
920 +              struct lookup_intent *it)
921  {
922         int error;
923         if (S_ISDIR(old_dentry->d_inode->i_mode))
924 -               error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
925 +               error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry,it);
926         else
927 -               error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
928 +               error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry,it);
929         if (!error) {
930                 if (old_dir == new_dir)
931                         inode_dir_notify(old_dir, DN_RENAME);
932 @@ -1864,6 +1992,7 @@
933         int error = 0;
934         struct dentry * old_dir, * new_dir;
935         struct dentry * old_dentry, *new_dentry;
936 +       struct lookup_intent it = { .it_op = IT_RENAME };
937         struct nameidata oldnd, newnd;
938  
939         error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
940 @@ -1889,7 +2018,7 @@
941  
942         double_lock(new_dir, old_dir);
943  
944 -       old_dentry = lookup_hash(&oldnd.last, old_dir);
945 +       old_dentry = lookup_hash_it(&oldnd.last, old_dir, &it);
946         error = PTR_ERR(old_dentry);
947         if (IS_ERR(old_dentry))
948                 goto exit3;
949 @@ -1905,18 +2034,21 @@
950                 if (newnd.last.name[newnd.last.len])
951                         goto exit4;
952         }
953 -       new_dentry = lookup_hash(&newnd.last, new_dir);
954 +       it.it_op = IT_RENAME2;
955 +       new_dentry = lookup_hash_it(&newnd.last, new_dir, &it);
956         error = PTR_ERR(new_dentry);
957         if (IS_ERR(new_dentry))
958                 goto exit4;
959  
960         lock_kernel();
961         error = vfs_rename(old_dir->d_inode, old_dentry,
962 -                                  new_dir->d_inode, new_dentry);
963 +                                  new_dir->d_inode, new_dentry, &it);
964         unlock_kernel();
965  
966 +       intent_release(new_dentry, NULL);
967         dput(new_dentry);
968  exit4:
969 +       intent_release(old_dentry, &it);
970         dput(old_dentry);
971  exit3:
972         double_up(&new_dir->d_inode->i_sem, &old_dir->d_inode->i_sem);
973 @@ -1965,7 +2097,8 @@
974  }
975  
976  static inline int
977 -__vfs_follow_link(struct nameidata *nd, const char *link)
978 +__vfs_follow_link(struct nameidata *nd, const char *link, 
979 +                     struct lookup_intent *it)
980  {
981         int res = 0;
982         char *name;
983 @@ -1978,7 +2111,7 @@
984                         /* weird __emul_prefix() stuff did it */
985                         goto out;
986         }
987 -       res = link_path_walk(link, nd);
988 +       res = link_path_walk_it(link, nd, it);
989  out:
990         if (current->link_count || res || nd->last_type!=LAST_NORM)
991                 return res;
992 @@ -2000,7 +2133,13 @@
993  
994  int vfs_follow_link(struct nameidata *nd, const char *link)
995  {
996 -       return __vfs_follow_link(nd, link);
997 +       return __vfs_follow_link(nd, link, NULL);
998 +}
999 +
1000 +int vfs_follow_link_it(struct nameidata *nd, const char *link, 
1001 +                       struct lookup_intent *it)
1002 +{
1003 +       return __vfs_follow_link(nd, link, it);
1004  }
1005  
1006  /* get the link contents into pagecache */
1007 @@ -2042,7 +2181,7 @@
1008  {
1009         struct page *page = NULL;
1010         char *s = page_getlink(dentry, &page);
1011 -       int res = __vfs_follow_link(nd, s);
1012 +       int res = __vfs_follow_link(nd, s, NULL);
1013         if (page) {
1014                 kunmap(page);
1015                 page_cache_release(page);
1016 --- linux-2.4.18-17.8.0-uml-pristine/fs/open.c  2002-10-19 11:43:53.000000000 -0600
1017 +++ linux-2.4.18-17.8.0-uml/fs/open.c   2002-10-19 11:44:51.000000000 -0600
1018 @@ -19,6 +19,9 @@
1019  #include <asm/uaccess.h>
1020  
1021  #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1022 +extern int path_walk_it(const char *name, struct nameidata *nd,
1023 +                       struct lookup_intent *it);
1024 +extern void intent_release(struct dentry *de, struct lookup_intent *it);
1025  
1026  int vfs_statfs(struct super_block *sb, struct statfs *buf)
1027  {
1028 @@ -118,12 +121,13 @@
1029         struct nameidata nd;
1030         struct inode * inode;
1031         int error;
1032 +       struct lookup_intent it = { .it_op = IT_SETATTR };
1033  
1034         error = -EINVAL;
1035         if (length < 0) /* sorry, but loff_t says... */
1036                 goto out;
1037  
1038 -       error = user_path_walk(path, &nd);
1039 +       error = user_path_walk_it(path, &nd, &it);
1040         if (error)
1041                 goto out;
1042         inode = nd.dentry->d_inode;
1043 @@ -168,6 +172,7 @@
1044         put_write_access(inode);
1045  
1046  dput_and_out:
1047 +       intent_release(nd.dentry, &it);
1048         path_release(&nd);
1049  out:
1050         return error;
1051 @@ -259,8 +264,9 @@
1052         struct nameidata nd;
1053         struct inode * inode;
1054         struct iattr newattrs;
1055 +       struct lookup_intent it = { .it_op = IT_SETATTR };
1056  
1057 -       error = user_path_walk(filename, &nd);
1058 +       error = user_path_walk_it(filename, &nd, &it);
1059         if (error)
1060                 goto out;
1061         inode = nd.dentry->d_inode;
1062 @@ -286,6 +292,7 @@
1063         }
1064         error = notify_change(nd.dentry, &newattrs);
1065  dput_and_out:
1066 +       intent_release(nd.dentry, &it);
1067         path_release(&nd);
1068  out:
1069         return error;
1070 @@ -303,8 +310,9 @@
1071         struct nameidata nd;
1072         struct inode * inode;
1073         struct iattr newattrs;
1074 +       struct lookup_intent it = { .it_op = IT_SETATTR };
1075  
1076 -       error = user_path_walk(filename, &nd);
1077 +       error = user_path_walk_it(filename, &nd, &it);
1078  
1079         if (error)
1080                 goto out;
1081 @@ -331,6 +339,7 @@
1082         }
1083         error = notify_change(nd.dentry, &newattrs);
1084  dput_and_out:
1085 +       intent_release(nd.dentry, &it);
1086         path_release(&nd);
1087  out:
1088         return error;
1089 @@ -347,6 +356,7 @@
1090         int old_fsuid, old_fsgid;
1091         kernel_cap_t old_cap;
1092         int res;
1093 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1094  
1095         if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
1096                 return -EINVAL;
1097 @@ -364,13 +374,14 @@
1098         else
1099                 current->cap_effective = current->cap_permitted;
1100  
1101 -       res = user_path_walk(filename, &nd);
1102 +       res = user_path_walk_it(filename, &nd, &it);
1103         if (!res) {
1104                 res = permission(nd.dentry->d_inode, mode);
1105                 /* SuS v2 requires we report a read only fs too */
1106                 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1107                    && !special_file(nd.dentry->d_inode->i_mode))
1108                         res = -EROFS;
1109 +               intent_release(nd.dentry, &it);
1110                 path_release(&nd);
1111         }
1112  
1113 @@ -385,8 +396,11 @@
1114  {
1115         int error;
1116         struct nameidata nd;
1117 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1118  
1119 -       error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1120 +       error = __user_walk_it(filename,
1121 +                              LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,
1122 +                              &nd, &it);
1123         if (error)
1124                 goto out;
1125  
1126 @@ -397,6 +411,7 @@
1127         set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1128  
1129  dput_and_out:
1130 +       intent_release(nd.dentry, &it);
1131         path_release(&nd);
1132  out:
1133         return error;
1134 @@ -436,9 +451,10 @@
1135  {
1136         int error;
1137         struct nameidata nd;
1138 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1139  
1140 -       error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1141 -                     LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1142 +       error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1143 +                              LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1144         if (error)
1145                 goto out;
1146  
1147 @@ -454,6 +470,7 @@
1148         set_fs_altroot();
1149         error = 0;
1150  dput_and_out:
1151 +       intent_release(nd.dentry, &it);
1152         path_release(&nd);
1153  out:
1154         return error;
1155 @@ -498,8 +515,9 @@
1156         struct inode * inode;
1157         int error;
1158         struct iattr newattrs;
1159 +       struct lookup_intent it = { .it_op = IT_SETATTR };
1160  
1161 -       error = user_path_walk(filename, &nd);
1162 +       error = user_path_walk_it(filename, &nd, &it);
1163         if (error)
1164                 goto out;
1165         inode = nd.dentry->d_inode;
1166 @@ -519,6 +537,7 @@
1167         error = notify_change(nd.dentry, &newattrs);
1168  
1169  dput_and_out:
1170 +       intent_release(nd.dentry, &it);
1171         path_release(&nd);
1172  out:
1173         return error;
1174 @@ -588,10 +607,12 @@
1175  {
1176         struct nameidata nd;
1177         int error;
1178 +       struct lookup_intent it = { .it_op = IT_SETATTR };
1179  
1180 -       error = user_path_walk(filename, &nd);
1181 +       error = user_path_walk_it(filename, &nd, &it);
1182         if (!error) {
1183                 error = chown_common(nd.dentry, user, group);
1184 +               intent_release(nd.dentry, &it);
1185                 path_release(&nd);
1186         }
1187         return error;
1188 @@ -601,10 +622,12 @@
1189  {
1190         struct nameidata nd;
1191         int error;
1192 +       struct lookup_intent it = { .it_op = IT_SETATTR };
1193  
1194 -       error = user_path_walk_link(filename, &nd);
1195 +       error = user_path_walk_link_it(filename, &nd, &it);
1196         if (!error) {
1197                 error = chown_common(nd.dentry, user, group);
1198 +               intent_release(nd.dentry, &it);
1199                 path_release(&nd);
1200         }
1201         return error;
1202 @@ -638,10 +661,16 @@
1203   * for the internal routines (ie open_namei()/follow_link() etc). 00 is
1204   * used by symlinks.
1205   */
1206 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1207 +                        struct nameidata *nd, struct lookup_intent *it);
1208 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1209 +                           int flags, struct lookup_intent *it);
1210 +
1211  struct file *filp_open(const char * filename, int flags, int mode)
1212  {
1213         int namei_flags, error;
1214         struct nameidata nd;
1215 +       struct lookup_intent it = { .it_op = IT_OPEN };
1216  
1217         namei_flags = flags;
1218         if ((namei_flags+1) & O_ACCMODE)
1219 @@ -649,18 +678,19 @@
1220         if (namei_flags & O_TRUNC)
1221                 namei_flags |= 2;
1222  
1223 -       error = open_namei(filename, namei_flags, mode, &nd);
1224 -       if (!error)
1225 -               return dentry_open(nd.dentry, nd.mnt, flags);
1226 +       error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1227 +       if (error)
1228 +               return ERR_PTR(error);
1229  
1230 -       return ERR_PTR(error);
1231 +       return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1232  }
1233  
1234  extern ssize_t do_readahead(struct file *file, unsigned long index, unsigned long nr);
1235  /* for files over a certains size it doesn't pay to do readahead on open */
1236  #define READAHEAD_CUTOFF 48000
1237  
1238 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1239 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1240 +                           int flags, struct lookup_intent *it)
1241  {
1242         struct file * f;
1243         struct inode *inode;
1244 @@ -711,6 +741,7 @@
1245                 do_readahead(f, 0, (48 * 1024) >> PAGE_SHIFT);
1246         
1247  
1248 +       intent_release(dentry, it);
1249         return f;
1250  
1251  cleanup_all:
1252 @@ -725,11 +756,17 @@
1253  cleanup_file:
1254         put_filp(f);
1255  cleanup_dentry:
1256 +       intent_release(dentry, it);
1257         dput(dentry);
1258         mntput(mnt);
1259         return ERR_PTR(error);
1260  }
1261  
1262 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1263 +{
1264 +       return dentry_open_it(dentry, mnt, flags, NULL);
1265 +}
1266 +
1267  /*
1268   * Find an empty file descriptor entry, and mark it busy.
1269   */
1270 --- linux-2.4.18-17.8.0-uml-pristine/fs/stat.c  2002-10-19 11:43:53.000000000 -0600
1271 +++ linux-2.4.18-17.8.0-uml/fs/stat.c   2002-10-19 11:44:51.000000000 -0600
1272 @@ -13,6 +13,7 @@
1273  
1274  #include <asm/uaccess.h>
1275  
1276 +extern void intent_release(struct dentry *de, struct lookup_intent *it);
1277  /*
1278   * Revalidate the inode. This is required for proper NFS attribute caching.
1279   */
1280 @@ -104,10 +105,12 @@
1281  {
1282         struct nameidata nd;
1283         int error;
1284 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1285  
1286 -       error = user_path_walk(name, &nd);
1287 +       error = user_path_walk_it(name, &nd, &it);
1288         if (!error) {
1289                 error = do_getattr(nd.mnt, nd.dentry, stat);
1290 +               intent_release(nd.dentry, &it);
1291                 path_release(&nd);
1292         }
1293         return error;
1294 @@ -117,10 +120,12 @@
1295  {
1296         struct nameidata nd;
1297         int error;
1298 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1299  
1300 -       error = user_path_walk_link(name, &nd);
1301 +       error = user_path_walk_link_it(name, &nd, &it);
1302         if (!error) {
1303                 error = do_getattr(nd.mnt, nd.dentry, stat);
1304 +               intent_release(nd.dentry, &it);
1305                 path_release(&nd);
1306         }
1307         return error;
1308 --- linux-2.4.18-17.8.0-uml-pristine/mm/slab.c  2002-10-19 11:43:54.000000000 -0600
1309 +++ linux-2.4.18-17.8.0-uml/mm/slab.c   2002-10-19 11:44:51.000000000 -0600
1310 @@ -1208,6 +1208,59 @@
1311   * Called with the cache-lock held.
1312   */
1313  
1314 +extern struct page *check_get_page(unsigned long kaddr);
1315 +struct page *page_mem_map(struct page *page);
1316 +static int kmem_check_cache_obj (kmem_cache_t * cachep,
1317 +                                slab_t *slabp, void * objp)
1318 +{
1319 +       int i;
1320 +       unsigned int objnr;
1321 +
1322 +#if DEBUG
1323 +       if (cachep->flags & SLAB_RED_ZONE) {
1324 +               objp -= BYTES_PER_WORD;
1325 +               if ( *(unsigned long *)objp != RED_MAGIC2)
1326 +                       /* Either write before start, or a double free. */
1327 +                       return 0;
1328 +               if (*(unsigned long *)(objp+cachep->objsize -
1329 +                               BYTES_PER_WORD) != RED_MAGIC2)
1330 +                       /* Either write past end, or a double free. */
1331 +                       return 0;
1332 +       }
1333 +#endif
1334 +
1335 +       objnr = (objp-slabp->s_mem)/cachep->objsize;
1336 +       if (objnr >= cachep->num)
1337 +               return 0;
1338 +       if (objp != slabp->s_mem + objnr*cachep->objsize)
1339 +               return 0;
1340 +
1341 +       /* Check slab's freelist to see if this obj is there. */
1342 +       for (i = slabp->free; i != BUFCTL_END; i = slab_bufctl(slabp)[i]) {
1343 +               if (i == objnr)
1344 +                       return 0;
1345 +       }
1346 +       return 1;
1347 +}
1348 +
1349 +
1350 +int kmem_cache_validate(kmem_cache_t *cachep, void *objp)
1351 +{
1352 +       struct page *page = check_get_page((unsigned long)objp);
1353 +
1354 +       if (!VALID_PAGE(page))
1355 +               return 0;
1356 +
1357 +       if (!PageSlab(page))
1358 +               return 0;
1359 +
1360 +       /* XXX check for freed slab objects ? */
1361 +       if (!kmem_check_cache_obj(cachep, GET_PAGE_SLAB(page), objp))
1362 +               return 0;
1363 +
1364 +       return (cachep == GET_PAGE_CACHE(page));
1365 +}
1366 +
1367  #if DEBUG
1368  static int kmem_extra_free_checks (kmem_cache_t * cachep,
1369                         slab_t *slabp, void * objp)