1 Index: linus-2.6.7-bk-latest/include/linux/namei.h
2 ===================================================================
3 --- linus-2.6.7-bk-latest.orig/include/linux/namei.h 2004-07-07 10:56:34.232378296 +0300
4 +++ linus-2.6.7-bk-latest/include/linux/namei.h 2004-07-07 11:41:48.569736296 +0300
8 #include <linux/linkage.h>
9 +#include <linux/string.h>
15 +#define IT_CREAT (1<<1)
16 +#define IT_READDIR (1<<2)
17 +#define IT_GETATTR (1<<3)
18 +#define IT_LOOKUP (1<<4)
19 +#define IT_UNLINK (1<<5)
20 +#define IT_TRUNC (1<<6)
21 +#define IT_GETXATTR (1<<7)
23 +#define INTENT_MAGIC 0x19620323
28 + void (*op_release)(struct open_intent *);
32 + void *fs_data; /* FS-specific intent data */
36 +static inline void intent_init(struct open_intent *it, int op)
38 + memset(it, 0, sizeof(*it));
39 + it->magic = INTENT_MAGIC;
45 struct dentry *dentry;
47 #define LOOKUP_ACCESS (0x0400)
49 extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
50 +extern int FASTCALL(__user_walk_it(const char __user *, unsigned, struct nameidata *));
51 #define user_path_walk(name,nd) \
52 __user_walk(name, LOOKUP_FOLLOW, nd)
53 +#define user_path_walk_it(name,nd) \
54 + __user_walk_it(name, LOOKUP_FOLLOW, nd)
55 #define user_path_walk_link(name,nd) \
56 __user_walk(name, 0, nd)
57 +#define user_path_walk_link_it(name,nd) \
58 + __user_walk_it(name, 0, nd)
59 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
60 +extern int FASTCALL(path_lookup_it(const char *, unsigned, struct nameidata *));
61 extern int FASTCALL(path_walk(const char *, struct nameidata *));
62 +extern int FASTCALL(path_walk_it(const char *, struct nameidata *));
63 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
64 extern void path_release(struct nameidata *);
65 +extern void intent_release(struct open_intent *);
67 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
68 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
69 Index: linus-2.6.7-bk-latest/include/linux/fs.h
70 ===================================================================
71 --- linus-2.6.7-bk-latest.orig/include/linux/fs.h 2004-07-07 10:56:33.720456120 +0300
72 +++ linus-2.6.7-bk-latest/include/linux/fs.h 2004-07-07 11:38:42.864967712 +0300
75 #endif /* #ifdef CONFIG_EPOLL */
76 struct address_space *f_mapping;
77 + struct open_intent *f_it;
79 extern spinlock_t files_lock;
80 #define file_list_lock() spin_lock(&files_lock);
82 extern int do_truncate(struct dentry *, loff_t start);
83 extern struct file *filp_open(const char *, int, int);
84 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
85 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct open_intent *);
86 extern int filp_close(struct file *, fl_owner_t id);
87 extern char * getname(const char __user *);
89 Index: linus-2.6.7-bk-latest/fs/namei.c
90 ===================================================================
91 --- linus-2.6.7-bk-latest.orig/fs/namei.c 2004-07-07 10:56:13.455536856 +0300
92 +++ linus-2.6.7-bk-latest/fs/namei.c 2004-07-07 11:38:42.866967408 +0300
97 +void intent_release(struct open_intent *it)
101 + if (it->magic != INTENT_MAGIC)
103 + if (it->op_release)
104 + it->op_release(it);
107 void path_release(struct nameidata *nd)
109 + intent_release(&nd->intent.open);
117 +int fastcall path_walk_it(const char * name, struct nameidata *nd)
119 + current->total_link_count = 0;
120 + return link_path_walk(name, nd);
122 int fastcall path_walk(const char * name, struct nameidata *nd)
124 + intent_init(&nd->intent.open, IT_LOOKUP);
125 current->total_link_count = 0;
126 return link_path_walk(name, nd);
129 /* returns 1 if everything is done */
130 static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
132 - if (path_walk(name, nd))
133 + if (path_walk_it(name, nd))
134 return 0; /* something went wrong... */
136 if (!nd->dentry->d_inode || S_ISDIR(nd->dentry->d_inode->i_mode)) {
141 -int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
142 +static inline int it_mode_from_lookup_flags(int flags)
144 + int mode = IT_LOOKUP;
146 + if (flags & LOOKUP_OPEN)
148 + if (flags & LOOKUP_CREATE)
153 +int fastcall path_lookup_it(const char *name, unsigned int flags, struct nameidata *nd)
161 +int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
163 + intent_init(&nd->intent.open, it_mode_from_lookup_flags(flags));
164 + return path_lookup_it(name, flags, nd);
168 * Restricted form of lookup. Doesn't follow links, single-component only,
169 * needs parent already locked. Doesn't follow mounts.
174 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
175 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
179 @@ -984,11 +1018,16 @@
181 this.hash = end_name_hash(hash);
183 - return lookup_hash(&this, base);
184 + return __lookup_hash(&this, base, nd);
186 return ERR_PTR(-EACCES);
189 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
191 + return lookup_one_len_it(name, base, len, NULL);
197 @@ -1000,18 +1039,24 @@
198 * that namei follows links, while lnamei does not.
201 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
202 +int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
204 char *tmp = getname(name);
205 int err = PTR_ERR(tmp);
208 - err = path_lookup(tmp, flags, nd);
209 + err = path_lookup_it(tmp, flags, nd);
215 +int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
217 + intent_init(&nd->intent.open, it_mode_from_lookup_flags(flags));
218 + return __user_walk_it(name, flags, nd);
222 * It's inline, so penalty for filesystems that don't use sticky bit is
224 @@ -1296,7 +1341,7 @@
225 * The simplest case - just a plain lookup.
227 if (!(flag & O_CREAT)) {
228 - error = path_lookup(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd);
229 + error = path_lookup_it(pathname, lookup_flags(flag), nd);
233 @@ -1305,7 +1350,8 @@
235 * Create - we need to know the parent.
237 - error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
238 + nd->intent.open.op |= IT_CREAT;
239 + error = path_lookup_it(pathname, LOOKUP_PARENT, nd);
243 @@ -2214,6 +2260,7 @@
244 static int __vfs_follow_link(struct nameidata *nd, const char *link)
247 + struct open_intent it = nd->intent.open;
251 @@ -2224,6 +2271,10 @@
252 /* weird __emul_prefix() stuff did it */
255 + intent_release(&nd->intent.open);
256 + intent_init(&nd->intent.open, it.op);
257 + nd->intent.open.flags = it.flags;
258 + nd->intent.open.create_mode = it.create_mode;
259 res = link_path_walk(link, nd);
261 if (nd->depth || res || nd->last_type!=LAST_NORM)
262 @@ -2322,6 +2372,7 @@
267 int page_symlink(struct inode *inode, const char *symname, int len)
269 struct address_space *mapping = inode->i_mapping;
270 @@ -2385,8 +2436,10 @@
271 EXPORT_SYMBOL(page_symlink);
272 EXPORT_SYMBOL(page_symlink_inode_operations);
273 EXPORT_SYMBOL(path_lookup);
274 +EXPORT_SYMBOL(path_lookup_it);
275 EXPORT_SYMBOL(path_release);
276 EXPORT_SYMBOL(path_walk);
277 +EXPORT_SYMBOL(path_walk_it);
278 EXPORT_SYMBOL(permission);
279 EXPORT_SYMBOL(unlock_rename);
280 EXPORT_SYMBOL(vfs_create);
281 Index: linus-2.6.7-bk-latest/fs/open.c
282 ===================================================================
283 --- linus-2.6.7-bk-latest.orig/fs/open.c 2004-07-07 10:56:13.610513296 +0300
284 +++ linus-2.6.7-bk-latest/fs/open.c 2004-07-07 11:38:42.867967256 +0300
285 @@ -216,11 +216,12 @@
286 struct inode * inode;
289 + intent_init(&nd.intent.open, IT_GETATTR);
291 if (length < 0) /* sorry, but loff_t says... */
294 - error = user_path_walk(path, &nd);
295 + error = user_path_walk_it(path, &nd);
298 inode = nd.dentry->d_inode;
300 kernel_cap_t old_cap;
303 + intent_init(&nd.intent.open, IT_GETATTR);
304 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
309 current->cap_effective = current->cap_permitted;
311 - res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
312 + res = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
314 res = permission(nd.dentry->d_inode, mode, &nd);
315 /* SuS v2 requires we report a read only fs too */
320 - error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
321 + intent_init(&nd.intent.open, IT_GETATTR);
322 + error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
330 - error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
331 + intent_init(&nd.intent.open, IT_GETATTR);
332 + error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
338 int namei_flags, error;
340 + intent_init(&nd.intent.open, IT_OPEN);
343 if ((namei_flags+1) & O_ACCMODE)
344 @@ -763,14 +768,14 @@
346 error = open_namei(filename, namei_flags, mode, &nd);
348 - return dentry_open(nd.dentry, nd.mnt, flags);
349 + return dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent.open);
351 return ERR_PTR(error);
354 EXPORT_SYMBOL(filp_open);
356 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
357 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct open_intent *it)
364 f->f_mode = (flags+1) & O_ACCMODE;
366 inode = dentry->d_inode;
367 if (f->f_mode & FMODE_WRITE) {
368 error = get_write_access(inode);
370 error = f->f_op->open(inode,f);
373 + intent_release(it);
375 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
377 @@ -825,11 +832,20 @@
381 + intent_release(it);
384 return ERR_PTR(error);
387 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
389 + struct open_intent it;
390 + intent_init(&it, IT_LOOKUP);
392 + return dentry_open_it(dentry, mnt, flags, &it);
395 EXPORT_SYMBOL(dentry_open);
398 Index: linus-2.6.7-bk-latest/fs/stat.c
399 ===================================================================
400 --- linus-2.6.7-bk-latest.orig/fs/stat.c 2004-07-07 10:56:13.635509496 +0300
401 +++ linus-2.6.7-bk-latest/fs/stat.c 2004-07-07 11:38:42.868967104 +0300
407 EXPORT_SYMBOL(vfs_getattr);
409 int vfs_stat(char __user *name, struct kstat *stat)
413 + intent_init(&nd.intent.open, IT_GETATTR);
415 - error = user_path_walk(name, &nd);
416 + error = user_path_walk_it(name, &nd);
418 error = vfs_getattr(nd.mnt, nd.dentry, stat);
424 + intent_init(&nd.intent.open, IT_GETATTR);
426 - error = user_path_walk_link(name, &nd);
427 + error = user_path_walk_link_it(name, &nd);
429 error = vfs_getattr(nd.mnt, nd.dentry, stat);
433 struct file *f = fget(fd);
435 + struct nameidata nd;
436 + intent_init(&nd.intent.open, IT_GETATTR);
439 error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
440 + intent_release(&nd.intent.open);
444 Index: linus-2.6.7-bk-latest/fs/namespace.c
445 ===================================================================
446 --- linus-2.6.7-bk-latest.orig/fs/namespace.c 2004-07-07 10:56:13.605514056 +0300
447 +++ linus-2.6.7-bk-latest/fs/namespace.c 2004-07-07 11:38:42.868967104 +0300
450 static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
452 + memset(old_nd, 0, sizeof(*old_nd));
453 old_nd->dentry = mnt->mnt_mountpoint;
454 old_nd->mnt = mnt->mnt_parent;
455 mnt->mnt_parent = mnt;
456 Index: linus-2.6.7-bk-latest/fs/exec.c
457 ===================================================================
458 --- linus-2.6.7-bk-latest.orig/fs/exec.c 2004-07-07 10:56:13.395545976 +0300
459 +++ linus-2.6.7-bk-latest/fs/exec.c 2004-07-07 11:38:42.869966952 +0300
464 + intent_init(&nd.intent.open, IT_OPEN);
465 nd.intent.open.flags = FMODE_READ;
466 - error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
467 + error = user_path_walk_it(library, &nd);
475 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
476 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent.open);
477 error = PTR_ERR(file);
484 + intent_init(&nd.intent.open, IT_OPEN);
485 nd.intent.open.flags = FMODE_READ;
486 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
487 + err = path_lookup_it(name, LOOKUP_FOLLOW, &nd);
495 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
496 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent.open);
498 err = deny_write_access(file);
500 Index: linus-2.6.7-bk-latest/fs/xattr.c
501 ===================================================================
502 --- linus-2.6.7-bk-latest.orig/fs/xattr.c 2004-07-07 10:56:13.643508280 +0300
503 +++ linus-2.6.7-bk-latest/fs/xattr.c 2004-07-07 11:38:42.870966800 +0300
508 - error = user_path_walk(path, &nd);
509 + intent_init(&nd.intent.open, IT_GETXATTR);
510 + error = user_path_walk_it(path, &nd);
513 error = getxattr(nd.dentry, name, value, size);
518 - error = user_path_walk_link(path, &nd);
519 + intent_init(&nd.intent.open, IT_GETXATTR);
520 + error = user_path_walk_link_it(path, &nd);
523 error = getxattr(nd.dentry, name, value, size);
528 - error = user_path_walk(path, &nd);
529 + intent_init(&nd.intent.open, IT_GETXATTR);
530 + error = user_path_walk_it(path, &nd);
533 error = listxattr(nd.dentry, list, size);
538 - error = user_path_walk_link(path, &nd);
539 + intent_init(&nd.intent.open, IT_GETXATTR);
540 + error = user_path_walk_link_it(path, &nd);
543 error = listxattr(nd.dentry, list, size);
545 --- linux-2.6.7.orig/include/linux/mount.h 2004-06-16 13:18:57.000000000 +0800
546 +++ linux-2.6.7/include/linux/mount.h 2004-09-06 21:05:29.000000000 +0800
549 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
550 struct list_head mnt_list;
551 + struct list_head mnt_lustre_list; /* GNS mount list */
552 + unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */
555 static inline struct vfsmount *mntget(struct vfsmount *mnt)