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
2c8af6b8
Commit
2c8af6b8
authored
Sep 19, 2014
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proc_parse: Rework fdinfo parser to use bfd
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
53771adc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
18 deletions
+31
-18
proc_parse.c
proc_parse.c
+31
-18
No files found.
proc_parse.c
View file @
2c8af6b8
...
...
@@ -23,7 +23,7 @@
#include "kerndat.h"
#include "vdso.h"
#include "vma.h"
#include "bfd.h"
#include "proc_parse.h"
#include "cr_options.h"
#include "sysfs_parse.h"
...
...
@@ -1080,7 +1080,7 @@ static void parse_fhandle_encoded(char *tok, FhEntry *fh)
}
}
static
int
parse_timerfd
(
FILE
*
f
,
char
*
buf
,
size_t
size
,
TimerfdEntry
*
tfy
)
static
int
parse_timerfd
(
struct
bfd
*
f
,
char
*
str
,
TimerfdEntry
*
tfy
)
{
/*
* Format is
...
...
@@ -1093,26 +1093,30 @@ static int parse_timerfd(FILE *f, char *buf, size_t size, TimerfdEntry *tfy)
if
(
sscanf
(
buf
,
"clockid: %d"
,
&
tfy
->
clockid
)
!=
1
)
goto
parse_err
;
if
(
!
fgets
(
buf
,
size
,
f
))
str
=
breadline
(
f
);
if
(
str
==
NULL
||
str
==
BREADERR
)
goto
nodata
;
if
(
sscanf
(
buf
,
"ticks: %llu"
,
(
unsigned
long
long
*
)
&
tfy
->
ticks
)
!=
1
)
if
(
sscanf
(
str
,
"ticks: %llu"
,
(
unsigned
long
long
*
)
&
tfy
->
ticks
)
!=
1
)
goto
parse_err
;
if
(
!
fgets
(
buf
,
size
,
f
))
str
=
breadline
(
f
);
if
(
str
==
NULL
||
str
==
BREADERR
)
goto
nodata
;
if
(
sscanf
(
buf
,
"settime flags: 0%o"
,
&
tfy
->
settime_flags
)
!=
1
)
if
(
sscanf
(
str
,
"settime flags: 0%o"
,
&
tfy
->
settime_flags
)
!=
1
)
goto
parse_err
;
if
(
!
fgets
(
buf
,
size
,
f
))
str
=
breadline
(
f
);
if
(
str
==
NULL
||
str
==
BREADERR
)
goto
nodata
;
if
(
sscanf
(
buf
,
"it_value: (%llu, %llu)"
,
if
(
sscanf
(
str
,
"it_value: (%llu, %llu)"
,
(
unsigned
long
long
*
)
&
tfy
->
vsec
,
(
unsigned
long
long
*
)
&
tfy
->
vnsec
)
!=
2
)
goto
parse_err
;
if
(
!
fgets
(
buf
,
size
,
f
))
str
=
breadline
(
f
);
if
(
str
==
NULL
||
str
==
BREADERR
)
goto
nodata
;
if
(
sscanf
(
buf
,
"it_interval: (%llu, %llu)"
,
if
(
sscanf
(
str
,
"it_interval: (%llu, %llu)"
,
(
unsigned
long
long
*
)
&
tfy
->
isec
,
(
unsigned
long
long
*
)
&
tfy
->
insec
)
!=
2
)
goto
parse_err
;
...
...
@@ -1130,20 +1134,29 @@ nodata:
static
int
parse_fdinfo_pid_s
(
int
pid
,
int
fd
,
int
type
,
int
(
*
cb
)(
union
fdinfo_entries
*
e
,
void
*
arg
),
void
*
arg
)
{
FILE
*
f
;
char
str
[
256
]
;
struct
bfd
f
;
char
*
str
;
bool
entry_met
=
false
;
int
ret
=
-
1
;
f
=
f
open_proc
(
pid
,
"fdinfo/%d"
,
fd
);
if
(
!
f
)
{
pr_perror
(
"Can't open
%s to parse"
,
str
);
f
.
fd
=
open_proc
(
pid
,
"fdinfo/%d"
,
fd
);
if
(
f
.
fd
<
0
)
{
pr_perror
(
"Can't open
fdinfo/%d to parse"
,
fd
);
return
-
1
;
}
while
(
fgets
(
str
,
sizeof
(
str
),
f
))
{
if
(
bfdopen
(
&
f
))
return
-
1
;
while
(
1
)
{
union
fdinfo_entries
entry
;
str
=
breadline
(
&
f
);
if
(
!
str
)
break
;
if
(
str
==
BREADERR
)
goto
out
;
if
(
fdinfo_field
(
str
,
"pos"
)
||
fdinfo_field
(
str
,
"flags"
)
||
fdinfo_field
(
str
,
"mnt_id"
))
{
...
...
@@ -1191,7 +1204,7 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
if
(
type
!=
FD_TYPES__TIMERFD
)
goto
parse_err
;
ret
=
parse_timerfd
(
f
,
str
,
sizeof
(
str
)
,
&
entry
.
tfy
);
ret
=
parse_timerfd
(
&
f
,
str
,
&
entry
.
tfy
);
if
(
ret
)
goto
parse_err
;
ret
=
cb
(
&
entry
,
arg
);
...
...
@@ -1394,7 +1407,7 @@ parse_err:
ret
=
-
1
;
pr_perror
(
"%s: error parsing [%s] for %d"
,
__func__
,
str
,
type
);
out:
fclose
(
f
);
bclose
(
&
f
);
return
ret
;
}
...
...
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