Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bf936aa
HFS+: Support listing all attributes for a file.
tmyroadctfig Apr 30, 2019
f701ecd
EXT4: Fix an out-of-bounds exception when the inode data was only 128…
tmyroadctfig May 27, 2019
30d0cda
NTFS: fix a stack overflow error getting the file record's file name.
tmyroadctfig May 31, 2019
d1626fc
NTFS: fix another stack overflow error getting the file record's file…
tmyroadctfig Jun 3, 2019
925ab0f
NTFS: Always log the attribute entry reference.
tmyroadctfig Jun 3, 2019
906dbe2
NTFS: Log the entry reference ID on error.
tmyroadctfig Jun 3, 2019
373268b
NTFS: fix a stack overflow, take 3. Fix a possible NPE.
tmyroadctfig Jun 3, 2019
4237134
NTFS: fallback to stored attributes if all attributes can't be read.
tmyroadctfig Jun 3, 2019
492c0bb
HFS+: Fix a null pointer exception.
tmyroadctfig Jun 21, 2019
fb5a9e1
TRIAGE-1037: stop throwing IOException on empty reads in readVCN for
Aug 2, 2019
cb98e31
Merge pull request #3 from corence/triage-1037/stop-throwing-ioexcept…
tmyroadctfig Aug 13, 2019
5d530bd
FAT: expose base name.
tmyroadctfig Aug 22, 2019
485b9c8
exFAT: fixes around allocated size vs file size.
tmyroadctfig Aug 22, 2019
16d4806
Merge branch 'master' of github.com:tmyroadctfig/jnode
tmyroadctfig Aug 22, 2019
0112ad6
exFAT: expose the file's node.
tmyroadctfig Aug 22, 2019
3786512
NTFS: Add support for 5-byte cluster offsets in data runs.
tmyroadctfig Sep 5, 2019
d47b3db
NTFS: Fix a NPE decoding data runs.
tmyroadctfig Sep 19, 2019
224ec63
NTFS: lazily evaluate stored attributes.
tmyroadctfig Sep 24, 2019
95bfcb8
NTFS: improve attribute debug logging.
tmyroadctfig Sep 26, 2019
067c20b
NTFS: Fix a possible stack overflow.
tmyroadctfig Oct 28, 2019
5690429
Merge branch 'master' of github.com:tmyroadctfig/jnode
tmyroadctfig Oct 28, 2019
fa67b95
NTFS: Fix a possible stack overflow.
tmyroadctfig Oct 29, 2019
1d02fc4
FAT: fix logging.
tmyroadctfig Oct 29, 2019
3ca02ac
FAT: code tidy up to help track down a defect.
tmyroadctfig Oct 29, 2019
7ef2b87
FAT: attempt to fix a race condition getting entries by ID.
tmyroadctfig Nov 4, 2019
cf568d5
FAT: some additional debug logging.
tmyroadctfig Nov 7, 2019
3adefca
FAT: remove the cache which had some bugs.
tmyroadctfig Nov 7, 2019
d8b8ef4
FAT: Fix a bug introduced in the removal of the cache.
tmyroadctfig Nov 7, 2019
4dfa831
NTFS: fix an issue where trying to read the MFT would cause an infini…
tmyroadctfig Dec 16, 2019
1b60b3b
NTFS: fix an issue where trying to read the MFT would cause an infini…
tmyroadctfig Jan 23, 2020
e83ab78
FS: remove usage of an internal Sun class.
tmyroadctfig Feb 12, 2020
33adc9d
NTFS: Skip lookups for invalid entries.
tmyroadctfig Feb 12, 2020
7ea7b8c
ignore CRC and name hash checks
Jun 16, 2020
c8d32be
Merge pull request #4 from thlv/master
tmyroadctfig Jun 16, 2020
6c066d4
NTFS: Fix an issue with 4k sector sizes. The fix-up should always app…
tmyroadctfig Jun 25, 2020
e8ce74d
HFS+: remove final from some methods.
tmyroadctfig Jun 25, 2020
9a51e3a
TRIAGE-2820: fix arrayindexoutofbounds when ext2 data is shorter than it
Aug 27, 2020
a39ae75
Merge pull request #5 from corence/TRIAGE-2820/better-handling-at-eof…
tmyroadctfig Aug 27, 2020
7a1663d
Reverting change that introduced a regression where $MFTs with Attrib…
Jan 22, 2021
a01ca7f
Merge pull request #6 from itajun/bugfix/itamar/tlemu-34
tmyroadctfig Jan 22, 2021
3b147ff
Add archival notice
tmyroadctfig Mar 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Welcome to JNode!

