From 20d78d563e552823b4a01d04199b8027ef3a3447 Mon Sep 17 00:00:00 2001 From: marcel Date: Thu, 15 May 2014 00:48:05 +0000 Subject: [PATCH] Have the format resize twice. The first time is before we call scheme_write(). The second time is immediately before we call the format's write function. The first call is needed to have the scheme know the right image size. The second call is needed to compensate for the scheme adjusting the size while writing. --- format.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/format.c b/format.c index 5afcf982c54..57bbd98d047 100644 --- a/format.c +++ b/format.c @@ -48,7 +48,7 @@ int format_resize(lba_t end) { - if (format == NULL || format->resize == NULL) + if (format == NULL) return (ENOSYS); return (format->resize(end)); } @@ -78,8 +78,14 @@ format_selected(void) int format_write(int fd) { + lba_t size; + int error; - if (format == NULL || format->write == NULL) + if (format == NULL) return (ENOSYS); - return (format->write(fd)); + size = image_get_size(); + error = format->resize(size); + if (!error) + error = format->write(fd); + return (error); } -- 2.45.2