Skip to contentSkip to conversation

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

PATCH New Austin Morgan 1 participant 1 message Oct 28, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

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().

---
 kexec/kexec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kexec/kexec.c +1 -1
index 10ad41d..e9d6a54 100644
@@ -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)
Signature · 7 lines
1.7.2.2


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec