From: Andreas Fenkart <afenkart@gmail.com>
To: kexec@lists.infradead.org
Cc: Andreas Fenkart <andreas.fenkart@dev.digitalstrom.org>
Subject: [PATCH v3] kexec: determine size of block device
Date: Mon, 9 Nov 2015 10:42:56 +0100 [thread overview]
Message-ID: <1447062176-13234-1-git-send-email-andreas.fenkart@dev.digitalstrom.org> (raw)
starting 'kexec -l /dev/mmcblk0p1' fails since the size of
a block device can not be determined with stat
Signed-off-by: Andreas Fenkart <andreas.fenkart@dev.digitalstrom.org>
---
kexec/kexec.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kexec/kexec.c b/kexec/kexec.c
index ca1e81d..cf6e03d 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -26,6 +26,8 @@
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/reboot.h>
@@ -555,6 +557,12 @@ static char *slurp_file_generic(const char *filename, off_t *r_size,
die("Can not seek to the begin of file %s: %s\n",
filename, strerror(errno));
buf = slurp_fd(fd, filename, size, &nread);
+ } else if (S_ISBLK(stats.st_mode)) {
+ err = ioctl(fd, BLKGETSIZE64, &size);
+ if (err < 0)
+ die("Can't retrieve size of block device %s: %s\n",
+ filename, strerror(errno));
+ buf = slurp_fd(fd, filename, size, &nread);
} else {
size = stats.st_size;
if (use_mmap) {
--
2.6.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next reply other threads:[~2015-11-09 9:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 9:42 Andreas Fenkart [this message]
2015-11-11 2:05 ` [PATCH v3] kexec: determine size of block device 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=1447062176-13234-1-git-send-email-andreas.fenkart@dev.digitalstrom.org \
--to=afenkart@gmail.com \
--cc=andreas.fenkart@dev.digitalstrom.org \
--cc=kexec@lists.infradead.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