/src/sleuthkit/tsk/fs/apfs_open.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "../libtsk.h" |
11 | | |
12 | | #include "apfs_compat.hpp" |
13 | | #include "../img/pool.hpp" |
14 | | #include "tsk_fs_i.h" |
15 | | |
16 | | TSK_FS_INFO* apfs_open_auto_detect(TSK_IMG_INFO * img_info, TSK_OFF_T offset, |
17 | 0 | TSK_FS_TYPE_ENUM fstype, uint8_t test) { |
18 | |
|
19 | 0 | return apfs_open(img_info, offset, fstype, ""); |
20 | 0 | } |
21 | | |
22 | | TSK_FS_INFO* apfs_open(TSK_IMG_INFO * img_info, TSK_OFF_T offset, |
23 | 0 | TSK_FS_TYPE_ENUM fstype, const char* pass) { |
24 | 0 | tsk_error_reset(); |
25 | |
|
26 | 0 | if (img_info->itype != TSK_IMG_TYPE_POOL) { |
27 | 0 | tsk_error_reset(); |
28 | 0 | tsk_error_set_errno(TSK_ERR_FS_ARG); |
29 | 0 | tsk_error_set_errstr("tsk_apfs_open: Not a pool image"); |
30 | 0 | return nullptr; |
31 | 0 | } |
32 | 0 | IMG_POOL_INFO *pool_img = (IMG_POOL_INFO*)img_info; |
33 | |
|
34 | 0 | if (pool_img->pool_info == nullptr) { |
35 | 0 | tsk_error_reset(); |
36 | 0 | tsk_error_set_errno(TSK_ERR_FS_ARG); |
37 | 0 | tsk_error_set_errstr("tsk_apfs_open: Null pool_info"); |
38 | 0 | return nullptr; |
39 | 0 | } |
40 | | |
41 | 0 | if (fstype != TSK_FS_TYPE_APFS) { |
42 | 0 | tsk_error_reset(); |
43 | 0 | tsk_error_set_errno(TSK_ERR_FS_ARG); |
44 | 0 | tsk_error_set_errstr("tsk_apfs_open: invalid fstype"); |
45 | 0 | return nullptr; |
46 | 0 | } |
47 | | |
48 | 0 | try { |
49 | 0 | auto fs = new APFSFSCompat(img_info, pool_img->pool_info, pool_img->pvol_block, pass); |
50 | 0 | return &fs->fs_info(); |
51 | 0 | } catch (std::runtime_error& e) { |
52 | 0 | tsk_error_set_errno(TSK_ERR_FS_GENFS); |
53 | 0 | tsk_error_set_errstr("tsk_apfs_open: %s", e.what()); |
54 | 0 | return nullptr; |
55 | 0 | } |
56 | 0 | } |