LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-04-2007, 12:48 AM   #1
vishalsaraswat247
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Rep: Reputation: 0
Lightbulb inode and special files.


hii,
i was going through the filesystem explanation of linux and it was mentioned there that any root directory is always stored in inode number 2. Why sooo???
 
Old 01-04-2007, 03:32 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
I'm no expert in these matters, but that's probably because the very first inode(s) (numbers 0 and 1) are used
to store the so-called "superblock", which holds a record of the available inodes. Inode 2 would then be the first one after that, and hence the logical one to use for the highest level directory.
 
Old 01-05-2007, 12:06 AM   #3
vishalsaraswat247
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Original Poster
Rep: Reputation: 0
maybe, but thn why superblock occupies to inode values???
 
Old 01-05-2007, 01:37 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
I'm not sure it does. It could be that it just occupies the first one, and that the second inode is occupied by something else (for instance, a backup copy of the superblock or of some other important filesystem table).
 
Old 01-06-2007, 03:24 PM   #5
vishalsaraswat247
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Original Poster
Rep: Reputation: 0
it cud be a possibility...but still it leaves it in the middle
 
Old 01-06-2007, 05:26 PM   #6
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Inodes 0 and 1 have special and historical meanings which may or may not be valid for your filesystem. But because of this, inode 2 is always used for the root of the filesystem so that it's consistent.

Inode 0: deleted files/directories, some systems use it to point the the inodes, some don't use it at all, system dependent.
Inode 1: bad blocks, file system creation time, etc... again it's very fs dependent.

It's not for storing a backup of the superblock or anything else like that. It's just two reserved data structures which have special purposes for the file-system. What exactly is dependent on the file-system itself.

Edit: The man-page fs(5) (in FreeBSD) says the following about why they stick with the number 2 for the root.
Code:
     The root inode is the root of the file system.  Inode 0 cannot be used
     for normal purposes and historically bad blocks were linked to inode 1,
     thus the root inode is 2 (inode 1 is no longer used for this purpose,
     however numerous dump tapes make this assumption, so we are stuck with
     it).

Last edited by frob23; 01-06-2007 at 05:38 PM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
block special and character special files s_shenbaga Linux - Newbie 4 06-23-2015 02:16 AM
Can two files have the same inode number? sambyte Linux - Newbie 5 02-04-2009 06:27 AM
removing special lines from files Prasun1 Linux - General 3 09-11-2005 05:16 AM
special files in /dev oasisbhrnw99 Linux - Newbie 1 05-06-2004 11:34 AM
O_EXCL on device special files devershetty Linux - Newbie 0 06-19-2003 08:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:43 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
Open Source Consulting | Domain Registration