🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Adrian Booth Computing Consultan... Thu, 17 Dec 1992 08:36
Reading an inode directly from filesystem - how?
#27
Author: Adrian Booth Computing Consultan...
Date: Thu, 17 Dec 1992 08:36
39 lines
2168 bytes
<SunOS 4.1.x>

Given that I can traverse the mount table and obtain the struct fs via the
superblock, and that I know the inode number, how do I read an inode from 
the filesystem?

I assumed from <ufs/fs.h> that I should say:

	blk = itod(fs, inum);
	off = itoo(fs, inum);

	seekpos = blk * fs->fs_bsize + off * sizeof(struct inode);

and then lseek to seekpos on the filesystem device and read sizeof(struct inode)
bytes.

(BTW, I assumed I had to multiply off by sizeof(struct inode) since with
two files with inodes x and x+1, the value I get for blk is constant and the
value for off is either y or y+1, respectively).

However I'm just getting garbage back on the read. I tried the fsbtodb macro 
in <ufs/fs.h> will no improvement.

What's the simple way to read a given inode given the appropriate struct fs
and the inode number? Alternatively, what's wrong with any of my assumptions
above?

Thanks in advance...

 --------------------------------------------------------------------------
 | Adrian Booth					|	                  |
 | Adrian Booth Computing Consultants		|	Ph: (09) 354 4936 |
 | 7 Glenrowan Pl., Willetton WA 6155		|	abcc@DIALix.oz.au |
 | AUSTRALIA                                    |                         |
 --------------------------------------------------------------------------
for a in past present future; do
	for b in clients employers associates relatives neighbours pets; do
echo The opinions in this article in no way reflect the opinions of my $a $b.
done;done
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads