All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] kexec: determine size of block device
@ 2015-11-09  9:42 Andreas Fenkart
  2015-11-11  2:05 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Fenkart @ 2015-11-09  9:42 UTC (permalink / raw)
  To: kexec; +Cc: Andreas Fenkart

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] kexec: determine size of block device
  2015-11-09  9:42 [PATCH v3] kexec: determine size of block device Andreas Fenkart
@ 2015-11-11  2:05 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2015-11-11  2:05 UTC (permalink / raw)
  To: Andreas Fenkart; +Cc: Andreas Fenkart, kexec

On Mon, Nov 09, 2015 at 10:42:56AM +0100, Andreas Fenkart wrote:
> 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>

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-11  2:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-09  9:42 [PATCH v3] kexec: determine size of block device Andreas Fenkart
2015-11-11  2:05 ` Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.