Skip to content

Commit

Permalink
Update pmparser
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Mar 24, 2021
1 parent 2313823 commit 7af56bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions manager/src/main/jni/pmparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ procmaps_iterator* pmparser_parse(int pid){
procmaps_struct* list_maps=NULL;
procmaps_struct* tmp;
procmaps_struct* current_node=list_maps;
char addr1[20],addr2[20], perm[8], offset[20], dev[10],inode[30],pathname[PATH_MAX];
char addr1[20],addr2[20], offset[20], inode[30];
while( !feof(file) ){
fgets(buf,PROCMAPS_LINE_MAX_LENGTH,file);
//allocate a node
tmp=(procmaps_struct*)malloc(sizeof(procmaps_struct));
//fill the node
_pmparser_split_line(buf,addr1,addr2,perm,offset, dev,inode,pathname);
_pmparser_split_line(buf,addr1,addr2,tmp->perm,offset, tmp->dev,inode,tmp->pathname);
//printf("#%s",buf);
//printf("%s-%s %s %s %s %s\t%s\n",addr1,addr2,perm,offset,dev,inode,pathname);
//addr_start & addr_end
Expand All @@ -57,20 +57,15 @@ procmaps_iterator* pmparser_parse(int pid){
//size
tmp->length=(unsigned long)(tmp->addr_end-tmp->addr_start);
//perm
strcpy(tmp->perm,perm);
tmp->is_r=(perm[0]=='r');
tmp->is_w=(perm[1]=='w');
tmp->is_x=(perm[2]=='x');
tmp->is_p=(perm[3]=='p');
tmp->is_r=(tmp->perm[0]=='r');
tmp->is_w=(tmp->perm[1]=='w');
tmp->is_x=(tmp->perm[2]=='x');
tmp->is_p=(tmp->perm[3]=='p');

//offset
sscanf(offset,"%lx",&tmp->offset );
//device
strcpy(tmp->dev,dev);
//inode
tmp->inode=atoi(inode);
//pathname
strcpy(tmp->pathname,pathname);
tmp->next=NULL;
//attach the node
if(ind==0){
Expand Down
2 changes: 1 addition & 1 deletion manager/src/main/jni/pmparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct procmaps_struct{
char dev[12]; //< dev major:minor
int inode; //< inode of the file that backs the area

char pathname[600]; //< the path of the file that backs the area
char pathname[PATH_MAX]; //< the path of the file that backs the area
//chained list
struct procmaps_struct* next; //<handler of the chinaed list
} procmaps_struct;
Expand Down

0 comments on commit 7af56bb

Please sign in to comment.