[![Build Status](https://travis-ci.org/jnode/jnode.svg?branch=master)](https://travis-ci.org/jnode/jnode)
## Archived

This project has been archived, and moved to https://github.com/Nuix/jnode-fs

In this file, you find the instructions needed to setup a JNode development environment.

## Sub-Projects

Expand Down
17 changes: 17 additions & 0 deletions core/src/core/org/jnode/util/LittleEndian.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ public static int getInt32(byte[] src, int offset) {
return ((v3 << 24) | (v2 << 16) | (v1 << 8) | v0);
}

/**
* Gets a 40-bit signed integer from the given byte array at the given offset.
*
* @param src
* @param offset
*/
public static long getInt40(byte[] src, int offset) {
final long v0 = src[offset + 0] & 0xFF;
final long v1 = src[offset + 1] & 0xFF;
final long v2 = src[offset + 2] & 0xFF;
final long v3 = src[offset + 3] & 0xFF;
final long v4 = src[offset + 4] & 0xFF;
long tmp = (v4 << 32) | (v3 << 24) | (v2 << 16) | (v1 << 8) | v0;
tmp <<= 24; // Shift the value to the top of the 8 bytes in the long, and back to extend any -ve sign
return tmp >> 24;
}

/**
* Gets a 48-bit unsigned integer from the given byte array at the given offset.
*
Expand Down
24 changes: 11 additions & 13 deletions fs/src/fs/org/jnode/fs/exfat/DirectoryParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public class DirectoryParser {
private static final int FLAG_CONTIGUOUS = 3;

public static DirectoryParser create(Node node) throws IOException {
return create(node, false);
return create(node, false, false);
}

public static DirectoryParser create(Node node, boolean showDeleted) throws IOException {
public static DirectoryParser create(Node node, boolean showDeleted, boolean performChecks) throws IOException {
assert (node.isDirectory()) : "not a directory"; //NOI18N

final DirectoryParser result = new DirectoryParser(node, showDeleted);
final DirectoryParser result = new DirectoryParser(node, showDeleted, performChecks);
result.init();
return result;
}
Expand All @@ -66,13 +66,15 @@ public static DirectoryParser create(Node node, boolean showDeleted) throws IOEx
private final ByteBuffer chunk;
private final Node node;
private boolean showDeleted;
private boolean performChecks;
private long cluster;
private UpcaseTable upcase;
private int index;

private DirectoryParser(Node node, boolean showDeleted) {
private DirectoryParser(Node node, boolean showDeleted, boolean performChecks) {
this.node = node;
this.showDeleted = showDeleted;
this.performChecks = performChecks;
this.sb = node.getSuperBlock();
this.chunk = ByteBuffer.allocate(sb.getBytesPerCluster());
this.chunk.order(ByteOrder.LITTLE_ENDIAN);
Expand Down Expand Up @@ -232,14 +234,10 @@ private void parseFile(Visitor v, boolean deleted) throws IOException {
int nameLen = DeviceAccess.getUint8(chunk);
final int nameHash = DeviceAccess.getUint16(chunk);
skip(2); /* unknown */
final long realSize = DeviceAccess.getUint64(chunk);
final long size = DeviceAccess.getUint64(chunk);
skip(4); /* unknown */
final long startCluster = DeviceAccess.getUint32(chunk);
final long size = DeviceAccess.getUint64(chunk);

if (realSize != size) {
throw new IOException("real size does not equal size");
}
final long allocatedSize = DeviceAccess.getUint64(chunk);

conts--;

Expand Down Expand Up @@ -276,19 +274,19 @@ private void parseFile(Visitor v, boolean deleted) throws IOException {
}
}

if (!deleted && referenceChecksum != actualChecksum) {
if (performChecks && !deleted && referenceChecksum != actualChecksum) {
throw new IOException("checksum mismatch");
}

final String name = nameBuilder.toString();

if ((this.upcase != null) && (hashName(name) != nameHash)) {
if (performChecks && (this.upcase != null) && (hashName(name) != nameHash)) {
throw new IOException("name hash mismatch ("
+ Integer.toHexString(hashName(name)) +
" != " + Integer.toHexString(nameHash) + ")");
}

v.foundNode(Node.create(sb, startCluster, attrib, name, (flag == FLAG_CONTIGUOUS), realSize, times, deleted),
v.foundNode(Node.create(sb, startCluster, attrib, name, (flag == FLAG_CONTIGUOUS), size, allocatedSize, times, deleted),
index);
}

Expand Down
26 changes: 25 additions & 1 deletion fs/src/fs/org/jnode/fs/exfat/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.jnode.fs.exfat;

import java.io.IOException;
import org.apache.log4j.Logger;

/**
* @author Matthias Treydte &lt;waldheinz at gmail.com&gt;
Expand All @@ -47,16 +48,21 @@ public static Node createRoot(ExFatSuperBlock sb)

public static Node create(
ExFatSuperBlock sb, long startCluster, int flags,
String name, boolean isContiguous, long size, EntryTimes times, boolean deleted) {
String name, boolean isContiguous, long size, long allocatedSize, EntryTimes times, boolean deleted) {

final Node result = new Node(sb, startCluster, times);

result.name = name;
result.isContiguous = isContiguous;
result.size = size;
result.allocatedSize = allocatedSize;
result.flags = flags;
result.deleted = deleted;

if (allocatedSize < size) {
Logger.getLogger(Node.class).warn("Allocated size less than file size: " + result);
}

return result;
}

Expand All @@ -69,7 +75,17 @@ public static Node create(
private long clusterCount;
private int flags;
private String name;

/**
* The size of the file in bytes.
*/
private long size;

/**
* The size allocated for the file in bytes. This may be larger than {@code size} if the OS has reserved some space
* for the file to grow into.
*/
private long allocatedSize;
private boolean deleted;

private Node(ExFatSuperBlock sb, long startCluster, EntryTimes times) {
Expand Down Expand Up @@ -125,6 +141,10 @@ public long getSize() {
return size;
}

public long getAllocatedSize() {
return allocatedSize;
}

public boolean isDeleted() {
return deleted;
}
Expand Down Expand Up @@ -170,6 +190,10 @@ public String toString() {
result.append(this.name);
result.append(", contiguous=");
result.append(this.isContiguous);
result.append(", size=");
result.append(size);
result.append(", allocated-size=");
result.append(allocatedSize);
result.append("]");

return result.toString();
Expand Down
8 changes: 4 additions & 4 deletions fs/src/fs/org/jnode/fs/exfat/NodeDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public class NodeDirectory extends AbstractFSObject implements FSDirectory, FSDi
public NodeDirectory(ExFatFileSystem fs, NodeEntry nodeEntry)
throws IOException {

this(fs, nodeEntry, false);
this(fs, nodeEntry, false, false);
}

public NodeDirectory(ExFatFileSystem fs, NodeEntry nodeEntry, boolean showDeleted)
public NodeDirectory(ExFatFileSystem fs, NodeEntry nodeEntry, boolean showDeleted, boolean performChecks)
throws IOException {

super(fs);
Expand All @@ -57,7 +57,7 @@ public NodeDirectory(ExFatFileSystem fs, NodeEntry nodeEntry, boolean showDelete
this.idToNode = new LinkedHashMap<String, NodeEntry>();

DirectoryParser.
create(nodeEntry.getNode(), showDeleted).
create(nodeEntry.getNode(), showDeleted, performChecks).
setUpcase(this.upcase).
parse(new VisitorImpl());

Expand Down Expand Up @@ -145,7 +145,7 @@ public void foundBitmap(
@Override
public void foundUpcaseTable(DirectoryParser parser, long checksum,
long startCluster, long size) {

/* ignore */
}

Expand Down
4 changes: 4 additions & 0 deletions fs/src/fs/org/jnode/fs/exfat/NodeFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public NodeFile(ExFatFileSystem fs, Node node) {
this.node = node;
}

public Node getNode() {
return node;
}

@Override
public long getLength() {
return this.node.getSize();
Expand Down
4 changes: 2 additions & 2 deletions fs/src/fs/org/jnode/fs/ext2/Ext2DirectoryRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public Ext2DirectoryRecord(Ext2FileSystem fs, byte[] data, int offset, int fileO
synchronized (data) {
byte[] newData = new byte[Math.max(8, getRecLen())];
int copySize = getRecLen();
if (copySize + offset > data.length) {
copySize = Math.max(0, copySize - offset);
if (offset + copySize > data.length) {
copySize = data.length - offset;
}
System.arraycopy(data, offset, newData, 0, copySize);
this.data = newData;
Expand Down
2 changes: 1 addition & 1 deletion fs/src/fs/org/jnode/fs/ext2/INode.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public Ext2FileSystem getExt2FileSystem() {
* @return the extra size.
*/
public int getExtraISize() {
if (getExt2FileSystem().hasROFeature(Ext2Constants.EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)) {
if (getExt2FileSystem().hasROFeature(Ext2Constants.EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE) && data.length > 0x82) {
return LittleEndian.getInt16(data, 0x80);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/src/fs/org/jnode/fs/hfsplus/HfsPlusDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private FSEntryTable readEntries() throws IOException {
List<FSEntry> pathList = new LinkedList<FSEntry>();
HfsPlusFileSystem fs = getFileSystem();
if (fs.getVolumeHeader().getFolderCount() > 0) {
LeafRecord[] records;
List<LeafRecord> records;

if ((folder.getFlags() & CatalogFile.FLAGS_HARDLINK_CHAIN) != 0) {
records = fs.getCatalog().getRecords(getHardLinkFolder().getFolderId());
Expand Down
8 changes: 3 additions & 5 deletions fs/src/fs/org/jnode/fs/hfsplus/HfsPlusFileSystemType.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@
public class HfsPlusFileSystemType implements BlockDeviceFileSystemType<HfsPlusFileSystem> {
public static final Class<HfsPlusFileSystemType> ID = HfsPlusFileSystemType.class;

public final HfsPlusFileSystem create(final Device device, final boolean readOnly) throws FileSystemException {
public HfsPlusFileSystem create(final Device device, final boolean readOnly) throws FileSystemException {
HfsPlusFileSystem fs = new HfsPlusFileSystem(device, readOnly, this);
fs.read();
return fs;
}

public final String getName() {
public String getName() {
return "HFS+";
}

public final boolean supports(final PartitionTableEntry pte, final byte[] firstSector,
final FSBlockDeviceAPI devApi) {
public boolean supports(final PartitionTableEntry pte, final byte[] firstSector, final FSBlockDeviceAPI devApi) {
/*
* if (pte != null) { if (pte instanceof IBMPartitionTableEntry) { if (((IBMPartitionTableEntry)
* pte).getSystemIndicator() != IBMPartitionTypes.PARTTYPE_LINUXNATIVE) { return false; } } }
Expand All @@ -62,5 +61,4 @@ public final boolean supports(final PartitionTableEntry pte, final byte[] firstS
return (magicNumber == SuperBlock.HFSPLUS_SUPER_MAGIC && version == 4)
|| (magicNumber == SuperBlock.HFSX_SUPER_MAGIC && version == 5);
}

}
4 changes: 2 additions & 2 deletions fs/src/fs/org/jnode/fs/hfsplus/HfsPlusForkData.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class HfsPlusForkData {
/**
* Overflow extents.
*/
private ExtentDescriptor[] overflowExtents;
private List<ExtentDescriptor> overflowExtents;

/**
* The catalog node ID that owns this fork.
Expand Down Expand Up @@ -178,7 +178,7 @@ public Collection<ExtentDescriptor> getAllExtents(HfsPlusFileSystem fileSystem)

// Add the overflow extents if the exist
if (overflowExtents != null) {
Collections.addAll(allExtents, overflowExtents);
allExtents.addAll(overflowExtents);
}

return allExtents;
Expand Down
32 changes: 30 additions & 2 deletions fs/src/fs/org/jnode/fs/hfsplus/HfsUnicodeString.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import org.jnode.util.BigEndian;

public class HfsUnicodeString {
public class HfsUnicodeString implements Comparable<HfsUnicodeString> {
/**
* Length of string in characters.
*/
Expand Down Expand Up @@ -55,7 +55,7 @@ public HfsUnicodeString(final byte[] src, final int offset) {
*/
public HfsUnicodeString(String string) {
this.string = string;
this.length = string.length();
this.length = string == null ? 0 : string.length();
}

public final int getLength() {
Expand Down Expand Up @@ -83,4 +83,32 @@ public final byte[] getBytes() {
public String toString() {
return string;
}

@Override
public int hashCode() {
return string == null ? 0 : string.hashCode();
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof HfsUnicodeString)) {
return false;
}

HfsUnicodeString other = (HfsUnicodeString) obj;
return compareTo(other) == 0;
}

@Override
public int compareTo(HfsUnicodeString other) {
if (string == null && other.string == null) {
return 0;
} else if (string == null) {
return -1;
} else if (other.string == null) {
return 1;
}

return string.compareTo(other.string);
}
}
6 changes: 3 additions & 3 deletions fs/src/fs/org/jnode/fs/hfsplus/attributes/AttributeKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public int compareTo(Key key) {
// Note: this is unlikely to be correct. See TN1150 section "Unicode Subtleties" for details
// For reading in data is should be safe since the B-Tree will be pre-sorted, but for adding new entries
// it will cause the order to be wrong.
result = this.getAttributeName().getUnicodeString()
.compareTo(otherKey.getAttributeName().getUnicodeString());
result = this.getAttributeName().compareTo(otherKey.getAttributeName());
}
}
return result;
Expand All @@ -103,7 +102,8 @@ public boolean equals(Object obj) {

return
fileId.getId() == otherKey.fileId.getId() &&
attributeName.getUnicodeString().equals(otherKey.getAttributeName().getUnicodeString());
(attributeName.getUnicodeString() == null || otherKey.getAttributeName().getUnicodeString() == null ||
attributeName.getUnicodeString().equals(otherKey.getAttributeName().getUnicodeString()));
}

@Override
Expand Down
Loading