LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-30-2007, 01:07 AM   #1
Macska
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Rep: Reputation: 0
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
 
Old 12-01-2007, 11:19 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Reply



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



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:19 AM.

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
Open Source Consulting | Domain Registration