summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kexec/kexec.c8
1 files changed, 8 insertions, 0 deletions
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) {