Revision: 5901 http://jnode.svn.sourceforge.net/jnode/?rev=5901&view=rev Author: galatnm Date: 2012-08-09 11:04:47 +0000 (Thu, 09 Aug 2012) Log Message: ----------- Add initial support for HFSX file systems (patch from L. Quinane)
Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java trunk/fs/src/fs/org/jnode/fs/hfsplus/SuperBlock.java trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2012-07-09 08:15:39 UTC (rev 5900) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java 2012-08-09 11:04:47 UTC (rev 5901) @@ -22,14 +22,11 @@ import java.io.IOException; import java.nio.ByteBuffer; - import org.jnode.driver.Device; import org.jnode.driver.block.FSBlockDeviceAPI; import org.jnode.fs.BlockDeviceFileSystemType; import org.jnode.fs.FileSystemException; import org.jnode.partitions.PartitionTableEntry; -import org.jnode.partitions.ibm.IBMPartitionTableEntry; -import org.jnode.partitions.ibm.IBMPartitionTypes; import org.jnode.util.BigEndian; public class HfsPlusFileSystemType implements BlockDeviceFileSystemType<HfsPlusFileSystem> { @@ -48,13 +45,13 @@ public final boolean supports(final PartitionTableEntry pte, final byte[] firstSector, final FSBlockDeviceAPI devApi) { - if (pte != null) { + /*if (pte != null) { if (pte instanceof IBMPartitionTableEntry) { if (((IBMPartitionTableEntry) pte).getSystemIndicator() != IBMPartitionTypes.PARTTYPE_LINUXNATIVE) { return false; } } - } + } */ // need to check the magic ByteBuffer magic = ByteBuffer.allocate(2); try { @@ -63,7 +60,7 @@ return false; } int magicNumber = BigEndian.getInt16(magic.array(), 0); - return (magicNumber == SuperBlock.HFSPLUS_SUPER_MAGIC); + return (magicNumber == SuperBlock.HFSPLUS_SUPER_MAGIC || magicNumber == SuperBlock.HFSX_SUPER_MAGIC); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/SuperBlock.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/SuperBlock.java 2012-07-09 08:15:39 UTC (rev 5900) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/SuperBlock.java 2012-08-09 11:04:47 UTC (rev 5901) @@ -41,7 +41,8 @@ */ public class SuperBlock extends HfsPlusObject { - public static final int HFSPLUS_SUPER_MAGIC = 0x482b; + public static final int HFSPLUS_SUPER_MAGIC = 0x482b; // H+ + public static final int HFSX_SUPER_MAGIC = 0x4858; // HX public static final int HFSPLUS_MIN_VERSION = 0x0004; /* HFS+ */ public static final int HFSPLUS_CURRENT_VERSION = 5; /* HFSX */ @@ -85,7 +86,7 @@ fs.getApi().read(1024, b); data = new byte[SUPERBLOCK_LENGTH]; System.arraycopy(b.array(), 0, data, 0, SUPERBLOCK_LENGTH); - if (getMagic() != HFSPLUS_SUPER_MAGIC) { + if (getMagic() != HFSPLUS_SUPER_MAGIC && getMagic() != HFSX_SUPER_MAGIC) { throw new FileSystemException("Not hfs+ volume header (" + getMagic() + ": bad magic)"); } @@ -151,7 +152,7 @@ forkdata.addDescriptor(0, desc); forkdata.write(data, 112); // Journal creation - int nextBlock = 0; + long nextBlock = 0; if (params.isJournaled()) { this.setFileCount(2); this.setAttribute(HFSPLUS_VOL_JOURNALED_BIT); @@ -248,8 +249,8 @@ return BigEndian.getInt32(data, 12); } - public final void setJournalInfoBlock(final int value) { - BigEndian.setInt32(data, 12, value); + public final void setJournalInfoBlock(final long value) { + BigEndian.setInt32(data, 12, (int) value); } // Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2012-07-09 08:15:39 UTC (rev 5900) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/extent/ExtentDescriptor.java 2012-08-09 11:04:47 UTC (rev 5901) @@ -27,10 +27,10 @@ public static final int EXTENT_DESCRIPTOR_LENGTH = 8; /** The first allocation block. */ - private int startBlock; + private long startBlock; /** The length in allocation blocks of the extent. */ - private int blockCount; + private long blockCount; public ExtentDescriptor() { this.startBlock = 0; @@ -43,7 +43,7 @@ * @param startBlock first allocation block. * @param blockCount number of blocks in the extent. */ - public ExtentDescriptor(int startBlock, int blockCount) { + public ExtentDescriptor(long startBlock, long blockCount) { this.startBlock = startBlock; this.blockCount = blockCount; } @@ -57,8 +57,8 @@ public ExtentDescriptor(final byte[] src, final int offset) { byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; System.arraycopy(src, offset, data, 0, EXTENT_DESCRIPTOR_LENGTH); - startBlock = BigEndian.getInt32(data, 0); - blockCount = BigEndian.getInt32(data, 4); + startBlock = BigEndian.getUInt32(data, 0); + blockCount = BigEndian.getUInt32(data, 4); } /** @@ -66,15 +66,15 @@ */ public final byte[] getBytes() { byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; - BigEndian.setInt32(data, 0, startBlock); - BigEndian.setInt32(data, 4, blockCount); + BigEndian.setInt32(data, 0, (int) startBlock); + BigEndian.setInt32(data, 4, (int) blockCount); return data; } public byte[] write(byte[] dest, int destOffSet) { byte[] data = new byte[EXTENT_DESCRIPTOR_LENGTH]; - BigEndian.setInt32(data, 0, startBlock); - BigEndian.setInt32(data, 4, blockCount); + BigEndian.setInt32(data, 0, (int) startBlock); + BigEndian.setInt32(data, 4, (int) blockCount); System.arraycopy(data, 0, dest, destOffSet, EXTENT_DESCRIPTOR_LENGTH); return dest; } @@ -90,7 +90,7 @@ * @return offset of the extent. */ public long getStartOffset(int nodeSize) { - return (long)startBlock * nodeSize; + return startBlock * nodeSize; } /** @@ -98,7 +98,7 @@ * * @return block number of the next extent. */ - public int getNext() { + public long getNext() { return startBlock + blockCount; } @@ -109,7 +109,7 @@ * @return size of the extent. */ public long getSize(int nodeSize) { - return (long)blockCount * nodeSize; + return blockCount * nodeSize; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Jnode-svn-commits mailing list Jnode-svn-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits