Hello!
On Mon, Oct 09, 2006 at 02:40:52AM +0200, Goswin von Brederlow
wrote:> Does that work? Doesn''t other code add flags to the intent
structure
> between intent_init and path_lookup that intent_init would revert?
Yes, it works. There isspecial path_lookup_it function added for intent-aware
users. Everything else comes through path_lookup that inits intent to something
sensible.
(See patch attached)
> And while we are on the topic, why does the intent have a magic field
> when the field isn''t checked to catch uninitialized intents? Any
idea
> what the field is used for?
The magic is checked, but only inside of lustre client.
Bye,
Oleg
-------------- next part --------------
--- linux-2.6.9-34.EL/fs/namei.c.orig 2006-09-19 13:06:11.000000000 +0300
+++ linux-2.6.9-34.EL/fs/namei.c 2006-09-19 13:18:05.000000000 +0300
@@ -1042,7 +1042,7 @@ set_it:
}
/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
-int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
*nd)
+int fastcall path_lookup_it(const char *name, unsigned int flags, struct
nameidata *nd)
{
int retval = 0;
@@ -1076,6 +1076,12 @@ out:
return retval;
}
+int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata
*nd)
+{
+ intent_init(&nd->intent, IT_GETATTR);
+ return path_lookup_it(name, flags, nd);
+}
+
/*
* Restricted form of lookup. Doesn''t follow links, single-component
only,
* needs parent already locked. Doesn''t follow mounts.
@@ -1173,7 +1179,7 @@ int fastcall __user_walk_it(const char _
int err = PTR_ERR(tmp);
if (!IS_ERR(tmp)) {
- err = path_lookup(tmp, flags, nd);
+ err = path_lookup_it(tmp, flags, nd);
putname(tmp);
}
return err;
@@ -1478,7 +1484,7 @@ int open_namei(const char * pathname, in
* The simplest case - just a plain lookup.
*/
if (!(flag & O_CREAT)) {
- error = path_lookup(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd);
+ error = path_lookup_it(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd);
if (error)
return error;
goto ok;
@@ -1488,7 +1494,7 @@ int open_namei(const char * pathname, in
* Create - we need to know the parent.
*/
nd->intent.it_op |= IT_CREAT;
- error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
+ error = path_lookup_it(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
if (error)
return error;
@@ -1697,7 +1703,7 @@ asmlinkage long sys_mknod(const char __u
if (IS_ERR(tmp))
return PTR_ERR(tmp);
- error = path_lookup(tmp, LOOKUP_PARENT, &nd);
+ error = path_lookup_it(tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
@@ -1780,7 +1786,7 @@ asmlinkage long sys_mkdir(const char __u
struct nameidata nd;
intent_init(&nd.intent, IT_LOOKUP);
- error = path_lookup(tmp, LOOKUP_PARENT, &nd);
+ error = path_lookup_it(tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
if (nd.dentry->d_inode->i_op->mkdir_raw) {
@@ -1886,7 +1892,7 @@ asmlinkage long sys_rmdir(const char __u
if(IS_ERR(name))
return PTR_ERR(name);
- error = path_lookup(name, LOOKUP_PARENT, &nd);
+ error = path_lookup_it(name, LOOKUP_PARENT, &nd);
if (error)
goto exit;
@@ -1975,7 +1981,7 @@ asmlinkage long sys_unlink(const char __
if(IS_ERR(name))
return PTR_ERR(name);
- error = path_lookup(name, LOOKUP_PARENT, &nd);
+ error = path_lookup_it(name, LOOKUP_PARENT, &nd);
if (error)
goto exit;
error = -EISDIR;
@@ -2057,7 +2063,7 @@ asmlinkage long sys_symlink(const char _
struct nameidata nd;
intent_init(&nd.intent, IT_LOOKUP);
- error = path_lookup(to, LOOKUP_PARENT, &nd);
+ error = path_lookup_it(to, LOOKUP_PARENT, &nd);
if (error)
goto out;
if (nd.dentry->d_inode->i_op->symlink_raw) {
@@ -2149,7 +2155,7 @@ asmlinkage long sys_link(const char __us
error = __user_walk(oldname, 0, &old_nd);
if (error)
goto exit;
- error = path_lookup(to, LOOKUP_PARENT, &nd);
+ error = path_lookup_it(to, LOOKUP_PARENT, &nd);
if (error)
goto out;
error = -EXDEV;
@@ -2339,11 +2345,11 @@ static inline int do_rename(const char *
intent_init(&oldnd.intent, IT_LOOKUP);
intent_init(&newnd.intent, IT_LOOKUP);
- error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
+ error = path_lookup_it(oldname, LOOKUP_PARENT, &oldnd);
if (error)
goto exit;
- error = path_lookup(newname, LOOKUP_PARENT, &newnd);
+ error = path_lookup_it(newname, LOOKUP_PARENT, &newnd);
if (error)
goto exit1;
@@ -2589,6 +2595,7 @@ EXPORT_SYMBOL(page_readlink);
EXPORT_SYMBOL(page_symlink);
EXPORT_SYMBOL(page_symlink_inode_operations);
EXPORT_SYMBOL(path_lookup);
+EXPORT_SYMBOL(path_lookup_it);
EXPORT_SYMBOL(path_release);
EXPORT_SYMBOL(path_walk);
EXPORT_SYMBOL(permission);
--- linux-2.6.9-34.EL/include/linux/namei.h.orig 2006-09-19 13:13:05.000000000
+0300
+++ linux-2.6.9-34.EL/include/linux/namei.h 2006-09-19 13:13:23.000000000 +0300
@@ -100,6 +100,7 @@ extern void intent_release(struct lookup
#define user_path_walk_link(name,nd) \
__user_walk(name, 0, nd)
extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
+extern int FASTCALL(path_lookup_it(const char *, unsigned, struct nameidata
*));
extern int FASTCALL(path_walk(const char *, struct nameidata *));
extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
extern void path_release(struct nameidata *);
--- linux-2.6.9-34.EL/fs/exec.c.orig 2006-09-19 20:33:56.047773027 +0300
+++ linux-2.6.9-34.EL/fs/exec.c 2006-09-19 13:12:09.000000000 +0300
@@ -493,7 +493,7 @@ struct file *open_exec(const char *name)
intent_init(&nd.intent, IT_OPEN);
nd.intent.it_flags = FMODE_READ|FMODE_EXEC;
- err = path_lookup(name, LOOKUP_FOLLOW, &nd);
+ err = path_lookup_it(name, LOOKUP_FOLLOW, &nd);
file = ERR_PTR(err);
if (!err) {
--- linux-2.6.9-34.EL/fs/block_dev.c.orig 2006-09-19 20:33:49.554900684 +0300
+++ linux-2.6.9-34.EL/fs/block_dev.c 2006-09-19 13:11:54.000000000 +0300
@@ -842,7 +842,7 @@ struct block_device *lookup_bdev(const c
return ERR_PTR(-EINVAL);
intent_init(&nd.intent, IT_LOOKUP);
- error = path_lookup(path, LOOKUP_FOLLOW, &nd);
+ error = path_lookup_it(path, LOOKUP_FOLLOW, &nd);
if (error)
return ERR_PTR(error);
--- linux-2.6.9-34.EL/fs/namespace.c.orig 2006-09-19 20:33:33.250265887 +0300
+++ linux-2.6.9-34.EL/fs/namespace.c 2006-09-19 20:34:02.633586286 +0300
@@ -635,7 +635,7 @@ static int do_loopback(struct nameidata
if (!old_name || !*old_name)
return -EINVAL;
intent_init(&old_nd.intent, IT_LOOKUP);
- err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
+ err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
if (err)
return err;
@@ -710,7 +710,7 @@ static int do_move_mount(struct nameidat
if (!old_name || !*old_name)
return -EINVAL;
intent_init(&old_nd.intent, IT_LOOKUP);
- err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
+ err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
if (err)
return err;
@@ -1046,7 +1046,7 @@ long do_mount(char * dev_name, char * di
flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
/* ... and get the mountpoint */
- retval = path_lookup_it(dir_name, LOOKUP_FOLLOW, &nd);
+ retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
if (retval)
return retval;