Re^2: 4BSD file system structure

Chris Torek chris at mimsy.umd.edu
Thu Nov 23 11:40:12 AEST 1989


In article <1727 at neon.siesoft.co.uk> duncan at helium.siesoft.co.uk
(Duncan McEwan) writes:
>....  Do the disk addresses kept in the inode and indirect blocks
>address blocks or fragments?

The things *in* ip->i_db[i] are in terms of fragments.  The values i
used to index into ip->i_db[] are in terms of blocks.  That is:

	ip->i_db[howmany(offset, blksize)]

is the fragment-wise block number of the disk-block-or-fragment
that holds the bytes from floor(offset/blksize)*blksize to
ceil(offset/blksize)*blksize-1.

More specifically, on an 8k/1k file system, if you want to find
the set of 1024-byte disk `blocks' that contain bytes 8192..16383
of a given file, you look at ip->i_db[1].  If this contains the
number 2000, those bytes are in the eight consecutive 1024-byte
fragments numbered 2000, 2001, 2002, ..., 2007.  If, however, the
file is only 10240 bytes long, then there are only two such 1024-byte
blocks, namely 2000 and 2001.

There are various implications here that I leave to the reader.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list