From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Fri, 23 Sep 2016 15:57:47 -0400 Subject: [U-Boot] [U-Boot, v5, 15/16] ext4: Correct block number handling, empty block vs. error code In-Reply-To: <1e280a6594174f6cb3f260890dfd64ac@rwthex-w2-b.rwth-ad.de> References: <1e280a6594174f6cb3f260890dfd64ac@rwthex-w2-b.rwth-ad.de> Message-ID: <20160923195747.GS4884@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Sep 06, 2016 at 04:36:55AM +0200, Stefan Br?ns wrote: > read_allocated block may return block number 0, which is just an indicator > a chunk of the file is not backed by a block, i.e. it is sparse. > > During file deletions, just continue with the next logical block, for other > operations treat blocknumber <= 0 as an error. > > For writes, blocknumber 0 should never happen, as U-Boot always allocates > blocks for the whole file. Reading already handles this correctly, i.e. the > read buffer is 0-fillled. > > Not treating block 0 as sparse block leads to FS corruption, e.g. > ./sandbox/u-boot -c 'host bind 0 ./sandbox/test/fs/3GB.ext4.img ; > ext4write host 0 0 /2.5GB.file 1 ' > The 2.5GB.file from the fs test is actually a sparse file. > > Signed-off-by: Stefan Br?ns Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: