[net.unix-wizards] What is the root inode number in BSD 4.1 and 4.2?

steffen@ihu1h.UUCP (Joe Steffen) (08/04/84)

In System V you can test to see if the current directory is root by 

	if (stat(".", &status) == 0 && status.st_ino == ROOTINO)
	
where ROOTINO defined in sys/params.h as 2.  This header file in BSD 4.2
does not have ROOTINO.  Is 2 the correct value in BSD, is it something
else, or do I have to stat("/", ...) to get the value?  I want to avoid the
latter if possible.
-- 


#	Joe Steffen, AT&T Bell Labs, Naperville, IL, (312) 979-5381

steffen@ihu1h.UUCP (Joe Steffen) (08/06/84)

Thanks to all those who replied that ROOTINO is also 2 in BSD 4.2, and is
defined in sys/fs.h instead of sys/param.h, as it is in System V.
-- 


#	Joe Steffen, AT&T Bell Labs, Naperville, IL, (312) 979-5381

smk@axiom.UUCP (Steven M. Kramer) (08/08/84)

People, if you want YOUR root to be the one displayed and you
assume ROOTINO, be advised that chroot() destroys that assumption.
-- 
	--steve kramer
	{allegra,genrad,ihnp4,utzoo,philabs,uw-beaver}!linus!axiom!smk	(UUCP)
	linus!axiom!smk@mitre-bedford					(MIL)

lcc.bob@UCLA-LOCUS.ARPA (08/10/84)

From:            Bob English <lcc.bob@UCLA-LOCUS.ARPA>

	Date: 7 Aug 84 15:18:42-PDT (Tue)
	To: Unix-Wizards@BRL-VGR.ARPA
	From: decvax!linus!axiom!smk@UCB-VAX.ARPA
	Subject: Re: What is the root inode number in BSD 4.1 and 4.2?

	Article-I.D.: axiom.589
	In-Reply-To: Article <280@ihu1h.UUCP>

	People, if you want YOUR root to be the one displayed and you
	assume ROOTINO, be advised that chroot() destroys that assumption.
	-- 
		--steve kramer

And if your system has any mounted filesystems, ROOTINO does not
indicate the root unless the dev's are the same.  The only way to
find the root's device is with a stat.

"stat("/", &statb)" is cheap.  I really can't believe you're
worried about the extra cost.

--bob--