Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Sep 1999 22:00:26 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        ticso@cicely.de (Bernd Walter)
Cc:        freebsd-fs@FreeBSD.ORG
Subject:   Re: FFS-questions
Message-ID:  <199909142200.PAA22155@usr09.primenet.com>
In-Reply-To: <19990912115904.A37697@cicely8.cicely.de> from "Bernd Walter" at Sep 12, 99 11:59:04 am

next in thread | previous in thread | raw e-mail | index | archive | help
> I thought that a directory always contains full blocks and never
> contain a fragment.

Physical device blocks.

> Now I have the following situation:
> dirsize = 512, fragsize = 1024, blocksize = 4096

dirsize		= 1 physical device block
fragsize	= 2 physical device blocks
blocksize	= 8 physical device blocks

> The dirrectory contains including . and .. 5 Entries.
> 
> It seems to me that the size of a directory is always a multiple
> of 512.

The size of a directory entry block (dirsize) is always a physical
device block.

At a fragsize of 1024 bytes, directories are allocates in 1024 byte
fragments, which act as an index reference for 2 physical device
blocks each.


> My problem is that I need to know how big the last datareference of
> a given inode is: How many frags does it contain or is the last
> reference a complete block.

This can be determined via the standard fragment lookup code on
directories, just as with files.


> Another problem might be the situation if the fs is mounted:
> AFAIK FFS allocates complete blocks (or clusters?) in case
> the file gets bigger.  I can't find out if it's a block or a
> couple of frags depending on the ino->di_size.

This is problematic, because files can be sparse.

The value of ino->di_size is the file size, in bytes.

If you take the remainder modulo the physical block size, you
will get the size of the remainder.

If this value is less than the file system block size minus the
fragment size (4096 - 1024 = 3072), then there are frag(s) involved,
unless it has been truncated back.

The correct place to look for this information is /usr/src/sys/ufs/ffs/fs.h,
since frags are FFS specific.



> Is there a relyable way for doing such things?
> Do I still have any missunderstandings about fileendings?

Look also in ffs_alloc.c and ffs_inode.c; pay special attention to
the macro "numfrags".


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-fs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199909142200.PAA22155>