From 7c70e8e153012ca743ffb3b967bdb112fd6ecfd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20=C3=96lmann?= Date: Fri, 29 Apr 2016 19:17:59 +0200 Subject: bootstrap_read_devfs(): optionally inform the caller of the buffer size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The size of the buffer allocated in the function is needed if it shall be inspected more closely later. Therefore optionally return it via a new pointer argument. Signed-off-by: Ulrich Ölmann --- lib/bootstrap/devfs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/bootstrap/devfs.c b/lib/bootstrap/devfs.c index 6a3dd76cdd..6d28b1cb4d 100644 --- a/lib/bootstrap/devfs.c +++ b/lib/bootstrap/devfs.c @@ -80,8 +80,8 @@ static unsigned int get_image_size(void *head) } #endif -void* bootstrap_read_devfs(const char *devname, bool use_bb, int offset, - int default_size, int max_size) +void* bootstrap_read_devfs(char *devname, bool use_bb, int offset, + int default_size, int max_size, size_t *bufsize) { int ret; int size = 0; @@ -133,10 +133,13 @@ void* bootstrap_read_devfs(const char *devname, bool use_bb, int offset, ret = cdev_read(cdev, to, size, 0, 0); cdev_close(cdev); - if (ret != size) + if (ret != size) { bootstrap_err("%s: failed to read from %s\n", devname, partname); - else + } else { result = to; + if (bufsize) + *bufsize = size; + } free_memory: free(header); -- cgit v1.2.1 From c98507f40d39633e345230caa00f78c9065da845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20=C3=96lmann?= Date: Fri, 29 Apr 2016 19:36:21 +0200 Subject: bootstrap_read_disk(): optionally inform the caller of the buffer size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The size of the buffer allocated in the function is needed if it shall be inspected more closely later. Therefore optionally return it via a new pointer argument. Signed-off-by: Ulrich Ölmann --- lib/bootstrap/disk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/bootstrap/disk.c b/lib/bootstrap/disk.c index fd016166e6..ed8b1aa407 100644 --- a/lib/bootstrap/disk.c +++ b/lib/bootstrap/disk.c @@ -14,7 +14,7 @@ #include #include -void* bootstrap_read_disk(const char *dev, const char *fstype) +void* bootstrap_read_disk(const char *dev, char *fstype, size_t *bufsize) { int ret; void *buf; @@ -34,5 +34,8 @@ void* bootstrap_read_disk(const char *dev, const char *fstype) return NULL; } + if (bufsize) + *bufsize = len; + return buf; } -- cgit v1.2.1