On Tue, Oct 07, 2003 at 11:42:10AM -0400, Pisupati, Ajay wrote:
> Ethan,
>
> I am making the following changes to the code and I wanted to check w/ you.
>
> 1) adding the following two fields to the __fsdriver struct.
> void *file_ptr <- this is where you would store your EXT2_FILE
> void *filefs_ptr <- for saving EXT2_FS
> I think this is logically the correct place to put it because these are
> internal to a fs driver
yeah probably.
> 2) I am going to implement the following struct
> {
> char *device /* device node */
> char *partition /* device partition? */
> char *alias /* alias for the above device node - eg: hd:3 */
> __fsdriver *driver /* stores correct fs driver for this
> particular partition */
> int fs /* ? Maybe the magic number */
> }
> I was thinking that we could use this struct to store the correct fs driver
> for a particular device node (and partition) after we call fs->verify().
> Store an array of these things and then use them later. do you think this
> type of setup would be good for getcwd() and chdir()? I will try and check
probably yes.
> the kernel code to see how the kernel implements this to get an idea how to
> proceed. unfortunately, this the first time that I am looking at the code,
> so it is taking me a while. Do you have any ideas on implementing these two
> things? I think we have to keep track of where we are in the FS
> constantly, because the first step is getting _to_ someplace is know _where_
> we are. again, my guess is that the kernel does something similar but I
> don't know where...
>
> 3) I still have 2 unresolved variables in ext2.c - DEVICENODE and FILENAME.
> I know the names are quite obvious, but I wanted to confirm that these are
> in fact the same DEVICENODE and FILENAME that the client asks to open() or
> read() or write() correct? the reason that you had to make them place
> holders was because there is no implementation for those functions yet.
placeholders. DEVICENODE=hd:3 FILENAME=/etc/passwd
they come from open() which would have been called as
open("hd:3,/etc/passwd", O_RDONLY)
> 4) Other than the kernel, is there any other place where I can look for how
> to implement a verify for FS? (I am thinking other than the ext2 FS). I
> have read some stuff about ext2 FS but not having done this before, I don't
> even know where to start. is it as simple as just reading block 0? if so
> can I do it on a normally functioning unix system ( I don't think the OS
> will let me access it)?
yeah i still haven't got around to making a ext2 verify, i know
ext2fs_open() does so, so you could look at this function within
libext2 (it lives in e2fsprogs source). you can also look at the
xfs_mount() function in the old yaboot1 xfs driver for how its done in
XFS. i think some improvements can be done there.
basically you just need to know about 1 or preferably a couple known
magic numbers in the filesystem, and thier offsets, then you open the
device, lseek() to the right offset, and read() the number of bytes
you need to get the magic number, then compare. its good to check
more then one if possible since its sometimes possible for a magic
number of one filesystem to exist in another (XFS' magic number is
"XFSB" litteraly at block zero of the device, mke2fs sometimes leaves
block 0 alone as it can contain bootblocks, the reiserfs magic lives
so far into the device it can end up not being scribbed by other mkfs,
such as xfs' unless the program explicity zeroed a certian number of
blocks (mkfs.xfs started doing this some time ago to avoid that exact
issue).
--
Ethan Benson
http://www.alaska.net/~erbenson/
Attachment:
pgp00001.pgp
Description: PGP signature