[PATCH v1 1/4] [makedumpfile] Add read_string routine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a read_string() wrapper around readmem().

int read_string(int type_addr, unsigned long long addr, char *bufptr, size_t len);

The functionality is similar to that of readmem(), except that we stop reading
when we find an end-of-string marker than reading 'len' bytes.

This will be useful for reading the name of the 'powerpc' platform which is
needed for dynamic page address definition bits.


Signed-off-by: Suzuki K. Poulose <suzuki at in.ibm.com>
---

 makedumpfile.c |   12 ++++++++++++
 makedumpfile.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 901b85c..e978e1c 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -373,6 +373,18 @@ error:
 	return FALSE;
 }
 
+int
+read_string(int type_addr, unsigned long long addr, char *buf, size_t len)
+{
+	int i;
+
+	memset(buf, 0, len);
+	for (i = 0; i < len; i ++)
+		if (!readmem(VADDR, addr + i, &buf[i], 1))
+			break;
+	return i;
+}
+
 int32_t
 get_kernel_version(char *release)
 {
diff --git a/makedumpfile.h b/makedumpfile.h
index e43ea84..9dc254e 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1243,6 +1243,7 @@ extern struct srcfile_table	srcfile_table;
 
 
 int readmem(int type_addr, unsigned long long addr, void *bufptr, size_t size);
+int read_string(int type_addr, unsigned long long addr, char *bufptr, size_t len);
 int get_str_osrelease_from_vmlinux(void);
 int read_vmcoreinfo_xen(void);
 int exclude_xen_user_domain(void);




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux