From owner-freebsd-fs Fri Apr 27 9:51:33 2001 Delivered-To: freebsd-fs@freebsd.org Received: from harrier.mail.pas.earthlink.net (harrier.mail.pas.earthlink.net [207.217.121.12]) by hub.freebsd.org (Postfix) with ESMTP id 2B0DD37B422; Fri, 27 Apr 2001 09:51:30 -0700 (PDT) (envelope-from shmukler@mail.ru) Received: from tp600e (user-2ivebdo.dialup.mindspring.com [165.247.45.184]) by harrier.mail.pas.earthlink.net (EL-8_9_3_3/8.9.3) with SMTP id JAA22139; Fri, 27 Apr 2001 09:51:24 -0700 (PDT) Message-ID: <006501c0cf3a$597d2380$7b02a8c0@tp600e> From: "Igor Shmukler" To: "Ian Dowse" Cc: , References: <200104271348.aa54585@salmon.maths.tcd.ie> Subject: Re: more on FFS Date: Fri, 27 Apr 2001 12:51:45 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > > >How do I find where on disk ROOT inode is located. > >I tried to thru sources, but FS structure quite large and I get lost in = > >offsets. > > The `ino_to_fsba' and `ino_to_fsbo' macros defined in fs.h are probably > what you want. `ino_to_fsba' returns the offset from the start of the > partition of the block containing the specified inode. This offset is > in units of the filesystem fragment size, and you are expected to read > a full fs_bsize block starting at that offset. Then `ino_to_fsbo' tells > you the inode number within that block. e.g. (untested, and has no > error checking): > > struct fs *fs; > char *sbbuf; > char *blockbuf; > struct dinode *dip; > off_t offset; > > fd = open("/dev/da0s1a", O_RDONLY); > > /* read superblock and point `fs' at it. */ > sbbuf = malloc(SBSIZE); > pread(fd, sbbuf, SBSIZE, SBOFF); > fs = (struct fs *)sbbuf; > > /* Get the root inode */ > offset = (off_t)ino_to_fsba(fs, ROOTINO) * (off_t)fs->fs_fsize; > blockbuf = malloc(fs->fs_bsize); > pread(fd, blockbuf, fs->fs_bsize, offset); > dip = &((struct dinode *)blockbuf)[ino_to_fsbo(fs, ROOTINO)]; > > /* `dip' now points to the root inode */ > I ran this thing on a 1.44M floppy and came out to offset 0x7000 dip 0x804e100. Does not seem right to me. Is filesystem fragment size 512? Any ideas? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message