tests: remove crufty test=test_name code from old tests
[coreutils/ericb.git] / src / extent-scan.h
blobd3d57457913b647147a3e2a24bf75bd0cc9ee911
1 /* core functions for efficient reading sparse files
2 Copyright (C) 2010-2012 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Written by Jie Liu (jeff.liu@oracle.com). */
19 #ifndef EXTENT_SCAN_H
20 # define EXTENT_SCAN_H
22 /* Structure used to store information of each extent. */
23 struct extent_info
25 /* Logical offset of an extent. */
26 off_t ext_logical;
28 /* Extent length. */
29 uint64_t ext_length;
31 /* Extent flags, use it for FIEMAP only, or set it to zero. */
32 uint32_t ext_flags;
35 /* Structure used to reserve extent scan information per file. */
36 struct extent_scan
38 /* File descriptor of extent scan run against. */
39 int fd;
41 /* Next scan start offset. */
42 off_t scan_start;
44 /* Flags to use for scan. */
45 uint32_t fm_flags;
47 /* How many extent info returned for a scan. */
48 uint32_t ei_count;
50 /* If true, fall back to a normal copy, either set by the
51 failure of ioctl(2) for FIEMAP or lseek(2) with SEEK_DATA. */
52 bool initial_scan_failed;
54 /* If true, the total extent scan per file has been finished. */
55 bool hit_final_extent;
57 /* Extent information: a malloc'd array of ei_count structs. */
58 struct extent_info *ext_info;
61 void extent_scan_init (int src_fd, struct extent_scan *scan);
63 bool extent_scan_read (struct extent_scan *scan);
65 static inline void
66 extent_scan_free (struct extent_scan *scan)
68 free (scan->ext_info);
69 scan->ext_info = NULL;
70 scan->ei_count = 0;
73 #endif /* EXTENT_SCAN_H */