[PATCH 7/8] mmap_cache: record device major and minor numbers

Masatake YAMATO yamato at redhat.com
Fri Jan 26 20:36:43 UTC 2018


* defs.h (struct mmap_cache_t): add major and minor fields.
* mmap_cache.c: record device major and minor numbers.

Signed-off-by: Masatake YAMATO <yamato at redhat.com>
---
 defs.h       | 3 +++
 mmap_cache.c | 9 +++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/defs.h b/defs.h
index 6c5f293d..881768dd 100644
--- a/defs.h
+++ b/defs.h
@@ -716,12 +716,15 @@ struct mmap_cache_t {
 	 * end_addr    is 0x7fabbb09f000
 	 * mmap_offset is 0x179000
 	 * protections is MMAP_CACHE_PROT_READABLE|MMAP_CACHE_PROT_EXECUTABLE
+	 * major       is 0xfc
+	 * minor       is 0x00
 	 * binary_filename is "/lib/libc-2.11.1.so"
 	 */
 	unsigned long start_addr;
 	unsigned long end_addr;
 	unsigned long mmap_offset;
 	unsigned char protections;
+	unsigned long major, minor;
 	char *binary_filename;
 };
 
diff --git a/mmap_cache.c b/mmap_cache.c
index 336bbdcd..88753071 100644
--- a/mmap_cache.c
+++ b/mmap_cache.c
@@ -81,12 +81,15 @@ build_mmap_cache(struct tcb *tcp)
 		char write_bit;
 		char exec_bit;
 		char shared_bit;
+		unsigned long major, minor;
 		char binary_path[sizeof(buffer)];
 
-		if (sscanf(buffer, "%lx-%lx %c%c%c%c %lx %*x:%*x %*d %[^\n]",
+		if (sscanf(buffer, "%lx-%lx %c%c%c%c %lx %lx:%lx %*d %[^\n]",
 			   &start_addr, &end_addr,
 			   &read_bit, &write_bit, &exec_bit, &shared_bit,
-			   &mmap_offset, binary_path) != 8)
+			   &mmap_offset,
+			   &major, &minor,
+			   binary_path) != 10)
 			continue;
 
 		/* skip mappings having unknown protection */
@@ -142,6 +145,8 @@ build_mmap_cache(struct tcb *tcp)
 			| ((exec_bit   == 'x')? MMAP_CACHE_PROT_EXECUTABLE: 0)
 			| ((shared_bit == 's')? MMAP_CACHE_PROT_SHARED    : 0)
 			);
+		entry->major = major;
+		entry->minor = minor;
 		entry->binary_filename = xstrdup(binary_path);
 		tcp->mmap_cache_size++;
 	}
-- 
2.14.3





More information about the Strace-devel mailing list