Class IndexNode

java.lang.Object
   |
   +----IndexNode

public class IndexNode
extends Object
An index node for a simulated file system.

Author:
Ray Ontko

Variable Index

 o INDEX_NODE_SIZE
Size of each index node in bytes.
 o MAX_DIRECT_BLOCKS
Maximum number of direct blocks in an index node.
 o MAX_FILE_BLOCKS
Maximum number of blocks in a file.

Constructor Index

 o IndexNode()
Creates an index node.

Method Index

 o copy(IndexNode)
 o getAtime()
 o getBlockAddress(int)
Gets the address corresponding to the specified sequential block of the file.
 o getCtime()
 o getGid()
 o getMode()
Gets the mode for this IndexNode.
 o getMtime()
 o getNlink()
Get the number of links for this IndexNode.
 o getSize()
Gets the size for this IndexNode.
 o getUid()
 o main(String[])
A test driver for IndexNode.
 o read(byte[], int)
Reads the contents of an index node from a byte array.
 o setAtime(int)
 o setBlockAddress(int, int)
Sets the address corresponding to the specified sequential block of the file.
 o setCtime(int)
 o setGid(short)
 o setMode(short)
Sets the mode for this IndexNode.
 o setMtime(int)
 o setNlink(short)
Set the number of links for this IndedNode.
 o setSize(int)
Sets the size for this IndexNode.
 o setUid(short)
 o toString()
Converts an index node into a printable string.
 o write(byte[], int)
Writes the contents of an index node to a byte array.

Variables

 o INDEX_NODE_SIZE
 public static final int INDEX_NODE_SIZE
Size of each index node in bytes.

 o MAX_DIRECT_BLOCKS
 public static final int MAX_DIRECT_BLOCKS
Maximum number of direct blocks in an index node.

 o MAX_FILE_BLOCKS
 public static final int MAX_FILE_BLOCKS
Maximum number of blocks in a file. If indirect, doubleIndirect, or tripleIndirect blocks are implemented, this number will need to be increased.

Constructors

 o IndexNode
 public IndexNode()
Creates an index node.

Methods

 o setMode
 public void setMode(short newMode)
Sets the mode for this IndexNode. This is the file type and file protection information.

 o getMode
 public short getMode()
Gets the mode for this IndexNode. This is the file type and file protection information.

 o setNlink
 public void setNlink(short newNlink)
Set the number of links for this IndedNode.

Parameters:
newNlink - the number of links
 o getNlink
 public short getNlink()
Get the number of links for this IndexNode.

Returns:
the number of links
 o setUid
 public void setUid(short newUid)
 o getUid
 public short getUid()
 o getGid
 public short getGid()
 o setGid
 public void setGid(short newGid)
 o setSize
 public void setSize(int newSize)
Sets the size for this IndexNode. This is the number of bytes in the file.

 o getSize
 public int getSize()
Gets the size for this IndexNode. This is the number of bytes in the file.

 o getBlockAddress
 public int getBlockAddress(int block) throws Exception
Gets the address corresponding to the specified sequential block of the file.

Parameters:
block - the sequential block number
Returns:
the address of the block, a number between zero and one less than the number of blocks in the file system
Throws: Exception
if the block number is invalid
 o setBlockAddress
 public void setBlockAddress(int block,
                             int address) throws Exception
Sets the address corresponding to the specified sequential block of the file.

Parameters:
block - the sequential block number
address - the address of the block, a number between zero and one less than the number of blocks in the file system
Throws: Exception
if the block number is invalid
 o setAtime
 public void setAtime(int newAtime)
 o getAtime
 public int getAtime()
 o setMtime
 public void setMtime(int newMtime)
 o getMtime
 public int getMtime()
 o setCtime
 public void setCtime(int newCtime)
 o getCtime
 public int getCtime()
 o write
 public void write(byte buffer[],
                   int offset)
Writes the contents of an index node to a byte array. This is used to copy the bytes which correspond to the disk image of the index node onto a block buffer so that they may be written to the file system.

Parameters:
buffer - the buffer to which bytes should be written
offset - the offset from the beginning of the buffer at which bytes should be written
 o read
 public void read(byte buffer[],
                  int offset)
Reads the contents of an index node from a byte array. This is used to copy the bytes which correspond to the disk image of the index node from a block buffer that has been read from the file system.

Parameters:
buffer - the buffer from which bytes should be read
offset - the offset from the beginning of the buffer at which bytes should be read
 o toString
 public String toString()
Converts an index node into a printable string.

Returns:
the printable string
Overrides:
toString in class Object
 o copy
 public void copy(IndexNode indexNode)
 o main
 public static void main(String args[]) throws Exception
A test driver for IndexNode.

Throws: Exception
any exception which may occur