| Linux - Kernel This forum is for all discussion relating to the Linux kernel. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-18-2009, 02:35 AM
|
#1
|
|
LQ Newbie
Registered: May 2009
Posts: 12
Rep:
|
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 09:23 AM.
|
|
|
|
05-18-2009, 10:59 AM
|
#2
|
|
LQ Newbie
Registered: Apr 2009
Posts: 17
Rep:
|
__user_walk() is split into user_path_at() (for no LOOKUP_PARENT) and user_path_parent() (for LOOKUP_PARENT)
|
|
|
|
05-18-2009, 09:20 PM
|
#3
|
|
LQ Newbie
Registered: May 2009
Posts: 12
Original Poster
Rep:
|
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 09:26 PM.
|
|
|
|
05-19-2009, 07:04 AM
|
#4
|
|
LQ Newbie
Registered: May 2009
Posts: 12
Original Poster
Rep:
|
Thanks, and more question
Quote:
Originally Posted by titan22
__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?
|
|
|
|
05-19-2009, 08:26 AM
|
#5
|
|
LQ Newbie
Registered: May 2009
Posts: 12
Original Poster
Rep:
|
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?
|
|
|
|
05-19-2009, 08:52 PM
|
#6
|
|
LQ Newbie
Registered: Apr 2009
Posts: 17
Rep:
|
__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);
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:07 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|