LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 05-18-2009, 03:35 AM   #1
ao.yuan.young
LQ Newbie
 
Registered: May 2009
Posts: 12

Rep: Reputation: 0
Question some question about the __user_walk function declared in linux-2.4.20/fs/namei.c


Can any one tell me that which function in kernel-2.6.27 replaces the function __user_walk defined kernel-2.4.20?

Last edited by ao.yuan.young; 05-18-2009 at 10:23 AM.
 
Old 05-18-2009, 11:59 AM   #2
titan22
LQ Newbie
 
Registered: Apr 2009
Posts: 17

Rep: Reputation: 3
__user_walk() is split into user_path_at() (for no LOOKUP_PARENT) and user_path_parent() (for LOOKUP_PARENT)
 
Old 05-18-2009, 10:20 PM   #3
ao.yuan.young
LQ Newbie
 
Registered: May 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Thank you for your answer very much.

The codes I have in kernel-2.4.20 are:
...
error = 0;
error = __user_walk(filename, LOOKUP_FOLLOW, &nd);
if (error) return error;
...

so, if I want to implement the code block above in kernel-2.6.27, I should code like this:
...
error = 0;
error = user_path_at('dfd', 'name', LOOKUP_FOLLOW, 'path');
if (error) return error;
...

Sorry, I haven't been sure the value of argument "int dfd", "const char __user *name", and "struct path *path", so I use placeholder here.

Am I right? Will you introduce the use of user_path_at and user_path_parent here?

Last edited by ao.yuan.young; 05-18-2009 at 10:26 PM.
 
Old 05-19-2009, 08:04 AM   #4
ao.yuan.young
LQ Newbie
 
Registered: May 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Smile Thanks, and more question

Quote:
Originally Posted by titan22 View Post
__user_walk() is split into user_path_at() (for no LOOKUP_PARENT) and user_path_parent() (for LOOKUP_PARENT)
Thank you for your answer very much.

The codes I have in kernel-2.4.20 are:
...
error = 0;
error = __user_walk(filename, LOOKUP_FOLLOW, &nd);
if (error) return error;
...

so, if I want to implement the code block above in kernel-2.6.27, I should code like this:
...
error = 0;
error = user_path_at('dfd', 'name', LOOKUP_FOLLOW, 'path');
if (error) return error;
...

Sorry, I haven't been sure the value of argument "int dfd", "const char __user *name", and "struct path *path", so I use placeholder here.

Am I right? Will you introduce the use of user_path_at and user_path_parent here, for I have been looking for a long time by google, but I can't find any article which introduce the usage of the two funciton?
 
Old 05-19-2009, 09:26 AM   #5
ao.yuan.young
LQ Newbie
 
Registered: May 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Smile maybe I shoud use path_lookup to replace __user_walk

The code of function __user_walk() in kernel-2.4.20 is follows:

int __user_walk(const char *name, unsigned flags, struct nameidata *nd)
{
char *tmp;
int err;

tmp = getname(name);
err = PTR_ERR(tmp);
if (!IS_ERR(tmp)) {
err = 0;
err = path_lookup(tmp, flags, nd);
putname(tmp);
}
return err;
}

As we can see, in the function, its main point is calling function path_lookup(), the only difference with calling path_lookup() directly is that, it calls function getname() to copy the argument name from user space into kernel space, and free the space allocated after calling, so I think perhaps I should should use the function path_lookup() to replace the function __user_walk(), just like this:
...
error = 0;
error = path_lookup(filename, LOOKUP_FOLLOW, &nd);
if (error) return error;
...

How do you think?
 
Old 05-19-2009, 09:52 PM   #6
titan22
LQ Newbie
 
Registered: Apr 2009
Posts: 17

Rep: Reputation: 3
__user_walk() and user_path_xxx() take user space filename
path_lookup() and do_path_lookup() take kernel space filename

user_walk() cannot be replaced by path_lookup() which does not know how to handle user space address. You probably want to read through the new/old APIs and printk or debug to verify.

error = __user_walk(filename, LOOKUP_FOLLOW, &nd);
==>
error = user_path_at(AT_FDCWD, filename, LOOKUP_FOLLOW, &nd);
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to know the reason why 'State' has been declared as 'Long' in Linux PCB. LinuxInfo Programming 4 09-16-2008 01:02 AM
Compilation issue when Function is parameter in function call on LINUX sa20358 Linux - Software 2 07-24-2008 11:19 PM
no member function declared in class...weird behavior... jaepi Programming 1 12-11-2007 11:23 PM
Howto access a variable outside the function from where it is declared in C daYz Programming 4 03-09-2007 02:37 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 01:21 PM


All times are GMT -5. The time now is 11:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration