OpenCoverage

extent-scan.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/extent-scan.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static -
6 _Bool-
7-
8extent_need_sync (void)-
9{-
10-
11-
12-
13-
14 return
executed 65 times by 1 test: return 1 ;
Executed by:
  • cp
executed 65 times by 1 test: return 1 ;
Executed by:
  • cp
65
15 1
executed 65 times by 1 test: return 1 ;
Executed by:
  • cp
65
16 ;
executed 65 times by 1 test: return 1 ;
Executed by:
  • cp
65
17}-
18-
19-
20-
21extern void-
22extent_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 ()
extent_need_sync ()Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • cp
FALSEnever evaluated
? 0x00000001 : 0;
0-65
37}
executed 65 times by 1 test: end of block
Executed by:
  • cp
65
38-
39-
40-
41-
42-
43-
44-
45extern -
46 _Bool-
47-
48extent_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,
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
76 (((2U|1U) << (((0 +8)+8)+14)) | (((
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
77 'f'
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
78 )) << (0 +8)) | (((
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
79 11
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
80 )) << 0) | ((((sizeof(
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
81 struct fiemap
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
82 )))) << ((0 +8)+8)))
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
5-68
83 , fiemap) < 0
ioctl (scan->f... , fiemap) < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 68 times by 1 test
Evaluated by:
  • cp
)
5-68
84 {-
85 if (scan->scan_start == 0
scan->scan_start == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • cp
FALSEnever evaluated
)
0-5
86 scan->initial_scan_failed =
executed 5 times by 1 test: scan->initial_scan_failed = 1 ;
Executed by:
  • cp
5
87 1
executed 5 times by 1 test: scan->initial_scan_failed = 1 ;
Executed by:
  • cp
5
88 ;
executed 5 times by 1 test: scan->initial_scan_failed = 1 ;
Executed by:
  • cp
5
89 return
executed 5 times by 1 test: return 0 ;
Executed by:
  • cp
executed 5 times by 1 test: return 0 ;
Executed by:
  • cp
5
90 0
executed 5 times by 1 test: return 0 ;
Executed by:
  • cp
5
91 ;
executed 5 times by 1 test: return 0 ;
Executed by:
  • cp
5
92 }-
93-
94-
95 if (fiemap->fm_mapped_extents == 0
fiemap->fm_mapped_extents == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 64 times by 1 test
Evaluated by:
  • cp
)
4-64
96 {-
97 scan->hit_final_extent = -
98 1-
99 ;-
100 return
executed 4 times by 1 test: return scan->scan_start != 0;
Executed by:
  • cp
scan->scan_start != 0;
executed 4 times by 1 test: return scan->scan_start != 0;
Executed by:
  • cp
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
i < fiemap->fm_mapped_extentsDescription
TRUEevaluated 1397 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 64 times by 1 test
Evaluated by:
  • cp
; i++)
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
siDescription
TRUEevaluated 1333 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 64 times by 1 test
Evaluated by:
  • cp
&& last_ei->ext_flags
last_ei->ext_f...& ~0x00000001)Description
TRUEevaluated 1330 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 3 times by 1 test
Evaluated by:
  • cp
3-1333
141 == (fm_extents[i].fe_flags & ~0x00000001)
last_ei->ext_f...& ~0x00000001)Description
TRUEevaluated 1330 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 3 times by 1 test
Evaluated by:
  • cp
3-1330
142 && (
(last_ei->ext_...i].fe_logical)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 1327 times by 1 test
Evaluated by:
  • cp
last_ei->ext_logical + last_ei->ext_length
(last_ei->ext_...i].fe_logical)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 1327 times by 1 test
Evaluated by:
  • cp
3-1327
143 == fm_extents[i].fe_logical)
(last_ei->ext_...i].fe_logical)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 1327 times by 1 test
Evaluated by:
  • cp
)
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 block
Executed by:
  • cp
3
150 else if ((si == 0
si == 0Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 1330 times by 1 test
Evaluated by:
  • cp
&& scan->scan_start > fm_extents[i].fe_logical
scan->scan_sta...[i].fe_logicalDescription
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • cp
)
0-1330
151 || (si
siDescription
TRUEevaluated 1330 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 64 times by 1 test
Evaluated by:
  • cp
&& (
(last_ei->ext_...i].fe_logical)Description
TRUEnever evaluated
FALSEevaluated 1330 times by 1 test
Evaluated by:
  • cp
last_ei->ext_logical + last_ei->ext_length
(last_ei->ext_...i].fe_logical)Description
TRUEnever evaluated
FALSEevaluated 1330 times by 1 test
Evaluated by:
  • cp
0-1330
152 > fm_extents[i].fe_logical)
(last_ei->ext_...i].fe_logical)Description
TRUEnever evaluated
FALSEevaluated 1330 times by 1 test
Evaluated by:
  • cp
))
0-1330
153 {-
154-
155-
156-
157-
158 uint64_t new_logical;-
159 uint64_t length_adjust;-
160 if (si == 0
si == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
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
length_adjust ...s[i].fe_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
171 {-
172 if (scan->scan_start == 0
scan->scan_start == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
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 block
Executed by:
  • cp
1394
194 }-
195-
196 if (last_ei->ext_flags & 0x00000001
last_ei->ext_f...s & 0x00000001Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 8 times by 1 test
Evaluated by:
  • cp
)
8-56
197 scan->hit_final_extent =
executed 56 times by 1 test: scan->hit_final_extent = 1 ;
Executed by:
  • cp
56
198 1
executed 56 times by 1 test: scan->hit_final_extent = 1 ;
Executed by:
  • cp
56
199 ;
executed 56 times by 1 test: scan->hit_final_extent = 1 ;
Executed by:
  • cp
56
200-
201-
202-
203 if (si > count
si > countDescription
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • cp
&& !scan->hit_final_extent
!scan->hit_final_extentDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
scan->hit_final_extentDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • cp
FALSEevaluated 8 times by 1 test
Evaluated by:
  • cp
)
8-56
210 break;
executed 56 times by 1 test: break;
Executed by:
  • cp
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:
  • cp
8
213-
214 if (si >= count
si >= countDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • cp
FALSEnever evaluated
)
0-8
215 break;
executed 8 times by 1 test: break;
Executed by:
  • cp
8
216 }
never executed: end of block
0
217-
218 return
executed 64 times by 1 test: return 1 ;
Executed by:
  • cp
executed 64 times by 1 test: return 1 ;
Executed by:
  • cp
64
219 1
executed 64 times by 1 test: return 1 ;
Executed by:
  • cp
64
220 ;
executed 64 times by 1 test: return 1 ;
Executed by:
  • cp
64
221}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2