Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Apr 2001 12:51:45 -0400
From:      "Igor Shmukler" <shmukler@mail.ru>
To:        "Ian Dowse" <iedowse@maths.tcd.ie>
Cc:        <freebsd-fs@FreeBSD.ORG>, <grog@FreeBSD.ORG>
Subject:   Re: more on FFS 
Message-ID:  <006501c0cf3a$597d2380$7b02a8c0@tp600e>
References:   <200104271348.aa54585@salmon.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help

> >
> >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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?006501c0cf3a$597d2380$7b02a8c0>