Question

When uploading big .pdf/.jpg files to jffs2 file system, fwrite() fails.

My device is having 1024KB space, I am uploading .pdf file of 500KB. My program streams the upload to bytes and writes to jffs2 filesystem. The length given to fwrite() is not same as the length returned from fwrite()(i.e. the number of bytes written). It sets Error number to -11, which says "out of space"

Was it helpful?

Solution

JFFS2 is a compressed file system, so it's very likely that what appears to you as 1024 Kb is actually a 512 Kb area that the device thinks can be compressed at least 2:1, which is a typical value.

But since PDF and JPEG are both compressed formats, they can't be compressed again; trying to do so will actually often expand them. And that's when the JFFS2 write fails.

To check (if you haven't the specs of your device reporting the true physical space), you can try using the pdftk tool to obtain an uncompressed PDF. You will probably see that a uncompressed PDF of 1024K, or maybe even bigger, will be uploaded without problems... but nothing larger than a maybe 490-500 Kb compressed PDF will be, because the physical space just isn't there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top