From db2bd193a2a58c9f7f32578b71bb514eb47867ef Mon Sep 17 00:00:00 2001
From: "Peter J. Martel" <pmartel@basistech.com>
Date: Fri, 11 Nov 2011 15:10:54 -0500
Subject: [PATCH] Added 'sequence' field to tsk_file_layout

---
 tsk3/auto/auto_db.cpp     | 2 +-
 tsk3/auto/db_sqlite.cpp   | 9 +++++----
 tsk3/auto/tsk_db_sqlite.h | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/tsk3/auto/auto_db.cpp b/tsk3/auto/auto_db.cpp
index ee703f3ff..f3414b9ef 100644
--- a/tsk3/auto/auto_db.cpp
+++ b/tsk3/auto/auto_db.cpp
@@ -556,7 +556,7 @@ TskAutoDb::processAttribute(TSK_FS_FILE * fs_file,
 
             // @@@ We probaly want ot keep on going here
             if (m_db->addFsBlockInfo(m_curFsId, m_curFileId,
-                    run->addr * block_size, run->len * block_size)) {
+                    run->addr * block_size, run->len * block_size, 0)) {
                 return TSK_ERR;
             }
         }
diff --git a/tsk3/auto/db_sqlite.cpp b/tsk3/auto/db_sqlite.cpp
index 71a1f6031..c1f8beeaf 100644
--- a/tsk3/auto/db_sqlite.cpp
+++ b/tsk3/auto/db_sqlite.cpp
@@ -242,7 +242,7 @@ int
 
     if (m_blkMapFlag) {
         if (attempt_exec
-            ("CREATE TABLE tsk_file_layout (fs_id INTEGER NOT NULL, byte_start INTEGER NOT NULL, byte_len INTEGER NOT NULL, obj_id);",
+            ("CREATE TABLE tsk_file_layout (fs_id INTEGER NOT NULL, byte_start INTEGER NOT NULL, byte_len INTEGER NOT NULL, obj_id INTEGER, sequence INTEGER);",
                 "Error creating tsk_fs_blocks table: %s\n")) {
             return 1;
         }
@@ -730,18 +730,19 @@ int
  * @param a_fileObjId ID of the file
  * @param a_byteStart Byte address relative to the start of the image file
  * @param a_byteLen Length of the run in bytes
+ * @param a_sequence Sequence of this run in the file
  * @returns 1 on error
  */
 int
  TskDbSqlite::addFsBlockInfo(int64_t a_fsObjId, int64_t a_fileObjId,
-    uint64_t a_byteStart, uint64_t a_byteLen)
+    uint64_t a_byteStart, uint64_t a_byteLen, int a_sequence)
 {
     char
      foo[1024];
 
     snprintf(foo, 1024,
-        "INSERT INTO tsk_file_layout (fs_id, byte_start, byte_len, obj_id) VALUES (%lld, %lld, %llu, %llu)",
-        a_fsObjId, a_byteStart, a_byteLen, a_fileObjId);
+        "INSERT INTO tsk_file_layout (fs_id, byte_start, byte_len, obj_id, sequence) VALUES (%lld, %lld, %llu, %llu, %d)",
+        a_fsObjId, a_byteStart, a_byteLen, a_fileObjId, a_sequence);
 
     return attempt_exec(foo,
         "Error adding data to tsk_fs_info table: %s\n");
diff --git a/tsk3/auto/tsk_db_sqlite.h b/tsk3/auto/tsk_db_sqlite.h
index ffb8ade75..dd67f61d6 100755
--- a/tsk3/auto/tsk_db_sqlite.h
+++ b/tsk3/auto/tsk_db_sqlite.h
@@ -61,7 +61,7 @@ class TskDbSqlite {
         const TSK_AUTO_CASE_KNOWN_FILE_ENUM known, int64_t fsObjId,
         int64_t & objId);
     int addFsBlockInfo(int64_t a_fsObjId, int64_t a_fileObjId,
-        uint64_t a_byteStart, uint64_t a_byteLen);
+        uint64_t a_byteStart, uint64_t a_byteLen, int a_sequence);
     
     bool dbExist() const;
     int createSavepoint(const char *name);
-- 
GitLab