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
941ee1fe
Unverified
Commit
941ee1fe
authored
Dec 13, 2017
by
Stéphane Graber
Committed by
GitHub
Dec 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2017 from brauner/generic/patch_testing
coverity: bugfixes
parents
352e79d4
9e132956
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
109 additions
and
48 deletions
+109
-48
af_unix.c
src/lxc/af_unix.c
+1
-1
attach.c
src/lxc/attach.c
+19
-7
cgfsng.c
src/lxc/cgroups/cgfsng.c
+1
-2
conf.h
src/lxc/conf.h
+1
-1
confile.c
src/lxc/confile.c
+6
-1
console.c
src/lxc/console.c
+12
-5
criu.c
src/lxc/criu.c
+14
-5
lxc_user_nic.c
src/lxc/lxc_user_nic.c
+1
-1
lxccontainer.c
src/lxc/lxccontainer.c
+4
-6
start.c
src/lxc/start.c
+25
-3
start.h
src/lxc/start.h
+1
-0
overlay.c
src/lxc/storage/overlay.c
+3
-9
storage_utils.c
src/lxc/storage/storage_utils.c
+1
-0
lxc_attach.c
src/lxc/tools/lxc_attach.c
+1
-0
lxc_top.c
src/lxc/tools/lxc_top.c
+9
-4
utils.c
src/lxc/utils.c
+10
-3
No files found.
src/lxc/af_unix.c
View file @
941ee1fe
...
@@ -62,7 +62,7 @@ int lxc_abstract_unix_open(const char *path, int type, int flags)
...
@@ -62,7 +62,7 @@ int lxc_abstract_unix_open(const char *path, int type, int flags)
return
-
1
;
return
-
1
;
}
}
/* addr.sun_path[0] has already been set to 0 by memset() */
/* addr.sun_path[0] has already been set to 0 by memset() */
strncpy
(
&
addr
.
sun_path
[
1
],
&
path
[
1
],
strlen
(
&
path
[
1
])
);
strncpy
(
&
addr
.
sun_path
[
1
],
&
path
[
1
],
len
);
ret
=
bind
(
fd
,
(
struct
sockaddr
*
)
&
addr
,
ret
=
bind
(
fd
,
(
struct
sockaddr
*
)
&
addr
,
offsetof
(
struct
sockaddr_un
,
sun_path
)
+
len
+
1
);
offsetof
(
struct
sockaddr_un
,
sun_path
)
+
len
+
1
);
...
...
src/lxc/attach.c
View file @
941ee1fe
...
@@ -859,13 +859,17 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -859,13 +859,17 @@ int lxc_attach(const char *name, const char *lxcpath,
init_ctx
->
personality
=
personality
;
init_ctx
->
personality
=
personality
;
init_ctx
->
container
=
lxc_container_new
(
name
,
lxcpath
);
init_ctx
->
container
=
lxc_container_new
(
name
,
lxcpath
);
if
(
!
init_ctx
->
container
)
if
(
!
init_ctx
->
container
)
{
lxc_proc_put_context_info
(
init_ctx
);
return
-
1
;
return
-
1
;
}
if
(
!
init_ctx
->
container
->
lxc_conf
)
{
if
(
!
init_ctx
->
container
->
lxc_conf
)
{
init_ctx
->
container
->
lxc_conf
=
lxc_conf_init
();
init_ctx
->
container
->
lxc_conf
=
lxc_conf_init
();
if
(
!
init_ctx
->
container
->
lxc_conf
)
if
(
!
init_ctx
->
container
->
lxc_conf
)
{
lxc_proc_put_context_info
(
init_ctx
);
return
-
ENOMEM
;
return
-
ENOMEM
;
}
}
}
if
(
!
fetch_seccomp
(
init_ctx
->
container
,
options
))
if
(
!
fetch_seccomp
(
init_ctx
->
container
,
options
))
...
@@ -1166,6 +1170,7 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1166,6 +1170,7 @@ int lxc_attach(const char *name, const char *lxcpath,
if
(
ret
<=
0
)
{
if
(
ret
<=
0
)
{
ERROR
(
"Expected to receive sequence number 0: %s."
,
strerror
(
errno
));
ERROR
(
"Expected to receive sequence number 0: %s."
,
strerror
(
errno
));
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
lxc_proc_put_context_info
(
init_ctx
);
rexit
(
-
1
);
rexit
(
-
1
);
}
}
...
@@ -1176,6 +1181,7 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1176,6 +1181,7 @@ int lxc_attach(const char *name, const char *lxcpath,
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"Failed to enter namespaces."
);
ERROR
(
"Failed to enter namespaces."
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
lxc_proc_put_context_info
(
init_ctx
);
rexit
(
-
1
);
rexit
(
-
1
);
}
}
/* close namespace file descriptors */
/* close namespace file descriptors */
...
@@ -1186,9 +1192,11 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1186,9 +1192,11 @@ int lxc_attach(const char *name, const char *lxcpath,
new_cwd
=
options
->
initial_cwd
;
new_cwd
=
options
->
initial_cwd
;
else
else
new_cwd
=
cwd
;
new_cwd
=
cwd
;
ret
=
chdir
(
new_cwd
);
if
(
new_cwd
)
{
if
(
ret
<
0
)
ret
=
chdir
(
new_cwd
);
WARN
(
"Could not change directory to
\"
%s
\"
."
,
new_cwd
);
if
(
ret
<
0
)
WARN
(
"Could not change directory to
\"
%s
\"
"
,
new_cwd
);
}
free
(
cwd
);
free
(
cwd
);
/* Now create the real child process. */
/* Now create the real child process. */
...
@@ -1212,6 +1220,7 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1212,6 +1220,7 @@ int lxc_attach(const char *name, const char *lxcpath,
if
(
pid
<=
0
)
{
if
(
pid
<=
0
)
{
SYSERROR
(
"Failed to create subprocess."
);
SYSERROR
(
"Failed to create subprocess."
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
lxc_proc_put_context_info
(
init_ctx
);
rexit
(
-
1
);
rexit
(
-
1
);
}
}
...
@@ -1226,10 +1235,12 @@ int lxc_attach(const char *name, const char *lxcpath,
...
@@ -1226,10 +1235,12 @@ int lxc_attach(const char *name, const char *lxcpath,
*/
*/
ERROR
(
"Intended to send pid %d: %s."
,
pid
,
strerror
(
errno
));
ERROR
(
"Intended to send pid %d: %s."
,
pid
,
strerror
(
errno
));
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
shutdown
(
ipc_sockets
[
1
],
SHUT_RDWR
);
lxc_proc_put_context_info
(
init_ctx
);
rexit
(
-
1
);
rexit
(
-
1
);
}
}
/* The rest is in the hands of the initial and the attached process. */
/* The rest is in the hands of the initial and the attached process. */
lxc_proc_put_context_info
(
init_ctx
);
rexit
(
0
);
rexit
(
0
);
}
}
...
@@ -1504,7 +1515,6 @@ int lxc_attach_run_shell(void* payload)
...
@@ -1504,7 +1515,6 @@ int lxc_attach_run_shell(void* payload)
user_shell
=
lxc_attach_getpwshell
(
uid
);
user_shell
=
lxc_attach_getpwshell
(
uid
);
else
else
user_shell
=
passwd
->
pw_shell
;
user_shell
=
passwd
->
pw_shell
;
if
(
user_shell
)
if
(
user_shell
)
execlp
(
user_shell
,
user_shell
,
(
char
*
)
NULL
);
execlp
(
user_shell
,
user_shell
,
(
char
*
)
NULL
);
...
@@ -1512,6 +1522,8 @@ int lxc_attach_run_shell(void* payload)
...
@@ -1512,6 +1522,8 @@ int lxc_attach_run_shell(void* payload)
* on /bin/sh as a default shell.
* on /bin/sh as a default shell.
*/
*/
execlp
(
"/bin/sh"
,
"/bin/sh"
,
(
char
*
)
NULL
);
execlp
(
"/bin/sh"
,
"/bin/sh"
,
(
char
*
)
NULL
);
SYSERROR
(
"Failed to exec shell."
);
SYSERROR
(
"Failed to execute shell"
);
if
(
!
passwd
)
free
(
user_shell
);
return
-
1
;
return
-
1
;
}
}
src/lxc/cgroups/cgfsng.c
View file @
941ee1fe
...
@@ -766,8 +766,7 @@ static char **get_controllers(char **klist, char **nlist, char *line, int type)
...
@@ -766,8 +766,7 @@ static char **get_controllers(char **klist, char **nlist, char *line, int type)
return
NULL
;
return
NULL
;
p
++
;
p
++
;
}
}
if
(
!
p
)
return
NULL
;
/* note - if we change how mountinfo works, then our caller
/* note - if we change how mountinfo works, then our caller
* will need to verify /sys/fs/cgroup/ in this field */
* will need to verify /sys/fs/cgroup/ in this field */
if
(
strncmp
(
p
,
"/sys/fs/cgroup/"
,
15
))
{
if
(
strncmp
(
p
,
"/sys/fs/cgroup/"
,
15
))
{
...
...
src/lxc/conf.h
View file @
941ee1fe
...
@@ -386,7 +386,7 @@ struct lxc_conf {
...
@@ -386,7 +386,7 @@ struct lxc_conf {
char
*
inherit_ns
[
LXC_NS_MAX
];
char
*
inherit_ns
[
LXC_NS_MAX
];
/* init working directory */
/* init working directory */
char
*
init_cwd
;
char
*
init_cwd
;
/* A list of clients registered to be informed about a container state. */
/* A list of clients registered to be informed about a container state. */
struct
lxc_list
state_clients
;
struct
lxc_list
state_clients
;
...
...
src/lxc/confile.c
View file @
941ee1fe
...
@@ -773,8 +773,13 @@ static int set_config_net_ipv6_address(const char *key, const char *value,
...
@@ -773,8 +773,13 @@ static int set_config_net_ipv6_address(const char *key, const char *value,
if
(
slash
)
{
if
(
slash
)
{
*
slash
=
'\0'
;
*
slash
=
'\0'
;
netmask
=
slash
+
1
;
netmask
=
slash
+
1
;
if
(
lxc_safe_uint
(
netmask
,
&
inet6dev
->
prefix
)
<
0
)
ret
=
lxc_safe_uint
(
netmask
,
&
inet6dev
->
prefix
);
if
(
ret
<
0
)
{
free
(
list
);
free
(
inet6dev
);
free
(
valdup
);
return
-
1
;
return
-
1
;
}
}
}
ret
=
inet_pton
(
AF_INET6
,
valdup
,
&
inet6dev
->
addr
);
ret
=
inet_pton
(
AF_INET6
,
valdup
,
&
inet6dev
->
addr
);
...
...
src/lxc/console.c
View file @
941ee1fe
...
@@ -588,15 +588,22 @@ void lxc_console_delete(struct lxc_console *console)
...
@@ -588,15 +588,22 @@ void lxc_console_delete(struct lxc_console *console)
free
(
console
->
tios
);
free
(
console
->
tios
);
console
->
tios
=
NULL
;
console
->
tios
=
NULL
;
close
(
console
->
peer
);
if
(
console
->
peer
>=
0
)
close
(
console
->
master
);
close
(
console
->
peer
);
close
(
console
->
slave
);
if
(
console
->
log_fd
>=
0
)
close
(
console
->
log_fd
);
console
->
peer
=
-
1
;
console
->
peer
=
-
1
;
if
(
console
->
master
>=
0
)
close
(
console
->
master
);
console
->
master
=
-
1
;
console
->
master
=
-
1
;
if
(
console
->
slave
>=
0
)
close
(
console
->
slave
);
console
->
slave
=
-
1
;
console
->
slave
=
-
1
;
if
(
console
->
log_fd
>=
0
)
close
(
console
->
log_fd
);
console
->
log_fd
=
-
1
;
console
->
log_fd
=
-
1
;
if
(
console
->
buffer_log_file_fd
>=
0
)
if
(
console
->
buffer_log_file_fd
>=
0
)
close
(
console
->
buffer_log_file_fd
);
close
(
console
->
buffer_log_file_fd
);
console
->
buffer_log_file_fd
=
-
1
;
console
->
buffer_log_file_fd
=
-
1
;
...
...
src/lxc/criu.c
View file @
941ee1fe
...
@@ -1120,14 +1120,16 @@ static int save_tty_major_minor(char *directory, struct lxc_container *c, char *
...
@@ -1120,14 +1120,16 @@ static int save_tty_major_minor(char *directory, struct lxc_container *c, char *
/* do one of either predump or a regular dump */
/* do one of either predump or a regular dump */
static
bool
do_dump
(
struct
lxc_container
*
c
,
char
*
mode
,
struct
migrate_opts
*
opts
)
static
bool
do_dump
(
struct
lxc_container
*
c
,
char
*
mode
,
struct
migrate_opts
*
opts
)
{
{
int
ret
;
pid_t
pid
;
pid_t
pid
;
char
*
criu_version
=
NULL
;
int
criuout
[
2
];
int
criuout
[
2
];
char
*
criu_version
=
NULL
;
if
(
!
criu_ok
(
c
,
&
criu_version
))
if
(
!
criu_ok
(
c
,
&
criu_version
))
return
false
;
return
false
;
if
(
pipe
(
criuout
)
<
0
)
{
ret
=
pipe
(
criuout
);
if
(
ret
<
0
)
{
SYSERROR
(
"pipe() failed"
);
SYSERROR
(
"pipe() failed"
);
return
false
;
return
false
;
}
}
...
@@ -1147,6 +1149,8 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
...
@@ -1147,6 +1149,8 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
close
(
criuout
[
0
]);
close
(
criuout
[
0
]);
lxc_zero_handler
(
&
h
);
h
.
name
=
c
->
name
;
h
.
name
=
c
->
name
;
if
(
!
cgroup_init
(
&
h
))
{
if
(
!
cgroup_init
(
&
h
))
{
ERROR
(
"failed to cgroup_init()"
);
ERROR
(
"failed to cgroup_init()"
);
...
@@ -1160,12 +1164,16 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
...
@@ -1160,12 +1164,16 @@ static bool do_dump(struct lxc_container *c, char *mode, struct migrate_opts *op
os
.
console_name
=
c
->
lxc_conf
->
console
.
path
;
os
.
console_name
=
c
->
lxc_conf
->
console
.
path
;
os
.
criu_version
=
criu_version
;
os
.
criu_version
=
criu_version
;
if
(
save_tty_major_minor
(
opts
->
directory
,
c
,
os
.
tty_id
,
sizeof
(
os
.
tty_id
))
<
0
)
ret
=
save_tty_major_minor
(
opts
->
directory
,
c
,
os
.
tty_id
,
sizeof
(
os
.
tty_id
));
exit
(
1
);
if
(
ret
<
0
)
{
free
(
criu_version
);
exit
(
EXIT_FAILURE
);
}
/* exec_criu() returning is an error */
/* exec_criu() returning is an error */
exec_criu
(
&
os
);
exec_criu
(
&
os
);
exit
(
1
);
free
(
criu_version
);
exit
(
EXIT_FAILURE
);
}
else
{
}
else
{
int
status
;
int
status
;
ssize_t
n
;
ssize_t
n
;
...
@@ -1212,6 +1220,7 @@ fail:
...
@@ -1212,6 +1220,7 @@ fail:
close
(
criuout
[
0
]);
close
(
criuout
[
0
]);
close
(
criuout
[
1
]);
close
(
criuout
[
1
]);
rmdir
(
opts
->
directory
);
rmdir
(
opts
->
directory
);
free
(
criu_version
);
return
false
;
return
false
;
}
}
...
...
src/lxc/lxc_user_nic.c
View file @
941ee1fe
...
@@ -625,8 +625,8 @@ static bool cull_entries(int fd, char *name, char *net_type, char *net_link,
...
@@ -625,8 +625,8 @@ static bool cull_entries(int fd, char *name, char *net_type, char *net_link,
}
}
free
(
entry_lines
);
free
(
entry_lines
);
lxc_strmunmap
(
buf
,
sb
.
st_size
);
ret
=
ftruncate
(
fd
,
buf_start
-
buf
);
ret
=
ftruncate
(
fd
,
buf_start
-
buf
);
lxc_strmunmap
(
buf
,
sb
.
st_size
);
if
(
ret
<
0
)
if
(
ret
<
0
)
usernic_error
(
"Failed to set new file size: %s
\n
"
,
usernic_error
(
"Failed to set new file size: %s
\n
"
,
strerror
(
errno
));
strerror
(
errno
));
...
...
src/lxc/lxccontainer.c
View file @
941ee1fe
...
@@ -656,9 +656,6 @@ static bool am_single_threaded(void)
...
@@ -656,9 +656,6 @@ static bool am_single_threaded(void)
}
}
while
((
direntp
=
readdir
(
dir
)))
{
while
((
direntp
=
readdir
(
dir
)))
{
if
(
!
direntp
)
break
;
if
(
!
strcmp
(
direntp
->
d_name
,
"."
))
if
(
!
strcmp
(
direntp
->
d_name
,
"."
))
continue
;
continue
;
...
@@ -2177,11 +2174,14 @@ static char ** do_lxcapi_get_interfaces(struct lxc_container *c)
...
@@ -2177,11 +2174,14 @@ static char ** do_lxcapi_get_interfaces(struct lxc_container *c)
close
(
pipefd
[
1
]);
close
(
pipefd
[
1
]);
while
(
read
(
pipefd
[
0
],
&
interface
,
IFNAMSIZ
)
==
IFNAMSIZ
)
{
while
(
read
(
pipefd
[
0
],
&
interface
,
IFNAMSIZ
)
==
IFNAMSIZ
)
{
interface
[
IFNAMSIZ
-
1
]
=
'\0'
;
if
(
array_contains
(
&
interfaces
,
interface
,
count
))
if
(
array_contains
(
&
interfaces
,
interface
,
count
))
continue
;
continue
;
if
(
!
add_to_array
(
&
interfaces
,
interface
,
count
))
if
(
!
add_to_array
(
&
interfaces
,
interface
,
count
))
ERROR
(
"PARENT: add_to_array failed"
);
ERROR
(
"Failed to add
\"
%s
\"
to array"
,
interface
);
count
++
;
count
++
;
}
}
...
@@ -4192,8 +4192,6 @@ static bool remove_all_snapshots(const char *path)
...
@@ -4192,8 +4192,6 @@ static bool remove_all_snapshots(const char *path)
return
false
;
return
false
;
}
}
while
((
direntp
=
readdir
(
dir
)))
{
while
((
direntp
=
readdir
(
dir
)))
{
if
(
!
direntp
)
break
;
if
(
!
strcmp
(
direntp
->
d_name
,
"."
))
if
(
!
strcmp
(
direntp
->
d_name
,
"."
))
continue
;
continue
;
if
(
!
strcmp
(
direntp
->
d_name
,
".."
))
if
(
!
strcmp
(
direntp
->
d_name
,
".."
))
...
...
src/lxc/start.c
View file @
941ee1fe
...
@@ -203,9 +203,6 @@ restart:
...
@@ -203,9 +203,6 @@ restart:
struct
lxc_list
*
cur
;
struct
lxc_list
*
cur
;
bool
matched
=
false
;
bool
matched
=
false
;
if
(
!
direntp
)
break
;
if
(
!
strcmp
(
direntp
->
d_name
,
"."
))
if
(
!
strcmp
(
direntp
->
d_name
,
"."
))
continue
;
continue
;
...
@@ -507,6 +504,31 @@ out_sigfd:
...
@@ -507,6 +504,31 @@ out_sigfd:
return
-
1
;
return
-
1
;
}
}
void
lxc_zero_handler
(
struct
lxc_handler
*
handler
)
{
int
i
;
memset
(
handler
,
0
,
sizeof
(
struct
lxc_handler
));
handler
->
clone_flags
=
-
1
;
handler
->
pinfd
=
-
1
;
handler
->
sigfd
=
-
1
;
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
handler
->
nsfd
[
i
]
=
-
1
;
handler
->
data_sock
[
0
]
=
-
1
;
handler
->
data_sock
[
1
]
=
-
1
;
handler
->
state_socket_pair
[
0
]
=
-
1
;
handler
->
state_socket_pair
[
1
]
=
-
1
;
handler
->
sync_sock
[
0
]
=
-
1
;
handler
->
sync_sock
[
1
]
=
-
1
;
}
void
lxc_free_handler
(
struct
lxc_handler
*
handler
)
void
lxc_free_handler
(
struct
lxc_handler
*
handler
)
{
{
if
(
handler
->
conf
&&
handler
->
conf
->
maincmd_fd
)
if
(
handler
->
conf
&&
handler
->
conf
->
maincmd_fd
)
...
...
src/lxc/start.h
View file @
941ee1fe
...
@@ -120,6 +120,7 @@ extern struct lxc_handler *lxc_init_handler(const char *name,
...
@@ -120,6 +120,7 @@ extern struct lxc_handler *lxc_init_handler(const char *name,
struct
lxc_conf
*
conf
,
struct
lxc_conf
*
conf
,
const
char
*
lxcpath
,
const
char
*
lxcpath
,
bool
daemonize
);
bool
daemonize
);
extern
void
lxc_zero_handler
(
struct
lxc_handler
*
handler
);
extern
void
lxc_free_handler
(
struct
lxc_handler
*
handler
);
extern
void
lxc_free_handler
(
struct
lxc_handler
*
handler
);
extern
int
lxc_init
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
extern
int
lxc_init
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
extern
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
extern
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
...
...
src/lxc/storage/overlay.c
View file @
941ee1fe
...
@@ -207,8 +207,8 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
...
@@ -207,8 +207,8 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
odelta
=
strchr
(
nsrc
,
':'
);
odelta
=
strchr
(
nsrc
,
':'
);
if
(
!
odelta
)
{
if
(
!
odelta
)
{
free
(
osrc
);
ERROR
(
"Failed to find
\"
:
\"
in
\"
%s
\"
"
,
nsrc
);
ERROR
(
"Failed to find
\"
:
\"
in
\"
%s
\"
"
,
nsrc
);
free
(
osrc
);
return
-
22
;
return
-
22
;
}
}
...
@@ -722,15 +722,9 @@ char *ovl_get_rootfs(const char *rootfs_path, size_t *rootfslen)
...
@@ -722,15 +722,9 @@ char *ovl_get_rootfs(const char *rootfs_path, size_t *rootfslen)
*
s3
=
'\0'
;
*
s3
=
'\0'
;
rootfsdir
=
strdup
(
s2
);
rootfsdir
=
strdup
(
s2
);
if
(
!
rootfsdir
)
{
free
(
s1
);
free
(
s1
);
return
NULL
;
}
if
(
!
rootfsdir
)
if
(
!
rootfsdir
)
rootfsdir
=
s1
;
return
NULL
;
else
free
(
s1
);
*
rootfslen
=
strlen
(
rootfsdir
);
*
rootfslen
=
strlen
(
rootfsdir
);
...
...
src/lxc/storage/storage_utils.c
View file @
941ee1fe
...
@@ -280,6 +280,7 @@ int do_mkfs_exec_wrapper(void *args)
...
@@ -280,6 +280,7 @@ int do_mkfs_exec_wrapper(void *args)
TRACE
(
"executing
\"
%s %s
\"
"
,
mkfs
,
data
[
1
]);
TRACE
(
"executing
\"
%s %s
\"
"
,
mkfs
,
data
[
1
]);
execlp
(
mkfs
,
mkfs
,
data
[
1
],
(
char
*
)
NULL
);
execlp
(
mkfs
,
mkfs
,
data
[
1
],
(
char
*
)
NULL
);
SYSERROR
(
"failed to run
\"
%s %s
\"
"
,
mkfs
,
data
[
1
]);
SYSERROR
(
"failed to run
\"
%s %s
\"
"
,
mkfs
,
data
[
1
]);
free
(
mkfs
);
return
-
1
;
return
-
1
;
}
}
...
...
src/lxc/tools/lxc_attach.c
View file @
941ee1fe
...
@@ -348,6 +348,7 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
...
@@ -348,6 +348,7 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
if
(
c
->
attach
(
c
,
get_pty_on_host_callback
,
wrap
,
wrap
->
options
,
pid
)
<
0
)
if
(
c
->
attach
(
c
,
get_pty_on_host_callback
,
wrap
,
wrap
->
options
,
pid
)
<
0
)
goto
err1
;
goto
err1
;
close
(
conf
->
console
.
slave
);
/* Close slave side. */
close
(
conf
->
console
.
slave
);
/* Close slave side. */
conf
->
console
.
slave
=
-
1
;
ret
=
lxc_mainloop_open
(
&
descr
);
ret
=
lxc_mainloop_open
(
&
descr
);
if
(
ret
)
{
if
(
ret
)
{
...
...
src/lxc/tools/lxc_top.c
View file @
941ee1fe
...
@@ -206,21 +206,26 @@ static void sig_handler(int sig)
...
@@ -206,21 +206,26 @@ static void sig_handler(int sig)
static
void
size_humanize
(
unsigned
long
long
val
,
char
*
buf
,
size_t
bufsz
)
static
void
size_humanize
(
unsigned
long
long
val
,
char
*
buf
,
size_t
bufsz
)
{
{
int
ret
;
if
(
val
>
1
<<
30
)
{
if
(
val
>
1
<<
30
)
{
snprintf
(
buf
,
bufsz
,
"%u.%2.2u GiB"
,
ret
=
snprintf
(
buf
,
bufsz
,
"%u.%2.2u GiB"
,
(
unsigned
int
)(
val
>>
30
),
(
unsigned
int
)(
val
>>
30
),
(
unsigned
int
)(
val
&
((
1
<<
30
)
-
1
))
/
10737419
);
(
unsigned
int
)(
val
&
((
1
<<
30
)
-
1
))
/
10737419
);
}
else
if
(
val
>
1
<<
20
)
{
}
else
if
(
val
>
1
<<
20
)
{
unsigned
int
x
=
val
+
5243
;
/* for rounding */
unsigned
int
x
=
val
+
5243
;
/* for rounding */
snprintf
(
buf
,
bufsz
,
"%u.%2.2u MiB"
,
ret
=
snprintf
(
buf
,
bufsz
,
"%u.%2.2u MiB"
,
x
>>
20
,
((
x
&
((
1
<<
20
)
-
1
))
*
100
)
>>
20
);
x
>>
20
,
((
x
&
((
1
<<
20
)
-
1
))
*
100
)
>>
20
);
}
else
if
(
val
>
1
<<
10
)
{
}
else
if
(
val
>
1
<<
10
)
{
unsigned
int
x
=
val
+
5
;
/* for rounding */
unsigned
int
x
=
val
+
5
;
/* for rounding */
snprintf
(
buf
,
bufsz
,
"%u.%2.2u KiB"
,
ret
=
snprintf
(
buf
,
bufsz
,
"%u.%2.2u KiB"
,
x
>>
10
,
((
x
&
((
1
<<
10
)
-
1
))
*
100
)
>>
10
);
x
>>
10
,
((
x
&
((
1
<<
10
)
-
1
))
*
100
)
>>
10
);
}
else
{
}
else
{
snprintf
(
buf
,
bufsz
,
"%3u.00 "
,
(
unsigned
int
)
val
);
ret
=
snprintf
(
buf
,
bufsz
,
"%3u.00 "
,
(
unsigned
int
)
val
);
}
}
if
(
ret
<
0
||
(
size_t
)
ret
>=
bufsz
)
fprintf
(
stderr
,
"Failed to create string
\n
"
);
}
}
static
uint64_t
stat_get_int
(
struct
lxc_container
*
c
,
const
char
*
item
)
static
uint64_t
stat_get_int
(
struct
lxc_container
*
c
,
const
char
*
item
)
...
...
src/lxc/utils.c
View file @
941ee1fe
...
@@ -717,10 +717,12 @@ char *lxc_deslashify(const char *path)
...
@@ -717,10 +717,12 @@ char *lxc_deslashify(const char *path)
char
*
lxc_append_paths
(
const
char
*
first
,
const
char
*
second
)
char
*
lxc_append_paths
(
const
char
*
first
,
const
char
*
second
)
{
{
size_t
len
=
strlen
(
first
)
+
strlen
(
second
)
+
1
;
int
ret
;
const
char
*
pattern
=
"%s%s"
;
size_t
len
;
char
*
result
=
NULL
;
char
*
result
=
NULL
;
const
char
*
pattern
=
"%s%s"
;
len
=
strlen
(
first
)
+
strlen
(
second
)
+
1
;
if
(
second
[
0
]
!=
'/'
)
{
if
(
second
[
0
]
!=
'/'
)
{
len
+=
1
;
len
+=
1
;
pattern
=
"%s/%s"
;
pattern
=
"%s/%s"
;
...
@@ -730,7 +732,12 @@ char *lxc_append_paths(const char *first, const char *second)
...
@@ -730,7 +732,12 @@ char *lxc_append_paths(const char *first, const char *second)
if
(
!
result
)
if
(
!
result
)
return
NULL
;
return
NULL
;
snprintf
(
result
,
len
,
pattern
,
first
,
second
);
ret
=
snprintf
(
result
,
len
,
pattern
,
first
,
second
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
{
free
(
result
);
return
NULL
;
}
return
result
;
return
result
;
}
}
...
...
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