1 Index: linux-2.6.10/fs/open.c
2 ===================================================================
3 --- linux-2.6.10.orig/fs/open.c 2005-03-31 15:35:27.683586616 +0800
4 +++ linux-2.6.10/fs/open.c 2005-03-31 17:13:48.440535208 +0800
9 + intent_init(&nd.intent.open, IT_GETATTR);
11 if (length < 0) /* sorry, but loff_t says... */
14 - error = user_path_walk(path, &nd);
15 + error = user_path_walk_it(path, &nd);
18 inode = nd.dentry->d_inode;
23 + intent_init(&nd.intent.open, IT_GETATTR);
24 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
29 current->cap_effective = current->cap_permitted;
31 - res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
32 + res = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
34 res = permission(nd.dentry->d_inode, mode, &nd);
35 /* SuS v2 requires we report a read only fs too */
40 - error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
41 + intent_init(&nd.intent.open, IT_GETATTR);
42 + error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
50 - error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
51 + intent_init(&nd.intent.open, IT_GETATTR);
52 + error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
58 int namei_flags, error;
60 + intent_init(&nd.intent.open, IT_OPEN);
63 if ((namei_flags+1) & O_ACCMODE)
66 error = open_namei(filename, namei_flags, mode, &nd);
68 - return dentry_open(nd.dentry, nd.mnt, flags);
69 + return dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent.open);
71 return ERR_PTR(error);
74 EXPORT_SYMBOL(filp_open);
76 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
77 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct open_intent *it)
84 f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
86 inode = dentry->d_inode;
87 if (f->f_mode & FMODE_WRITE) {
88 error = get_write_access(inode);
90 error = f->f_op->open(inode,f);
95 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
101 + intent_release(it);
104 return ERR_PTR(error);
107 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
109 + struct open_intent it;
110 + intent_init(&it, IT_LOOKUP);
112 + return dentry_open_it(dentry, mnt, flags, &it);
115 EXPORT_SYMBOL(dentry_open);
118 Index: linux-2.6.10/fs/xattr.c
119 ===================================================================
120 --- linux-2.6.10.orig/fs/xattr.c 2004-12-25 05:34:32.000000000 +0800
121 +++ linux-2.6.10/fs/xattr.c 2005-03-31 17:03:37.148465728 +0800
126 - error = user_path_walk(path, &nd);
127 + intent_init(&nd.intent.open, IT_GETXATTR);
128 + error = user_path_walk_it(path, &nd);
131 error = getxattr(nd.dentry, name, value, size);
136 - error = user_path_walk_link(path, &nd);
137 + intent_init(&nd.intent.open, IT_GETXATTR);
138 + error = user_path_walk_link_it(path, &nd);
141 error = getxattr(nd.dentry, name, value, size);
146 - error = user_path_walk(path, &nd);
147 + intent_init(&nd.intent.open, IT_GETXATTR);
148 + error = user_path_walk_it(path, &nd);
151 error = listxattr(nd.dentry, list, size);
156 - error = user_path_walk_link(path, &nd);
157 + intent_init(&nd.intent.open, IT_GETXATTR);
158 + error = user_path_walk_link_it(path, &nd);
161 error = listxattr(nd.dentry, list, size);
162 Index: linux-2.6.10/fs/namei.c
163 ===================================================================
164 --- linux-2.6.10.orig/fs/namei.c 2005-03-31 15:35:26.294797744 +0800
165 +++ linux-2.6.10/fs/namei.c 2005-03-31 17:12:26.403006808 +0800
170 +void intent_release(struct open_intent *it)
174 + if (it->magic != INTENT_MAGIC)
176 + if (it->op_release)
177 + it->op_release(it);
180 void path_release(struct nameidata *nd)
182 + intent_release(&nd->intent.open);
187 static inline int __vfs_follow_link(struct nameidata *nd, const char *link)
190 + struct open_intent it = nd->intent.open;
195 /* weird __emul_prefix() stuff did it */
198 + intent_release(&nd->intent.open);
199 + intent_init(&nd->intent.open, it.op);
200 + nd->intent.open.flags = it.flags;
201 + nd->intent.open.create_mode = it.create_mode;
202 res = link_path_walk(link, nd);
204 if (nd->depth || res || nd->last_type!=LAST_NORM)
209 +int fastcall path_walk_it(const char * name, struct nameidata *nd)
211 + current->total_link_count = 0;
212 + return link_path_walk(name, nd);
214 int fastcall path_walk(const char * name, struct nameidata *nd)
216 + intent_init(&nd->intent.open, IT_LOOKUP);
217 current->total_link_count = 0;
218 return link_path_walk(name, nd);
221 /* returns 1 if everything is done */
222 static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
224 - if (path_walk(name, nd))
225 + if (path_walk_it(name, nd))
226 return 0; /* something went wrong... */
228 if (!nd->dentry->d_inode || S_ISDIR(nd->dentry->d_inode->i_mode)) {
233 -int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
234 +static inline int it_mode_from_lookup_flags(int flags)
236 + int mode = IT_LOOKUP;
238 + if (flags & LOOKUP_OPEN)
240 + if (flags & LOOKUP_CREATE)
245 +int fastcall path_lookup_it(const char *name, unsigned int flags, struct nameidata *nd)
249 @@ -982,6 +1015,12 @@
253 +int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
255 + intent_init(&nd->intent.open, it_mode_from_lookup_flags(flags));
256 + return path_lookup_it(name, flags, nd);
260 * Restricted form of lookup. Doesn't follow links, single-component only,
261 * needs parent already locked. Doesn't follow mounts.
262 @@ -1032,7 +1071,7 @@
266 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
267 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
271 @@ -1052,11 +1091,16 @@
273 this.hash = end_name_hash(hash);
275 - return lookup_hash(&this, base);
276 + return __lookup_hash(&this, base, nd);
278 return ERR_PTR(-EACCES);
281 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
283 + return lookup_one_len_it(name, base, len, NULL);
289 @@ -1068,18 +1112,24 @@
290 * that namei follows links, while lnamei does not.
293 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
294 +int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
296 char *tmp = getname(name);
297 int err = PTR_ERR(tmp);
300 - err = path_lookup(tmp, flags, nd);
301 + err = path_lookup_it(tmp, flags, nd);
307 +int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
309 + intent_init(&nd->intent.open, it_mode_from_lookup_flags(flags));
310 + return __user_walk_it(name, flags, nd);
314 * It's inline, so penalty for filesystems that don't use sticky bit is
316 @@ -1370,7 +1420,7 @@
317 * The simplest case - just a plain lookup.
319 if (!(flag & O_CREAT)) {
320 - error = path_lookup(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd);
321 + error = path_lookup_it(pathname, lookup_flags(flag), nd);
325 @@ -1379,7 +1429,8 @@
327 * Create - we need to know the parent.
329 - error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
330 + nd->intent.open.op |= IT_CREAT;
331 + error = path_lookup_it(pathname, LOOKUP_PARENT, nd);
335 @@ -2344,6 +2395,7 @@
340 int page_symlink(struct inode *inode, const char *symname, int len)
342 struct address_space *mapping = inode->i_mapping;
343 @@ -2405,8 +2457,10 @@
344 EXPORT_SYMBOL(page_symlink);
345 EXPORT_SYMBOL(page_symlink_inode_operations);
346 EXPORT_SYMBOL(path_lookup);
347 +EXPORT_SYMBOL(path_lookup_it);
348 EXPORT_SYMBOL(path_release);
349 EXPORT_SYMBOL(path_walk);
350 +EXPORT_SYMBOL(path_walk_it);
351 EXPORT_SYMBOL(permission);
352 EXPORT_SYMBOL(unlock_rename);
353 EXPORT_SYMBOL(vfs_create);
354 Index: linux-2.6.10/fs/stat.c
355 ===================================================================
356 --- linux-2.6.10.orig/fs/stat.c 2004-12-25 05:34:02.000000000 +0800
357 +++ linux-2.6.10/fs/stat.c 2005-03-31 17:03:37.144466336 +0800
363 EXPORT_SYMBOL(vfs_getattr);
365 int vfs_stat(char __user *name, struct kstat *stat)
369 + intent_init(&nd.intent.open, IT_GETATTR);
371 - error = user_path_walk(name, &nd);
372 + error = user_path_walk_it(name, &nd);
374 error = vfs_getattr(nd.mnt, nd.dentry, stat);
380 + intent_init(&nd.intent.open, IT_GETATTR);
382 - error = user_path_walk_link(name, &nd);
383 + error = user_path_walk_link_it(name, &nd);
385 error = vfs_getattr(nd.mnt, nd.dentry, stat);
389 struct file *f = fget(fd);
391 + struct nameidata nd;
392 + intent_init(&nd.intent.open, IT_GETATTR);
395 error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
396 + intent_release(&nd.intent.open);
400 Index: linux-2.6.10/fs/namespace.c
401 ===================================================================
402 --- linux-2.6.10.orig/fs/namespace.c 2005-03-31 15:35:26.295797592 +0800
403 +++ linux-2.6.10/fs/namespace.c 2005-03-31 17:03:37.145466184 +0800
406 static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
408 + memset(old_nd, 0, sizeof(*old_nd));
409 old_nd->dentry = mnt->mnt_mountpoint;
410 old_nd->mnt = mnt->mnt_parent;
411 mnt->mnt_parent = mnt;
412 Index: linux-2.6.10/fs/exec.c
413 ===================================================================
414 --- linux-2.6.10.orig/fs/exec.c 2005-03-31 16:20:09.692859232 +0800
415 +++ linux-2.6.10/fs/exec.c 2005-03-31 17:03:37.147465880 +0800
420 + intent_init(&nd.intent.open, IT_OPEN);
421 nd.intent.open.flags = FMODE_READ;
422 - error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
423 + error = user_path_walk_it(library, &nd);
431 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
432 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent.open);
433 error = PTR_ERR(file);
440 + intent_init(&nd.intent.open, IT_OPEN);
441 nd.intent.open.flags = FMODE_READ;
442 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
443 + err = path_lookup_it(name, LOOKUP_FOLLOW, &nd);
451 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
452 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent.open);
454 err = deny_write_access(file);
456 Index: linux-2.6.10/include/linux/fs.h
457 ===================================================================
458 --- linux-2.6.10.orig/include/linux/fs.h 2005-03-31 15:35:26.317794248 +0800
459 +++ linux-2.6.10/include/linux/fs.h 2005-03-31 17:03:37.135467704 +0800
461 spinlock_t f_ep_lock;
462 #endif /* #ifdef CONFIG_EPOLL */
463 struct address_space *f_mapping;
464 + struct open_intent *f_it;
466 extern spinlock_t files_lock;
467 #define file_list_lock() spin_lock(&files_lock);
468 @@ -1245,6 +1246,7 @@
469 extern int do_truncate(struct dentry *, loff_t start);
470 extern struct file *filp_open(const char *, int, int);
471 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
472 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct open_intent *);
473 extern int filp_close(struct file *, fl_owner_t id);
474 extern char * getname(const char __user *);
476 Index: linux-2.6.10/include/linux/namei.h
477 ===================================================================
478 --- linux-2.6.10.orig/include/linux/namei.h 2005-03-31 15:35:27.689585704 +0800
479 +++ linux-2.6.10/include/linux/namei.h 2005-03-31 17:10:14.746021712 +0800
481 #define _LINUX_NAMEI_H
483 #include <linux/linkage.h>
484 +#include <linux/string.h>
488 +/* intent opcodes */
490 +#define IT_CREAT (1<<1)
491 +#define IT_READDIR (1<<2)
492 +#define IT_GETATTR (1<<3)
493 +#define IT_LOOKUP (1<<4)
494 +#define IT_UNLINK (1<<5)
495 +#define IT_TRUNC (1<<6)
496 +#define IT_GETXATTR (1<<7)
498 +#define INTENT_MAGIC 0x19620323
504 + void (*op_release)(struct open_intent *);
508 + void *fs_data; /* FS-specific intent data */
512 +static inline void intent_init(struct open_intent *it, int op)
514 + memset(it, 0, sizeof(*it));
515 + it->magic = INTENT_MAGIC;
519 enum { MAX_NESTED_LINKS = 8 };
523 #define LOOKUP_ACCESS (0x0400)
525 extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
526 +extern int FASTCALL(__user_walk_it(const char __user *, unsigned, struct nameidata *));
527 #define user_path_walk(name,nd) \
528 __user_walk(name, LOOKUP_FOLLOW, nd)
529 +#define user_path_walk_it(name,nd) \
530 + __user_walk_it(name, LOOKUP_FOLLOW, nd)
531 #define user_path_walk_link(name,nd) \
532 __user_walk(name, 0, nd)
533 +#define user_path_walk_link_it(name,nd) \
534 + __user_walk_it(name, 0, nd)
535 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
536 +extern int FASTCALL(path_lookup_it(const char *, unsigned, struct nameidata *));
537 extern int FASTCALL(path_walk(const char *, struct nameidata *));
538 +extern int FASTCALL(path_walk_it(const char *, struct nameidata *));
539 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
540 extern void path_release(struct nameidata *);
541 +extern void intent_release(struct open_intent *);
542 extern void path_release_on_umount(struct nameidata *);
544 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
545 Index: linux-2.6.10/include/linux/mount.h
546 ===================================================================
547 --- linux-2.6.10.orig/include/linux/mount.h 2004-12-25 05:33:51.000000000 +0800
548 +++ linux-2.6.10/include/linux/mount.h 2005-03-31 17:15:40.613482328 +0800
550 struct list_head mnt_list;
551 struct list_head mnt_fslink; /* link in fs-specific expiry list */
552 struct namespace *mnt_namespace; /* containing namespace */
553 + struct list_head mnt_lustre_list; /* GNS mount list */
554 + unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */
557 static inline struct vfsmount *mntget(struct vfsmount *mnt)