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
57095eb9
Commit
57095eb9
authored
Jun 27, 2012
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util: Helper for reading a string from image
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
fc416d86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
files-reg.c
files-reg.c
+1
-10
util.h
include/util.h
+27
-0
No files found.
files-reg.c
View file @
57095eb9
...
@@ -394,8 +394,6 @@ int collect_reg_files(void)
...
@@ -394,8 +394,6 @@ int collect_reg_files(void)
return
-
1
;
return
-
1
;
while
(
1
)
{
while
(
1
)
{
int
len
;
rfi
=
xmalloc
(
sizeof
(
*
rfi
));
rfi
=
xmalloc
(
sizeof
(
*
rfi
));
ret
=
-
1
;
ret
=
-
1
;
if
(
rfi
==
NULL
)
if
(
rfi
==
NULL
)
...
@@ -406,18 +404,11 @@ int collect_reg_files(void)
...
@@ -406,18 +404,11 @@ int collect_reg_files(void)
if
(
ret
<=
0
)
if
(
ret
<=
0
)
break
;
break
;
len
=
rfi
->
rfe
.
len
;
ret
=
read_img_str
(
fd
,
&
rfi
->
path
,
rfi
->
rfe
.
len
);
rfi
->
path
=
xmalloc
(
len
+
1
);
ret
=
-
1
;
if
(
rfi
->
path
==
NULL
)
break
;
ret
=
read_img_buf
(
fd
,
rfi
->
path
,
len
);
if
(
ret
<
0
)
if
(
ret
<
0
)
break
;
break
;
rfi
->
remap_path
=
NULL
;
rfi
->
remap_path
=
NULL
;
rfi
->
path
[
len
]
=
'\0'
;
pr_info
(
"Collected [%s] ID %#x
\n
"
,
rfi
->
path
,
rfi
->
rfe
.
id
);
pr_info
(
"Collected [%s] ID %#x
\n
"
,
rfi
->
path
,
rfi
->
rfe
.
id
);
file_desc_add
(
&
rfi
->
d
,
rfi
->
rfe
.
id
,
&
reg_desc_ops
);
file_desc_add
(
&
rfi
->
d
,
rfi
->
rfe
.
id
,
&
reg_desc_ops
);
...
...
include/util.h
View file @
57095eb9
...
@@ -235,6 +235,8 @@ int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
...
@@ -235,6 +235,8 @@ int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
___p; \
___p; \
})
})
#include <stdlib.h>
#define xstrdup(str) __xalloc(strdup, strlen(str) + 1, str)
#define xstrdup(str) __xalloc(strdup, strlen(str) + 1, str)
#define xmalloc(size) __xalloc(malloc, size, size)
#define xmalloc(size) __xalloc(malloc, size, size)
#define xzalloc(size) __xalloc(calloc, size, 1, size)
#define xzalloc(size) __xalloc(calloc, size, 1, size)
...
@@ -287,4 +289,29 @@ int is_anon_link_type(int lfd, char *type);
...
@@ -287,4 +289,29 @@ int is_anon_link_type(int lfd, char *type);
((c) >= 'a' && (c) <= 'f') || \
((c) >= 'a' && (c) <= 'f') || \
((c) >= 'A' && (c) <= 'F'))
((c) >= 'A' && (c) <= 'F'))
/*
* read_img_str -- same as read_img_buf, but allocates memory for
* the buffer and puts the '\0' at the end
*/
static
inline
int
read_img_str
(
int
fd
,
char
**
pstr
,
int
size
)
{
int
ret
;
char
*
str
;
str
=
xmalloc
(
size
+
1
);
if
(
!
str
)
return
-
1
;
ret
=
read_img_buf
(
fd
,
str
,
size
);
if
(
ret
<
0
)
{
xfree
(
str
);
return
-
1
;
}
str
[
size
]
=
'\0'
;
*
pstr
=
str
;
return
0
;
}
#endif
/* UTIL_H_ */
#endif
/* UTIL_H_ */
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