diff options
Diffstat (limited to 'scripts/lib/wic/filemap.py')
| -rw-r--r-- | scripts/lib/wic/filemap.py | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/scripts/lib/wic/filemap.py b/scripts/lib/wic/filemap.py index 8cfed5afa8..f8c6e09d01 100644 --- a/scripts/lib/wic/filemap.py +++ b/scripts/lib/wic/filemap.py | |||
| @@ -155,15 +155,6 @@ class _FilemapBase(object): | |||
| 155 | 155 | ||
| 156 | raise Error("the method is not implemented") | 156 | raise Error("the method is not implemented") |
| 157 | 157 | ||
| 158 | def get_unmapped_ranges(self, start, count): # pylint: disable=W0613,R0201 | ||
| 159 | """ | ||
| 160 | This method has has to be implemented by child classes. Just like | ||
| 161 | 'get_mapped_ranges()', but yields unmapped block ranges instead | ||
| 162 | (holes). | ||
| 163 | """ | ||
| 164 | |||
| 165 | raise Error("the method is not implemented") | ||
| 166 | |||
| 167 | 158 | ||
| 168 | # The 'SEEK_HOLE' and 'SEEK_DATA' options of the file seek system call | 159 | # The 'SEEK_HOLE' and 'SEEK_DATA' options of the file seek system call |
| 169 | _SEEK_DATA = 3 | 160 | _SEEK_DATA = 3 |
| @@ -258,9 +249,8 @@ class FilemapSeek(_FilemapBase): | |||
| 258 | 249 | ||
| 259 | def _get_ranges(self, start, count, whence1, whence2): | 250 | def _get_ranges(self, start, count, whence1, whence2): |
| 260 | """ | 251 | """ |
| 261 | This function implements 'get_mapped_ranges()' and | 252 | This function implements 'get_mapped_ranges()' depending |
| 262 | 'get_unmapped_ranges()' depending on what is passed in the 'whence1' | 253 | on what is passed in the 'whence1' and 'whence2' arguments. |
| 263 | and 'whence2' arguments. | ||
| 264 | """ | 254 | """ |
| 265 | 255 | ||
| 266 | assert whence1 != whence2 | 256 | assert whence1 != whence2 |
| @@ -290,12 +280,6 @@ class FilemapSeek(_FilemapBase): | |||
| 290 | % (start, count, start + count - 1)) | 280 | % (start, count, start + count - 1)) |
| 291 | return self._get_ranges(start, count, _SEEK_DATA, _SEEK_HOLE) | 281 | return self._get_ranges(start, count, _SEEK_DATA, _SEEK_HOLE) |
| 292 | 282 | ||
| 293 | def get_unmapped_ranges(self, start, count): | ||
| 294 | """Refer the '_FilemapBase' class for the documentation.""" | ||
| 295 | self._log.debug("FilemapSeek: get_unmapped_ranges(%d, %d(%d))" | ||
| 296 | % (start, count, start + count - 1)) | ||
| 297 | return self._get_ranges(start, count, _SEEK_HOLE, _SEEK_DATA) | ||
| 298 | |||
| 299 | 283 | ||
| 300 | # Below goes the FIEMAP ioctl implementation, which is not very readable | 284 | # Below goes the FIEMAP ioctl implementation, which is not very readable |
| 301 | # because it deals with the rather complex FIEMAP ioctl. To understand the | 285 | # because it deals with the rather complex FIEMAP ioctl. To understand the |
| @@ -485,24 +469,6 @@ class FilemapFiemap(_FilemapBase): | |||
| 485 | % (first_prev, last_prev)) | 469 | % (first_prev, last_prev)) |
| 486 | yield (first_prev, last_prev) | 470 | yield (first_prev, last_prev) |
| 487 | 471 | ||
| 488 | def get_unmapped_ranges(self, start, count): | ||
| 489 | """Refer the '_FilemapBase' class for the documentation.""" | ||
| 490 | self._log.debug("FilemapFiemap: get_unmapped_ranges(%d, %d(%d))" | ||
| 491 | % (start, count, start + count - 1)) | ||
| 492 | hole_first = start | ||
| 493 | for first, last in self._do_get_mapped_ranges(start, count): | ||
| 494 | if first > hole_first: | ||
| 495 | self._log.debug("FilemapFiemap: yielding range (%d, %d)" | ||
| 496 | % (hole_first, first - 1)) | ||
| 497 | yield (hole_first, first - 1) | ||
| 498 | |||
| 499 | hole_first = last + 1 | ||
| 500 | |||
| 501 | if hole_first < start + count: | ||
| 502 | self._log.debug("FilemapFiemap: yielding range (%d, %d)" | ||
| 503 | % (hole_first, start + count - 1)) | ||
| 504 | yield (hole_first, start + count - 1) | ||
| 505 | |||
| 506 | def filemap(image, log=None): | 472 | def filemap(image, log=None): |
| 507 | """ | 473 | """ |
| 508 | Create and return an instance of a Filemap class - 'FilemapFiemap' or | 474 | Create and return an instance of a Filemap class - 'FilemapFiemap' or |
