rossi.fstools.fs.reiserfs
Class ReiserFileSystem

java.lang.Object
  extended byrossi.fstools.fs.reiserfs.ReiserFileSystem
All Implemented Interfaces:
FileSystem

public class ReiserFileSystem
extends java.lang.Object
implements FileSystem

Representation of the reiser file system. Application code is to use this class.


Constructor Summary
ReiserFileSystem()
           
 
Method Summary
 void close()
          Close the underlying BlockReader used by this file system.
 Device createReiserDevice(StatDataItem sdItem)
          Create a Device from a StatDataItem.
 Directory createReiserDirectory(StatDataItem sdItem)
          Create a Directory given the StatDataItem describing it.
 File createReiserFile(StatDataItem sdItem)
          Creates a file for the given StatDataItem.
 SymLink createReiserSymLink(StatDataItem sdItem)
          Create a Symlink from a StatDataItem.
 LeafNode findLeaf(Key key)
          This is temporarily public just for testing.
 LeafNode findLeftMostLeaf(FBlock parent, int startblock)
          Gets the leftmost leaf of the given block if startblock points to an internal node.
 Item findNextItem(Key key)
          Finds the item whose key is equal to key if key exists in the tree.
 Inode getInode(InodePtr ptr)
          Gets an inode given a pointer.
protected  FBlock getNode(int blkno)
          Gets a tree node.
 FsObject getObject(Inode inode)
          Get the file system object that is pointed to by the given Inode.
 InodePtr getRootDir()
          Returns pointer to root directory.
 LeafNode nextLeaf(LeafNode current)
          Returns the next leaf following the given leaf.
 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
 

Constructor Detail

ReiserFileSystem

public ReiserFileSystem()
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()
Returns pointer to root directory.

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

getNode

protected FBlock getNode(int blkno)
                  throws java.io.IOException,
                         FsException
Gets a tree node.

Throws:
java.io.IOException
FsException

getInode

public Inode getInode(InodePtr ptr)
               throws java.io.IOException,
                      FsException
Gets an inode given a pointer.

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

findLeaf

public LeafNode findLeaf(Key key)
                  throws FsException,
                         java.io.IOException
This is temporarily public just for testing. Find the first leaf node that may contain the given key -- if it exists.

Parameters:
key - the Key to look for.
Returns:
the leaf node containing the item pointed to by the key
Throws:
FsException
java.io.IOException

findLeftMostLeaf

public LeafNode findLeftMostLeaf(FBlock parent,
                                 int startblock)
                          throws FsException,
                                 java.io.IOException
Gets the leftmost leaf of the given block if startblock points to an internal node. If startblock points to a Leaf, just return it.

Parameters:
parent - a FBlock which is the parent of startblock
startblock - a int pointing to the starting node/leaf block.
Returns:
LeafNode the first leafnode within start block
Throws:
FsException - if a parsing error occurs.
java.io.IOException - if an IO error occurs

nextLeaf

public LeafNode nextLeaf(LeafNode current)
                  throws FsException,
                         java.io.IOException
Returns the next leaf following the given leaf.

Parameters:
current - The current leaf
Returns:
the leaf node just after (right of) the current leaf
Throws:
FsException - if the next leaf cant be found.
java.io.IOException - if an IO error occurs.

findNextItem

public Item findNextItem(Key key)
                  throws FsException,
                         java.io.IOException
Finds the item whose key is equal to key if key exists in the tree. Otherwise returns the next greater key.

Parameters:
key -
Returns:
Item
Throws:
FsException - if a parse error occurs
java.io.IOException - if an IO error occurs

createReiserSymLink

public SymLink createReiserSymLink(StatDataItem sdItem)
                            throws FsException,
                                   java.io.IOException
Create a Symlink from a StatDataItem.

Parameters:
sdItem - a StatDataItem
Returns:
SymLink
Throws:
FsException
java.io.IOException

createReiserFile

public File createReiserFile(StatDataItem sdItem)
                      throws FsException,
                             java.io.IOException
Creates a file for the given StatDataItem. The information in the StatDataItem is sufficent to create a Key to find the Direct and Indirect items that compose the file.

Parameters:
sdItem - a StatDataItem
Returns:
File
Throws:
FsException
java.io.IOException

createReiserDirectory

public Directory createReiserDirectory(StatDataItem sdItem)
                                throws FsException,
                                       java.io.IOException
Create a Directory given the StatDataItem describing it.

Parameters:
sdItem - a StatDataItem
Returns:
Directory
Throws:
FsException
java.io.IOException

createReiserDevice

public Device createReiserDevice(StatDataItem sdItem)
                          throws FsException,
                                 java.io.IOException
Create a Device from a StatDataItem.

Parameters:
sdItem - a StatDataItem
Returns:
Device
Throws:
FsException
java.io.IOException

getObject

public FsObject getObject(Inode inode)
                   throws FsException,
                          java.io.IOException
Get the file system object that is pointed to by the given Inode.

Specified by:
getObject in interface FileSystem
Parameters:
inode - a Inode
Returns:
FsObject
Throws:
FsException
java.io.IOException