LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   need help with do_path_lookup and lookup_hash (https://www.linuxquestions.org/questions/programming-9/need-help-with-do_path_lookup-and-lookup_hash-603420/)

Macska 11-30-2007 01:07 AM

need help with do_path_lookup and lookup_hash
 
Hello

All I want to do right now in my system call in namei.c is get the function of knowing whether or not a file exists to work.

I pass in the filename, and copy it to kernel space.

Then I call:
err = do_path_lookup(AT_FDCWD, pathname_in_system_space, LOOKUP_PARENT, &nd);,

which always returns a value of zero unless I give it an invalid path.
It is not really checking to see if the file exists, but just if the path exists. This is what it should do, right?

Then if err is >= 0
I call:
new_dentry = lookup_hash(&nd);
err = PTR_ERR(new_dentry);
printk(KERN_ALERT"err %d\n", err);

if(IS_ERR(new_dentry)){
printk(KERN_ALERT"This file does not exist yet%s\n",to);
}
There is never an error with new_dentry, even if the file does not exist. And err that I print from PTR_ERR is always a large random negative number. I know this is not working as it should, I just do not know what I am missing? Do I need to call putname right after calling do_path_lookup? Please if you can help me I would appreciate it.

Thank you
Macska

Tinkster 12-01-2007 11:19 AM

Moved: This thread is more suitable in <programming>, and has been moved accordingly to help your thread/question get the exposure it deserves.


All times are GMT -5. The time now is 01:18 AM.