summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/filemap.py
AgeCommit message (Collapse)Author
2023-03-27filemap.py: enforce maximum of 4kb block sizeAndrew Geissler
The logic in this script validates that the length of data sections are evenly divisible by the block size. On most systems the block size is 4KB and all is good. Some systems though, such as ppc64le, have a block size larger then 4KB. For example on a POWER9 based ppc64le system, the block size is 64KB. This results in this script failing with errors like this when building wic images: |440, in _do_get_mapped_ranges | assert extent_len % self.block_size == 0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | AssertionError In this case the data section size was 268KB and the block size was 64KB, resulting in the above assert failure. Resolves https://bugzilla.yoctoproject.org/show_bug.cgi?id=15075 (From OE-Core rev: 1e23b803af6991fc20e4a4e88a0ef0541399e722) Signed-off-by: Andrew Geissler <geissonator@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-18wic/filemap: Fall back to standard copy when no way to get the block mapKevin Hao
For some filesystems, such as aufs which may be used by docker container, don't support either the SEEK_DATA/HOLE or FIEMAP to get the block map. So add a FileNobmap class to fall back to standard copy when there is no way to get the block map. [Yocto #12988] (From OE-Core rev: 7934ed49179242f15b413c0275040a3bb6b68876) Signed-off-by: Kevin Hao <kexin.hao@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-18wic/filemap: Drop the unused get_unmapped_ranges()Kevin Hao
This method is not used by any code, so drop it. (From OE-Core rev: 6513fd9302b9989f97fc9d95e76e06ad5d266774) Signed-off-by: Kevin Hao <kexin.hao@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-18wic/filemap: Drop the unused block_is_unmapped()Kevin Hao
This method is not used by any code, so drop it. (From OE-Core rev: fb62a15349597ee026c67a0bb0a6ca2cc9bfe420) Signed-off-by: Kevin Hao <kexin.hao@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-02wic/filemap: If FIGETBSZ iotctl fail, failback to os.statKalle Lampila
Some file systems don't support fetching the block size (notably the file system Docker uses for containers), so if iotctl() fail, try to use failback via os.stat() to get block size. (From OE-Core rev: e219f5175177a640dd62833082ea19adc1c13d42) Signed-off-by: Kalle lampila <kalle.lampila@lempea.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-06-08wic/filemap: handle FIGETBSZ failingRoss Burton
Some file systems don't support fetching the block size (notably the file system Docker uses for containers), so handle the iotctl() failing and raise the expected error. (From OE-Core rev: 3757073726a00c5250556aae3d0daac76b88085e) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09meta/lib+scripts: Convert to SPDX license headersRichard Purdie
This adds SPDX license headers in place of the wide assortment of things currently in our script headers. We default to GPL-2.0-only except for the oeqa code where it was clearly submitted and marked as MIT on the most part or some scripts which had the "or later" GPL versioning. The patch also drops other obsolete bits of file headers where they were encoountered such as editor modelines, obsolete maintainer information or the phrase "All rights reserved" which is now obsolete and not required in copyright headers (in this case its actually confusing for licensing as all rights were not reserved). More work is needed for OE-Core but this takes care of the bulk of the scripts and meta/lib directories. The top level LICENSE files are tweaked to match the new structure and the SPDX naming. (From OE-Core rev: f8c9c511b5f1b7dbd45b77f345cb6c048ae6763e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-07wic: use explicit errno importRoss Burton
os.errno doesn't work in Python 3.7 and shouldn't have ever worked, so use import errno explicitly. (From OE-Core rev: 82f9157e84dcaf0ad4292053b09be68c2290d197) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-01-14wic: if we can't get from ioctl, try from os.stat()Dogukan Ergun
Under some conditions, ioctl FIGETBSZ can't return real value. We can try to use fallback via os.stat() to get block size. Source of patch: https://github.com/intel/bmap-tools/commit/17365f4fe9089df7ee9800a2a0ced177ec4798a4 (From OE-Core rev: d8f7cf2d38934c248be91101236f7537d0d31ea7) Signed-off-by: Dogukan Ergun <dogukan.ergun@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-23wic: code cleanupEd Bartosh
Split long lines. Removed unused imports. (From OE-Core rev: 49b704864c7db49e41a0b6bbdb8a2840e7fa232b) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14filemap: calculate dst size correctlyEd Bartosh
Fixed calculation of the dst file size using skip, seek and length parameters. Current code does it incorrectly which causes sparse_copy API to create unnecessary big output files. (From OE-Core rev: e6d709a6382e4b913612f597e66ad07b0e351d5f) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14filemap: check if dest is written for every blockEd Bartosh
If lenght parameter is provided to sparse_copy call it's mandatory to check if the output file is fully written after reading unmapped block from input file. If it's not done then sparse_copy can write more data than specified length. (From OE-Core rev: 289b1767182982dfb6912e64481150697ba93e4d) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14filemap: change signature of sparse_copy functionEd Bartosh
Renamed parameter offset->skip to match names of dd parameters. Changed affected sparse_copy calls. Added explanation of the parameters to docstring. (From OE-Core rev: 08e2f4e59816c5757686255b267b08cbc46fbd95) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14filemap: add parameter 'length' to sparse_copyEd Bartosh
Added parameter 'length' to specify amount of data to write into destination file. This is useful when only part of source file should be written into destination file. (From OE-Core rev: cc44e2eb3b5027a3531e6349937a23d73313b3c6) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-14filemap: fix skip logicEd Bartosh
Fixed bug in processing 'skip' parameter: don't read input file if end of bmap block is less than skip Simplified logic of positioning to the start of data inside a partially skipped bmap block. (From OE-Core rev: c19f78a0713c8ac9d28b78f86c6d7b96157788f0) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-04-12oe-selftest: test wic sparse_copy APIEd Bartosh
Added new parameter 'api' to sparse_copy function to specify underlying filemap API to use. By default sparse_copy will try both available APIs. Added test case for sparse_copy to wic test suite. (From OE-Core rev: 88701cef6ba399e82f96ed1b0eef9a44ed8c1687) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-04-05Revert "filemap: remove FilemapSeek class"Ed Bartosh
FIEMAP API is not supported by tmpfs file system, but SEEK_HOLE/SEEK_DATA is supported. Returned back FilemapSeek class that implements support of SEEK_HOLE/SEEK_DATA API to make sparse_copy API working on tmpfs again. This reverts commit 6b80c13f7a82a312a3b981de5a56c66466ba1fac. (From OE-Core rev: e75bd6a7dd5c1b4bad039c35cf4a2ffc2f77c60a) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-04-01filemap: remove FilemapSeek classEd Bartosh
FIEMAP API was added to Linux kernel 2.6.28 back in 2008 SEEK_HOLE and SEEK_DATA API was added much letter. As FIEMAP is used by filemap module as a default API it's safe to remove FileMpSeek class as it's never used. [YOCTO #10618] (From OE-Core rev: 44e9406ea6e3263d2fb95e9d534a21f74f318480) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-03-23wic: fix bug in sparse_copyEd Bartosh
sparse_copy creates output file that is smaller than input file when input file ends with unmapped blocks. Used truncate(<input file size>) when output file is created to ensure the size of output file will always be equal to the size of input file. (From OE-Core rev: 567186f995302a095a771baede4ff5034d1d1862) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-03-10wic: filemap: Fixed spared_copy skipDaniel Schultz
This patches removes the empty space in front of the copied file which was skipped. Without this reduction it's not possible to place a partition with rawcopy and skip parameter on a desired alignment. (From OE-Core rev: 5c024d71f9413b81ee1707dbc41f0721f8f27bdb) Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-14wic: use next builtin instead of .next methodEd Bartosh
Generators in Python 3 don't have .next method. It's recommended to use 'next' builtin instead. As it also present in Python >= 2.6 it should make wic code compatible with both Python 2 and Python 3. [YOCTO #9412] (From OE-Core rev: 9b7ab632e47d786dd979262015dbfb1254103f83) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-14wic: use // operator instead of /Ed Bartosh
Division operator works differently in Python 3. It results in float unlike in Python 2, where it results in int. Explicitly used "floor division" operator instead of 'division' operator. This should make the code to result in integer under both pythons. [YOCTO #9412] (From OE-Core rev: 997ff239bd753a7957cc14c6829b2f093d9bcef6) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-06wic: add sparse_copy APIEd Bartosh
In order to make wic images sparse sparse_copy function has been copied from meta-ostro: https://github.com/kad/meta-ostro/blob/master/meta-ostro/lib/image-dsk.py This function uses filemap APIs to copy source sparse file into destination file preserving sparseness. The function has been modified to satisfy wic requirements: parameter 'skip' has been added. [YOCTO #9099] (From OE-Core rev: bfde62bdc03152a4d3d383512479b974fa867f94) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-06wic: add FIEMAP and SEEK_HOLE / SEEK_DATA APIsEd Bartosh
In order to make wic images sparse set of APIs has been copied from bmap-tools project. filemap.py module is taken from bmap-tools project: https://github.com/01org/bmap-tools/blob/master/bmaptools/Filemap.py It implements two ways of get information about file block: FIEMAP ioctl and the 'SEEK_HOLE / SEEK_DATA' features of the file seek syscall. Note that this module will be removed as soon as bmaptool utility supports copying sparse source file into destination file (this is already agreed with the maintainer of bmap-tools project). [YOCTO #9099] (From OE-Core rev: 182639ddc9cda85c896a54c1c64fd1fb145071a1) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>