Ejemplo n.º 1
0
  protected static void writeToINode(INode node) {
    int blockID = node.getIndex() / (Constants.BLOCK_SIZE / Constants.INODE_SIZE);
    int inodeOffset = node.getIndex() % (Constants.BLOCK_SIZE / Constants.INODE_SIZE);
    byte[] dataToWrite = new byte[Constants.BLOCK_SIZE];
    byte[] fileMetadata = node.getMetadata();

    DBuffer buffer = _cache.getBlock(blockID);
    buffer.read(dataToWrite, 0, Constants.BLOCK_SIZE);
    for (int k = 0; k < fileMetadata.length; k++)
      dataToWrite[inodeOffset * Constants.INODE_SIZE + k] = fileMetadata[k];

    buffer.write(dataToWrite, 0, Constants.BLOCK_SIZE);
    _cache.releaseBlock(buffer);
  }