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
ad08bbb7
Commit
ad08bbb7
authored
May 04, 2012
by
David Ward
Committed by
Daniel Lezcano
May 04, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroup: rearrange code blocks
Avoid nesting and improve readability. Signed-off-by:
David Ward
<
david.ward@ll.mit.edu
>
Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
f10e7166
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
38 deletions
+32
-38
cgroup.c
src/lxc/cgroup.c
+32
-38
No files found.
src/lxc/cgroup.c
View file @
ad08bbb7
...
...
@@ -157,6 +157,7 @@ static int get_cgroup_mount(const char *subsystem, char *mnt)
struct
mntent
*
mntent
;
char
initcgroup
[
MAXPATHLEN
];
FILE
*
file
=
NULL
;
int
ret
,
flags
,
err
=
-
1
;
file
=
setmntent
(
MTAB
,
"r"
);
if
(
!
file
)
{
...
...
@@ -165,32 +166,29 @@ static int get_cgroup_mount(const char *subsystem, char *mnt)
}
while
((
mntent
=
getmntent
(
file
)))
{
if
(
strcmp
(
mntent
->
mnt_type
,
"cgroup"
))
continue
;
if
(
!
subsystem
||
hasmntopt_multiple
(
mntent
,
subsystem
))
{
int
ret
;
int
flags
=
get_cgroup_flags
(
mntent
);
ret
=
snprintf
(
mnt
,
MAXPATHLEN
,
"%s%s%s"
,
mntent
->
mnt_dir
,
get_init_cgroup
(
subsystem
,
NULL
,
initcgroup
),
(
flags
&
CGROUP_NS_CGROUP
)
?
""
:
"/lxc"
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
goto
fail
;
fclose
(
file
);
DEBUG
(
"using cgroup mounted at '%s'"
,
mnt
);
return
0
;
}
if
(
subsystem
&&
!
hasmntopt_multiple
(
mntent
,
subsystem
))
continue
;
flags
=
get_cgroup_flags
(
mntent
);
ret
=
snprintf
(
mnt
,
MAXPATHLEN
,
"%s%s%s"
,
mntent
->
mnt_dir
,
get_init_cgroup
(
subsystem
,
NULL
,
initcgroup
),
(
flags
&
CGROUP_NS_CGROUP
)
?
""
:
"/lxc"
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
goto
fail
;
DEBUG
(
"using cgroup mounted at '%s'"
,
mnt
);
err
=
0
;
goto
out
;
};
fail:
DEBUG
(
"Failed to find cgroup for %s
\n
"
,
subsystem
?
subsystem
:
"(NULL)"
);
fclose
(
file
);
return
-
1
;
out:
endmntent
(
file
);
return
err
;
}
int
lxc_ns_is_mounted
(
void
)
...
...
@@ -409,18 +407,17 @@ int lxc_cgroup_create(const char *name, pid_t pid)
}
while
((
mntent
=
getmntent
(
file
)))
{
DEBUG
(
"checking '%s' (%s)"
,
mntent
->
mnt_dir
,
mntent
->
mnt_type
);
if
(
!
strcmp
(
mntent
->
mnt_type
,
"cgroup"
))
{
if
(
strcmp
(
mntent
->
mnt_type
,
"cgroup"
))
continue
;
INFO
(
"[%d] found cgroup mounted at '%s',opts='%s'"
,
++
found
,
mntent
->
mnt_dir
,
mntent
->
mnt_opts
);
INFO
(
"[%d] found cgroup mounted at '%s',opts='%s'"
,
++
found
,
mntent
->
mnt_dir
,
mntent
->
mnt_opts
);
err
=
lxc_one_cgroup_create
(
name
,
mntent
,
pid
);
if
(
err
)
goto
out
;
}
err
=
lxc_one_cgroup_create
(
name
,
mntent
,
pid
);
if
(
err
)
goto
out
;
};
if
(
!
found
)
...
...
@@ -498,7 +495,7 @@ int lxc_cgroup_destroy(const char *name)
{
struct
mntent
*
mntent
;
FILE
*
file
=
NULL
;
int
ret
,
err
=
-
1
;
int
err
=
-
1
;
file
=
setmntent
(
MTAB
,
"r"
);
if
(
!
file
)
{
...
...
@@ -507,18 +504,15 @@ int lxc_cgroup_destroy(const char *name)
}
while
((
mntent
=
getmntent
(
file
)))
{
if
(
!
strcmp
(
mntent
->
mnt_type
,
"cgroup"
))
{
ret
=
lxc_one_cgroup_destroy
(
mntent
,
name
);
if
(
ret
)
{
fclose
(
file
);
return
ret
;
}
err
=
0
;
}
}
if
(
strcmp
(
mntent
->
mnt_type
,
"cgroup"
))
continue
;
fclose
(
file
);
err
=
lxc_one_cgroup_destroy
(
mntent
,
name
);
if
(
err
)
break
;
}
endmntent
(
file
);
return
err
;
}
/*
...
...
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