Skip to contentSkip to conversation

Inode question

DISCUSSION sankarshana rao 4 participants 10 messages Jul 21, 2004 – Jul 27, 2004

lore
Share & tools
lore
#0 lore raw

Hi,
I want to call namei() function in order to derive an inode from a path name. Can I do this inside a kernel module???
If yes, what object file should I link to in order to get namei() definition??

pls advice...

Thx in advance
Sankarshana M

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#1 lore raw
Quoted 6 lines · sankarshana rao

Hi,
I want to call namei() function in order to derive an inode from a path name. Can I do this inside a kernel module???

From a kernel module, you should probably call path_lookup().

Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#2 lore raw

Thx for the reply...
When I try to call lookup() from my kernel module, it gives undefined symbol error during INSMOD.. any clues???

Quoted 4 lines · --- Dave Kleikamp
Quoted 2 lines · sankarshana rao

Hi,
I want to call namei() function in order to derive

an

Quoted 13 lines
Quoted 1 line

inode from a path name. Can I do this inside a

kernel

Quoted 3 lines

module???

From a kernel module, you should probably call

path_lookup().

Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center

__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/

#3 lore raw
Quoted 4 lines · sankarshana rao

Thx for the reply...
When I try to call lookup() from my kernel module, it gives undefined symbol error during INSMOD.. any clues???

Not lookup, but path_lookup.

#include <linux/namei.h>
struct nameidata nd;
rc = path_lookup(path, LOOKUP_FOLLOW, &nd);
if (rc)
file not found
else

	inum = nd.dentry->d_inode->i_ino;
	path_release(&nd);
Quoted 13 lines
Quoted 12 lines · --- Dave Kleikamp
Quoted 2 lines · sankarshana rao

Hi,
I want to call namei() function in order to derive

an

Quoted 1 line

inode from a path name. Can I do this inside a

kernel

Quoted 3 lines

module???

From a kernel module, you should probably call

path_lookup().

Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#4 lore raw
In reply to sankarshana rao
Quoted 5 lines · sankarshana rao

Thx for the reply...
When I try to call lookup() from my kernel module, it gives undefined symbol error during INSMOD.. any clues???

It's probably not an exported symbol.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.

#5 lore raw

Guys,
Thx for the inputs...I got it with path_lookup....

Can I pass the inode pointer back to the user space??? I have a scenario in which I have to create multiple folders on the harddisk. The number of folders can be in hundreds. Instead of parsing the path name everytime I need to create a folder (that's what sys_mkdir does??? ), I was thinking if I have the inode* of the parent folder, I can avoid this parsing and directly create a subfolder under the parent folder...

Pls advice if this approach makes sense or not and if it is doable or not??

any input in this regard will be very helpful..

--- "Richard B. Johnson" <[email protected]>

Quoted 9 lines · wrote:
Quoted 2 lines · sankarshana rao

Thx for the reply...
When I try to call lookup() from my kernel module,

it

Quoted 3 lines

gives undefined symbol error during INSMOD..
any clues???

Quoted 11 lines

It's probably not an exported symbol.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine
(5570.56 BogoMips).
Note 96.31% of all statistics are
fiction.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#6 lore raw
Quoted 4 lines · sankarshana rao

Guys,
Thx for the inputs...I got it with path_lookup....

Can I pass the inode pointer back to the user space???

To get an inode number from user space you can simply use the "stat" or "fstat" functions. You don't need to create your own module.

Quoted 8 lines

I have a scenario in which I have to create multiple folders on the harddisk. The number of folders can be in hundreds. Instead of parsing the path name everytime I need to create a folder (that's what sys_mkdir does??? ), I was thinking if I have the inode* of the parent folder, I can avoid this parsing and directly create a subfolder under the parent folder...

Is this really a problem? The dentry cache should make this quite fast, leaving the bottleneck to the actual write on disk of the result.

I tried a small program (if it can be called a program) to create a thousand directories and it takes less than 100 ms on my machine.

Best regards,

Signature · 2 lines
Paulo Marques - www.grupopie.com
"In a world without walls and fences who needs windows and gates?"
#7 lore raw

Thx for the inputs..
I am trying this thing on Mips processor and creating 500 folders itself takes about 1.6 seconds. That's why I was wondering if using inodes would make it any faster..
pls guide...

Quoted 29 lines · --- Paulo Marques
Quoted 4 lines · sankarshana rao

Guys,
Thx for the inputs...I got it with path_lookup....

Can I pass the inode pointer back to the user

space???

To get an inode number from user space you can simply use the "stat" or
"fstat" functions. You don't need to create your own module.

Quoted 1 line

I have a scenario in which I have to create

multiple

Quoted 1 line

folders on the harddisk. The number of folders can

be

Quoted 4 lines

in hundreds. Instead of parsing the path name everytime I need to create a folder (that's what sys_mkdir does??? ), I was thinking if I have the inode* of the parent folder, I can avoid this

parsing

Quoted 2 lines

and directly create a subfolder under the parent folder...

Is this really a problem? The dentry cache should make this quite fast,
leaving the bottleneck to the actual write on disk of the result.

Quoted 13 lines

I tried a small program (if it can be called a program) to create a
thousand directories and it takes less than 100 ms on my machine.

Best regards,

Signature · 3 lines
Paulo Marques - www.grupopie.com
"In a world without walls and fences who needs
windows and gates?"

__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail

#8 lore raw
Quoted 6 lines · sankarshana rao

Thx for the inputs..
I am trying this thing on Mips processor and creating 500 folders itself takes about 1.6 seconds. That's why I was wondering if using inodes would make it any faster..
pls guide...

I really think the name lookup is not your bottleneck.

I did some more tests to check where the time to create a dir came from and, as expected, it depends a lot on the filesystem.

Using ext3, creating 1000 dirs on my machine (P4 2.8GHz) takes about 100 ms. Using tmpfs, takes only 6 ms. Even a machine 20 times slower would take at most 60ms to do the 500 lookups.

Both tests have to do the same lookup on the dentry cache and check for duplicate names, etc.

So the real difference is the time *the filesystem* takes to create a dir.

You're probably using JFFS2 or something like that, which is almost synchronous (I don't know for sure if it is really synchronous), and writes the updates to flash on every dir creation.

I hope this helps,

Signature · 2 lines
Paulo Marques - www.grupopie.com
"In a world without walls and fences who needs windows and gates?"
#9 lore raw
In reply to sankarshana rao
Quoted 4 lines · sankarshana rao

Guys,
Thx for the inputs...I got it with path_lookup....

Can I pass the inode pointer back to the user space???

You shouldn't do that.

Quoted 8 lines

I have a scenario in which I have to create multiple folders on the harddisk. The number of folders can be in hundreds. Instead of parsing the path name everytime I need to create a folder (that's what sys_mkdir does??? ), I was thinking if I have the inode* of the parent folder, I can avoid this parsing and directly create a subfolder under the parent folder...

Couldn't the program chdir to the parent directory and create the folders with a relative pathname?

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center