From owner-freebsd-fs Tue Sep 14 15: 0:43 1999 Delivered-To: freebsd-fs@freebsd.org Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (Postfix) with ESMTP id 6FB9514CCD for ; Tue, 14 Sep 1999 15:00:37 -0700 (PDT) (envelope-from tlambert@usr09.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id PAA05989; Tue, 14 Sep 1999 15:00:30 -0700 (MST) Received: from usr09.primenet.com(206.165.6.209) via SMTP by smtp02.primenet.com, id smtpd005976; Tue Sep 14 15:00:28 1999 Received: (from tlambert@localhost) by usr09.primenet.com (8.8.5/8.8.5) id PAA22155; Tue, 14 Sep 1999 15:00:26 -0700 (MST) From: Terry Lambert Message-Id: <199909142200.PAA22155@usr09.primenet.com> Subject: Re: FFS-questions To: ticso@cicely.de (Bernd Walter) Date: Tue, 14 Sep 1999 22:00:26 +0000 (GMT) Cc: freebsd-fs@FreeBSD.ORG In-Reply-To: <19990912115904.A37697@cicely8.cicely.de> from "Bernd Walter" at Sep 12, 99 11:59:04 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > 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