rossi.fstools.fs.ext2fs
Class Ext2FileSystem

java.lang.Object
  extended byrossi.fstools.fs.ext2fs.Ext2FileSystem
All Implemented Interfaces:
FileSystem

public class Ext2FileSystem
extends java.lang.Object
implements FileSystem

Implementation of the EXT2 and EXT3 file systems.


Field Summary
static long EXT2_BAD_INO
          Inode number of the bad blocks file.
static long EXT2_ROOT_INO
          Inode number of the root directory.
 
Constructor Summary
Ext2FileSystem()
           
 
Method Summary
 void close()
          Close the underlying BlockReader used by this file system.
 Device createExt2Device(Ext2Inode inode)
          Create a device.
 Directory createExt2Directory(Ext2Inode inode)
          Create a directory.
 File createExt2File(Ext2Inode inode)
          Creates a file from an inode
 SymLink createExt2SymLink(Ext2Inode inode)
          Create a symlink.
 Inode getInode(InodePtr ptr)
          Gets an inode.
 FsObject getObject(Inode inode)
          Get the filesystem object represented by an inode.
 InodePtr getRootDir()
          Get a pointer to the root directory's inode.
 SuperBlock open(BlockReader br)
          Open a file system for reading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXT2_BAD_INO

public static final long EXT2_BAD_INO
Inode number of the bad blocks file.

See Also:
Constant Field Values

EXT2_ROOT_INO

public static final long EXT2_ROOT_INO
Inode number of the root directory.

See Also:
Constant Field Values
Constructor Detail

Ext2FileSystem

public Ext2FileSystem()
Method Detail

open

public SuperBlock open(BlockReader br)
                throws FsException,
                       java.io.IOException
Description copied from interface: FileSystem
Open a file system for reading. The BlockReader should be initialized to point to the phyical storage of the desired filesystem.

Specified by:
open in interface FileSystem
Parameters:
br - a BlockReader for accessing the physical filesystem.
Returns:
the filesystem's SuperBlock
Throws:
java.io.IOException
FsException - if the superblock cannot be parsed.

close

public void close()
           throws java.io.IOException
Description copied from interface: FileSystem
Close the underlying BlockReader used by this file system.

Specified by:
close in interface FileSystem
Throws:
java.io.IOException

getRootDir

public InodePtr getRootDir()
Description copied from interface: FileSystem
Get a pointer to the root directory's inode.

Specified by:
getRootDir in interface FileSystem
Returns:
InodePtr pointing to the root directory.

getInode

public Inode getInode(InodePtr ptr)
               throws FsException,
                      java.io.IOException
Gets an inode. Uses the inode pointer supplied to load an inode.

Specified by:
getInode in interface FileSystem
Parameters:
ptr - an InodePtr
Returns:
Inode pointed to by ptr
Throws:
FsException - if the Inode cannot be parsed.
java.io.IOException - if an IO error occurs

createExt2File

public File createExt2File(Ext2Inode inode)
                    throws FsException,
                           java.io.IOException
Creates a file from an inode

Parameters:
inode - the inode
Returns:
the file
Throws:
java.io.IOException - in case of an IO error
FSException - in case of a FS format error
FsException

createExt2Directory

public Directory createExt2Directory(Ext2Inode inode)
                              throws FsException,
                                     java.io.IOException
Create a directory.

Parameters:
inode - a Ext2Inode
Returns:
Directory
Throws:
FsException
java.io.IOException

createExt2Device

public Device createExt2Device(Ext2Inode inode)
Create a device.

Parameters:
inode - a Ext2Inode
Returns:
Device

createExt2SymLink

public SymLink createExt2SymLink(Ext2Inode inode)
                          throws FsException,
                                 java.io.IOException
Create a symlink. Note the blocks field of the inode controls whether it is a fast or slow symlink.

Parameters:
inode - a Ext2Inode
Returns:
SymLink
Throws:
FsException
java.io.IOException

getObject

public FsObject getObject(Inode inode)
                   throws FsException,
                          java.io.IOException
Description copied from interface: FileSystem
Get the filesystem object represented by an inode.

Specified by:
getObject in interface FileSystem
Parameters:
inode - an Inode
Returns:
FsObject that is represented by the inode
Throws:
FsException - if the object cannot be parsed.
java.io.IOException - if an IO error occurs.