Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
bbab13eb
Commit
bbab13eb
authored
Jan 31, 2014
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proc: Helper for opening vma's file
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
446ab1fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
30 deletions
+40
-30
proc_parse.c
proc_parse.c
+40
-30
No files found.
proc_parse.c
View file @
bbab13eb
...
...
@@ -142,6 +142,43 @@ static inline int is_anon_shmem_map(dev_t dev)
return
kerndat_shmem_dev
==
dev
;
}
static
int
vma_get_mapfile
(
struct
vma_area
*
vma
,
DIR
*
mfd
)
{
char
path
[
32
];
if
(
!
mfd
)
return
0
;
/* Figure out if it's file mapping */
snprintf
(
path
,
sizeof
(
path
),
"%lx-%lx"
,
vma
->
vma
.
start
,
vma
->
vma
.
end
);
/*
* Note that we "open" it in dumper process space
* so later we might refer to it via /proc/self/fd/vm_file_fd
* if needed.
*/
vma
->
vm_file_fd
=
openat
(
dirfd
(
mfd
),
path
,
O_RDONLY
);
if
(
vma
->
vm_file_fd
<
0
)
{
if
(
errno
==
ENXIO
)
{
struct
stat
buf
;
if
(
fstatat
(
dirfd
(
mfd
),
path
,
&
buf
,
0
))
return
-
1
;
if
(
!
S_ISSOCK
(
buf
.
st_mode
))
return
-
1
;
pr_info
(
"Found socket %"
PRIu64
" mapping @%lx
\n
"
,
buf
.
st_ino
,
vma
->
vma
.
start
);
vma
->
vma
.
status
|=
VMA_AREA_SOCKET
|
VMA_AREA_REGULAR
;
vma
->
vm_socket_id
=
buf
.
st_ino
;
}
else
if
(
errno
!=
ENOENT
)
return
-
1
;
}
return
0
;
}
int
parse_smaps
(
pid_t
pid
,
struct
vm_area_list
*
vma_area_list
,
bool
use_map_files
)
{
struct
vma_area
*
vma_area
=
NULL
;
...
...
@@ -230,41 +267,14 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
goto
err
;
}
if
(
map_files_dir
)
{
char
path
[
32
];
/* Figure out if it's file mapping */
snprintf
(
path
,
sizeof
(
path
),
"%lx-%lx"
,
start
,
end
);
/*
* Note that we "open" it in dumper process space
* so later we might refer to it via /proc/self/fd/vm_file_fd
* if needed.
*/
vma_area
->
vm_file_fd
=
openat
(
dirfd
(
map_files_dir
),
path
,
O_RDONLY
);
if
(
vma_area
->
vm_file_fd
<
0
)
{
if
(
errno
==
ENXIO
)
{
struct
stat
buf
;
if
(
fstatat
(
dirfd
(
map_files_dir
),
path
,
&
buf
,
0
))
goto
err_bogus_mapfile
;
if
(
!
S_ISSOCK
(
buf
.
st_mode
))
goto
err_bogus_mapfile
;
pr_info
(
"Found socket %"
PRIu64
" mapping @%lx
\n
"
,
buf
.
st_ino
,
start
);
vma_area
->
vma
.
status
|=
VMA_AREA_SOCKET
|
VMA_AREA_REGULAR
;
vma_area
->
vm_socket_id
=
buf
.
st_ino
;
}
else
if
(
errno
!=
ENOENT
)
goto
err_bogus_mapfile
;
}
}
vma_area
->
vma
.
start
=
start
;
vma_area
->
vma
.
end
=
end
;
vma_area
->
vma
.
pgoff
=
pgoff
;
vma_area
->
vma
.
prot
=
PROT_NONE
;
if
(
vma_get_mapfile
(
vma_area
,
map_files_dir
))
goto
err_bogus_mapfile
;
if
(
r
==
'r'
)
vma_area
->
vma
.
prot
|=
PROT_READ
;
if
(
w
==
'w'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment