Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Chen Yisong
lxc
Commits
db1d87ec
Unverified
Commit
db1d87ec
authored
Aug 31, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: pass around intmax_t
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
d3e91192
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
commands.c
src/lxc/commands.c
+13
-3
macro.h
src/lxc/macro.h
+3
-0
No files found.
src/lxc/commands.c
View file @
db1d87ec
...
@@ -375,12 +375,13 @@ int lxc_try_cmd(const char *name, const char *lxcpath)
...
@@ -375,12 +375,13 @@ int lxc_try_cmd(const char *name, const char *lxcpath)
pid_t
lxc_cmd_get_init_pid
(
const
char
*
name
,
const
char
*
lxcpath
)
pid_t
lxc_cmd_get_init_pid
(
const
char
*
name
,
const
char
*
lxcpath
)
{
{
int
ret
,
stopped
;
int
ret
,
stopped
;
intmax_t
pid
;
struct
lxc_cmd_rr
cmd
=
{
struct
lxc_cmd_rr
cmd
=
{
.
req
=
{
.
req
=
{
.
cmd
=
LXC_CMD_GET_INIT_PID
.
cmd
=
LXC_CMD_GET_INIT_PID
},
},
.
rsp
=
{
.
rsp
=
{
.
data
=
INT
_TO_PTR
((
in
t
){
-
1
})
.
data
=
INT
MAX_TO_PTR
((
intmax_
t
){
-
1
})
}
}
};
};
...
@@ -388,13 +389,22 @@ pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath)
...
@@ -388,13 +389,22 @@ pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath)
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
return
PTR_TO_INT
(
cmd
.
rsp
.
data
);
pid
=
PTR_TO_INTMAX
(
cmd
.
rsp
.
data
);
if
(
pid
<
0
)
return
-
1
;
/* We need to assume that pid_t can actually hold any pid given to us
* by the kernel. If it can't it's a libc bug.
*/
return
(
pid_t
)
pid
;
}
}
static
int
lxc_cmd_get_init_pid_callback
(
int
fd
,
struct
lxc_cmd_req
*
req
,
static
int
lxc_cmd_get_init_pid_callback
(
int
fd
,
struct
lxc_cmd_req
*
req
,
struct
lxc_handler
*
handler
)
struct
lxc_handler
*
handler
)
{
{
struct
lxc_cmd_rsp
rsp
=
{
.
data
=
INT_TO_PTR
(
handler
->
pid
)
};
struct
lxc_cmd_rsp
rsp
=
{
.
data
=
INTMAX_TO_PTR
(
handler
->
pid
)
};
return
lxc_cmd_rsp_send
(
fd
,
&
rsp
);
return
lxc_cmd_rsp_send
(
fd
,
&
rsp
);
}
}
...
...
src/lxc/macro.h
View file @
db1d87ec
...
@@ -312,4 +312,7 @@ extern int __build_bug_on_failed;
...
@@ -312,4 +312,7 @@ extern int __build_bug_on_failed;
#define PTR_TO_INT(p) ((int)((intptr_t)(p)))
#define PTR_TO_INT(p) ((int)((intptr_t)(p)))
#define INT_TO_PTR(u) ((void *)((intptr_t)(u)))
#define INT_TO_PTR(u) ((void *)((intptr_t)(u)))
#define PTR_TO_INTMAX(p) ((intmax_t)((intptr_t)(p)))
#define INTMAX_TO_PTR(u) ((void *)((intptr_t)(u)))
#endif
/* __LXC_MACRO_H */
#endif
/* __LXC_MACRO_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