[PATCH] slurpfile: use lseek() on block nodes instead of fstat() for file size

Austin Morgan admorgan at morgancomputers.net
Thu Oct 28 17:25:27 EDT 2010


fstat() is used to determine the file size before read() and
it requires a files ystem. That means that it can not be used
on block nodes. This makes it impossible to obtain the
kernel from a raw block device.

We can't use this in every case because files in /proc doesn't
support lseek().

Signed-off-by: Austin Morgan <admorgan at morgancomputers.net>
---
 kexec/kexec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index 10ad41d..e9d6a54 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -499,7 +499,7 @@ char *slurp_file(const char *filename, off_t *r_size)
 	 * This does not work on regular files which live in /proc and
 	 * we need this for some /proc/device-tree entries
 	 */
-	if (S_ISCHR(stats.st_mode)) {
+	if (S_ISCHR(stats.st_mode) || S_ISBLK(stats.st_mode)) {
 
 		size = lseek(fd, 0, SEEK_END);
 		if (size < 0)
-- 
1.7.2.2




More information about the kexec mailing list