starting 'kexec -l /dev/mmcblk0p1' fails since the size of
a block device can not be determined with stat

Signed-off-by: Andreas Fenkart <[email protected]>
---
 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
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to