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