If you look at testfile in block 635, the inode number of its directory (.) is 34, which is is ida's directory (see block 407). The directory "ida" is in the directory with inode number 9 (again look at the entry with the dot), which is the directory "tmp"..
In Unix filesystems all data files are made up of allocated blocks of disk but also all directories are also 'files'.
If the operating system needs to read the file:
it would go to inode 1 (well actually inode 2 on most operating systems because inode 1 is the bad block table), look up which block the root directory index is located on, and go to that block and look for 'tmp's inode number. It now knows that the 'tmp' directory inode is 9.
It goes to inode 9 and reads that the 'tmp' directory index starts at block 407. It goes to block 407, reads the index looking for 'ida' and then knows that 'ida's inode number is 34.
It goes to inode 34 and reads that the 'ida' directory index starts at block 635. It goes to block 635, reads the index looking for 'testfile' and then knows that 'testfile's inode number is 76.
It goes to inode 76 and reads the starting block number for testfile and it can now go to that block and start reading testfile's actual data content.
Additionally, if the O/S wanted to read /home then in the root directory index it would find that /home inode number is 6. Going to inode 6 is would read that /home directory index starts at block 321.
See your updated graphic attached.
Hope that helps. If you still don't get it, post back your questions.
The reason for this is that the block 321 starts at inode 6 which we also have listed in our root directory. so there is no long way.
Same goes for oswald inode 19:
If this is correct so far then the edited screenshot with description helped me so much too understand it.
The last question would be just how do I do it with a relative path?
I know that the absolute path starts from the root and the relative path to the current working directory. But how I find the current working directory? Should I just pick one of those blocks?
When you want to walk an absolute pathname starting from the process' root directory, a C program can use rootdir = opendir("/"); to open a directory stream to read the root directory and it can use currentdir = opendir("."); to open a directory stream to read the current working directory.
If you want the pathname of the current working directory in a process, a C program can use the getcwd() function to get an absolute pathname of the current working directory:
How can i trace Inode structure and modify it in UNIX kernel?
We want to change the inode structure in the sense that we want to add a new field to the inode data structure. So we want to know how and where to trace inode (7 Replies)
Dear Forum,
Please help me i have SUNW,Sun-Fire-V240 with sun solaris 8,if i check inode in /var like below:
# df -F ufs -o i
Filesystem iused ifree %iused Mounted on
/dev/md/dsk/d0 62354 310638 17% /
/dev/md/dsk/d3 372992 0 100% /var... (2 Replies)
Hi, sorry to have written in other language i think i could do that.
I would to know
A file system use inodes indexed allocation as a method of allocating space.
In the inode blocks are 10 references to direct, 1 indirect reference to a single block, 1 block indirect reference to a reference to... (1 Reply)
how is the location of inodes in the physical disk.
are they sequential like:
bootblock|superblock|inode1|inode2| ....| datablock1|datablock2|datablock3
or are they distributed among data blocks like:
bootblock|superblock|inode1|datablock1|inode2|datablock2|datablock3|inode3
|datablock4 (3 Replies)
hi
i need to find all the files that r linked to the current file as i need to delete the file as well as few of its links :confused:
thnx in advance (1 Reply)
Does anyone know what command I can run to check how many inodes are in use on a specific filesystem. On Data General servers I used to run the df -k command to check the status of the inodes for all file system.s (1 Reply)
Could someone please explain to me the concept of INodes?
Colour me a DOS/MacOS junkie, but I don't quite understand.
Is there any relation to clusters, or physical distro.?
ty. (3 Replies)