[PATCH] fastboot: sparse: print descriptive error on overflowing destination

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fastboot flash of both regular files and barebox update handlers will
print a message if the file being written doesn't fit the destination:

  barebox update:  "Image (%zd) is too big for device (%lld)\n"
  fastboot:        "write: No space left on device\n"

With sparse images however, not the write will fail, but the lseek to
the new offset, triggering a cryptic:

  "writing sparse image: Invalid argument"

Let's improve upon this a bit by translating lseek -EINVAL to -ENOSPC,
so we get:

  "writing sparse image: No space left on device"

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 common/fastboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index 65d1d30f9092..261283d50a3a 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -598,7 +598,7 @@ static int fastboot_handle_sparse(struct fastboot *fb,
 
 			pos = lseek(fd, pos, SEEK_SET);
 			if (pos == -1) {
-				ret = -errno;
+				ret = errno == EINVAL ? -ENOSPC : -errno;
 				goto out;
 			}
 
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux