diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp index daf05a52be274291c21bf578c82a41c0c2c9f778..9572b510cb9f631f0f92886b2947c8b8b87c6dd3 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp +++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp @@ -2315,6 +2315,15 @@ JNIEXPORT jboolean JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_isImageSupp return (jboolean) result; } +/* +* Returns the current Sleuthkit version as a long +* @return the current version +*/ +JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_getSleuthkitVersionNat +(JNIEnv * env, jclass obj) { + return (jlong)TSK_VERSION_NUM; +} + /* * Finish the image being created by image writer. diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.h b/bindings/java/jni/dataModel_SleuthkitJNI.h index a724200b043d2b21660a5b55e72e3a72a3e6b8c7..17bbaa66526e52f9a04d01c970b64148bdb4186c 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.h +++ b/bindings/java/jni/dataModel_SleuthkitJNI.h @@ -439,6 +439,14 @@ JNIEXPORT jstring JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_getCurDirNat JNIEXPORT jboolean JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_isImageSupportedNat (JNIEnv *, jclass, jstring); +/* + * Class: org_sleuthkit_datamodel_SleuthkitJNI + * Method: getSleuthkitVersionNat + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_getSleuthkitVersionNat + (JNIEnv *, jclass); + /* * Class: org_sleuthkit_datamodel_SleuthkitJNI * Method: finishImageWriterNat diff --git a/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java b/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java index 5adb2b2fd0b12c31151e41787c0faecb0e3094fd..db96a7f671cd8184f97d22d510879683a43d4eec 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/CaseDatabaseFactory.java @@ -30,7 +30,7 @@ import org.sleuthkit.datamodel.SQLHelper.SQLiteHelper; /** - * + * Creates a SQLite or PostgreSQL case database. */ class CaseDatabaseFactory { private static final Logger logger = Logger.getLogger(CaseDatabaseFactory.class.getName()); @@ -125,7 +125,7 @@ private void initializeSchema() throws TskCoreException { */ private void addDbInfo(Connection conn) throws TskCoreException { CaseDbSchemaVersionNumber version = SleuthkitCase.CURRENT_DB_SCHEMA_VERSION; - long tskVersionNum = 0; // This is the current version of TSK (not the DB schema version) + long tskVersionNum = SleuthkitJNI.getSleuthkitVersion(); // This is the current version of TSK try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE tsk_db_info (schema_ver INTEGER, tsk_ver INTEGER, schema_minor_ver INTEGER)"); @@ -552,8 +552,8 @@ private class SQLiteDbCreationHelper extends DbCreationHelper { @Override void createDatabase() throws TskCoreException { - // SQLite doesn't need to explicitly create the case database, so - // just check that the folder exists and the database does not + // SQLite doesn't need to explicitly create the case database but we will set the + // chunk size here after a check that the folder exists and the database does not File dbFile = new File(dbPath); if (dbFile.exists()) { throw new TskCoreException("Case database already exists : " + dbPath); @@ -584,7 +584,6 @@ Connection getConnection() { @Override void performPreInitialization(Connection conn) throws TskCoreException { - try (Statement stmt = conn.createStatement()) { stmt.execute(PRAGMA_SYNC_OFF); stmt.execute(PRAGMA_READ_UNCOMMITTED_TRUE); @@ -594,7 +593,7 @@ void performPreInitialization(Connection conn) throws TskCoreException { } catch (SQLException ex) { throw new TskCoreException("Error setting pragmas", ex); } - + /* TODO? Implement this C code // increase the DB by 1MB at a time -- supposed to help performance when populating int chunkSize = 1024 * 1024; diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java index 344c28e2ff7797b9c3bf940fbf3552b10e42dd46..6157528345caae39c14ecaa4291dcc72dd2ddb4a 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java @@ -1734,6 +1734,23 @@ public static long findDeviceSize(String devPath) throws TskCoreException { public static boolean isImageSupported(String imagePath) { return isImageSupportedNat(imagePath); } + + /** Get the version of the Sleuthkit code in number form. + * Upper byte is A, next is B, and next byte is C in version A.B.C. + * Lowest byte is 0xff, except in beta releases, in which case it + * increments from 1. Nightly snapshots will have upper byte as + * 0xff and next bytes with year, month, and date, respectively. + * Note that you will not be able to differentiate between snapshots + * from the trunk or branches with this method... + * For example, 3.1.2 would be stored as 0x030102FF. + * 3.1.2b1 would be 0x03010201. Snapshot from Jan 2, 2003 would be + * 0xFF030102. + * + * @return the current Sleuthkit version + */ + static long getSleuthkitVersion() { + return getSleuthkitVersionNat(); + } /** * Get a read lock for the C++ layer. Do not get this lock after obtaining @@ -1982,6 +1999,8 @@ public static long openFile(long fsHandle, long fileId, TSK_FS_ATTR_TYPE_ENUM at private static native String getCurDirNat(long process); private static native boolean isImageSupportedNat(String imagePath); + + private static native long getSleuthkitVersionNat(); private static native int finishImageWriterNat(long a_img_info);