mmap_cache: record device major and minor numbers

* defs.h (struct mmap_cache_t): Add major and minor fields.
* mmap_cache.c (build_mmap_cache): Record device major and minor numbers.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This commit is contained in:
Masatake YAMATO 2018-02-17 04:37:14 +09:00 committed by Dmitry V. Levin
parent c4e4ca97bc
commit 12f7d721e2
2 changed files with 10 additions and 2 deletions

3
defs.h
View File

@ -734,12 +734,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;
};

View File

@ -83,12 +83,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 that have unknown protection */
@ -144,6 +147,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++;
}