You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(97) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(127) |
Feb
(34) |
Mar
(16) |
Apr
(26) |
May
(55) |
Jun
(107) |
Jul
(36) |
Aug
(72) |
Sep
(90) |
Oct
(41) |
Nov
(27) |
Dec
(13) |
| 2008 |
Jan
(37) |
Feb
(39) |
Mar
(98) |
Apr
(115) |
May
(134) |
Jun
(120) |
Jul
(86) |
Aug
(149) |
Sep
(68) |
Oct
(66) |
Nov
(104) |
Dec
(49) |
| 2009 |
Jan
(131) |
Feb
(132) |
Mar
(125) |
Apr
(172) |
May
(161) |
Jun
(43) |
Jul
(47) |
Aug
(38) |
Sep
(18) |
Oct
(6) |
Nov
(1) |
Dec
(15) |
| 2010 |
Jan
(21) |
Feb
(8) |
Mar
(10) |
Apr
(4) |
May
(9) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(4) |
| 2011 |
Jan
(23) |
Feb
(10) |
Mar
(13) |
Apr
(3) |
May
|
Jun
(19) |
Jul
(11) |
Aug
(22) |
Sep
|
Oct
(4) |
Nov
(2) |
Dec
(12) |
| 2012 |
Jan
(3) |
Feb
(4) |
Mar
(7) |
Apr
(3) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(30) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(8) |
| 2013 |
Jan
(3) |
Feb
(40) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(12) |
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
|
From: <ga...@us...> - 2012-08-10 07:28:43
|
Revision: 5926
http://jnode.svn.sourceforge.net/jnode/?rev=5926&view=rev
Author: galatnm
Date: 2012-08-10 07:28:37 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Ext4 code review changes
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/ext4/
trunk/fs/src/fs/org/jnode/fs/ext4/Extent.java
trunk/fs/src/fs/org/jnode/fs/ext4/ExtentHeader.java
trunk/fs/src/fs/org/jnode/fs/ext4/ExtentIndex.java
Removed Paths:
-------------
trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java
trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2012-08-10 07:26:22 UTC (rev 5925)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -94,10 +94,10 @@
public static final long EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x0001;
public static final long EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x0002;
public static final long EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x0004;
- public static final long EXT4_FEATURE_ROCOMPAT_HUGE_FILE = 0x0008;
- public static final long EXT4_FEATURE_ROCOMPAT_GDT_CSUM = 0x0010;
- public static final long EXT4_FEATURE_ROCOMPAT_DIR_NLINK = 0x0020;
- public static final long EXT4_FEATURE_ROCOMPAT_EXTRA_ISIZE = 0x0040;
+ public static final long EXT4_FEATURE_RO_COMPAT_HUGE_FILE = 0x0008;
+ public static final long EXT4_FEATURE_RO_COMPAT_GDT_CSUM = 0x0010;
+ public static final long EXT4_FEATURE_RO_COMPAT_DIR_NLINK = 0x0020;
+ public static final long EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE = 0x0040;
// S_FEATURE_INCOMPAT constants
public static final long EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x0001;
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2012-08-10 07:26:22 UTC (rev 5925)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -151,19 +151,19 @@
log.info(getDevice().getId() + " Unsupported filesystem feature (BTREE_DIR) forces readonly mode");
setReadOnly(true);
}
- if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_HUGE_FILE)) {
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
log.info(getDevice().getId() + " Unsupported filesystem feature (HUGE_FILE) forces readonly mode");
setReadOnly(true);
}
- if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_GDT_CSUM)) {
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
log.info(getDevice().getId() + " Unsupported filesystem feature (GDT_CSUM) forces readonly mode");
setReadOnly(true);
}
- if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_DIR_NLINK)) {
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_RO_COMPAT_DIR_NLINK)) {
log.info(getDevice().getId() + " Unsupported filesystem feature (DIR_NLINK) forces readonly mode");
setReadOnly(true);
}
- if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_EXTRA_ISIZE)) {
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)) {
log.info(getDevice().getId() + " Unsupported filesystem feature (EXTRA_ISIZE) forces readonly mode");
setReadOnly(true);
}
@@ -348,7 +348,7 @@
*
* @return data block nr
*/
- protected byte[] getBlock(long nr) throws IOException {
+ public byte[] getBlock(long nr) throws IOException {
if (isClosed())
throw new IOException("FS closed (fs instance: " + this + ")");
// log.debug("blockCache size: "+blockCache.size());
Deleted: trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java 2012-08-10 07:26:22 UTC (rev 5925)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -1,55 +0,0 @@
-package org.jnode.fs.ext2;
-
-/**
- * An ext4 extent object.
- *
- * @author Luke Quinane
- */
-public class Extent {
- /**
- * The length of an extent.
- */
- public static final int EXTENT_LENGTH = 12;
-
- /**
- * The data for the extent.
- */
- private byte[] data;
-
- /**
- * Create an extent object.
- *
- * @param data the data for the extent.
- */
- public Extent(byte[] data) {
- this.data = new byte[EXTENT_LENGTH];
- System.arraycopy(data, 0, this.data, 0, EXTENT_LENGTH);
-
- // Safety check
- if (getStartHigh() != 0) {
- throw new UnsupportedOperationException("Extents that use the high bits aren't supported yet");
- }
- }
-
- public long getBlockIndex() {
- return Ext2Utils.get32(data, 0);
- }
-
- public int getBlockCount() {
- return Ext2Utils.get16(data, 4);
- }
-
- public long getStartLow() {
- return Ext2Utils.get32(data, 8);
- }
-
- public int getStartHigh() {
- return Ext2Utils.get16(data, 6);
- }
-
- @Override
- public String toString() {
- return String.format("Extent: blockindex:%d count:%d start(low:%d high:%d)", getBlockIndex(), getBlockCount(),
- getStartLow(), getStartHigh());
- }
-}
Deleted: trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java 2012-08-10 07:26:22 UTC (rev 5925)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -1,180 +0,0 @@
-package org.jnode.fs.ext2;
-
-import java.io.IOException;
-
-/**
- * An ext4 extent header.
- *
- * @author Luke Quinane
- */
-public class ExtentHeader {
- /**
- * The length of an extent header.
- */
- public static final int EXTENT_HEADER_LENGTH = 12;
-
- /**
- * The magic number for an extent header.
- */
- public static final int MAGIC = 0xf30a;
-
- /**
- * The data for the header.
- */
- private byte[] data;
-
- /**
- * The cache copy of the index entries.
- */
- private ExtentIndex[] indexEntries;
-
- /**
- * The cache copy of the extent entries.
- */
- private Extent[] extentEntries;
-
- /**
- * Create an extent header object.
- */
- public ExtentHeader(byte[] data) throws IOException {
- this.data = new byte[data.length];
- System.arraycopy(data, 0, this.data, 0, data.length);
-
- if (getMagic() != ExtentHeader.MAGIC) {
- throw new IOException("Extent had the wrong magic: " + getMagic());
- }
- }
-
- public int getMagic() {
- return Ext2Utils.get16(data, 0);
- }
-
- public int getEntryCount() {
- return Ext2Utils.get16(data, 2);
- }
-
- public int getMaximumEntryCount() {
- return Ext2Utils.get16(data, 4);
- }
-
- public int getDepth() {
- return Ext2Utils.get16(data, 6);
- }
-
- public ExtentIndex[] getIndexEntries() {
- if (getDepth() == 0) {
- throw new IllegalStateException("Trying to read index entries from a leaf.");
- }
-
- if (indexEntries == null) {
- indexEntries = new ExtentIndex[getEntryCount()];
- int offset = EXTENT_HEADER_LENGTH;
-
- for (int i = 0; i < getEntryCount(); i++) {
- byte[] indexBuffer = new byte[ExtentIndex.EXTENT_INDEX_LENGTH];
- System.arraycopy(data, offset, indexBuffer, 0, indexBuffer.length);
-
- indexEntries[i] = new ExtentIndex(indexBuffer);
- offset += ExtentIndex.EXTENT_INDEX_LENGTH;
- }
- }
-
- return indexEntries;
- }
-
- public Extent[] getExtentEntries() {
- if (getDepth() != 0) {
- throw new IllegalStateException("Trying to read extent entries from a non-leaf.");
- }
-
- if (extentEntries == null) {
- extentEntries = new Extent[getEntryCount()];
- int offset = EXTENT_HEADER_LENGTH;
-
- for (int i = 0; i < getEntryCount(); i++) {
- byte[] indexBuffer = new byte[Extent.EXTENT_LENGTH];
- System.arraycopy(data, offset, indexBuffer, 0, indexBuffer.length);
-
- extentEntries[i] = new Extent(indexBuffer);
- offset += Extent.EXTENT_LENGTH;
- }
- }
-
- return extentEntries;
- }
-
- public long getBlockNumber(Ext2FileSystem fs, long index) throws IOException {
- if (getDepth() > 0) {
- ExtentIndex extentIndex = binarySearchIndexes(index, getIndexEntries());
- byte[] indexData = fs.getBlock(extentIndex.getLeafLow());
-
- ExtentHeader indexHeader = new ExtentHeader(indexData);
- return indexHeader.getBlockNumber(fs, index);
- }
- else {
- Extent extent = binarySearchExtents(index, getExtentEntries());
- return index - extent.getBlockIndex() + extent.getStartLow();
- }
- }
-
- /**
- * Performs a binary search in the extent indexes.
- *
- * @param index the index of the block to match.
- * @param indexes the indexes to search in.
- * @return the matching index.
- */
- private ExtentIndex binarySearchIndexes(long index, ExtentIndex[] indexes)
- {
- int lowIndex = 0;
- int highIndex = indexes.length - 1;
- ExtentIndex extentIndex = null;
-
- while (lowIndex <= highIndex) {
- int middle = lowIndex + (highIndex - lowIndex) / 2;
- extentIndex = indexes[middle];
-
- if (index < extentIndex.getBlockIndex()) {
- highIndex = middle - 1;
- }
- else {
- lowIndex = middle + 1;
- }
- }
-
- return indexes[Math.max(0, lowIndex - 1)];
- }
-
- /**
- * Performs a binary search in the extents.
- *
- * @param index the index of the block to match.
- * @param extents the extents to search in.
- * @return the matching extent.
- */
- private Extent binarySearchExtents(long index, Extent[] extents)
- {
- int lowIndex = 0;
- int highIndex = extents.length - 1;
- Extent extent = null;
-
- while (lowIndex <= highIndex) {
- int middle = lowIndex + (highIndex - lowIndex) / 2;
- extent = extents[middle];
-
- if (index < extent.getBlockIndex()) {
- highIndex = middle - 1;
- }
- else {
- lowIndex = middle + 1;
- }
- }
-
- return extents[Math.max(0, lowIndex - 1)];
- }
-
- @Override
- public String toString() {
- return String.format("ExtentHeader: depth:%d entries:%d/%d", getDepth(), getEntryCount(), getMaximumEntryCount());
- }
-}
Deleted: trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java 2012-08-10 07:26:22 UTC (rev 5925)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -1,51 +0,0 @@
-package org.jnode.fs.ext2;
-
-/**
- * An ext4 extent index.
- *
- * @author Luke Quinane
- */
-public class ExtentIndex {
- /**
- * The length of an extent index.
- */
- public static final int EXTENT_INDEX_LENGTH = 12;
-
- /**
- * The data for the index.
- */
- private byte[] data;
-
- /**
- * Create an extent index object.
- *
- * @param data the data for the index.
- */
- public ExtentIndex(byte[] data) {
- this.data = new byte[EXTENT_INDEX_LENGTH];
- System.arraycopy(data, 0, this.data, 0, EXTENT_INDEX_LENGTH);
-
- // Safety check
- if (getLeafHigh() != 0) {
- throw new UnsupportedOperationException("Extent indexes that use the high bits aren't supported yet");
- }
- }
-
- public long getBlockIndex() {
- return Ext2Utils.get32(data, 0);
- }
-
- public long getLeafLow() {
- return Ext2Utils.get32(data, 4);
- }
-
- public int getLeafHigh() {
- return Ext2Utils.get16(data, 8);
- }
-
- @Override
- public String toString() {
- return String.format("ExtentIndex: blockindex:%d leaf(low:%d high:%d)", getBlockIndex(), getLeafLow(),
- getLeafHigh());
- }
-}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 07:26:22 UTC (rev 5925)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -26,6 +26,7 @@
import org.apache.log4j.Logger;
import org.jnode.fs.FileSystemException;
import org.jnode.fs.ext2.exception.UnallocatedBlockException;
+import org.jnode.fs.ext4.ExtentHeader;
/**
* This class represents an inode. Once they are allocated, inodes are read and
Added: trunk/fs/src/fs/org/jnode/fs/ext4/Extent.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext4/Extent.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/ext4/Extent.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -0,0 +1,57 @@
+package org.jnode.fs.ext4;
+
+import org.jnode.fs.ext2.Ext2Utils;
+
+/**
+ * An ext4 extent object.
+ *
+ * @author Luke Quinane
+ */
+public class Extent {
+ /**
+ * The length of an extent.
+ */
+ public static final int EXTENT_LENGTH = 12;
+
+ /**
+ * The data for the extent.
+ */
+ private byte[] data;
+
+ /**
+ * Create an extent object.
+ *
+ * @param data the data for the extent.
+ */
+ public Extent(byte[] data) {
+ this.data = new byte[EXTENT_LENGTH];
+ System.arraycopy(data, 0, this.data, 0, EXTENT_LENGTH);
+
+ // Safety check
+ if (getStartHigh() != 0) {
+ throw new UnsupportedOperationException("Extents that use the high bits aren't supported yet");
+ }
+ }
+
+ public long getBlockIndex() {
+ return Ext2Utils.get32(data, 0);
+ }
+
+ public int getBlockCount() {
+ return Ext2Utils.get16(data, 4);
+ }
+
+ public long getStartLow() {
+ return Ext2Utils.get32(data, 8);
+ }
+
+ public int getStartHigh() {
+ return Ext2Utils.get16(data, 6);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("Extent: blockindex:%d count:%d start(low:%d high:%d)", getBlockIndex(), getBlockCount(),
+ getStartLow(), getStartHigh());
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/ext4/ExtentHeader.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext4/ExtentHeader.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/ext4/ExtentHeader.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -0,0 +1,182 @@
+package org.jnode.fs.ext4;
+
+import java.io.IOException;
+import org.jnode.fs.ext2.Ext2FileSystem;
+import org.jnode.fs.ext2.Ext2Utils;
+
+/**
+ * An ext4 extent header.
+ *
+ * @author Luke Quinane
+ */
+public class ExtentHeader {
+ /**
+ * The length of an extent header.
+ */
+ public static final int EXTENT_HEADER_LENGTH = 12;
+
+ /**
+ * The magic number for an extent header.
+ */
+ public static final int MAGIC = 0xf30a;
+
+ /**
+ * The data for the header.
+ */
+ private final byte[] data;
+
+ /**
+ * The cache copy of the index entries.
+ */
+ private ExtentIndex[] indexEntries;
+
+ /**
+ * The cache copy of the extent entries.
+ */
+ private Extent[] extentEntries;
+
+ /**
+ * Create an extent header object.
+ */
+ public ExtentHeader(byte[] data) throws IOException {
+ this.data = new byte[data.length];
+ System.arraycopy(data, 0, this.data, 0, data.length);
+
+ if (getMagic() != ExtentHeader.MAGIC) {
+ throw new IOException("Extent had the wrong magic: " + getMagic());
+ }
+ }
+
+ public int getMagic() {
+ return Ext2Utils.get16(data, 0);
+ }
+
+ public int getEntryCount() {
+ return Ext2Utils.get16(data, 2);
+ }
+
+ public int getMaximumEntryCount() {
+ return Ext2Utils.get16(data, 4);
+ }
+
+ public int getDepth() {
+ return Ext2Utils.get16(data, 6);
+ }
+
+ public ExtentIndex[] getIndexEntries() {
+ if (getDepth() == 0) {
+ throw new IllegalStateException("Trying to read index entries from a leaf.");
+ }
+
+ if (indexEntries == null) {
+ indexEntries = new ExtentIndex[getEntryCount()];
+ int offset = EXTENT_HEADER_LENGTH;
+
+ for (int i = 0; i < getEntryCount(); i++) {
+ byte[] indexBuffer = new byte[ExtentIndex.EXTENT_INDEX_LENGTH];
+ System.arraycopy(data, offset, indexBuffer, 0, indexBuffer.length);
+
+ indexEntries[i] = new ExtentIndex(indexBuffer);
+ offset += ExtentIndex.EXTENT_INDEX_LENGTH;
+ }
+ }
+
+ return indexEntries;
+ }
+
+ public Extent[] getExtentEntries() {
+ if (getDepth() != 0) {
+ throw new IllegalStateException("Trying to read extent entries from a non-leaf.");
+ }
+
+ if (extentEntries == null) {
+ extentEntries = new Extent[getEntryCount()];
+ int offset = EXTENT_HEADER_LENGTH;
+
+ for (int i = 0; i < getEntryCount(); i++) {
+ byte[] indexBuffer = new byte[Extent.EXTENT_LENGTH];
+ System.arraycopy(data, offset, indexBuffer, 0, indexBuffer.length);
+
+ extentEntries[i] = new Extent(indexBuffer);
+ offset += Extent.EXTENT_LENGTH;
+ }
+ }
+
+ return extentEntries;
+ }
+
+ public long getBlockNumber(Ext2FileSystem fs, long index) throws IOException {
+ if (getDepth() > 0) {
+ ExtentIndex extentIndex = binarySearchIndexes(index, getIndexEntries());
+ byte[] indexData = fs.getBlock(extentIndex.getLeafLow());
+
+ ExtentHeader indexHeader = new ExtentHeader(indexData);
+ return indexHeader.getBlockNumber(fs, index);
+ }
+ else {
+ Extent extent = binarySearchExtents(index, getExtentEntries());
+ return index - extent.getBlockIndex() + extent.getStartLow();
+ }
+ }
+
+ /**
+ * Performs a binary search in the extent indexes.
+ *
+ * @param index the index of the block to match.
+ * @param indexes the indexes to search in.
+ * @return the matching index.
+ */
+ private ExtentIndex binarySearchIndexes(long index, ExtentIndex[] indexes)
+ {
+ int lowIndex = 0;
+ int highIndex = indexes.length - 1;
+ ExtentIndex extentIndex = null;
+
+ while (lowIndex <= highIndex) {
+ int middle = lowIndex + (highIndex - lowIndex) / 2;
+ extentIndex = indexes[middle];
+
+ if (index < extentIndex.getBlockIndex()) {
+ highIndex = middle - 1;
+ }
+ else {
+ lowIndex = middle + 1;
+ }
+ }
+
+ return indexes[Math.max(0, lowIndex - 1)];
+ }
+
+ /**
+ * Performs a binary search in the extents.
+ *
+ * @param index the index of the block to match.
+ * @param extents the extents to search in.
+ * @return the matching extent.
+ */
+ private Extent binarySearchExtents(long index, Extent[] extents)
+ {
+ int lowIndex = 0;
+ int highIndex = extents.length - 1;
+ Extent extent = null;
+
+ while (lowIndex <= highIndex) {
+ int middle = lowIndex + (highIndex - lowIndex) / 2;
+ extent = extents[middle];
+
+ if (index < extent.getBlockIndex()) {
+ highIndex = middle - 1;
+ }
+ else {
+ lowIndex = middle + 1;
+ }
+ }
+
+ return extents[Math.max(0, lowIndex - 1)];
+ }
+
+ @Override
+ public String toString() {
+ return String.format("ExtentHeader: depth:%d entries:%d/%d", getDepth(), getEntryCount(), getMaximumEntryCount());
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/ext4/ExtentIndex.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext4/ExtentIndex.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/ext4/ExtentIndex.java 2012-08-10 07:28:37 UTC (rev 5926)
@@ -0,0 +1,53 @@
+package org.jnode.fs.ext4;
+
+import org.jnode.fs.ext2.Ext2Utils;
+
+/**
+ * An ext4 extent index.
+ *
+ * @author Luke Quinane
+ */
+public class ExtentIndex {
+ /**
+ * The length of an extent index.
+ */
+ public static final int EXTENT_INDEX_LENGTH = 12;
+
+ /**
+ * The data for the index.
+ */
+ private final byte[] data;
+
+ /**
+ * Create an extent index object.
+ *
+ * @param data the data for the index.
+ */
+ public ExtentIndex(byte[] data) {
+ this.data = new byte[EXTENT_INDEX_LENGTH];
+ System.arraycopy(data, 0, this.data, 0, EXTENT_INDEX_LENGTH);
+
+ // Safety check
+ if (getLeafHigh() != 0) {
+ throw new UnsupportedOperationException("Extent indexes that use the high bits aren't supported yet");
+ }
+ }
+
+ public long getBlockIndex() {
+ return Ext2Utils.get32(data, 0);
+ }
+
+ public long getLeafLow() {
+ return Ext2Utils.get32(data, 4);
+ }
+
+ public int getLeafHigh() {
+ return Ext2Utils.get16(data, 8);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("ExtentIndex: blockindex:%d leaf(low:%d high:%d)", getBlockIndex(), getLeafLow(),
+ getLeafHigh());
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:26:29
|
Revision: 5925
http://jnode.svn.sourceforge.net/jnode/?rev=5925&view=rev
Author: galatnm
Date: 2012-08-10 07:26:22 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Further support for ext4 extents and bug fixes
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java
trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java 2012-08-10 07:23:31 UTC (rev 5924)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java 2012-08-10 07:26:22 UTC (rev 5925)
@@ -103,33 +103,74 @@
return extentEntries;
}
- public long getBlockNumber(long index) {
+ public long getBlockNumber(Ext2FileSystem fs, long index) throws IOException {
if (getDepth() > 0) {
- ExtentIndex[] indexes = getIndexEntries();
+ ExtentIndex extentIndex = binarySearchIndexes(index, getIndexEntries());
+ byte[] indexData = fs.getBlock(extentIndex.getLeafLow());
- throw new UnsupportedOperationException();
+ ExtentHeader indexHeader = new ExtentHeader(indexData);
+ return indexHeader.getBlockNumber(fs, index);
}
else {
- Extent[] extents = getExtentEntries();
+ Extent extent = binarySearchExtents(index, getExtentEntries());
+ return index - extent.getBlockIndex() + extent.getStartLow();
+ }
+ }
- int lowIndex = 0;
- int highIndex = extents.length - 1;
- Extent extent = null;
+ /**
+ * Performs a binary search in the extent indexes.
+ *
+ * @param index the index of the block to match.
+ * @param indexes the indexes to search in.
+ * @return the matching index.
+ */
+ private ExtentIndex binarySearchIndexes(long index, ExtentIndex[] indexes)
+ {
+ int lowIndex = 0;
+ int highIndex = indexes.length - 1;
+ ExtentIndex extentIndex = null;
- while (lowIndex <= highIndex) {
- int middle = lowIndex + (highIndex - lowIndex) / 2;
- extent = extents[middle];
+ while (lowIndex <= highIndex) {
+ int middle = lowIndex + (highIndex - lowIndex) / 2;
+ extentIndex = indexes[middle];
- if (index < extent.getBlockIndex()) {
- highIndex = middle - 1;
- }
- else {
- lowIndex = middle + 1;
- }
+ if (index < extentIndex.getBlockIndex()) {
+ highIndex = middle - 1;
}
+ else {
+ lowIndex = middle + 1;
+ }
+ }
- return index - extent.getBlockIndex() + extent.getStartLow();
+ return indexes[Math.max(0, lowIndex - 1)];
+ }
+
+ /**
+ * Performs a binary search in the extents.
+ *
+ * @param index the index of the block to match.
+ * @param extents the extents to search in.
+ * @return the matching extent.
+ */
+ private Extent binarySearchExtents(long index, Extent[] extents)
+ {
+ int lowIndex = 0;
+ int highIndex = extents.length - 1;
+ Extent extent = null;
+
+ while (lowIndex <= highIndex) {
+ int middle = lowIndex + (highIndex - lowIndex) / 2;
+ extent = extents[middle];
+
+ if (index < extent.getBlockIndex()) {
+ highIndex = middle - 1;
+ }
+ else {
+ lowIndex = middle + 1;
+ }
}
+
+ return extents[Math.max(0, lowIndex - 1)];
}
@Override
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java 2012-08-10 07:23:31 UTC (rev 5924)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java 2012-08-10 07:26:22 UTC (rev 5925)
@@ -24,6 +24,11 @@
public ExtentIndex(byte[] data) {
this.data = new byte[EXTENT_INDEX_LENGTH];
System.arraycopy(data, 0, this.data, 0, EXTENT_INDEX_LENGTH);
+
+ // Safety check
+ if (getLeafHigh() != 0) {
+ throw new UnsupportedOperationException("Extent indexes that use the high bits aren't supported yet");
+ }
}
public long getBlockIndex() {
@@ -37,4 +42,10 @@
public int getLeafHigh() {
return Ext2Utils.get16(data, 8);
}
+
+ @Override
+ public String toString() {
+ return String.format("ExtentIndex: blockindex:%d leaf(low:%d high:%d)", getBlockIndex(), getLeafLow(),
+ getLeafHigh());
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 07:23:31 UTC (rev 5924)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 07:26:22 UTC (rev 5925)
@@ -300,7 +300,7 @@
extentHeader = new ExtentHeader(getINodeBlockData());
}
- return extentHeader.getBlockNumber(i);
+ return extentHeader.getBlockNumber(fs, i);
}
else {
return getDataBlockNrIndirect(i);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:23:38
|
Revision: 5924
http://jnode.svn.sourceforge.net/jnode/?rev=5924&view=rev
Author: galatnm
Date: 2012-08-10 07:23:31 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Implement our last accessed interface
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 07:22:07 UTC (rev 5923)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 07:23:31 UTC (rev 5924)
@@ -25,6 +25,7 @@
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
import org.jnode.fs.FSEntryCreated;
+import org.jnode.fs.FSEntryLastAccessed;
import org.jnode.fs.FSFile;
import org.jnode.fs.FileSystem;
import org.jnode.fs.hfsplus.catalog.CatalogFile;
@@ -33,7 +34,7 @@
import org.jnode.fs.spi.AbstractFSEntry;
import org.jnode.fs.spi.UnixFSAccessRights;
-public class HfsPlusEntry implements FSEntry, FSEntryCreated {
+public class HfsPlusEntry implements FSEntry, FSEntryCreated, FSEntryLastAccessed {
protected HfsPlusFileSystem fs;
protected HfsPlusDirectory parent;
@@ -208,6 +209,7 @@
}
}
+ @Override
public long getLastAccessed() throws IOException {
if (isFile()) {
CatalogFile catalogFile = new CatalogFile(getData());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:22:13
|
Revision: 5923
http://jnode.svn.sourceforge.net/jnode/?rev=5923&view=rev
Author: galatnm
Date: 2012-08-10 07:22:07 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Expose some more HFS+ entry details
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 07:20:25 UTC (rev 5922)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 07:22:07 UTC (rev 5923)
@@ -141,6 +141,22 @@
return (type == AbstractFSEntry.FILE_ENTRY);
}
+ public CatalogFile createCatalogFile() {
+ if (!isFile()) {
+ throw new IllegalStateException("Attempted to create a catalog file but this entry is not a file!");
+ }
+
+ return new CatalogFile(getData());
+ }
+
+ public CatalogFolder createCatalogFolder() {
+ if (isFile()) {
+ throw new IllegalStateException("Attempted to create a catalog folder but this entry is not a directory!");
+ }
+
+ return new CatalogFolder(getData());
+ }
+
@Override
public void setLastModified(long lastModified) throws IOException {
if (isFile()) {
@@ -191,4 +207,15 @@
return catalogFolder.getCreateDate();
}
}
+
+ public long getLastAccessed() throws IOException {
+ if (isFile()) {
+ CatalogFile catalogFile = new CatalogFile(getData());
+ return catalogFile.getAccessDate();
+ }
+ else {
+ CatalogFolder catalogFolder = new CatalogFolder(getData());
+ return catalogFolder.getAccessDate();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:20:31
|
Revision: 5922
http://jnode.svn.sourceforge.net/jnode/?rev=5922&view=rev
Author: galatnm
Date: 2012-08-10 07:20:25 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Add HFS+ file info and BSD info fields Extract out some more dates
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/hfsplus/FileInfo.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusBSDInfo.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/FileInfo.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/FileInfo.java 2012-08-10 07:18:21 UTC (rev 5921)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/FileInfo.java 2012-08-10 07:20:25 UTC (rev 5922)
@@ -17,9 +17,31 @@
* 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.util.BigEndian;
+
public class FileInfo {
+ private int fileType;
+ private int fileCreator;
+ private int finderFlags;
+ public FileInfo(byte[] data, int offset) {
+ fileType = BigEndian.getInt32(data, offset);
+ fileCreator = BigEndian.getInt32(data, offset + 4);
+ finderFlags = BigEndian.getInt16(data, offset + 8);
+ }
+
+ public int getFileType() {
+ return fileType;
+ }
+
+ public int getFileCreator() {
+ return fileCreator;
+ }
+
+ public int getFinderFlags() {
+ return finderFlags;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusBSDInfo.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusBSDInfo.java 2012-08-10 07:18:21 UTC (rev 5921)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusBSDInfo.java 2012-08-10 07:20:25 UTC (rev 5922)
@@ -20,6 +20,46 @@
package org.jnode.fs.hfsplus;
+import org.jnode.util.BigEndian;
+
public class HfsPlusBSDInfo {
+ private int ownerID;
+ private int groupID;
+ private int adminFlags;
+ private int ownerFlags;
+ private int fileMode;
+ private int special;
+ public HfsPlusBSDInfo(byte[] data, int offset) {
+ ownerID = BigEndian.getInt32(data, offset);
+ groupID = BigEndian.getInt32(data, offset + 4);
+ adminFlags = data[offset + 8];
+ ownerFlags = data[offset + 9];
+ fileMode = BigEndian.getInt16(data, offset + 10);
+ special = BigEndian.getInt32(data, offset + 12);
+ }
+
+ public int getOwnerID() {
+ return ownerID;
+ }
+
+ public int getGroupID() {
+ return groupID;
+ }
+
+ public int getAdminFlags() {
+ return adminFlags;
+ }
+
+ public int getOwnerFlags() {
+ return ownerFlags;
+ }
+
+ public int getFileMode() {
+ return fileMode;
+ }
+
+ public int getSpecial() {
+ return special;
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java 2012-08-10 07:18:21 UTC (rev 5921)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java 2012-08-10 07:20:25 UTC (rev 5922)
@@ -82,6 +82,10 @@
createDate = BigEndian.getInt32(data, 12);
contentModDate = BigEndian.getInt32(data, 16);
attrModDate = BigEndian.getInt32(data, 20);
+ accessDate = BigEndian.getInt32(data, 24);
+ backupDate = BigEndian.getInt32(data, 28);
+ permissions = new HfsPlusBSDInfo(data, 32);
+ userInfo = new FileInfo(data, 48);
datas = new HfsPlusForkData(data, 88);
resources = new HfsPlusForkData(data, 168);
}
@@ -145,8 +149,8 @@
return HfsUtils.getDate(contentModDate & 0xffffffffL, false) * 1000L;
}
- public int getAttrModDate() {
- return attrModDate;
+ public long getAttrModDate() {
+ return HfsUtils.getDate(attrModDate & 0xffffffffL, false) * 1000L;
}
public HfsPlusForkData getDatas() {
@@ -157,12 +161,12 @@
return resources;
}
- public int getAccessDate() {
- return accessDate;
+ public long getAccessDate() {
+ return HfsUtils.getDate(accessDate & 0xffffffffL, false) * 1000L;
}
- public int getBackupDate() {
- return backupDate;
+ public long getBackupDate() {
+ return HfsUtils.getDate(backupDate & 0xffffffffL, false) * 1000L;
}
public HfsPlusBSDInfo getPermissions() {
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2012-08-10 07:18:21 UTC (rev 5921)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2012-08-10 07:20:25 UTC (rev 5922)
@@ -20,6 +20,7 @@
package org.jnode.fs.hfsplus.catalog;
+import org.jnode.fs.hfsplus.HfsPlusBSDInfo;
import org.jnode.fs.hfsplus.HfsUtils;
import org.jnode.util.BigEndian;
@@ -36,6 +37,9 @@
private int createDate;
private int contentModDate;
private int attrModDate;
+ private int accessDate;
+ private int backupDate;
+ private HfsPlusBSDInfo permissions;
/**
*
@@ -50,6 +54,9 @@
createDate = BigEndian.getInt32(data, 12);
contentModDate = BigEndian.getInt32(data, 16);
attrModDate = BigEndian.getInt32(data, 20);
+ accessDate = BigEndian.getInt32(data, 24);
+ backupDate = BigEndian.getInt32(data, 28);
+ permissions = new HfsPlusBSDInfo(data, 32);
}
/**
@@ -120,10 +127,22 @@
return HfsUtils.getDate(contentModDate & 0xffffffffL, false) * 1000L;
}
- public int getAttrModDate() {
- return attrModDate;
+ public long getAttrModDate() {
+ return HfsUtils.getDate(attrModDate & 0xffffffffL, false) * 1000L;
}
+ public long getAccessDate() {
+ return HfsUtils.getDate(accessDate & 0xffffffffL, false) * 1000L;
+ }
+
+ public long getBackupDate() {
+ return HfsUtils.getDate(backupDate & 0xffffffffL, false) * 1000L;
+ }
+
+ public HfsPlusBSDInfo getPermissions() {
+ return permissions;
+ }
+
public void setRecordType(int recordType) {
this.recordType = recordType;
}
@@ -144,8 +163,8 @@
this.contentModDate = (int) HfsUtils.getDate(contentModDate / 1000L, true);
}
- public void setAttrModDate(int attrModDate) {
- this.attrModDate = attrModDate;
+ public void setAttrModDate(long attrModDate) {
+ this.attrModDate = (int) HfsUtils.getDate(attrModDate / 1000L, true);
}
public void incrementValence(){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:18:28
|
Revision: 5921
http://jnode.svn.sourceforge.net/jnode/?rev=5921&view=rev
Author: galatnm
Date: 2012-08-10 07:18:21 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Make inode public
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java
trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2012-08-10 07:15:24 UTC (rev 5920)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2012-08-10 07:18:21 UTC (rev 5921)
@@ -87,7 +87,7 @@
return type;
}
- INode getINode() {
+ public INode getINode() {
return iNode;
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 07:15:24 UTC (rev 5920)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 07:18:21 UTC (rev 5921)
@@ -105,7 +105,7 @@
log.setLevel(Level.DEBUG);
}
- protected int getINodeNr() {
+ public int getINodeNr() {
return desc.getINodeNr();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:15:31
|
Revision: 5920
http://jnode.svn.sourceforge.net/jnode/?rev=5920&view=rev
Author: galatnm
Date: 2012-08-10 07:15:24 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Log at the correct level
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2012-08-10 07:12:00 UTC (rev 5919)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2012-08-10 07:15:24 UTC (rev 5920)
@@ -174,7 +174,7 @@
}
if (log.isDebugEnabled()) {
- log.info("File:" + entry.getName() + " size:" + getLength() + " read offset: " + fileOffset + " len: " +
+ log.debug("File:" + entry.getName() + " size:" + getLength() + " read offset: " + fileOffset + " len: " +
dest.length);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:12:07
|
Revision: 5919
http://jnode.svn.sourceforge.net/jnode/?rev=5919&view=rev
Author: galatnm
Date: 2012-08-10 07:12:00 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Fix a bug in extent block lookups
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java
trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java 2012-08-10 07:08:00 UTC (rev 5918)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java 2012-08-10 07:12:00 UTC (rev 5919)
@@ -24,6 +24,11 @@
public Extent(byte[] data) {
this.data = new byte[EXTENT_LENGTH];
System.arraycopy(data, 0, this.data, 0, EXTENT_LENGTH);
+
+ // Safety check
+ if (getStartHigh() != 0) {
+ throw new UnsupportedOperationException("Extents that use the high bits aren't supported yet");
+ }
}
public long getBlockIndex() {
@@ -41,4 +46,10 @@
public int getStartHigh() {
return Ext2Utils.get16(data, 6);
}
+
+ @Override
+ public String toString() {
+ return String.format("Extent: blockindex:%d count:%d start(low:%d high:%d)", getBlockIndex(), getBlockCount(),
+ getStartLow(), getStartHigh());
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java 2012-08-10 07:08:00 UTC (rev 5918)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java 2012-08-10 07:12:00 UTC (rev 5919)
@@ -128,7 +128,12 @@
}
}
- return extent.getStartLow();
+ return index - extent.getBlockIndex() + extent.getStartLow();
}
}
+
+ @Override
+ public String toString() {
+ return String.format("ExtentHeader: depth:%d entries:%d/%d", getDepth(), getEntryCount(), getMaximumEntryCount());
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 07:08:10
|
Revision: 5918
http://jnode.svn.sourceforge.net/jnode/?rev=5918&view=rev
Author: galatnm
Date: 2012-08-10 07:08:00 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Add some extra debugging to Ext2File
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2012-08-10 06:57:21 UTC (rev 5917)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2012-08-10 07:08:00 UTC (rev 5918)
@@ -227,10 +227,10 @@
//so synchronize to the inode.
synchronized (iNode) {
try {
- Ext2File dir = new Ext2File(iNode); //read itself as a file
+ Ext2File dir = new Ext2File(entry); //read itself as a file
//find the last directory record (if any)
- Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(iNode);
+ Ext2FSEntryIterator iterator = new Ext2FSEntryIterator(entry);
Ext2DirectoryRecord rec = null;
while (iterator.hasNext()) {
rec = iterator.nextDirectoryRecord();
@@ -337,9 +337,9 @@
Ext2DirectoryRecord current;
- public Ext2FSEntryIterator(INode iNode) throws IOException {
+ public Ext2FSEntryIterator(Ext2Entry entry) throws IOException {
//read itself as a file
- Ext2File directoryFile = new Ext2File(iNode);
+ Ext2File directoryFile = new Ext2File(entry);
//read the whole directory
data = ByteBuffer.allocate((int) directoryFile.getLength());
@@ -424,7 +424,7 @@
* @return the FSEntryTable containing the directory's entries.
*/
protected FSEntryTable readEntries() throws IOException {
- Ext2FSEntryIterator it = new Ext2FSEntryIterator(iNode);
+ Ext2FSEntryIterator it = new Ext2FSEntryIterator(entry);
ArrayList<FSEntry> entries = new ArrayList<FSEntry>();
while (it.hasNext()) {
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2012-08-10 06:57:21 UTC (rev 5917)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2012-08-10 07:08:00 UTC (rev 5918)
@@ -34,13 +34,15 @@
*/
public class Ext2File extends AbstractFSFile {
+ Ext2Entry entry;
INode iNode;
private final Logger log = Logger.getLogger(getClass());
- public Ext2File(INode iNode) {
- super(iNode.getExt2FileSystem());
- this.iNode = iNode;
+ public Ext2File(Ext2Entry entry) {
+ super(entry.getINode().getExt2FileSystem());
+ this.iNode = entry.getINode();
+ this.entry = entry;
log.setLevel(Level.DEBUG);
}
@@ -170,6 +172,12 @@
// different INode instances)
iNode.incLocked();
}
+
+ if (log.isDebugEnabled()) {
+ log.info("File:" + entry.getName() + " size:" + getLength() + " read offset: " + fileOffset + " len: " +
+ dest.length);
+ }
+
//a single inode may be represented by more than one Ext2Directory
// instances,
//but each will use the same instance of the underlying inode (see
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2012-08-10 06:57:21 UTC (rev 5917)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2012-08-10 07:08:00 UTC (rev 5918)
@@ -898,7 +898,7 @@
*/
protected FSFile createFile(FSEntry entry) throws IOException {
Ext2Entry e = (Ext2Entry) entry;
- return new Ext2File(e.getINode());
+ return new Ext2File(e);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:57:29
|
Revision: 5917
http://jnode.svn.sourceforge.net/jnode/?rev=5917&view=rev
Author: galatnm
Date: 2012-08-10 06:57:21 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Change HfsPlusEntry to implement FSEntryCreated
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 06:55:38 UTC (rev 5916)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 06:57:21 UTC (rev 5917)
@@ -24,6 +24,7 @@
import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
+import org.jnode.fs.FSEntryCreated;
import org.jnode.fs.FSFile;
import org.jnode.fs.FileSystem;
import org.jnode.fs.hfsplus.catalog.CatalogFile;
@@ -32,7 +33,7 @@
import org.jnode.fs.spi.AbstractFSEntry;
import org.jnode.fs.spi.UnixFSAccessRights;
-public class HfsPlusEntry implements FSEntry {
+public class HfsPlusEntry implements FSEntry, FSEntryCreated {
protected HfsPlusFileSystem fs;
protected HfsPlusDirectory parent;
@@ -179,6 +180,7 @@
return this.record.getData();
}
+ @Override
public long getCreated() throws IOException {
if (isFile()) {
CatalogFile catalogFile = new CatalogFile(getData());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:55:45
|
Revision: 5916
http://jnode.svn.sourceforge.net/jnode/?rev=5916&view=rev
Author: galatnm
Date: 2012-08-10 06:55:38 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
FS Improvments
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2012-08-10 06:53:31 UTC (rev 5915)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2012-08-10 06:55:38 UTC (rev 5916)
@@ -24,6 +24,8 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jnode.fs.FSDirectory;
+import org.jnode.fs.FSEntryLastAccessed;
+import org.jnode.fs.FSEntryLastChanged;
import org.jnode.fs.spi.AbstractFSEntry;
/**
@@ -36,7 +38,7 @@
* TODO: besides getFile() and getDirectory(), we will need
* getBlockDevice() getCharacterDevice(), etc.
*/
-public class Ext2Entry extends AbstractFSEntry {
+public class Ext2Entry extends AbstractFSEntry implements FSEntryLastChanged, FSEntryLastAccessed {
private final Logger log = Logger.getLogger(getClass());
private INode iNode = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:53:39
|
Revision: 5915
http://jnode.svn.sourceforge.net/jnode/?rev=5915&view=rev
Author: galatnm
Date: 2012-08-10 06:53:31 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
FS improvments
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java
trunk/fs/src/fs/org/jnode/fs/fat/Fat.java
trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java
trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java
trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSEntry.java
trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java
trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexAllocationAttribute.java
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntry.java
trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java
trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableEntry.java
trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableType.java
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/FSEntryCreated.java
trunk/fs/src/fs/org/jnode/fs/FSEntryLastAccessed.java
trunk/fs/src/fs/org/jnode/fs/FSEntryLastChanged.java
Added: trunk/fs/src/fs/org/jnode/fs/FSEntryCreated.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSEntryCreated.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/FSEntryCreated.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -0,0 +1,10 @@
+package org.jnode.fs;
+
+import java.io.IOException;
+
+/**
+ * Interface to stack on to declare implementation of a {@code getCreated()} method, until JNode adds it to {@link FSEntry}.
+ */
+public interface FSEntryCreated {
+ public long getCreated() throws IOException;
+}
Added: trunk/fs/src/fs/org/jnode/fs/FSEntryLastAccessed.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSEntryLastAccessed.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/FSEntryLastAccessed.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -0,0 +1,10 @@
+package org.jnode.fs;
+
+import java.io.IOException;
+
+/**
+ * Interface to stack on to declare implementation of a {@code getLastAccessed()} method, until JNode adds it to {@link FSEntry}.
+ */
+public interface FSEntryLastAccessed {
+ public long getLastAccessed() throws IOException;
+}
Added: trunk/fs/src/fs/org/jnode/fs/FSEntryLastChanged.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/FSEntryLastChanged.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/FSEntryLastChanged.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -0,0 +1,10 @@
+package org.jnode.fs;
+
+import java.io.IOException;
+
+/**
+ * Interface to stack on to declare implementation of a {@code getLastChanged()} method, until JNode adds it to {@link FSEntry}.
+ */
+public interface FSEntryLastChanged {
+ public long getLastChanged() throws IOException;
+}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -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;
/**
* @author Andras Nagy
@@ -57,6 +54,7 @@
* @see org.jnode.fs.BlockDeviceFileSystemType#supports(PartitionTableEntry, byte[], FSBlockDeviceAPI)
*/
public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi) {
+/*
if (pte != null) {
if (pte instanceof IBMPartitionTableEntry) {
if (((IBMPartitionTableEntry) pte).getSystemIndicator() != IBMPartitionTypes.PARTTYPE_LINUXNATIVE) {
@@ -64,14 +62,19 @@
}
}
}
+*/
//need to check the magic
ByteBuffer magic = ByteBuffer.allocate(2);
+ ByteBuffer revLevel = ByteBuffer.allocate(4);
try {
devApi.read(1024 + 56, magic);
+ devApi.read(1024 + 78, revLevel);
} catch (IOException e) {
return false;
}
- return (Ext2Utils.get16(magic.array(), 0) == 0xEF53);
+ return
+ (Ext2Utils.get16(magic.array(), 0) == 0xEF53) &&
+ (Ext2Utils.get32(revLevel.array(), 0) == 0 || Ext2Utils.get32(revLevel.array(), 0) == 1);
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/Fat.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/Fat.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/fat/Fat.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -24,7 +24,6 @@
import java.io.PrintWriter;
import java.nio.ByteBuffer;
import java.util.Arrays;
-
import org.jnode.driver.block.BlockDeviceAPI;
import org.jnode.fs.FileSystemFullException;
@@ -198,6 +197,7 @@
while (!isEofCluster(entries[(int) cluster])) {
count++;
cluster = entries[(int) cluster];
+ testCluster(cluster); // prevent infinite loop in common case where it hits a 0
}
// Now create the chain
long[] chain = new long[count];
@@ -377,7 +377,7 @@
protected void testCluster(long cluster) throws IllegalArgumentException {
if ((cluster < 2) || (cluster >= entries.length)) {
- throw new IllegalArgumentException("Invalid cluster value");
+ throw new IllegalArgumentException("Invalid cluster value: 0x" + Long.toHexString(cluster));
}
}
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatDirEntry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -22,10 +22,11 @@
import java.io.IOException;
import java.util.Date;
-
import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
+import org.jnode.fs.FSEntryCreated;
+import org.jnode.fs.FSEntryLastAccessed;
import org.jnode.fs.FSFile;
import org.jnode.fs.spi.UnixFSAccessRights;
import org.jnode.fs.util.DosUtils;
@@ -35,7 +36,7 @@
/**
* @author epr
*/
-public class FatDirEntry extends FatBasicDirEntry implements FSEntry {
+public class FatDirEntry extends FatBasicDirEntry implements FSEntry, FSEntryCreated, FSEntryLastAccessed {
/** Name of this entry */
private String name;
Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemType.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -25,8 +25,6 @@
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;
/**
* @author epr
@@ -50,6 +48,7 @@
* @param firstSector
*/
public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi) {
+/*
if (pte != null) {
if (!pte.isValid()) {
return false;
@@ -66,14 +65,24 @@
} else {
return false;
}
-
}
+*/
+ try
+ {
if (!new BootSector(firstSector).isaValidBootSector())
return false;
+ }
+ catch (RuntimeException e)
+ {
+ return false;
+ }
- // Very ugly, but good enough for now.
- return true;
+ // FAT-32 is currently handled by the newer jfat package.
+ return (firstSector[38] == 0x29 &&
+ firstSector[54] == 'F' &&
+ firstSector[55] == 'A' &&
+ firstSector[56] == 'T');
}
/**
Modified: trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/fat/LfnEntry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -22,17 +22,18 @@
import java.io.IOException;
import java.util.Vector;
-
import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
+import org.jnode.fs.FSEntryCreated;
+import org.jnode.fs.FSEntryLastAccessed;
import org.jnode.fs.FSFile;
import org.jnode.fs.FileSystem;
/**
* @author gbin
*/
-class LfnEntry implements FSEntry {
+class LfnEntry implements FSEntry, FSEntryCreated, FSEntryLastAccessed {
// decompacted LFN entry
private String fileName;
// TODO: Make them available
Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSEntry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -20,13 +20,11 @@
package org.jnode.fs.ftpfs;
+import com.enterprisedt.net.ftp.FTPFile;
+import java.io.IOException;
+import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSEntry;
-import org.jnode.fs.FSAccessRights;
-import java.io.IOException;
-
-import com.enterprisedt.net.ftp.FTPFile;
-
/**
* @author Levente S\u00e1ntha
*/
@@ -77,6 +75,7 @@
/**
* Gets the last modification time of this entry.
*
+ * @return the last modification time, in milliseconds since January 1, 1970 UTC.
* @throws java.io.IOException
*/
@@ -86,6 +85,19 @@
}
/**
+ * <p>Gets the last access time of this entry.</p>
+ *
+ * <p>This implementation returns <code>0</code> as the FTP library has no means of
+ * obtaining the access time.</p>
+ *
+ * @return the last access time, in milliseconds since January 1, 1970 UTC.
+ * @throws IOException
+ */
+ public long getLastAccessed() throws IOException {
+ return 0;
+ }
+
+ /**
* Gets the name of this entry.
*/
public String getName() {
@@ -124,8 +136,9 @@
}
/**
- * Gets the last modification time of this entry.
+ * Sets the last modification time of this entry. This implementation does nothing.
*
+ * @param lastModified the new last modification time.
* @throws java.io.IOException
*/
public void setLastModified(long lastModified) throws IOException {
@@ -133,6 +146,14 @@
}
/**
+ * Sets the last access time of this entry. This implementation does nothing.
+ *
+ * @param lastAccessed the new last access time.
+ */
+ public void setLastAccessed(long lastAccessed) {
+ }
+
+ /**
* Sets the name of this entry.
*/
public void setName(String newName) throws IOException {
Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Entry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -21,7 +21,6 @@
package org.jnode.fs.iso9660;
import java.io.IOException;
-
import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
@@ -63,6 +62,10 @@
return entryRecord.getRecordingTime().toJavaMillis();
}
+ public long getLastAccessed() {
+ return 0;
+ }
+
/**
* @see org.jnode.fs.FSEntry#isFile()
*/
@@ -91,6 +94,10 @@
throw new UnsupportedOperationException("not yet implemented");
}
+ public void setLastAccessed(long lastAccessed) {
+ throw new UnsupportedOperationException("Filesystem is read-only");
+ }
+
/**
* @see org.jnode.fs.FSEntry#getFile()
*/
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatEntry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -20,20 +20,21 @@
package org.jnode.fs.jfat;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Vector;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-
import org.apache.log4j.Logger;
-import org.jnode.util.NumberUtils;
+import org.jnode.fs.FSAccessRights;
+import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
-import org.jnode.fs.FSDirectory;
+import org.jnode.fs.FSEntryCreated;
+import org.jnode.fs.FSEntryLastAccessed;
import org.jnode.fs.FSFile;
-import org.jnode.fs.FSAccessRights;
+import org.jnode.util.NumberUtils;
-public class FatEntry extends FatObject implements FSEntry {
+public class FatEntry extends FatObject implements FSEntry, FSEntryCreated, FSEntryLastAccessed {
private static final Logger log = Logger.getLogger(FatEntry.class);
private String name;
Modified: trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/jfat/FatFileSystemType.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -25,8 +25,6 @@
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;
/**
@@ -41,6 +39,7 @@
}
public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi) {
+/*
if (pte != null) {
if (!pte.isValid())
return false;
@@ -58,8 +57,14 @@
return false;
}
}
+*/
- return false;
+ // Only supports FAT-32 for now, don't want any false results
+ // for FAT-16 or FAT-12.
+ return (firstSector[66] == 0x29 &&
+ firstSector[82] == 'F' &&
+ firstSector[83] == 'A' &&
+ firstSector[84] == 'T');
}
public FatFileSystem create(Device device, boolean readOnly) throws FileSystemException {
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/IndexAllocationAttribute.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/IndexAllocationAttribute.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/IndexAllocationAttribute.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -28,14 +28,25 @@
final class IndexAllocationAttribute extends NTFSNonResidentAttribute {
/**
- * @param fileRecord
- * @param offset
+ * Creates the index allocation attribute.
+ *
+ * @param fileRecord the file record.
+ * @param offset the offset of this attribute into the file record.
*/
public IndexAllocationAttribute(FileRecord fileRecord, int offset) {
super(fileRecord, offset);
}
/**
+ * Gets the magic value of this record.
+ *
+ * @return the magic value.
+ */
+ public int getMagic() {
+ return getUInt32AsInt(0x00);
+ }
+
+ /**
* Read an index block starting at a given vcn.
*
* @param indexRoot
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -20,6 +20,7 @@
package org.jnode.fs.ntfs;
+import java.io.UnsupportedEncodingException;
/**
* Structure accessor of an Index Entry.
@@ -91,7 +92,12 @@
}
public String getFileName() {
- return new String(this.getFileNameAsCharArray());
+ try {
+ //XXX: For Java 6, should use the version that accepts a Charset.
+ return new String(this.getFileNameAsByteArray(), "UTF-16LE");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException("UTF-16LE charset missing from JRE", e);
+ }
}
public long getFileReferenceNumber() {
@@ -114,16 +120,15 @@
}
public long getSubnodeVCN() {
- return getUInt32(getSize() - 8);
+ return getInt64(getSize() - 8); // TODO: getUInt64AsInt
+ //return getUInt32(getSize() - 8);
}
- private char[] getFileNameAsCharArray() {
+ private byte[] getFileNameAsByteArray() {
final int len = getUInt8(0x50);
- final char[] name = new char[len];
- for (int i = 0; i < len; i++) {
- name[i] = getChar16(0x52 + (i * 2));
- }
- return name;
+ final byte[] bytes = new byte[len * 2];
+ getData(0x52, bytes, 0, bytes.length);
+ return bytes;
}
@Override
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSEntry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -21,10 +21,12 @@
package org.jnode.fs.ntfs;
import java.io.IOException;
-
import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
+import org.jnode.fs.FSEntryCreated;
+import org.jnode.fs.FSEntryLastAccessed;
+import org.jnode.fs.FSEntryLastChanged;
import org.jnode.fs.FSFile;
import org.jnode.fs.FSObject;
import org.jnode.fs.FileSystem;
@@ -33,7 +35,7 @@
* @author vali
* @author Ewout Prangsma (ep...@us...)
*/
-public class NTFSEntry implements FSEntry {
+public class NTFSEntry implements FSEntry, FSEntryCreated, FSEntryLastChanged, FSEntryLastAccessed {
private FSObject cachedFSObject;
Modified: trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableEntry.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -20,6 +20,7 @@
package org.jnode.partitions.ibm;
+import org.apache.log4j.Logger;
import org.jnode.driver.block.CHS;
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.util.LittleEndian;
@@ -29,6 +30,7 @@
* @author epr
*/
public class IBMPartitionTableEntry implements PartitionTableEntry {
+ private final Logger log = Logger.getLogger(getClass());
private final byte[] bs;
private final int ofs;
@@ -98,7 +100,13 @@
}
public IBMPartitionTypes getSystemIndicator() {
- return IBMPartitionTypes.valueOf(LittleEndian.getUInt8(bs, ofs + 4));
+ int code = LittleEndian.getUInt8(bs, ofs + 4);
+ try {
+ return IBMPartitionTypes.valueOf(code);
+ } catch (IllegalArgumentException e) {
+ log.warn("Invalid system indicator code: 0x" + Integer.toHexString(code));
+ return IBMPartitionTypes.PARTTYPE_EMPTY;
+ }
}
public void setSystemIndicator(IBMPartitionTypes type) {
Modified: trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableType.java 2012-08-10 06:44:27 UTC (rev 5914)
+++ trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTableType.java 2012-08-10 06:53:31 UTC (rev 5915)
@@ -42,7 +42,6 @@
}
public boolean supports(byte[] firstSector, BlockDeviceAPI devApi) {
- // TODO Make a suitable implementation
- return true;
+ return IBMPartitionTable.containsPartitionTable(firstSector);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:44:33
|
Revision: 5914
http://jnode.svn.sourceforge.net/jnode/?rev=5914&view=rev
Author: galatnm
Date: 2012-08-10 06:44:27 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Improve HFS+ date extraction
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 06:41:36 UTC (rev 5913)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HfsPlusEntry.java 2012-08-10 06:44:27 UTC (rev 5914)
@@ -17,11 +17,10 @@
* 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;
-
import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
@@ -44,10 +43,9 @@
protected boolean valid;
protected boolean dirty;
protected FSAccessRights rights;
- private long lastModified;
/**
- *
+ *
* @param fs
* @param parent
* @param name
@@ -61,7 +59,6 @@
this.record = record;
this.type = getFSEntryType();
this.rights = new UnixFSAccessRights(fs);
- this.lastModified = System.currentTimeMillis();
}
private int getFSEntryType() {
@@ -100,8 +97,14 @@
@Override
public long getLastModified() throws IOException {
- // TODO Auto-generated method stub
- return lastModified;
+ if (isFile()) {
+ CatalogFile catalogFile = new CatalogFile(getData());
+ return catalogFile.getContentModDate();
+ }
+ else {
+ CatalogFolder catalogFolder = new CatalogFolder(getData());
+ return catalogFolder.getContentModDate();
+ }
}
@Override
@@ -139,7 +142,15 @@
@Override
public void setLastModified(long lastModified) throws IOException {
- this.lastModified = lastModified;
+ if (isFile()) {
+ CatalogFile catalogFile = new CatalogFile(getData());
+ // catalogFile.setContentModDate();
+ throw new UnsupportedOperationException("Not implemented yet.");
+ }
+ else {
+ CatalogFolder catalogFolder = new CatalogFolder(getData());
+ catalogFolder.setContentModDate(lastModified);
+ }
}
@Override
@@ -168,4 +179,14 @@
return this.record.getData();
}
+ public long getCreated() throws IOException {
+ if (isFile()) {
+ CatalogFile catalogFile = new CatalogFile(getData());
+ return catalogFile.getCreateDate();
+ }
+ else {
+ CatalogFolder catalogFolder = new CatalogFolder(getData());
+ return catalogFolder.getCreateDate();
+ }
+ }
}
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java 2012-08-10 06:41:36 UTC (rev 5913)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFile.java 2012-08-10 06:44:27 UTC (rev 5914)
@@ -137,12 +137,12 @@
return fileId;
}
- public int getCreateDate() {
- return createDate;
+ public long getCreateDate() {
+ return HfsUtils.getDate(createDate & 0xffffffffL, false) * 1000L;
}
- public int getContentModDate() {
- return contentModDate;
+ public long getContentModDate() {
+ return HfsUtils.getDate(contentModDate & 0xffffffffL, false) * 1000L;
}
public int getAttrModDate() {
Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2012-08-10 06:41:36 UTC (rev 5913)
+++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogFolder.java 2012-08-10 06:44:27 UTC (rev 5914)
@@ -112,12 +112,12 @@
return folderId;
}
- public int getCreateDate() {
- return createDate;
+ public long getCreateDate() {
+ return HfsUtils.getDate(createDate & 0xffffffffL, false) * 1000L;
}
- public int getContentModDate() {
- return contentModDate;
+ public long getContentModDate() {
+ return HfsUtils.getDate(contentModDate & 0xffffffffL, false) * 1000L;
}
public int getAttrModDate() {
@@ -136,12 +136,12 @@
this.folderId = folderId;
}
- public void setCreateDate(int createDate) {
- this.createDate = createDate;
+ public void setCreateDate(long createDate) {
+ this.createDate = (int) HfsUtils.getDate(createDate / 1000L, true);
}
- public void setContentModDate(int contentModDate) {
- this.contentModDate = contentModDate;
+ public void setContentModDate(long contentModDate) {
+ this.contentModDate = (int) HfsUtils.getDate(contentModDate / 1000L, true);
}
public void setAttrModDate(int attrModDate) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:41:42
|
Revision: 5913
http://jnode.svn.sourceforge.net/jnode/?rev=5913&view=rev
Author: galatnm
Date: 2012-08-10 06:41:36 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Add in support for extracting sym-link target and identify block, char, fifo and link obje
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java
trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2012-08-10 06:39:34 UTC (rev 5912)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Entry.java 2012-08-10 06:41:36 UTC (rev 5913)
@@ -21,7 +21,6 @@
package org.jnode.fs.ext2;
import java.io.IOException;
-
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jnode.fs.FSDirectory;
@@ -97,7 +96,9 @@
return AbstractFSEntry.ROOT_ENTRY;
else if (mode == Ext2Constants.EXT2_S_IFDIR)
return AbstractFSEntry.DIR_ENTRY;
- else if (mode == Ext2Constants.EXT2_S_IFREG || mode == Ext2Constants.EXT2_FT_SYMLINK)
+ else if (mode == Ext2Constants.EXT2_S_IFREG || mode == Ext2Constants.EXT2_S_IFLNK ||
+ mode == Ext2Constants.EXT2_S_IFIFO || mode == Ext2Constants.EXT2_S_IFCHR ||
+ mode == Ext2Constants.EXT2_S_IFBLK)
return AbstractFSEntry.FILE_ENTRY;
else
return AbstractFSEntry.OTHER_ENTRY;
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2012-08-10 06:39:34 UTC (rev 5912)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2012-08-10 06:41:36 UTC (rev 5913)
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.nio.ByteBuffer;
-
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jnode.fs.FileSystemException;
@@ -180,20 +179,27 @@
try {
if (len + off > getLength())
throw new IOException("Can't read past the file!");
- long blockSize = iNode.getExt2FileSystem().getBlockSize();
- long bytesRead = 0;
- while (bytesRead < len) {
- long blockNr = (fileOffset + bytesRead) / blockSize;
- long blockOffset = (fileOffset + bytesRead) % blockSize;
- long copyLength = Math.min(len - bytesRead, blockSize - blockOffset);
- log.debug("blockNr: " + blockNr + ", blockOffset: " + blockOffset + ", copyLength: " + copyLength +
- ", bytesRead: " + bytesRead);
+ if ((iNode.getMode() & Ext2Constants.EXT2_S_IFLNK) == Ext2Constants.EXT2_S_IFLNK) {
+ // Sym-links are a special case: the data seems to be stored inline in the iNode
+ System.arraycopy(iNode.getINodeBlockData(), 0, dest, 0, Math.min(64, dest.length));
+ }
+ else {
+ long blockSize = iNode.getExt2FileSystem().getBlockSize();
+ long bytesRead = 0;
+ while (bytesRead < len) {
+ long blockNr = (fileOffset + bytesRead) / blockSize;
+ long blockOffset = (fileOffset + bytesRead) % blockSize;
+ long copyLength = Math.min(len - bytesRead, blockSize - blockOffset);
- System.arraycopy(iNode.getDataBlock(blockNr), (int) blockOffset, dest, off + (int) bytesRead,
- (int) copyLength);
+ log.debug("blockNr: " + blockNr + ", blockOffset: " + blockOffset + ", copyLength: " + copyLength +
+ ", bytesRead: " + bytesRead);
- bytesRead += copyLength;
+ System.arraycopy(iNode.getDataBlock(blockNr), (int) blockOffset, dest, off + (int) bytesRead,
+ (int) copyLength);
+
+ bytesRead += copyLength;
+ }
}
} catch (Throwable ex) {
final IOException ioe = new IOException();
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 06:39:34 UTC (rev 5912)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 06:41:36 UTC (rev 5913)
@@ -270,6 +270,17 @@
}
/**
+ * Gets the data stored inline in the inode's i_block element.
+ *
+ * @return the inode block data.
+ */
+ public byte[] getINodeBlockData() {
+ byte[] buffer = new byte[64];
+ System.arraycopy(data, 40, buffer, 0, buffer.length);
+ return buffer;
+ }
+
+ /**
* Return the number of the block in the filesystem that stores the ith
* block of the inode (i is a sequential index from the beginning of the
* file)
@@ -286,10 +297,7 @@
private long getDataBlockNr(long i) throws IOException {
if ((getFlags() & Ext2Constants.EXT4_INODE_EXTENTS_FLAG) != 0) {
if (extentHeader == null) {
- byte[] headerBuffer = new byte[64];
- System.arraycopy(data, 40, headerBuffer, 0, headerBuffer.length);
-
- extentHeader = new ExtentHeader(headerBuffer);
+ extentHeader = new ExtentHeader(getINodeBlockData());
}
return extentHeader.getBlockNumber(i);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:39:40
|
Revision: 5912
http://jnode.svn.sourceforge.net/jnode/?rev=5912&view=rev
Author: galatnm
Date: 2012-08-10 06:39:34 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Add some extra logging
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2012-08-10 06:37:15 UTC (rev 5911)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2012-08-10 06:39:34 UTC (rev 5912)
@@ -61,6 +61,8 @@
if ((iNode.getFlags() & Ext2Constants.EXT4_INODE_EXTENTS_FLAG) != 0)
log.info("inode uses extents: " + entry);
+ if ((iNode.getFlags() & Ext2Constants.EXT2_INDEX_FL) != 0)
+ log.info("inode uses index: " + entry);
}
else {
readOnly = fs.isReadOnly();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:37:22
|
Revision: 5911
http://jnode.svn.sourceforge.net/jnode/?rev=5911&view=rev
Author: galatnm
Date: 2012-08-10 06:37:15 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Detect inodes that use ext4 extents
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2012-08-10 06:36:07 UTC (rev 5910)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2012-08-10 06:37:15 UTC (rev 5911)
@@ -78,6 +78,7 @@
// behaviour control flags in the inode
public static final long EXT2_INDEX_FL = 0x00010000; // hash indexed directory
+ public static final long EXT4_INODE_EXTENTS_FLAG = 0x00080000;
// Filesystem state constants
public static final int EXT2_VALID_FS = 0x0001; // cleanly unmounted
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2012-08-10 06:36:07 UTC (rev 5910)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2012-08-10 06:37:15 UTC (rev 5911)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
-
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jnode.fs.FSEntry;
@@ -56,10 +55,16 @@
this.entry = entry;
log.setLevel(Level.DEBUG);
boolean readOnly;
- if ((iNode.getFlags() & Ext2Constants.EXT2_INDEX_FL) == 1)
+ if ((iNode.getFlags() & Ext2Constants.EXT2_INDEX_FL) != 0 ||
+ (iNode.getFlags() & Ext2Constants.EXT4_INODE_EXTENTS_FLAG) != 0) {
readOnly = true; //force readonly
- else
+
+ if ((iNode.getFlags() & Ext2Constants.EXT4_INODE_EXTENTS_FLAG) != 0)
+ log.info("inode uses extents: " + entry);
+ }
+ else {
readOnly = fs.isReadOnly();
+ }
setRights(true, !readOnly);
log.debug("directory size: " + iNode.getSize());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:36:13
|
Revision: 5910
http://jnode.svn.sourceforge.net/jnode/?rev=5910&view=rev
Author: galatnm
Date: 2012-08-10 06:36:07 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Add initial support for ext4 extents
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
Added Paths:
-----------
trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java
trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java
Added: trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Extent.java 2012-08-10 06:36:07 UTC (rev 5910)
@@ -0,0 +1,44 @@
+package org.jnode.fs.ext2;
+
+/**
+ * An ext4 extent object.
+ *
+ * @author Luke Quinane
+ */
+public class Extent {
+ /**
+ * The length of an extent.
+ */
+ public static final int EXTENT_LENGTH = 12;
+
+ /**
+ * The data for the extent.
+ */
+ private byte[] data;
+
+ /**
+ * Create an extent object.
+ *
+ * @param data the data for the extent.
+ */
+ public Extent(byte[] data) {
+ this.data = new byte[EXTENT_LENGTH];
+ System.arraycopy(data, 0, this.data, 0, EXTENT_LENGTH);
+ }
+
+ public long getBlockIndex() {
+ return Ext2Utils.get32(data, 0);
+ }
+
+ public int getBlockCount() {
+ return Ext2Utils.get16(data, 4);
+ }
+
+ public long getStartLow() {
+ return Ext2Utils.get32(data, 8);
+ }
+
+ public int getStartHigh() {
+ return Ext2Utils.get16(data, 6);
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/ExtentHeader.java 2012-08-10 06:36:07 UTC (rev 5910)
@@ -0,0 +1,134 @@
+package org.jnode.fs.ext2;
+
+import java.io.IOException;
+
+/**
+ * An ext4 extent header.
+ *
+ * @author Luke Quinane
+ */
+public class ExtentHeader {
+ /**
+ * The length of an extent header.
+ */
+ public static final int EXTENT_HEADER_LENGTH = 12;
+
+ /**
+ * The magic number for an extent header.
+ */
+ public static final int MAGIC = 0xf30a;
+
+ /**
+ * The data for the header.
+ */
+ private byte[] data;
+
+ /**
+ * The cache copy of the index entries.
+ */
+ private ExtentIndex[] indexEntries;
+
+ /**
+ * The cache copy of the extent entries.
+ */
+ private Extent[] extentEntries;
+
+ /**
+ * Create an extent header object.
+ */
+ public ExtentHeader(byte[] data) throws IOException {
+ this.data = new byte[data.length];
+ System.arraycopy(data, 0, this.data, 0, data.length);
+
+ if (getMagic() != ExtentHeader.MAGIC) {
+ throw new IOException("Extent had the wrong magic: " + getMagic());
+ }
+ }
+
+ public int getMagic() {
+ return Ext2Utils.get16(data, 0);
+ }
+
+ public int getEntryCount() {
+ return Ext2Utils.get16(data, 2);
+ }
+
+ public int getMaximumEntryCount() {
+ return Ext2Utils.get16(data, 4);
+ }
+
+ public int getDepth() {
+ return Ext2Utils.get16(data, 6);
+ }
+
+ public ExtentIndex[] getIndexEntries() {
+ if (getDepth() == 0) {
+ throw new IllegalStateException("Trying to read index entries from a leaf.");
+ }
+
+ if (indexEntries == null) {
+ indexEntries = new ExtentIndex[getEntryCount()];
+ int offset = EXTENT_HEADER_LENGTH;
+
+ for (int i = 0; i < getEntryCount(); i++) {
+ byte[] indexBuffer = new byte[ExtentIndex.EXTENT_INDEX_LENGTH];
+ System.arraycopy(data, offset, indexBuffer, 0, indexBuffer.length);
+
+ indexEntries[i] = new ExtentIndex(indexBuffer);
+ offset += ExtentIndex.EXTENT_INDEX_LENGTH;
+ }
+ }
+
+ return indexEntries;
+ }
+
+ public Extent[] getExtentEntries() {
+ if (getDepth() != 0) {
+ throw new IllegalStateException("Trying to read extent entries from a non-leaf.");
+ }
+
+ if (extentEntries == null) {
+ extentEntries = new Extent[getEntryCount()];
+ int offset = EXTENT_HEADER_LENGTH;
+
+ for (int i = 0; i < getEntryCount(); i++) {
+ byte[] indexBuffer = new byte[Extent.EXTENT_LENGTH];
+ System.arraycopy(data, offset, indexBuffer, 0, indexBuffer.length);
+
+ extentEntries[i] = new Extent(indexBuffer);
+ offset += Extent.EXTENT_LENGTH;
+ }
+ }
+
+ return extentEntries;
+ }
+
+ public long getBlockNumber(long index) {
+ if (getDepth() > 0) {
+ ExtentIndex[] indexes = getIndexEntries();
+
+ throw new UnsupportedOperationException();
+ }
+ else {
+ Extent[] extents = getExtentEntries();
+
+ int lowIndex = 0;
+ int highIndex = extents.length - 1;
+ Extent extent = null;
+
+ while (lowIndex <= highIndex) {
+ int middle = lowIndex + (highIndex - lowIndex) / 2;
+ extent = extents[middle];
+
+ if (index < extent.getBlockIndex()) {
+ highIndex = middle - 1;
+ }
+ else {
+ lowIndex = middle + 1;
+ }
+ }
+
+ return extent.getStartLow();
+ }
+ }
+}
Added: trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/ExtentIndex.java 2012-08-10 06:36:07 UTC (rev 5910)
@@ -0,0 +1,40 @@
+package org.jnode.fs.ext2;
+
+/**
+ * An ext4 extent index.
+ *
+ * @author Luke Quinane
+ */
+public class ExtentIndex {
+ /**
+ * The length of an extent index.
+ */
+ public static final int EXTENT_INDEX_LENGTH = 12;
+
+ /**
+ * The data for the index.
+ */
+ private byte[] data;
+
+ /**
+ * Create an extent index object.
+ *
+ * @param data the data for the index.
+ */
+ public ExtentIndex(byte[] data) {
+ this.data = new byte[EXTENT_INDEX_LENGTH];
+ System.arraycopy(data, 0, this.data, 0, EXTENT_INDEX_LENGTH);
+ }
+
+ public long getBlockIndex() {
+ return Ext2Utils.get32(data, 0);
+ }
+
+ public long getLeafLow() {
+ return Ext2Utils.get32(data, 4);
+ }
+
+ public int getLeafHigh() {
+ return Ext2Utils.get16(data, 8);
+ }
+}
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INode.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 06:32:22 UTC (rev 5909)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2012-08-10 06:36:07 UTC (rev 5910)
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.util.Arrays;
-
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jnode.fs.FileSystemException;
@@ -60,6 +59,11 @@
private Ext2FileSystem fs;
/**
+ * The cached extent header.
+ */
+ private ExtentHeader extentHeader;
+
+ /**
* Create an INode object from an existing inode on the disk.
*
* @param fs
@@ -280,6 +284,36 @@
* @throws IOException
*/
private long getDataBlockNr(long i) throws IOException {
+ if ((getFlags() & Ext2Constants.EXT4_INODE_EXTENTS_FLAG) != 0) {
+ if (extentHeader == null) {
+ byte[] headerBuffer = new byte[64];
+ System.arraycopy(data, 40, headerBuffer, 0, headerBuffer.length);
+
+ extentHeader = new ExtentHeader(headerBuffer);
+ }
+
+ return extentHeader.getBlockNumber(i);
+ }
+ else {
+ return getDataBlockNrIndirect(i);
+ }
+ }
+
+ /**
+ * Return the number of the block in the filesystem that stores the ith
+ * block of the inode (i is a sequential index from the beginning of the
+ * file) using an indirect (ext2 / ext3) lookup.
+ *
+ * [Naming convention used: in the code, a <code>...BlockNr</code> always
+ * means an absolute block nr (of the filesystem), while a
+ * <code>...BlockIndex</code> means an index relative to the beginning of
+ * a block]
+ *
+ * @param i
+ * @return the block number
+ * @throws IOException
+ */
+ private long getDataBlockNrIndirect(long i) throws IOException {
final long blockCount = getAllocatedBlockCount();
final int indirectCount = getIndirectCount();
if (i > blockCount - 1) {
@@ -910,6 +944,10 @@
public void setDirty(boolean b) {
dirty = b;
+
+ if (dirty) {
+ extentHeader = null;
+ }
}
public synchronized boolean isLocked() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:32:28
|
Revision: 5909
http://jnode.svn.sourceforge.net/jnode/?rev=5909&view=rev
Author: galatnm
Date: 2012-08-10 06:32:22 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Fix a problem reading ext4 inode tables
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/INodeTable.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INodeTable.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/INodeTable.java 2012-08-10 06:29:21 UTC (rev 5908)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/INodeTable.java 2012-08-10 06:32:22 UTC (rev 5909)
@@ -21,7 +21,6 @@
package org.jnode.fs.ext2;
import java.io.IOException;
-
import org.jnode.fs.FileSystemException;
/**
@@ -46,15 +45,13 @@
blockSize = fs.getBlockSize();
blockCount =
(int) Ext2Utils.ceilDiv(
- fs.getSuperblock().getINodesPerGroup() * INode.INODE_LENGTH, blockSize);
+ fs.getSuperblock().getINodesPerGroup() * fs.getSuperblock().getINodeSize(), blockSize);
}
public static int getSizeInBlocks(Ext2FileSystem fs) {
- int count =
- (int) Ext2Utils.ceilDiv(
- fs.getSuperblock().getINodesPerGroup() * INode.INODE_LENGTH,
- fs.getBlockSize());
- return count;
+ return (int) Ext2Utils.ceilDiv(
+ fs.getSuperblock().getINodesPerGroup() * fs.getSuperblock().getINodeSize(),
+ fs.getBlockSize());
}
/**
@@ -100,13 +97,14 @@
* safe to synchronize to it
*/
public synchronized byte[] getInodeData(int index) throws IOException, FileSystemException {
- byte data[] = new byte[INode.INODE_LENGTH];
+ int iNodeSize = (int) fs.getSuperblock().getINodeSize();
+ byte data[] = new byte[iNodeSize];
int indexCopied = 0;
- while (indexCopied < INode.INODE_LENGTH) {
- int blockNo = (index * INode.INODE_LENGTH + indexCopied) / blockSize;
- int blockOffset = (index * INode.INODE_LENGTH + indexCopied) % blockSize;
- int copyLength = Math.min(blockSize - blockOffset, INode.INODE_LENGTH);
+ while (indexCopied < iNodeSize) {
+ int blockNo = (index * iNodeSize + indexCopied) / blockSize;
+ int blockOffset = (index * iNodeSize + indexCopied) % blockSize;
+ int copyLength = Math.min(blockSize - blockOffset, iNodeSize);
System.arraycopy(getINodeTableBlock(blockNo), blockOffset, data, indexCopied,
copyLength);
indexCopied += copyLength;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:29:28
|
Revision: 5908
http://jnode.svn.sourceforge.net/jnode/?rev=5908&view=rev
Author: galatnm
Date: 2012-08-10 06:29:21 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Add support to detect Ext4 features.
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2012-08-10 06:19:44 UTC (rev 5907)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Constants.java 2012-08-10 06:29:21 UTC (rev 5908)
@@ -93,6 +93,10 @@
public static final long EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER = 0x0001;
public static final long EXT2_FEATURE_RO_COMPAT_LARGE_FILE = 0x0002;
public static final long EXT2_FEATURE_RO_COMPAT_BTREE_DIR = 0x0004;
+ public static final long EXT4_FEATURE_ROCOMPAT_HUGE_FILE = 0x0008;
+ public static final long EXT4_FEATURE_ROCOMPAT_GDT_CSUM = 0x0010;
+ public static final long EXT4_FEATURE_ROCOMPAT_DIR_NLINK = 0x0020;
+ public static final long EXT4_FEATURE_ROCOMPAT_EXTRA_ISIZE = 0x0040;
// S_FEATURE_INCOMPAT constants
public static final long EXT2_FEATURE_INCOMPAT_COMPRESSION = 0x0001;
@@ -100,6 +104,10 @@
public static final long EXT3_FEATURE_INCOMPAT_RECOVER = 0x0004;
public static final long EXT3_FEATURE_INCOMPAT_JOURNAL_DEV = 0x0008;
public static final long EXT2_FEATURE_INCOMPAT_META_BG = 0x0010;
+ public static final long EXT4_FEATURE_INCOMPAT_EXTENTS = 0x0040;
+ public static final long EXT4_FEATURE_INCOMPAT_64BIT = 0x0080;
+ public static final long EXT4_FEATURE_INCOMPAT_MMP = 0x0100;
+ public static final long EXT4_FEATURE_INCOMPAT_FLEX_BG = 0X0200;
// constants specific to this (JNode) implementation
/**
Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2012-08-10 06:19:44 UTC (rev 5907)
+++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2012-08-10 06:29:21 UTC (rev 5908)
@@ -24,7 +24,6 @@
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.util.Date;
-
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jnode.driver.Device;
@@ -119,16 +118,28 @@
// at all)
if (hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_COMPRESSION))
throw new FileSystemException(getDevice().getId() +
- " Unsupported filesystem feature (COMPRESSION) disallows mounting");
+ " Unsupported filesystem feature (COMPRESSION) disallows mounting");
if (hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_META_BG))
throw new FileSystemException(getDevice().getId() +
- " Unsupported filesystem feature (META_BG) disallows mounting");
+ " Unsupported filesystem feature (META_BG) disallows mounting");
if (hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_JOURNAL_DEV))
throw new FileSystemException(getDevice().getId() +
- " Unsupported filesystem feature (JOURNAL_DEV) disallows mounting");
- if (hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_RECOVER))
+ " Unsupported filesystem feature (JOURNAL_DEV) disallows mounting");
+// if (hasIncompatFeature(Ext2Constants.EXT3_FEATURE_INCOMPAT_RECOVER))
+// throw new FileSystemException(getDevice().getId() +
+// " Unsupported filesystem feature (RECOVER) disallows mounting");
+// if (hasIncompatFeature(Ext2Constants.EXT4_FEATURE_INCOMPAT_EXTENTS))
+// throw new FileSystemException(getDevice().getId() +
+// " Unsupported filesystem feature (EXTENTS) disallows mounting");
+ if (hasIncompatFeature(Ext2Constants.EXT4_FEATURE_INCOMPAT_64BIT))
throw new FileSystemException(getDevice().getId() +
- " Unsupported filesystem feature (RECOVER) disallows mounting");
+ " Unsupported filesystem feature (64BIT) disallows mounting");
+ if (hasIncompatFeature(Ext2Constants.EXT4_FEATURE_INCOMPAT_MMP))
+ throw new FileSystemException(getDevice().getId() +
+ " Unsupported filesystem feature (MMP) disallows mounting");
+ if (hasIncompatFeature(Ext2Constants.EXT4_FEATURE_INCOMPAT_FLEX_BG))
+ throw new FileSystemException(getDevice().getId() +
+ " Unsupported filesystem feature (FLEX_BG) disallows mounting");
// an unsupported RO_COMPAT feature means that the filesystem can only
// be mounted readonly
@@ -140,6 +151,22 @@
log.info(getDevice().getId() + " Unsupported filesystem feature (BTREE_DIR) forces readonly mode");
setReadOnly(true);
}
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_HUGE_FILE)) {
+ log.info(getDevice().getId() + " Unsupported filesystem feature (HUGE_FILE) forces readonly mode");
+ setReadOnly(true);
+ }
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_GDT_CSUM)) {
+ log.info(getDevice().getId() + " Unsupported filesystem feature (GDT_CSUM) forces readonly mode");
+ setReadOnly(true);
+ }
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_DIR_NLINK)) {
+ log.info(getDevice().getId() + " Unsupported filesystem feature (DIR_NLINK) forces readonly mode");
+ setReadOnly(true);
+ }
+ if (hasROFeature(Ext2Constants.EXT4_FEATURE_ROCOMPAT_EXTRA_ISIZE)) {
+ log.info(getDevice().getId() + " Unsupported filesystem feature (EXTRA_ISIZE) forces readonly mode");
+ setReadOnly(true);
+ }
// if the filesystem has not been cleanly unmounted, mount it readonly
if (superblock.getState() == Ext2Constants.EXT2_ERROR_FS) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:19:51
|
Revision: 5907
http://jnode.svn.sourceforge.net/jnode/?rev=5907&view=rev
Author: galatnm
Date: 2012-08-10 06:19:44 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Attempt to strengthen the APM magic checks
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
Modified: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java 2012-08-10 06:13:18 UTC (rev 5906)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java 2012-08-10 06:19:44 UTC (rev 5907)
@@ -20,6 +20,7 @@
package org.jnode.partitions.apm;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -84,6 +85,16 @@
if ((first16KiB[0x201] & 0xFF) != 0x4d) {
return false;
}
+
+ byte[] typeBytes = new byte[31];
+ System.arraycopy(first16KiB, 0x230, typeBytes, 0, typeBytes.length);
+ String type = new String(typeBytes, Charset.forName("ASCII")).replace("\u0000", "");
+
+ if (!"Apple_partition_map".equalsIgnoreCase(type))
+ {
+ return false;
+ }
+
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:13:24
|
Revision: 5906
http://jnode.svn.sourceforge.net/jnode/?rev=5906&view=rev
Author: galatnm
Date: 2012-08-10 06:13:18 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Code review changes update code style
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java
trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java
trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java
trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableType.java
Modified: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java 2012-08-10 06:11:00 UTC (rev 5905)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java 2012-08-10 06:13:18 UTC (rev 5906)
@@ -65,8 +65,7 @@
ApmPartitionTableEntry entry = new ApmPartitionTableEntry(this, first16KiB, offset);
- if (entry.isValid())
- {
+ if (entry.isValid()) {
partitions.add(entry);
}
}
@@ -88,6 +87,7 @@
return true;
}
+ @Override
public Iterator<ApmPartitionTableEntry> iterator() {
return Collections.unmodifiableList(partitions).iterator();
}
@@ -95,6 +95,7 @@
/**
* @see org.jnode.partitions.PartitionTable#getType()
*/
+ @Override
public PartitionTableType getType() {
return tableType;
}
Modified: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java 2012-08-10 06:11:00 UTC (rev 5905)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java 2012-08-10 06:13:18 UTC (rev 5906)
@@ -51,6 +51,7 @@
this.offset = offset;
}
+ @Override
public boolean isValid() {
return first16KiB.length > offset + 128;
}
@@ -58,6 +59,7 @@
/**
* @see org.jnode.partitions.PartitionTableEntry#getChildPartitionTable()
*/
+ @Override
public IBMPartitionTable getChildPartitionTable() {
throw new UnsupportedOperationException("No child partitions.");
}
@@ -65,6 +67,7 @@
/**
* @see org.jnode.partitions.PartitionTableEntry#hasChildPartitionTable()
*/
+ @Override
public boolean hasChildPartitionTable() {
return false;
}
@@ -98,9 +101,7 @@
return b.toString();
}
- /**
- * @see Object#toString()
- */
+ @Override
public String toString() {
StringBuilder builder = new StringBuilder(32);
builder.append('[').append(getName()).append(' ');
Modified: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java 2012-08-10 06:11:00 UTC (rev 5905)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java 2012-08-10 06:13:18 UTC (rev 5906)
@@ -33,15 +33,18 @@
*/
public class ApmPartitionTableType implements PartitionTableType {
+ @Override
public PartitionTable<?> create(byte[] firstSector, Device device) throws PartitionTableException {
return new ApmPartitionTable(this, firstSector, device);
}
+ @Override
public String getName() {
return "APM";
}
+ @Override
public boolean supports(byte[] first16KiB, BlockDeviceAPI devApi) {
return ApmPartitionTable.containsPartitionTable(first16KiB);
}
-}
+}
\ No newline at end of file
Modified: trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java 2012-08-10 06:11:00 UTC (rev 5905)
+++ trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java 2012-08-10 06:13:18 UTC (rev 5906)
@@ -70,8 +70,7 @@
GptPartitionTableEntry entry = new GptPartitionTableEntry(this, first16KiB, offset, blockSize);
- if (entry.isValid())
- {
+ if (entry.isValid()) {
partitions.add(entry);
}
}
@@ -115,6 +114,7 @@
return detectBlockSize(first16KiB) != -1;
}
+ @Override
public Iterator<GptPartitionTableEntry> iterator() {
return Collections.unmodifiableList(partitions).iterator();
}
@@ -122,6 +122,7 @@
/**
* @see org.jnode.partitions.PartitionTable#getType()
*/
+ @Override
public PartitionTableType getType() {
return tableType;
}
Modified: trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java 2012-08-10 06:11:00 UTC (rev 5905)
+++ trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java 2012-08-10 06:13:18 UTC (rev 5906)
@@ -56,6 +56,7 @@
this.offset = offset;
}
+ @Override
public boolean isValid() {
return first16KiB.length > offset + 128 && !isEmpty();
}
@@ -63,6 +64,7 @@
/**
* @see org.jnode.partitions.PartitionTableEntry#getChildPartitionTable()
*/
+ @Override
public PartitionTable<?> getChildPartitionTable() {
throw new UnsupportedOperationException("No child partitions.");
}
@@ -70,6 +72,7 @@
/**
* @see org.jnode.partitions.PartitionTableEntry#hasChildPartitionTable()
*/
+ @Override
public boolean hasChildPartitionTable() {
return false;
}
@@ -117,9 +120,7 @@
return b.toString();
}
- /**
- * @see java.lang.Object#toString()
- */
+ @Override
public String toString() {
StringBuilder builder = new StringBuilder(32);
builder.append('[').append(getName()).append(' ');
Modified: trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableType.java 2012-08-10 06:11:00 UTC (rev 5905)
+++ trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableType.java 2012-08-10 06:13:18 UTC (rev 5906)
@@ -33,15 +33,18 @@
*/
public class GptPartitionTableType implements PartitionTableType {
+ @Override
public PartitionTable<?> create(byte[] firstSector, Device device) throws PartitionTableException {
return new GptPartitionTable(this, firstSector, device);
}
+ @Override
public String getName() {
return "EFI PART";
}
+ @Override
public boolean supports(byte[] first16KiB, BlockDeviceAPI devApi) {
return GptPartitionTable.containsPartitionTable(first16KiB);
}
-}
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-10 06:11:08
|
Revision: 5905
http://jnode.svn.sourceforge.net/jnode/?rev=5905&view=rev
Author: galatnm
Date: 2012-08-10 06:11:00 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
Stop using little endian Don t make any assumptions about reported partition type
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java
Modified: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java 2012-08-09 14:08:21 UTC (rev 5904)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java 2012-08-10 06:11:00 UTC (rev 5905)
@@ -28,7 +28,7 @@
import org.jnode.driver.Device;
import org.jnode.partitions.PartitionTable;
import org.jnode.partitions.PartitionTableType;
-import org.jnode.util.LittleEndian;
+import org.jnode.util.BigEndian;
/**
* The main Apple Partition Map (APM) partition table class.
@@ -56,7 +56,7 @@
public ApmPartitionTable(ApmPartitionTableType tableType, byte[] first16KiB, Device device) {
this.tableType = tableType;
- long entries = LittleEndian.getUInt32(first16KiB, 0x204);
+ long entries = BigEndian.getUInt32(first16KiB, 0x204);
for (int partitionNumber = 0; partitionNumber < entries; partitionNumber++) {
log.debug("try part " + partitionNumber);
@@ -98,4 +98,4 @@
public PartitionTableType getType() {
return tableType;
}
-}
+}
\ No newline at end of file
Modified: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java 2012-08-09 14:08:21 UTC (rev 5904)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java 2012-08-10 06:11:00 UTC (rev 5905)
@@ -24,7 +24,6 @@
import org.jnode.partitions.PartitionTableEntry;
import org.jnode.partitions.ibm.IBMPartitionTable;
import org.jnode.util.BigEndian;
-import org.jnode.util.LittleEndian;
import org.jnode.util.NumberUtils;
/**
@@ -53,7 +52,7 @@
}
public boolean isValid() {
- return first16KiB.length > offset + 128 && !isEmpty();
+ return first16KiB.length > offset + 128;
}
/**
@@ -70,10 +69,6 @@
return false;
}
- public boolean isEmpty() {
- return "Apple_Scratch".equals(getType());
- }
-
public long getStartOffset() {
return BigEndian.getInt32(first16KiB, offset + 0x8) * 0x200L;
}
@@ -97,7 +92,7 @@
public String dump() {
StringBuilder b = new StringBuilder();
for (int i = 0; i < 128; i++) {
- b.append(NumberUtils.hex(LittleEndian.getUInt8(first16KiB, offset + i), 2));
+ b.append(NumberUtils.hex(BigEndian.getUInt8(first16KiB, offset + i), 2));
b.append(' ');
}
return b.toString();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-09 14:08:27
|
Revision: 5904
http://jnode.svn.sourceforge.net/jnode/?rev=5904&view=rev
Author: galatnm
Date: 2012-08-09 14:08:21 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Initial Apple partition map support (patch from L. Quinane)
Added Paths:
-----------
trunk/fs/descriptors/org.jnode.partitions.apm.xml
trunk/fs/src/fs/org/jnode/partitions/apm/
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java
trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java
Added: trunk/fs/descriptors/org.jnode.partitions.apm.xml
===================================================================
--- trunk/fs/descriptors/org.jnode.partitions.apm.xml (rev 0)
+++ trunk/fs/descriptors/org.jnode.partitions.apm.xml 2012-08-09 14:08:21 UTC (rev 5904)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plugin SYSTEM "jnode.dtd">
+
+<plugin id="org.jnode.partitions.apm"
+ name="JNode APM partition table classes"
+ version="0.2.9-dev"
+ license-name="lgpl"
+ provider-name="JNode.org">
+
+ <requires>
+ <import plugin="org.jnode.partitions"/>
+ </requires>
+
+ <runtime>
+ <library name="jnode-fs.jar">
+ <export name="org.jnode.partitions.apm.*"/>
+ </library>
+ </runtime>
+
+ <extension point="org.jnode.partitions.types">
+ <type class="org.jnode.partitions.apm.ApmPartitionTableType"/>
+ </extension>
+
+</plugin>
Added: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTable.java 2012-08-09 14:08:21 UTC (rev 5904)
@@ -0,0 +1,101 @@
+/*
+ * $Id: $
+ *
+ * Copyright (C) 2003-2012 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * 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.partitions.apm;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.log4j.Logger;
+import org.jnode.driver.Device;
+import org.jnode.partitions.PartitionTable;
+import org.jnode.partitions.PartitionTableType;
+import org.jnode.util.LittleEndian;
+
+/**
+ * The main Apple Partition Map (APM) partition table class.
+ *
+ * @author Luke Quinane
+ */
+public class ApmPartitionTable implements PartitionTable<ApmPartitionTableEntry> {
+
+ /** The type of partition table */
+ private final ApmPartitionTableType tableType;
+
+ /** The partition entries */
+ private final List<ApmPartitionTableEntry> partitions = new ArrayList<ApmPartitionTableEntry>();
+
+ /** My logger */
+ private static final Logger log = Logger.getLogger(ApmPartitionTable.class);
+
+ /**
+ * Create a new instance
+ *
+ * @param tableType the partition table type.
+ * @param first16KiB the first 16,384 bytes of the disk.
+ * @param device the drive device.
+ */
+ public ApmPartitionTable(ApmPartitionTableType tableType, byte[] first16KiB, Device device) {
+ this.tableType = tableType;
+
+ long entries = LittleEndian.getUInt32(first16KiB, 0x204);
+
+ for (int partitionNumber = 0; partitionNumber < entries; partitionNumber++) {
+ log.debug("try part " + partitionNumber);
+
+ int offset = 0x200 + (partitionNumber * 0x200);
+
+ ApmPartitionTableEntry entry = new ApmPartitionTableEntry(this, first16KiB, offset);
+
+ if (entry.isValid())
+ {
+ partitions.add(entry);
+ }
+ }
+ }
+
+ /**
+ * Checks if the given boot sector contain a APM partition table.
+ *
+ * @param first16KiB the first 16,384 bytes of the disk.
+ * @return {@code true} if the boot sector contains a APM partition table.
+ */
+ public static boolean containsPartitionTable(byte[] first16KiB) {
+ if ((first16KiB[0x200] & 0xFF) != 0x50) {
+ return false;
+ }
+ if ((first16KiB[0x201] & 0xFF) != 0x4d) {
+ return false;
+ }
+ return true;
+ }
+
+ public Iterator<ApmPartitionTableEntry> iterator() {
+ return Collections.unmodifiableList(partitions).iterator();
+ }
+
+ /**
+ * @see org.jnode.partitions.PartitionTable#getType()
+ */
+ public PartitionTableType getType() {
+ return tableType;
+ }
+}
Added: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableEntry.java 2012-08-09 14:08:21 UTC (rev 5904)
@@ -0,0 +1,117 @@
+/*
+ * $Id: $
+ *
+ * Copyright (C) 2003-2012 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * 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.partitions.apm;
+
+import java.nio.charset.Charset;
+import org.jnode.partitions.PartitionTableEntry;
+import org.jnode.partitions.ibm.IBMPartitionTable;
+import org.jnode.util.BigEndian;
+import org.jnode.util.LittleEndian;
+import org.jnode.util.NumberUtils;
+
+/**
+ * A APM partition table entry.
+ *
+ * @author Luke Quinane
+ */
+public class ApmPartitionTableEntry implements PartitionTableEntry {
+
+ /** The first 16KiB of the drive. */
+ private final byte[] first16KiB;
+
+ /** The offset to this partition table entry. */
+ private final int offset;
+
+ /**
+ * Creates a new entry.
+ *
+ * @param parent the parent table.
+ * @param first16KiB the first 16,384 bytes of the disk.
+ * @param offset the offset of this entry in the table.
+ */
+ public ApmPartitionTableEntry(ApmPartitionTable parent, byte[] first16KiB, int offset) {
+ this.first16KiB = first16KiB;
+ this.offset = offset;
+ }
+
+ public boolean isValid() {
+ return first16KiB.length > offset + 128 && !isEmpty();
+ }
+
+ /**
+ * @see org.jnode.partitions.PartitionTableEntry#getChildPartitionTable()
+ */
+ public IBMPartitionTable getChildPartitionTable() {
+ throw new UnsupportedOperationException("No child partitions.");
+ }
+
+ /**
+ * @see org.jnode.partitions.PartitionTableEntry#hasChildPartitionTable()
+ */
+ public boolean hasChildPartitionTable() {
+ return false;
+ }
+
+ public boolean isEmpty() {
+ return "Apple_Scratch".equals(getType());
+ }
+
+ public long getStartOffset() {
+ return BigEndian.getInt32(first16KiB, offset + 0x8) * 0x200L;
+ }
+
+ public long getEndOffset() {
+ return getStartOffset() + (BigEndian.getInt32(first16KiB, offset + 0xc) + 1) * 0x200L;
+ }
+
+ public String getName() {
+ byte[] nameBytes = new byte[31];
+ System.arraycopy(first16KiB, offset + 0x10, nameBytes, 0, nameBytes.length);
+ return new String(nameBytes, Charset.forName("ASCII")).replace("\u0000", "");
+ }
+
+ public String getType() {
+ byte[] nameBytes = new byte[31];
+ System.arraycopy(first16KiB, offset + 0x30, nameBytes, 0, nameBytes.length);
+ return new String(nameBytes, Charset.forName("ASCII")).replace("\u0000", "");
+ }
+
+ public String dump() {
+ StringBuilder b = new StringBuilder();
+ for (int i = 0; i < 128; i++) {
+ b.append(NumberUtils.hex(LittleEndian.getUInt8(first16KiB, offset + i), 2));
+ b.append(' ');
+ }
+ return b.toString();
+ }
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString() {
+ StringBuilder builder = new StringBuilder(32);
+ builder.append('[').append(getName()).append(' ');
+ builder.append("t:").append(getType()).append(' ');
+ builder.append("s:").append(getStartOffset()).append(' ');
+ builder.append("e:").append(getEndOffset()).append(']');
+ return builder.toString();
+ }
+}
Added: trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java (rev 0)
+++ trunk/fs/src/fs/org/jnode/partitions/apm/ApmPartitionTableType.java 2012-08-09 14:08:21 UTC (rev 5904)
@@ -0,0 +1,47 @@
+/*
+ * $Id: $
+ *
+ * Copyright (C) 2003-2012 JNode.org
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * 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.partitions.apm;
+
+import org.jnode.driver.Device;
+import org.jnode.driver.block.BlockDeviceAPI;
+import org.jnode.partitions.PartitionTable;
+import org.jnode.partitions.PartitionTableException;
+import org.jnode.partitions.PartitionTableType;
+
+/**
+ * Apple Partition Map (APM) partition table type.
+ *
+ * @author Luke Quinane
+ */
+public class ApmPartitionTableType implements PartitionTableType {
+
+ public PartitionTable<?> create(byte[] firstSector, Device device) throws PartitionTableException {
+ return new ApmPartitionTable(this, firstSector, device);
+ }
+
+ public String getName() {
+ return "APM";
+ }
+
+ public boolean supports(byte[] first16KiB, BlockDeviceAPI devApi) {
+ return ApmPartitionTable.containsPartitionTable(first16KiB);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-09 14:04:38
|
Revision: 5903
http://jnode.svn.sourceforge.net/jnode/?rev=5903&view=rev
Author: galatnm
Date: 2012-08-09 14:04:32 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Detect GPT partitions with 8KB block sizes (patch from L. Quinane)
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java
Modified: trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java 2012-08-09 14:01:43 UTC (rev 5902)
+++ trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTable.java 2012-08-09 14:04:32 UTC (rev 5903)
@@ -85,7 +85,7 @@
* @return the detected block size or {@code -1} if no GPT partition is found.
*/
private static int detectBlockSize(byte[] first16KiB) {
- int[] detectionSizes = new int[] { 0x200, 0x1000 };
+ int[] detectionSizes = new int[] { 0x200, 0x1000, 0x2000 };
for (int blockSize : detectionSizes) {
if (first16KiB.length < blockSize + 8) {
@@ -125,4 +125,4 @@
public PartitionTableType getType() {
return tableType;
}
-}
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ga...@us...> - 2012-08-09 14:01:53
|
Revision: 5902
http://jnode.svn.sourceforge.net/jnode/?rev=5902&view=rev
Author: galatnm
Date: 2012-08-09 14:01:43 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Remove IBM partition table reference from GPT partition table entry (patch from L. Quinane)
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java
Modified: trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java 2012-08-09 11:04:47 UTC (rev 5901)
+++ trunk/fs/src/fs/org/jnode/partitions/gpt/GptPartitionTableEntry.java 2012-08-09 14:01:43 UTC (rev 5902)
@@ -21,8 +21,8 @@
package org.jnode.partitions.gpt;
import java.nio.charset.Charset;
+import org.jnode.partitions.PartitionTable;
import org.jnode.partitions.PartitionTableEntry;
-import org.jnode.partitions.ibm.IBMPartitionTable;
import org.jnode.util.LittleEndian;
import org.jnode.util.NumberUtils;
@@ -63,7 +63,7 @@
/**
* @see org.jnode.partitions.PartitionTableEntry#getChildPartitionTable()
*/
- public IBMPartitionTable getChildPartitionTable() {
+ public PartitionTable<?> getChildPartitionTable() {
throw new UnsupportedOperationException("No child partitions.");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|