blob: 43de53cc8d1c91b92ae8a3a7ba03e6b056346ab8
1 | /* |
2 | * runlist.h - Exports for runlist handling. Originated from the Linux-NTFS project. |
3 | * |
4 | * Copyright (c) 2002 Anton Altaparmakov |
5 | * Copyright (c) 2002 Richard Russon |
6 | * |
7 | * This program/include file is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License as published |
9 | * by the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program/include file is distributed in the hope that it will be |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program (in the main directory of the NTFS-3G |
19 | * distribution in the file COPYING); if not, write to the Free Software |
20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ |
22 | |
23 | #ifndef _NTFS_RUNLIST_H |
24 | #define _NTFS_RUNLIST_H |
25 | |
26 | #include "types.h" |
27 | |
28 | /* Forward declarations */ |
29 | typedef struct _runlist_element runlist_element; |
30 | typedef runlist_element runlist; |
31 | |
32 | #include "attrib.h" |
33 | #include "volume.h" |
34 | |
35 | /** |
36 | * struct _runlist_element - in memory vcn to lcn mapping array element. |
37 | * @vcn: starting vcn of the current array element |
38 | * @lcn: starting lcn of the current array element |
39 | * @length: length in clusters of the current array element |
40 | * |
41 | * The last vcn (in fact the last vcn + 1) is reached when length == 0. |
42 | * |
43 | * When lcn == -1 this means that the count vcns starting at vcn are not |
44 | * physically allocated (i.e. this is a hole / data is sparse). |
45 | */ |
46 | struct _runlist_element {/* In memory vcn to lcn mapping structure element. */ |
47 | VCN vcn; /* vcn = Starting virtual cluster number. */ |
48 | LCN lcn; /* lcn = Starting logical cluster number. */ |
49 | s64 length; /* Run length in clusters. */ |
50 | }; |
51 | |
52 | extern runlist_element *ntfs_rl_extend(runlist_element *rl, int more_entries); |
53 | |
54 | extern LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn); |
55 | |
56 | extern s64 ntfs_rl_pread(const ntfs_volume *vol, const runlist_element *rl, |
57 | const s64 pos, s64 count, void *b); |
58 | extern s64 ntfs_rl_pwrite(const ntfs_volume *vol, const runlist_element *rl, |
59 | s64 ofs, const s64 pos, s64 count, void *b); |
60 | |
61 | extern runlist_element *ntfs_runlists_merge(runlist_element *drl, |
62 | runlist_element *srl); |
63 | |
64 | extern runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol, |
65 | const ATTR_RECORD *attr, runlist_element *old_rl); |
66 | |
67 | extern int ntfs_get_nr_significant_bytes(const s64 n); |
68 | |
69 | extern int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol, |
70 | const runlist_element *rl, const VCN start_vcn, int max_size); |
71 | |
72 | extern int ntfs_write_significant_bytes(u8 *dst, const u8 *dst_max, |
73 | const s64 n); |
74 | |
75 | extern int ntfs_mapping_pairs_build(const ntfs_volume *vol, u8 *dst, |
76 | const int dst_len, const runlist_element *rl, |
77 | const VCN start_vcn, runlist_element const **stop_rl); |
78 | |
79 | extern int ntfs_rl_truncate(runlist **arl, const VCN start_vcn); |
80 | |
81 | extern int ntfs_rl_sparse(runlist *rl); |
82 | extern s64 ntfs_rl_get_compressed_size(ntfs_volume *vol, runlist *rl); |
83 | |
84 | #ifdef NTFS_TEST |
85 | int test_rl_main(int argc, char *argv[]); |
86 | #endif |
87 | |
88 | #endif /* defined _NTFS_RUNLIST_H */ |
89 | |
90 |