[Patch 17/21] Calculate the size of the core file

From: Suzuki K. Poulose
Date: Tue Dec 14 2010 - 05:20:30 EST


Calculate the size of the core file

Signed-off-by: Suzuki K. Poulose <suzuki@xxxxxxxxxx>
Signed-off-by: Ananth N. Mavinakayanahalli <ananth@xxxxxxxxxx>

---
fs/proc/gencore-elf.c | 6 ++++++
fs/proc/gencore.h | 1 +
2 files changed, 7 insertions(+)

Index: linux-2.6.36-rc7/fs/proc/gencore.h
===================================================================
--- linux-2.6.36-rc7.orig/fs/proc/gencore.h
+++ linux-2.6.36-rc7/fs/proc/gencore.h
@@ -27,6 +27,7 @@ struct core_proc {
size_t elf_buflen; /* size of elf_buf */
size_t nphdrs; /* number of phdrs */
size_t notes_size;
+ size_t size;
};

extern void try_to_freeze_core_threads(struct core_proc *cp);
Index: linux-2.6.36-rc7/fs/proc/gencore-elf.c
===================================================================
--- linux-2.6.36-rc7.orig/fs/proc/gencore-elf.c
+++ linux-2.6.36-rc7/fs/proc/gencore-elf.c
@@ -310,6 +310,9 @@ static int create_elf_header(struct core
dataoff, cp->nphdrs);
dataoff += sizeof(struct elf_shdr);
}
+
+ cp->size = dataoff;
+
/* Store the notes */
tinfo = cp->tinfo;
do {
@@ -371,6 +374,9 @@ ssize_t elf_read_gencore(struct core_pro
}
}

+ if (*fpos > cp->size)
+ goto out;
+
out:
return ret;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/