Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-30-2009, 10:00 AM
|
#1
|
|
LQ Newbie
Registered: May 2009
Location: Bangalore, India
Distribution: Kubuntu 2.6.31-14
Posts: 19
Rep:
|
Why do inode numbers start from 1 and not 0 ?
The C language convention counts array indices from 0. Why do inode numbers start from 1 and not 0 ?
I am currently reading "The design of the Unix Operating System" by Maurice J Bach and was struck on this question from the exercises.
|
|
|
|
12-30-2009, 10:50 AM
|
#2
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
Hint: what's the value of "null"?
|
|
|
|
12-30-2009, 11:00 AM
|
#3
|
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,797
|
Quote:
|
Why do inode numbers start from 1 and not 0 ?
|
Why should they start with 0?
Quote:
|
The C language convention counts array indices from 0.
|
So what?
Why does GRUB count from 0?
Why does hard disk device numbering start with "a" and "1"?
Seriously---there are many kinds of computer utilities and conventions--there is no standard that says that numbering should start with 0 or 1. Unfortunately, you simply have to remember what convetion is followed for each situation.
|
|
|
|
12-30-2009, 12:16 PM
|
#4
|
|
Member
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 806
Rep: 
|
Quote:
Originally Posted by pixellany
Why does GRUB count from 0?
Why does hard disk device numbering start with "a" and "1"?
Seriously---there are many kinds of computer utilities and conventions
|
Correct. But it's interesting to note that if you use inode=0 to mean that we're not referencing an inode (yet), that makes it easy to initialize a directory block: just smear it with 0x00 bytes.
|
|
|
|
12-31-2009, 03:04 PM
|
#5
|
|
Senior Member
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 4,554
|
Throughout the "C" world, an all-zero value is used to indicate "nothing." For instance, a value of zero in some inode-number slot would indicate that there is no inode associated with that slot.
Many Linux and Unix systems actually use inode numbers now that are random.
|
|
|
|
12-31-2009, 08:03 PM
|
#6
|
|
Member
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 806
Rep: 
|
Quote:
Originally Posted by sundialsvcs
Many Linux and Unix systems actually use inode numbers now that are random.
|
Citation needed.
|
|
|
|
12-31-2009, 09:20 PM
|
#7
|
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,797
|
Quote:
Originally Posted by wje_lq
Citation needed.
|
Why? (We're not writing peer-reviewed papers here......  )
|
|
|
|
01-01-2010, 12:24 AM
|
#8
|
|
Member
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 806
Rep: 
|
Quote:
Originally Posted by pixellany
Why? (We're not writing peer-reviewed papers here......  )
|
Not to prove the point, but to provide more information. I'd like to read about this random inode number assignment idea in more detail. Why would they do this? (for example)
|
|
|
|
01-01-2010, 04:00 AM
|
#9
|
|
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 2,967
Rep: 
|
Quote:
Originally Posted by wje_lq
Not to prove the point, but to provide more information. I'd like to read about this random inode number assignment idea in more detail. Why would they do this? (for example)
|
Security? One might derive some useful information from a file system based on the ordering of the inodes. I totally made that up, but it seems like something the government would do.
Kevin Barry
|
|
|
|
01-01-2010, 06:36 AM
|
#10
|
|
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,052
Rep: 
|
maybe for quicker inode searching algorithms?
Code:
for (n = x; n; ++n) {
...
n = n->next; # something similar?
}
|
|
|
|
01-07-2010, 06:33 AM
|
#11
|
|
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Squeeze (Fluxbox WM)
Posts: 1,357
|
Quote:
Originally Posted by sundialsvcs
Many Linux and Unix systems actually use inode numbers now that are random.
|
That might be true of a particular filesystem. But on Linux filesystems at least, many of the inode numbering schemes are simply an incrementing counter (exceptions including things like the implementation of FAT). The inode number does get hashed for lookup purposes.
Last edited by neonsignal; 01-07-2010 at 06:34 AM.
|
|
|
1 members found this post helpful.
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:21 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|