From: <ga...@us...> - 2009-03-19 19:10:22
|
Revision: 5121 http://jnode.svn.sourceforge.net/jnode/?rev=5121&view=rev Author: galatnm Date: 2009-03-19 19:10:14 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Fix checkstyle and Fix problem with creation of root entry. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/Extent.java trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2009-03-19 18:15:48 UTC (rev 5120) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusForkData.java 2009-03-19 19:10:14 UTC (rev 5121) @@ -72,8 +72,8 @@ extents[i] = new ExtentDescriptor(); } } - - public byte[] write(byte[] dest, int destOffSet){ + + public byte[] write(byte[] dest, int destOffSet) { byte[] data = new byte[FORK_DATA_LENGTH]; BigEndian.setInt64(data, 0, totalSize); BigEndian.setInt32(data, 8, clumpSize); Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.java 2009-03-19 18:15:48 UTC (rev 5120) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusParams.java 2009-03-19 19:10:14 UTC (rev 5121) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus; import org.jnode.fs.FileSystemException; @@ -73,7 +73,8 @@ * @throws FileSystemException * */ - public void initializeDefaultsValues(long blockDeviceSize, long sectorSize) throws FileSystemException { + public void initializeDefaultsValues(long blockDeviceSize, long sectorSize) + throws FileSystemException { long clumpSize = 0; this.blockDeviceSize = blockDeviceSize; if (resourceClumpBlocks == 0) { @@ -143,8 +144,9 @@ } - private int[] extentClumpTable = new int[] {4, 4, 4, 5, 5, 6, 7, 8, 9, 11, 14, 16, 20, 25, 32 }; - private int[] catalogClumpTable = new int[] {4, 6, 8, 11, 14, 19, 25, 34, 45, 60, 80, 107, 144, 192, 256 }; + private int[] extentClumpTable = new int[] {4, 4, 4, 5, 5, 6, 7, 8, 9, 11, 14, 16, 20, 25, 32}; + private int[] catalogClumpTable = + new int[] {4, 6, 8, 11, 14, 19, 25, 34, 45, 60, 80, 107, 144, 192, 256}; /** * Get the file clump size for Extent and catalog B-Tree files. @@ -152,7 +154,8 @@ * @param blockSize * @param nodeSize * @param sectors - * @param catalog If true, calculate catalog clump size. In the other case, calculate extent clump size. + * @param catalog If true, calculate catalog clump size. In the other case, + * calculate extent clump size. * * @return */ @@ -178,11 +181,11 @@ clumpSize /= size; clumpSize *= size; - + if (clumpSize == 0) { clumpSize = size; } - + return clumpSize; } @@ -195,7 +198,8 @@ private int clumpSizeCalculation(long clumpBlocks) throws FileSystemException { long clumpSize = clumpBlocks * blockSize; if ((clumpSize & 0XFFFFFFFF00000000L) == 0) { - throw new FileSystemException("Too many blocks (" + clumpBlocks + ") for clump size (" + clumpSize + ")."); + throw new FileSystemException("Too many blocks (" + clumpBlocks + ") for clump size (" + + clumpSize + ")."); } return (int) clumpSize; } @@ -284,9 +288,9 @@ public int getExtentNodeSize() { return extentNodeSize; } - - public int getInitializeNumRecords(){ + + public int getInitializeNumRecords() { return journaled ? 6 : 2; } - + } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2009-03-19 18:15:48 UTC (rev 5120) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystem.java 2009-03-19 19:10:14 UTC (rev 5121) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus; import java.io.IOException; @@ -62,21 +62,20 @@ */ public final void read() throws FileSystemException { sb = new Superblock(this, false); + log.debug(sb.toString()); if (!sb.isAttribute(Superblock.HFSPLUS_VOL_UNMNT_BIT)) { - log - .info(getDevice().getId() - + " Filesystem has not been cleanly unmounted, mounting it readonly"); + log.info(getDevice().getId() + + " Filesystem has not been cleanly unmounted, mounting it readonly"); setReadOnly(true); } if (sb.isAttribute(Superblock.HFSPLUS_VOL_SOFTLOCK_BIT)) { - log.info(getDevice().getId() - + " Filesystem is marked locked, mounting it readonly"); + log.info(getDevice().getId() + " Filesystem is marked locked, mounting it readonly"); setReadOnly(true); } if (sb.isAttribute(Superblock.HFSPLUS_VOL_JOURNALED_BIT)) { log - .info(getDevice().getId() - + " Filesystem is journaled, write access is not supported. Mounting it readonly"); + .info(getDevice().getId() + + " Filesystem is journaled, write access is not supported. Mounting it readonly"); setReadOnly(true); } try { @@ -87,8 +86,7 @@ } @Override - protected final FSDirectory createDirectory(final FSEntry entry) - throws IOException { + protected final FSDirectory createDirectory(final FSEntry entry) throws IOException { return entry.getDirectory(); } @@ -152,13 +150,13 @@ public void create(HFSPlusParams params) throws FileSystemException { sb = new Superblock(this, true); try { - params.initializeDefaultsValues(this.getApi().getLength(), this - .getFSApi().getSectorSize()); + params.initializeDefaultsValues(this.getApi().getLength(), this.getFSApi() + .getSectorSize()); sb.create(params); log.debug(sb.toString()); // --- - long volumeBlockUsed = sb.getTotalBlocks() - sb.getFreeBlocks() - - ((sb.getBlockSize() == 512) ? 2 : 1); + long volumeBlockUsed = + sb.getTotalBlocks() - sb.getFreeBlocks() - ((sb.getBlockSize() == 512) ? 2 : 1); // --- log.debug("Write allocation bitmap bits to disk."); writeAllocationFile((int) volumeBlockUsed); @@ -166,7 +164,7 @@ log.debug("Write Catalog to disk."); long offset = sb.getCatalogFile().getExtent(0).getStartOffset(sb.getBlockSize()); Catalog catalog = new Catalog(params); - this.getApi().write(offset, catalog.getBytes()); + this.getApi().write(offset, catalog.getBytes()); log.debug("Write volume header to disk."); this.getApi().write(1024, ByteBuffer.wrap(sb.getBytes())); flush(); @@ -176,9 +174,9 @@ throw new FileSystemException("Unable to create HFS+ filesystem", e); } } - + private void writeAllocationFile(int blockUsed) { int bytes = blockUsed >> 3; - int bits = blockUsed & 0x0007; + int bits = blockUsed & 0x0007; } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-03-19 18:15:48 UTC (rev 5120) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/Superblock.java 2009-03-19 19:10:14 UTC (rev 5121) @@ -41,7 +41,7 @@ * */ public class Superblock extends HFSPlusObject { - + public static final int HFSPLUS_SUPER_MAGIC = 0x482b; public static final int HFSPLUS_MIN_VERSION = 0x0004; /* HFS+ */ @@ -55,7 +55,7 @@ public static final int HFSPLUS_VOL_NODEID_REUSED_BIT = 12; public static final int HFSPLUS_VOL_JOURNALED_BIT = 13; public static final int HFSPLUS_VOL_SOFTLOCK_BIT = 15; - + private final Logger log = Logger.getLogger(getClass()); /** Volume header data length */ @@ -90,7 +90,7 @@ throw new FileSystemException("Not hfs+ volume header (" + getMagic() + ": bad magic)"); } - log.debug(this.toString()); + } } catch (IOException e) { throw new FileSystemException(e); @@ -108,7 +108,8 @@ */ public void create(HFSPlusParams params) throws IOException, ApiNotFoundException, FileSystemException { - log.info("Create new HFS+ volume header (" + params.getVolumeName() + ") with block size of " + params.getBlockSize() + " bytes."); + log.info("Create new HFS+ volume header (" + params.getVolumeName() + + ") with block size of " + params.getBlockSize() + " bytes."); int burnedBlocksBeforeVH = 0; int burnedBlocksAfterAltVH = 0; /* @@ -178,11 +179,13 @@ forkdata.addDescriptor(0, desc); forkdata.write(data, 192); blockUsed += forkdata.getTotalBlocks(); - nextBlock = desc.getNext(); + nextBlock = desc.getNext(); // Catalog B-Tree initialization log.info("Init catalog file."); - int totalBlocks = params.getCatalogClumpSize() / blockSize; - forkdata = new HFSPlusForkData(params.getCatalogClumpSize(), params.getCatalogClumpSize(), totalBlocks); + int totalBlocks = params.getCatalogClumpSize() / blockSize; + forkdata = + new HFSPlusForkData(params.getCatalogClumpSize(), params.getCatalogClumpSize(), + totalBlocks); desc = new ExtentDescriptor(nextBlock, totalBlocks); forkdata.addDescriptor(0, desc); forkdata.write(data, 272); Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-03-19 18:15:48 UTC (rev 5120) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2009-03-19 19:10:14 UTC (rev 5121) @@ -65,7 +65,7 @@ this.fs = fs; Superblock sb = fs.getVolumeHeader(); ExtentDescriptor firstExtent = sb.getCatalogFile().getExtent(0); - catalogHeaderNodeOffset = firstExtent.getSize(sb.getBlockSize()); + catalogHeaderNodeOffset = firstExtent.getStartOffset(sb.getBlockSize()); if (!firstExtent.isEmpty()) { buffer = ByteBuffer.allocate(NodeDescriptor.BT_HEADER_NODE + @@ -93,26 +93,22 @@ // int totalNodes = params.getCatalogClumpSize() / params.getCatalogNodeSize(); int freeNodes = totalNodes - 2; - bthr = new BTHeaderRecord(1, - 1, - params.getInitializeNumRecords(), - 1, - 1, - nodeSize, - CatalogKey.MAXIMUM_KEY_LENGTH, - totalNodes, - freeNodes, - params.getCatalogClumpSize(), - BTHeaderRecord.BT_TYPE_HFS, - BTHeaderRecord.KEY_COMPARE_TYPE_CASE_FOLDING, - BTHeaderRecord.BT_VARIABLE_INDEX_KEYS_MASK + BTHeaderRecord.BT_BIG_KEYS_MASK); + bthr = + new BTHeaderRecord(1, 1, params.getInitializeNumRecords(), 1, 1, nodeSize, + CatalogKey.MAXIMUM_KEY_LENGTH, totalNodes, freeNodes, params + .getCatalogClumpSize(), BTHeaderRecord.BT_TYPE_HFS, + BTHeaderRecord.KEY_COMPARE_TYPE_CASE_FOLDING, + BTHeaderRecord.BT_VARIABLE_INDEX_KEYS_MASK + + BTHeaderRecord.BT_BIG_KEYS_MASK); bufferLength += BTHeaderRecord.BT_HEADER_RECORD_LENGTH; // Create root node int rootNodePosition = bthr.getRootNode() * nodeSize; bufferLength += (rootNodePosition - bufferLength); // Create node descriptor - NodeDescriptor nd = new NodeDescriptor(0, 0, NodeDescriptor.BT_LEAF_NODE, 1, params.getInitializeNumRecords()); + NodeDescriptor nd = + new NodeDescriptor(0, 0, NodeDescriptor.BT_LEAF_NODE, 1, params + .getInitializeNumRecords()); CatalogNode rootNode = new CatalogNode(nd, nodeSize); int offset = NodeDescriptor.BT_HEADER_NODE; // First record (folder) Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/Extent.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/Extent.java 2009-03-19 18:15:48 UTC (rev 5120) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/Extent.java 2009-03-19 19:10:14 UTC (rev 5121) @@ -27,7 +27,7 @@ public class Extent { private final Logger log = Logger.getLogger(getClass()); - + private NodeDescriptor btnd; private BTHeaderRecord bthr; @@ -38,8 +38,11 @@ int totalNodes = params.getExtentClumpSize() / params.getExtentNodeSize(); int freeNodes = totalNodes - 1; bthr = - new BTHeaderRecord(0, 0, 0, 0, 0, params.getExtentNodeSize(), ExtentKey.MAXIMUM_KEY_LENGTH, - totalNodes, freeNodes, params.getExtentClumpSize(),BTHeaderRecord.BT_TYPE_HFS, BTHeaderRecord.KEY_COMPARE_TYPE_CASE_FOLDING, BTHeaderRecord.BT_BIG_KEYS_MASK); + new BTHeaderRecord(0, 0, 0, 0, 0, params.getExtentNodeSize(), + ExtentKey.MAXIMUM_KEY_LENGTH, totalNodes, freeNodes, params + .getExtentClumpSize(), BTHeaderRecord.BT_TYPE_HFS, + BTHeaderRecord.KEY_COMPARE_TYPE_CASE_FOLDING, + BTHeaderRecord.BT_BIG_KEYS_MASK); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2009-03-19 18:15:48 UTC (rev 5120) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2009-03-19 19:10:14 UTC (rev 5121) @@ -29,7 +29,7 @@ private int startBlock; /** The length in allocation blocks of the extent. */ private int blockCount; - + public ExtentDescriptor() { this.startBlock = 0; this.blockCount = 0; @@ -69,8 +69,8 @@ BigEndian.setInt32(data, 4, blockCount); return data; } - - public byte[] write(byte[] dest, int destOffSet){ + + public byte[] write(byte[] dest, int destOffSet) { byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; BigEndian.setInt32(data, 0, startBlock); BigEndian.setInt32(data, 4, blockCount); @@ -81,35 +81,39 @@ public final String toString() { return "Start block : " + startBlock + "\tBlock count : " + blockCount + "\n"; } - + /** * Returns start position in bytes of the extent. + * * @param nodeSize the size of a node. * @return offset of the extent. */ - public int getStartOffset(int nodeSize){ + public int getStartOffset(int nodeSize) { return startBlock * nodeSize; } - + /** * Returns block number of the next extent. + * * @return block number of the next extent. */ - public int getNext(){ + public int getNext() { return startBlock + blockCount; } - + /** * Returns size in byte of the extent. + * * @param nodeSize the size of a node. * @return size of the extent. */ - public int getSize(int nodeSize){ + public int getSize(int nodeSize) { return blockCount * nodeSize; - } + } /** * Returns <tt>true</tt> if the extent is empty. + * * @return <tt>true</tt> if the extent is empty. */ public boolean isEmpty() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |