1298178Sdelphij/* 2298178Sdelphij * runlist.h - Exports for runlist handling. Originated from the Linux-NTFS project. 3298178Sdelphij * 4298178Sdelphij * Copyright (c) 2002 Anton Altaparmakov 5298178Sdelphij * Copyright (c) 2002 Richard Russon 6298178Sdelphij * 7298178Sdelphij * This program/include file is free software; you can redistribute it and/or 8298178Sdelphij * modify it under the terms of the GNU General Public License as published 9298178Sdelphij * by the Free Software Foundation; either version 2 of the License, or 10298178Sdelphij * (at your option) any later version. 11298178Sdelphij * 12298178Sdelphij * This program/include file is distributed in the hope that it will be 13298178Sdelphij * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14298178Sdelphij * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15298178Sdelphij * GNU General Public License for more details. 16298178Sdelphij * 17298178Sdelphij * You should have received a copy of the GNU General Public License 18298178Sdelphij * along with this program (in the main directory of the NTFS-3G 19298178Sdelphij * distribution in the file COPYING); if not, write to the Free Software 20298178Sdelphij * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21298178Sdelphij */ 22298178Sdelphij 23298178Sdelphij#ifndef _NTFS_RUNLIST_H 24298178Sdelphij#define _NTFS_RUNLIST_H 25298178Sdelphij 26298178Sdelphij#include "types.h" 27298178Sdelphij 28298178Sdelphij/* Forward declarations */ 29298178Sdelphijtypedef struct _runlist_element runlist_element; 30298178Sdelphijtypedef runlist_element runlist; 31298178Sdelphij 32298178Sdelphij#include "attrib.h" 33298178Sdelphij#include "volume.h" 34298178Sdelphij 35298178Sdelphij/** 36298178Sdelphij * 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 */ 46struct _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 52extern runlist_element *ntfs_rl_extend(ntfs_attr *na, runlist_element *rl, 53 int more_entries); 54 55extern LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn); 56 57extern s64 ntfs_rl_pread(const ntfs_volume *vol, const runlist_element *rl, 58 const s64 pos, s64 count, void *b); 59extern s64 ntfs_rl_pwrite(const ntfs_volume *vol, const runlist_element *rl, 60 s64 ofs, const s64 pos, s64 count, void *b); 61 62extern runlist_element *ntfs_runlists_merge(runlist_element *drl, 63 runlist_element *srl); 64 65extern runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol, 66 const ATTR_RECORD *attr, runlist_element *old_rl); 67 68extern int ntfs_get_nr_significant_bytes(const s64 n); 69 70extern int ntfs_get_size_for_mapping_pairs(const ntfs_volume *vol, 71 const runlist_element *rl, const VCN start_vcn, int max_size); 72 73extern int ntfs_write_significant_bytes(u8 *dst, const u8 *dst_max, 74 const s64 n); 75 76extern int ntfs_mapping_pairs_build(const ntfs_volume *vol, u8 *dst, 77 const int dst_len, const runlist_element *rl, 78 const VCN start_vcn, runlist_element const **stop_rl); 79 80extern int ntfs_rl_truncate(runlist **arl, const VCN start_vcn); 81 82extern int ntfs_rl_sparse(runlist *rl); 83extern s64 ntfs_rl_get_compressed_size(ntfs_volume *vol, runlist *rl); 84 85#ifdef NTFS_TEST 86int test_rl_main(int argc, char *argv[]); 87#endif 88 89#endif /* defined _NTFS_RUNLIST_H */ 90 91