LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2013, 01:30 AM   #1
hizzana
LQ Newbie
 
Registered: May 2013
Posts: 4

Rep: Reputation: Disabled
Question Can someone explain the detail of the 'inode count' when using command 'll'


i can understand why hard links can change that number,but still confused with the number of a directory.

in fact, create a sub dir will change the number of his parent, regular files will not.

hard link:

file1
|
|——> inode -> data block
|
file2

the 2 files above have a common inode with the count value 2

directoy:

assume ./a/b, b is the only sub dir of a

inode(a) ——> data block(a) ——> contains {inode:[10, 11, 12], filename:[., .., b]} // this editor will ignore the extra blank, so here i use json instead

above show the struct of storage of a dir
if a's inode is 9, b's is 12, they are not the same
means only 2 filenames are linked to inode 9(a and .)

someone can help me understand why?

Last edited by hizzana; 06-07-2013 at 01:37 AM.
 
Old 06-07-2013, 04:35 AM   #2
shm0
Member
 
Registered: Aug 2012
Location: Bahrain
Distribution: Slackware
Posts: 58

Rep: Reputation: 16
Quote:
Originally Posted by hizzana View Post
i can understand why hard links can change that number,but still confused with the number of a directory.
Do you mean the "Total <number>" part of the command output? if yes, then check this from the GNU page on the ls command :

Quote:
For each directory that is listed, preface the files with a line ‘total blocks’, where blocks is the total disk allocation for all files in that directory. The block size currently defaults to 1024 bytes, but this can be overridden (see Block size). The blocks computed counts each hard link separately; this is arguably a deficiency.
 
Old 06-07-2013, 10:00 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,957

Rep: Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267
Quote:
Originally Posted by hizzana View Post
assume ./a/b, b is the only sub dir of a

inode(a) ——> data block(a) ——> contains {inode:[10, 11, 12], filename:[., .., b]} // this editor will ignore the extra blank, so here i use json instead

above show the struct of storage of a dir
if a's inode is 9, b's is 12, they are not the same
means only 2 filenames are linked to inode 9(a and .)
Directory b contains a ".." link, which is to the inode of directory a. The link count for a directory is always ( 2 + number_of_immediate_subdirs ) due to these ".." links.
 
1 members found this post helpful.
Old 06-07-2013, 10:10 AM   #4
hizzana
LQ Newbie
 
Registered: May 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
Directory b contains a ".." link, which is to the inode of directory a. The link count for a directory is always ( 2 + number_of_immediate_subdirs ) due to these ".." links.
hmm, i see, except the root, . and .. are same.
 
Old 06-07-2013, 10:28 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,957

Rep: Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267
Quote:
Originally Posted by hizzana View Post
hmm, i see, except the root, . and .. are same.
The formula (2 + number_of_subdirs) is correct for the root directory too. It's just that in the root directory, one of those "2" links is different. In a non-root directory, there is one link from the parent directory plus the directory's own "." link. In the root directory, there is no parent directory, but both "." and ".." point to the root directory, so there are still 2 links.

BTW, when you want to post something with spacing preserved, just wrap it in [CODE] ... [/CODE] tags. The "#" icon in the toolbar will do that for you.

Last edited by rknichols; 06-07-2013 at 10:33 AM. Reason: add BTW
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
can some one explain in a detail, plzz Sam124 Linux - Hardware 9 08-09-2012 06:19 AM
unattached inode, connect to lost+found, ref count is 2 should be 1 rjo98 Linux - Newbie 2 02-17-2012 08:37 AM
Can someone explain cron in some detail? chris24300 Linux - Newbie 2 10-22-2009 02:54 PM
inode count hybernate20 Linux - General 1 03-17-2009 06:46 PM
Increase max inode count xPhoenix Slackware 2 10-05-2006 03:14 AM


All times are GMT -5. The time now is 08:47 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration