public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Simon Horman <horms@verge.net.au>
Cc: linux-m68k@lists.linux-m68k.org, kexec@lists.infradead.org,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH 1/3] kexec: Let slurp_file_len() return the number of bytes read
Date: Tue, 15 Oct 2013 19:50:58 +0200	[thread overview]
Message-ID: <1381859460-13645-2-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1381859460-13645-1-git-send-email-geert@linux-m68k.org>

Add an optional output parameter to slurp_file_len() so it can return the
actual number of bytes read.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Dave Young <dyoung@redhat.com>
---
 kexec/arch/i386/crashdump-x86.c |    5 ++---
 kexec/kexec.c                   |    4 +++-
 kexec/kexec.h                   |    2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index e44fcebbd32b..e2da50b54c91 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -121,7 +121,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
 	struct mem_ehdr ehdr;
 	struct mem_phdr *phdr, *end_phdr;
 	int align;
-	unsigned long size;
+	off_t size;
 	uint32_t elf_flags = 0;
 
 	if (elf_info->machine != EM_X86_64)
@@ -131,8 +131,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
 		return 0;
 
 	align = getpagesize();
-	size = KCORE_ELF_HEADERS_SIZE;
-	buf = slurp_file_len(kcore, size);
+	buf = slurp_file_len(kcore, KCORE_ELF_HEADERS_SIZE, &size);
 	if (!buf) {
 		fprintf(stderr, "Cannot read %s: %s\n", kcore, strerror(errno));
 		return -1;
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 2ce570f7bb43..185c85bef342 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -537,7 +537,7 @@ char *slurp_file(const char *filename, off_t *r_size)
 /* This functions reads either specified number of bytes from the file or
    lesser if EOF is met. */
 
-char *slurp_file_len(const char *filename, off_t size)
+char *slurp_file_len(const char *filename, off_t size, off_t *nread)
 {
 	int fd;
 	char *buf;
@@ -575,6 +575,8 @@ char *slurp_file_len(const char *filename, off_t size)
 		die("Close of %s failed: %s\n",
 			filename, strerror(errno));
 	}
+	if (nread)
+		*nread = progress;
 	return buf;
 }
 
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 2904e03c79b8..8d5b512e365f 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -237,7 +237,7 @@ extern void die(const char *fmt, ...)
 extern void *xmalloc(size_t size);
 extern void *xrealloc(void *ptr, size_t size);
 extern char *slurp_file(const char *filename, off_t *r_size);
-extern char *slurp_file_len(const char *filename, off_t size);
+extern char *slurp_file_len(const char *filename, off_t size, off_t *nread);
 extern char *slurp_decompress_file(const char *filename, off_t *r_size);
 extern unsigned long virt_to_phys(unsigned long addr);
 extern void add_segment(struct kexec_info *info,
-- 
1.7.9.5

  reply	other threads:[~2013-10-15 17:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 17:50 [PATCH v2 0/3] kexec support for Linux/m68k (tools part) Geert Uytterhoeven
2013-10-15 17:50 ` Geert Uytterhoeven [this message]
2013-10-15 17:50 ` [PATCH 2/3] kexec: Extract slurp_fd() Geert Uytterhoeven
2013-10-15 17:51 ` [PATCH 3/3] kexec: Add m68k support Geert Uytterhoeven
2014-09-22 20:04   ` [PATCH] kexec: distribute kexec/arch/m68k/bootinfo.h Andreas Schwab
2014-10-12 19:37   ` Andreas Schwab
2014-10-14  5:06     ` Simon Horman
2013-10-16  7:22 ` [PATCH v2 0/3] kexec support for Linux/m68k (tools part) Simon Horman
2013-11-03 14:08   ` Geert Uytterhoeven
2013-11-05  7:05     ` Simon Horman
2013-12-01 11:40       ` Geert Uytterhoeven
2013-12-13  0:51         ` Simon Horman
2013-12-13  0:53 ` Simon Horman
2013-12-13  8:03   ` Geert Uytterhoeven
2013-12-14  0:31     ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1381859460-13645-2-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox