Coverage Report

Created: 2025-11-11 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/sleuthkit/tsk/fs/apfs_compat.hpp
Line
Count
Source
1
/*
2
 * The Sleuth Kit
3
 *
4
 * Brian Carrier [carrier <at> sleuthkit [dot] org]
5
 * Copyright (c) 2019-2020 Brian Carrier.  All Rights reserved
6
 * Copyright (c) 2018-2019 BlackBag Technologies.  All Rights reserved
7
 *
8
 * This software is distributed under the Common Public License 1.0
9
 */
10
#pragma once
11
12
#include "apfs_fs.hpp"
13
#include "tsk_fs.h"
14
15
#include <unordered_map>
16
17
class APFSFSCompat : public APFSJObjTree {
18
  class date_added_cache {
19
    std::unordered_map<uint64_t, uint64_t> _cache{};
20
    uint64_t _last_parent{};
21
    TSK_FS_INFO* _fs;
22
23
    void populate(uint64_t pid) noexcept;
24
25
   public:
26
1
    date_added_cache(TSK_FS_INFO* fs) noexcept : _fs{fs} {}
27
28
    uint64_t lookup(uint64_t parent_id, uint64_t private_id) noexcept;
29
  };
30
31
  mutable TSK_FS_INFO _fsinfo{};
32
  mutable date_added_cache _da_cache{&_fsinfo};
33
34
 public:
35
  APFSFSCompat(TSK_IMG_INFO* img_info, const TSK_POOL_INFO* pool_info, apfs_block_num vol_block,
36
               const char* pass = "");
37
0
  inline const TSK_FS_INFO& fs_info() const noexcept { return _fsinfo; }
38
1
  inline TSK_FS_INFO& fs_info() noexcept { return _fsinfo; }
39
  inline uint64_t date_added(uint64_t parent_id, uint64_t private_id) const
40
0
      noexcept {
41
0
    return _da_cache.lookup(parent_id, private_id);
42
0
  }
43
44
  uint8_t file_add_meta(TSK_FS_FILE*, TSK_INUM_T) const noexcept;
45
  uint8_t inode_walk(TSK_FS_INFO* fs, TSK_INUM_T start_inum, TSK_INUM_T end_inum,
46
      TSK_FS_META_FLAG_ENUM flags, TSK_FS_META_WALK_CB action,
47
      void* ptr);
48
  uint8_t fsstat(FILE*) const noexcept;
49
  uint8_t load_attrs(TSK_FS_FILE*) const noexcept;
50
  uint8_t istat(TSK_FS_ISTAT_FLAG_ENUM, FILE*, TSK_INUM_T, TSK_DADDR_T,
51
                int32_t) const noexcept;
52
  uint8_t block_walk(TSK_FS_INFO *, TSK_DADDR_T, TSK_DADDR_T,
53
      TSK_FS_BLOCK_WALK_FLAG_ENUM, TSK_FS_BLOCK_WALK_CB,
54
      void *);
55
  TSK_FS_BLOCK_FLAG_ENUM block_getflags(TSK_FS_INFO*, TSK_DADDR_T);
56
  uint8_t decrypt_block(TSK_DADDR_T, void*) noexcept;
57
  int name_cmp(const char*, const char*) const noexcept;
58
59
  TSK_RETVAL_ENUM dir_open_meta(TSK_FS_DIR**, TSK_INUM_T, int) const noexcept;
60
};