having problem in understanding namei module


 
Thread Tools Search this Thread
Special Forums Hardware Filesystems, Disks and Memory having problem in understanding namei module
# 1  
Old 10-20-2003
having problem in understanding namei module

can anyone give me some idea on unix filesystem namei's algorithsm
# 2  
Old 10-20-2003
Your question assumes that there is a module called namei() which is probably false. Back when there was a namei(), it took a pathname and returned a (in-core) inode or it returned an error. namei, by its very name, cannot handle a modern kernel's needs. Today a kernel would want a vnode, not an inode. And the change was made to support the concept of several types of filesystems. You can't return an inode for fat-32 or nfs.

I am guessing that your motivation for asking this question comes from looking at the output of sar which can tell you how often namei was called. Today that counter in incremented in a function called lookupname() (or something like that). And iget() is no longer around either. It is now VFS_LOOKUP() (a macro) (and again, the name may be a little different).

Even the old namei() was a rough algorithm. Look at the system call lstat().... that tells you that sometimes namei needs to not follow a symbolic link. And at some point a name cache appeared. Since I must go back in time, I'm going back far enough that there are no symlinks nor a name cache.

namei() is called by a system call and namei needs to access the uarea of the process that is making the system call. If a pathname starts with a /, namei must get the process root. That's how a chroot is enforced. Otherwise it must get the process CWD. Now it knows where to start. At each point it will also verify that the process has permission to access each component.

Now it needs to lookup the first name. So it reads the current directory and obtains a directory entry. Then it calls geti() to obtain an in-core inode. geti will notice if the inode is a mount point by checking the mount table.... if so, it will seek the inode in the mount table instead. It will also notice if the inode is in core, if not iget will read it.

This continues until the pathname is resolved or the procedure fails.

The only other problem is a path like /usr/local/../lib where /usr/local is a mounted filesystem. Here namei() must cross a mount point backwards and there is special code for that.

Nice first question of the day! I'm awake now! Smilie
# 3  
Old 10-22-2003
Bug thanks from my heart

first ,here i give my sincere thank to you.

I have go to the kernel of unix for about 2 months, i am a beginner.
I studied the kernel from a book structure analysis of unix, a relatively simple and basic one.So sometimes i really can't get it and can't get the whole of the unix,also some specific problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with (Understanding) function

I have this code #!/bin/bash LZ () { RETVAL="\n$(date +%Y-%m-%d_%H-%M-%S) --- " return RETVAL } echo -e $LZ"Test" sleep 3 echo -e $LZ"Test" which I want to use to make logentrys on my NAS. I expect of this code that there would be output like 2017-03-07_11-00-00 --- Test (4 Replies)
Discussion started by: matrois
4 Replies

2. Shell Programming and Scripting

Problem in understanding debugging

Hi i was going through the script debugging technique. below example was given in the book. 1 #!/bin/sh 2 3 Failed() { 4 if ; then 5 echo "Failed. Exiting." ; exit 1 ; 6 fi 7 echo "Done." 8 } 9 10 echo "Deleting old backups,... (11 Replies)
Discussion started by: scriptor
11 Replies

3. Shell Programming and Scripting

Problem on understanding the regexp command

Hi all, I'm not clear of this regexp command: regexp {(\S+)\/+$} $String match GetString From my observation and testing, if $String is abc/def/gh $GetString will be abc/def I don't understand how the /gh in $String got eliminated. Please help. Thanks (2 Replies)
Discussion started by: mar85
2 Replies

4. Shell Programming and Scripting

Problem in understanding export uses

i am beginner in shell scripting. not able to understand what below line will do. PS1=${HOST:=Žuname -nŽ}"$ " ; export PS1 HOST below is the script #!/bin/hash PS1=${HOST:=Žuname -nŽ}"$ " ; export PS1 HOST ; echo $PS1 and i getting the below output Žuname -nŽ$ (25 Replies)
Discussion started by: scriptor
25 Replies

5. UNIX for Dummies Questions & Answers

Problem understanding Paths

If I don't explain my issue well enough, I apologize ahead of time, extreme newbie here to scripting. I'm currently learning scripting from books and have moved on to the text Wicked Cool Shell Scripts by Dave Taylor, but there are still basic concepts that I'm having trouble understanding. ... (10 Replies)
Discussion started by: Chasman78
10 Replies

6. UNIX for Advanced & Expert Users

Problem loading cpufreq module

I'd like to install cpufreq modules on my server . I tried sudo modprobe acpi-cpufreq but got the error FATAL: Error inserting acpi_cpufreq (/lib/modules/2.6.18-238.12.1.el5xen/kernel/arch/x86_64/kernel/cpufreq/acpi-cpufreq.ko): No such device cat /proc/cpuinfo gives this ... (11 Replies)
Discussion started by: vishwamitra
11 Replies

7. Shell Programming and Scripting

Problem with the shell script for understanding

Can Anybody please tell me the meaning of the script: #!/bin/sh str=$@ echo $str | sed 's/.*\\//' exit 0 (6 Replies)
Discussion started by: nixhead
6 Replies

8. UNIX for Advanced & Expert Users

Kernel module compilation problem

I have one big module 2.6.18 kernel mod.c I want to divide this to several files. The problem is to write right Makefile lib1.h lib1.c mod.c mod.c works fine normally but when I divide into several files and try to compile with this makefile obj-m := mod.o mod-objs := lib1.o ... (3 Replies)
Discussion started by: marcintom
3 Replies

9. Red Hat

Problem with kernel-module-ntfs

Hi All Im trying to access the my windows XP NTFS from Redhat linux 4.0 Enterprise edition I have downloaded the respective rpm And im able to install it successfully Then i have given the following command , but got an error Here are my partitions And when i give the below... (1 Reply)
Discussion started by: balumankala
1 Replies

10. Shell Programming and Scripting

egrep understanding problem

Hi, Can anyone please let me know the meaning of this line,i am not able to understand the egrep part(egrep '^{1,2}).This will search for this combination in beginning but what does the values in {}signifies here. /bin/echo $WhenToRun | egrep '^{1,2}:$' >/dev/null (1 Reply)
Discussion started by: namishtiwari
1 Replies
Login or Register to Ask a Question