| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/extent-scan.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | static | - | ||||||||||||||||||
| 6 | _Bool | - | ||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | extent_need_sync (void) | - | ||||||||||||||||||
| 9 | { | - | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | return executed 65 times by 1 test: return 1 ;Executed by:
executed 65 times by 1 test: return 1 ;Executed by:
| 65 | ||||||||||||||||||
| 15 | 1 executed 65 times by 1 test: return 1 ;Executed by:
| 65 | ||||||||||||||||||
| 16 | ; executed 65 times by 1 test: return 1 ;Executed by:
| 65 | ||||||||||||||||||
| 17 | } | - | ||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | extern void | - | ||||||||||||||||||
| 22 | extent_scan_init (int src_fd, struct extent_scan *scan) | - | ||||||||||||||||||
| 23 | { | - | ||||||||||||||||||
| 24 | scan->fd = src_fd; | - | ||||||||||||||||||
| 25 | scan->ei_count = 0; | - | ||||||||||||||||||
| 26 | scan->ext_info = | - | ||||||||||||||||||
| 27 | ((void *)0) | - | ||||||||||||||||||
| 28 | ; | - | ||||||||||||||||||
| 29 | scan->scan_start = 0; | - | ||||||||||||||||||
| 30 | scan->initial_scan_failed = | - | ||||||||||||||||||
| 31 | 0 | - | ||||||||||||||||||
| 32 | ; | - | ||||||||||||||||||
| 33 | scan->hit_final_extent = | - | ||||||||||||||||||
| 34 | 0 | - | ||||||||||||||||||
| 35 | ; | - | ||||||||||||||||||
| 36 | scan->fm_flags = extent_need_sync ()
| 0-65 | ||||||||||||||||||
| 37 | } executed 65 times by 1 test: end of blockExecuted by:
| 65 | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | extern | - | ||||||||||||||||||
| 46 | _Bool | - | ||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | extent_scan_read (struct extent_scan *scan) | - | ||||||||||||||||||
| 49 | { | - | ||||||||||||||||||
| 50 | unsigned int si = 0; | - | ||||||||||||||||||
| 51 | struct extent_info *last_ei = scan->ext_info; | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | while ( | - | ||||||||||||||||||
| 54 | 1 | - | ||||||||||||||||||
| 55 | ) | - | ||||||||||||||||||
| 56 | { | - | ||||||||||||||||||
| 57 | union { struct fiemap f; char c[4096]; } fiemap_buf; | - | ||||||||||||||||||
| 58 | struct fiemap *fiemap = &fiemap_buf.f; | - | ||||||||||||||||||
| 59 | struct fiemap_extent *fm_extents = &fiemap->fm_extents[0]; | - | ||||||||||||||||||
| 60 | enum { count = (sizeof fiemap_buf - sizeof *fiemap)/sizeof *fm_extents }; | - | ||||||||||||||||||
| 61 | _Static_assert (count > 1, "verify (" "count > 1" ")"); | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | memset (&fiemap_buf, 0, sizeof fiemap_buf); | - | ||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | fiemap->fm_start = scan->scan_start; | - | ||||||||||||||||||
| 69 | fiemap->fm_flags = scan->fm_flags; | - | ||||||||||||||||||
| 70 | fiemap->fm_extent_count = count; | - | ||||||||||||||||||
| 71 | fiemap->fm_length = (~0ULL) - scan->scan_start; | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | if (ioctl (scan->fd,
| 5-68 | ||||||||||||||||||
| 76 | (((2U|1U) << (((0 +8)+8)+14)) | (((
| 5-68 | ||||||||||||||||||
| 77 | 'f'
| 5-68 | ||||||||||||||||||
| 78 | )) << (0 +8)) | (((
| 5-68 | ||||||||||||||||||
| 79 | 11
| 5-68 | ||||||||||||||||||
| 80 | )) << 0) | ((((sizeof(
| 5-68 | ||||||||||||||||||
| 81 | struct fiemap
| 5-68 | ||||||||||||||||||
| 82 | )))) << ((0 +8)+8)))
| 5-68 | ||||||||||||||||||
| 83 | , fiemap) < 0
| 5-68 | ||||||||||||||||||
| 84 | { | - | ||||||||||||||||||
| 85 | if (scan->scan_start == 0
| 0-5 | ||||||||||||||||||
| 86 | scan->initial_scan_failed = executed 5 times by 1 test: scan->initial_scan_failed = 1 ;Executed by:
| 5 | ||||||||||||||||||
| 87 | 1 executed 5 times by 1 test: scan->initial_scan_failed = 1 ;Executed by:
| 5 | ||||||||||||||||||
| 88 | ; executed 5 times by 1 test: scan->initial_scan_failed = 1 ;Executed by:
| 5 | ||||||||||||||||||
| 89 | return executed 5 times by 1 test: return 0 ;Executed by:
executed 5 times by 1 test: return 0 ;Executed by:
| 5 | ||||||||||||||||||
| 90 | 0 executed 5 times by 1 test: return 0 ;Executed by:
| 5 | ||||||||||||||||||
| 91 | ; executed 5 times by 1 test: return 0 ;Executed by:
| 5 | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | if (fiemap->fm_mapped_extents == 0
| 4-64 | ||||||||||||||||||
| 96 | { | - | ||||||||||||||||||
| 97 | scan->hit_final_extent = | - | ||||||||||||||||||
| 98 | 1 | - | ||||||||||||||||||
| 99 | ; | - | ||||||||||||||||||
| 100 | return executed 4 times by 1 test: scan->scan_start != 0;return scan->scan_start != 0;Executed by:
executed 4 times by 1 test: return scan->scan_start != 0;Executed by:
| 4 | ||||||||||||||||||
| 101 | } | - | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | (( | - | ||||||||||||||||||
| 105 | scan->ei_count <= | - | ||||||||||||||||||
| 106 | (18446744073709551615UL) | - | ||||||||||||||||||
| 107 | - fiemap->fm_mapped_extents | - | ||||||||||||||||||
| 108 | ) ? (void) (0) : __assert_fail ( | - | ||||||||||||||||||
| 109 | "scan->ei_count <= SIZE_MAX - fiemap->fm_mapped_extents" | - | ||||||||||||||||||
| 110 | , "src/extent-scan.c", 126, __PRETTY_FUNCTION__)) | - | ||||||||||||||||||
| 111 | ; | - | ||||||||||||||||||
| 112 | scan->ei_count += fiemap->fm_mapped_extents; | - | ||||||||||||||||||
| 113 | { | - | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | size_t prev_idx = last_ei - scan->ext_info; | - | ||||||||||||||||||
| 117 | scan->ext_info = xnrealloc (scan->ext_info, scan->ei_count, | - | ||||||||||||||||||
| 118 | sizeof (struct extent_info)); | - | ||||||||||||||||||
| 119 | last_ei = scan->ext_info + prev_idx; | - | ||||||||||||||||||
| 120 | } | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | unsigned int i = 0; | - | ||||||||||||||||||
| 123 | for (i = 0; i < fiemap->fm_mapped_extents
| 64-1397 | ||||||||||||||||||
| 124 | { | - | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | (( | - | ||||||||||||||||||
| 127 | fm_extents[i].fe_logical <= ((off_t) (! (! ((off_t) 0 < (off_t) -1)) ? (off_t) -1 : ((((off_t) 1 << ((sizeof (off_t) * 8) - 2)) - 1) * 2 + 1))) - fm_extents[i].fe_length | - | ||||||||||||||||||
| 128 | ) ? (void) (0) : __assert_fail ( | - | ||||||||||||||||||
| 129 | "fm_extents[i].fe_logical <= OFF_T_MAX - fm_extents[i].fe_length" | - | ||||||||||||||||||
| 130 | , | - | ||||||||||||||||||
| 131 | "src/extent-scan.c" | - | ||||||||||||||||||
| 132 | , | - | ||||||||||||||||||
| 133 | 141 | - | ||||||||||||||||||
| 134 | , __PRETTY_FUNCTION__)) | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | ; | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | _Static_assert (sizeof last_ei->ext_flags >= sizeof fm_extents->fe_flags, "verify (" "sizeof last_ei->ext_flags >= sizeof fm_extents->fe_flags" ")"); | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | if (si
| 3-1333 | ||||||||||||||||||
| 141 | == (fm_extents[i].fe_flags & ~0x00000001)
| 3-1330 | ||||||||||||||||||
| 142 | && (
| 3-1327 | ||||||||||||||||||
| 143 | == fm_extents[i].fe_logical)
| 3-1327 | ||||||||||||||||||
| 144 | { | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | last_ei->ext_length += fm_extents[i].fe_length; | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | last_ei->ext_flags = fm_extents[i].fe_flags; | - | ||||||||||||||||||
| 149 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 150 | else if ((si == 0
| 0-1330 | ||||||||||||||||||
| 151 | || (si
| 0-1330 | ||||||||||||||||||
| 152 | > fm_extents[i].fe_logical)
| 0-1330 | ||||||||||||||||||
| 153 | { | - | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | uint64_t new_logical; | - | ||||||||||||||||||
| 159 | uint64_t length_adjust; | - | ||||||||||||||||||
| 160 | if (si == 0
| 0 | ||||||||||||||||||
| 161 | new_logical = scan->scan_start; never executed: new_logical = scan->scan_start; | 0 | ||||||||||||||||||
| 162 | else | - | ||||||||||||||||||
| 163 | { | - | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | new_logical = last_ei->ext_logical + last_ei->ext_length; | - | ||||||||||||||||||
| 167 | } never executed: end of block | 0 | ||||||||||||||||||
| 168 | length_adjust = new_logical - fm_extents[i].fe_logical; | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | if (length_adjust < fm_extents[i].fe_length
| 0 | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | if (scan->scan_start == 0
| 0 | ||||||||||||||||||
| 173 | scan->initial_scan_failed = never executed: scan->initial_scan_failed = 1 ; | 0 | ||||||||||||||||||
| 174 | 1 never executed: scan->initial_scan_failed = 1 ; | 0 | ||||||||||||||||||
| 175 | ; never executed: scan->initial_scan_failed = 1 ; | 0 | ||||||||||||||||||
| 176 | return never executed: return 0 ;never executed: return 0 ; | 0 | ||||||||||||||||||
| 177 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||
| 178 | ; never executed: return 0 ; | 0 | ||||||||||||||||||
| 179 | } | - | ||||||||||||||||||
| 180 | fm_extents[i].fe_logical = new_logical; | - | ||||||||||||||||||
| 181 | fm_extents[i].fe_length -= length_adjust; | - | ||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | i--; | - | ||||||||||||||||||
| 184 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 185 | } | - | ||||||||||||||||||
| 186 | else | - | ||||||||||||||||||
| 187 | { | - | ||||||||||||||||||
| 188 | last_ei = scan->ext_info + si; | - | ||||||||||||||||||
| 189 | last_ei->ext_logical = fm_extents[i].fe_logical; | - | ||||||||||||||||||
| 190 | last_ei->ext_length = fm_extents[i].fe_length; | - | ||||||||||||||||||
| 191 | last_ei->ext_flags = fm_extents[i].fe_flags; | - | ||||||||||||||||||
| 192 | si++; | - | ||||||||||||||||||
| 193 | } executed 1394 times by 1 test: end of blockExecuted by:
| 1394 | ||||||||||||||||||
| 194 | } | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | if (last_ei->ext_flags & 0x00000001
| 8-56 | ||||||||||||||||||
| 197 | scan->hit_final_extent = executed 56 times by 1 test: scan->hit_final_extent = 1 ;Executed by:
| 56 | ||||||||||||||||||
| 198 | 1 executed 56 times by 1 test: scan->hit_final_extent = 1 ;Executed by:
| 56 | ||||||||||||||||||
| 199 | ; executed 56 times by 1 test: scan->hit_final_extent = 1 ;Executed by:
| 56 | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | if (si > count
| 0-64 | ||||||||||||||||||
| 204 | last_ei = scan->ext_info + --si - 1; never executed: last_ei = scan->ext_info + --si - 1; | 0 | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | scan->ei_count = si; | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | if (scan->hit_final_extent
| 8-56 | ||||||||||||||||||
| 210 | break; executed 56 times by 1 test: break;Executed by:
| 56 | ||||||||||||||||||
| 211 | else | - | ||||||||||||||||||
| 212 | scan->scan_start = last_ei->ext_logical + last_ei->ext_length; executed 8 times by 1 test: scan->scan_start = last_ei->ext_logical + last_ei->ext_length;Executed by:
| 8 | ||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | if (si >= count
| 0-8 | ||||||||||||||||||
| 215 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||
| 216 | } never executed: end of block | 0 | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | return executed 64 times by 1 test: return 1 ;Executed by:
executed 64 times by 1 test: return 1 ;Executed by:
| 64 | ||||||||||||||||||
| 219 | 1 executed 64 times by 1 test: return 1 ;Executed by:
| 64 | ||||||||||||||||||
| 220 | ; executed 64 times by 1 test: return 1 ;Executed by:
| 64 | ||||||||||||||||||
| 221 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |