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
8765242a
Unverified
Commit
8765242a
authored
Jan 12, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: move lxc-info to API symbols only
Closes #2073. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
49ac7514
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
11 deletions
+37
-11
lxc_info.c
src/lxc/tools/lxc_info.c
+9
-11
tool_utils.c
src/lxc/tools/tool_utils.c
+27
-0
tool_utils.h
src/lxc/tools/tool_utils.h
+1
-0
No files found.
src/lxc/tools/lxc_info.c
View file @
8765242a
...
@@ -21,21 +21,20 @@
...
@@ -21,21 +21,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#include <stdio.h>
#define _GNU_SOURCE
#include <libgen.h>
#include <limits.h>
#include <stdbool.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#include <limits.h>
#include <libgen.h>
#include <sys/types.h>
#include <sys/types.h>
#include <lxc/lxccontainer.h>
#include <lxc/lxccontainer.h>
#include "lxc.h"
#include "log.h"
#include "utils.h"
#include "commands.h"
#include "arguments.h"
#include "arguments.h"
#include "tool_utils.h"
static
bool
ips
;
static
bool
ips
;
static
bool
state
;
static
bool
state
;
...
@@ -205,7 +204,7 @@ static void print_stats(struct lxc_container *c)
...
@@ -205,7 +204,7 @@ static void print_stats(struct lxc_container *c)
char
buf
[
4096
];
char
buf
[
4096
];
ret
=
c
->
get_cgroup_item
(
c
,
"cpuacct.usage"
,
buf
,
sizeof
(
buf
));
ret
=
c
->
get_cgroup_item
(
c
,
"cpuacct.usage"
,
buf
,
sizeof
(
buf
));
if
(
ret
>
0
&&
ret
<
sizeof
(
buf
))
{
if
(
ret
>
0
&&
(
size_t
)
ret
<
sizeof
(
buf
))
{
str_chomp
(
buf
);
str_chomp
(
buf
);
if
(
humanize
)
{
if
(
humanize
)
{
float
seconds
=
strtof
(
buf
,
NULL
)
/
1000000000
.
0
;
float
seconds
=
strtof
(
buf
,
NULL
)
/
1000000000
.
0
;
...
@@ -217,7 +216,7 @@ static void print_stats(struct lxc_container *c)
...
@@ -217,7 +216,7 @@ static void print_stats(struct lxc_container *c)
}
}
ret
=
c
->
get_cgroup_item
(
c
,
"blkio.throttle.io_service_bytes"
,
buf
,
sizeof
(
buf
));
ret
=
c
->
get_cgroup_item
(
c
,
"blkio.throttle.io_service_bytes"
,
buf
,
sizeof
(
buf
));
if
(
ret
>
0
&&
ret
<
sizeof
(
buf
))
{
if
(
ret
>
0
&&
(
size_t
)
ret
<
sizeof
(
buf
))
{
char
*
ch
;
char
*
ch
;
/* put ch on last "Total" line */
/* put ch on last "Total" line */
...
@@ -247,7 +246,7 @@ static void print_stats(struct lxc_container *c)
...
@@ -247,7 +246,7 @@ static void print_stats(struct lxc_container *c)
for
(
i
=
0
;
lxstat
[
i
].
name
;
i
++
)
{
for
(
i
=
0
;
lxstat
[
i
].
name
;
i
++
)
{
ret
=
c
->
get_cgroup_item
(
c
,
lxstat
[
i
].
file
,
buf
,
sizeof
(
buf
));
ret
=
c
->
get_cgroup_item
(
c
,
lxstat
[
i
].
file
,
buf
,
sizeof
(
buf
));
if
(
ret
>
0
&&
ret
<
sizeof
(
buf
))
{
if
(
ret
>
0
&&
(
size_t
)
ret
<
sizeof
(
buf
))
{
str_chomp
(
buf
);
str_chomp
(
buf
);
str_size_humanize
(
buf
,
sizeof
(
buf
));
str_size_humanize
(
buf
,
sizeof
(
buf
));
printf
(
"%-15s %s
\n
"
,
lxstat
[
i
].
name
,
buf
);
printf
(
"%-15s %s
\n
"
,
lxstat
[
i
].
name
,
buf
);
...
@@ -409,7 +408,6 @@ int main(int argc, char *argv[])
...
@@ -409,7 +408,6 @@ int main(int argc, char *argv[])
if
(
lxc_log_init
(
&
log
))
if
(
lxc_log_init
(
&
log
))
exit
(
ret
);
exit
(
ret
);
lxc_log_options_no_override
();
/* REMOVE IN LXC 3.0 */
/* REMOVE IN LXC 3.0 */
setenv
(
"LXC_UPDATE_CONFIG_FORMAT"
,
"1"
,
0
);
setenv
(
"LXC_UPDATE_CONFIG_FORMAT"
,
"1"
,
0
);
...
...
src/lxc/tools/tool_utils.c
View file @
8765242a
...
@@ -823,3 +823,30 @@ void lxc_config_define_free(struct lxc_list *defines)
...
@@ -823,3 +823,30 @@ void lxc_config_define_free(struct lxc_list *defines)
free
(
it
);
free
(
it
);
}
}
}
}
int
lxc_read_from_file
(
const
char
*
filename
,
void
*
buf
,
size_t
count
)
{
int
fd
=
-
1
,
saved_errno
;
ssize_t
ret
;
fd
=
open
(
filename
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd
<
0
)
return
-
1
;
if
(
!
buf
||
!
count
)
{
char
buf2
[
100
];
size_t
count2
=
0
;
while
((
ret
=
read
(
fd
,
buf2
,
100
))
>
0
)
count2
+=
ret
;
if
(
ret
>=
0
)
ret
=
count2
;
}
else
{
memset
(
buf
,
0
,
count
);
ret
=
read
(
fd
,
buf
,
count
);
}
saved_errno
=
errno
;
close
(
fd
);
errno
=
saved_errno
;
return
ret
;
}
src/lxc/tools/tool_utils.h
View file @
8765242a
...
@@ -143,6 +143,7 @@ extern char **lxc_string_split_quoted(char *string);
...
@@ -143,6 +143,7 @@ extern char **lxc_string_split_quoted(char *string);
extern
int
mkdir_p
(
const
char
*
dir
,
mode_t
mode
);
extern
int
mkdir_p
(
const
char
*
dir
,
mode_t
mode
);
extern
bool
file_exists
(
const
char
*
f
);
extern
bool
file_exists
(
const
char
*
f
);
extern
int
is_dir
(
const
char
*
path
);
extern
int
is_dir
(
const
char
*
path
);
extern
int
lxc_read_from_file
(
const
char
*
filename
,
void
*
buf
,
size_t
count
);
extern
char
*
get_template_path
(
const
char
*
t
);
extern
char
*
get_template_path
(
const
char
*
t
);
...
...
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