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
a099c5db
Unverified
Commit
a099c5db
authored
Feb 05, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: switch __cg_mount_direct() to use the new mount api
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
23a20dbe
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
15 deletions
+35
-15
cgfsng.c
src/lxc/cgroups/cgfsng.c
+35
-15
No files found.
src/lxc/cgroups/cgfsng.c
View file @
a099c5db
...
@@ -1763,42 +1763,62 @@ static int __cg_mount_direct(int type, struct hierarchy *h,
...
@@ -1763,42 +1763,62 @@ static int __cg_mount_direct(int type, struct hierarchy *h,
struct
lxc_rootfs
*
rootfs
,
struct
lxc_rootfs
*
rootfs
,
int
dfd_mnt_cgroupfs
,
const
char
*
hierarchy_mnt
)
int
dfd_mnt_cgroupfs
,
const
char
*
hierarchy_mnt
)
{
{
__do_
free
char
*
controllers
=
NULL
;
__do_
close
int
fd_fs
=
-
EBADF
;
unsigned
long
flags
=
0
;
unsigned
int
flags
=
0
;
char
*
fstype
;
char
*
fstype
;
int
ret
;
int
ret
;
if
(
dfd_mnt_cgroupfs
<
0
)
if
(
dfd_mnt_cgroupfs
<
0
)
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
flags
|=
M
S
_NOSUID
;
flags
|=
M
OUNT_ATTR
_NOSUID
;
flags
|=
M
S
_NOEXEC
;
flags
|=
M
OUNT_ATTR
_NOEXEC
;
flags
|=
M
S
_NODEV
;
flags
|=
M
OUNT_ATTR
_NODEV
;
flags
|=
M
S
_RELATIME
;
flags
|=
M
OUNT_ATTR
_RELATIME
;
if
(
type
==
LXC_AUTO_CGROUP_RO
||
type
==
LXC_AUTO_CGROUP_FULL_RO
)
if
(
type
==
LXC_AUTO_CGROUP_RO
||
type
==
LXC_AUTO_CGROUP_FULL_RO
)
flags
|=
M
S
_RDONLY
;
flags
|=
M
OUNT_ATTR
_RDONLY
;
if
(
is_unified_hierarchy
(
h
))
{
if
(
is_unified_hierarchy
(
h
))
{
fstype
=
"cgroup2"
;
fstype
=
"cgroup2"
;
}
else
{
}
else
{
fstype
=
"cgroup"
;
fstype
=
"cgroup"
;
}
fd_fs
=
fs_prepare
(
fstype
,
-
EBADF
,
""
,
0
,
0
);
if
(
fd_fs
<
0
)
{
__do_free
char
*
controllers
=
NULL
,
*
target
=
NULL
;
unsigned
int
old_flags
=
0
;
const
char
*
rootfs_mnt
;
if
(
!
is_unified_hierarchy
(
h
))
{
controllers
=
lxc_string_join
(
","
,
(
const
char
**
)
h
->
controllers
,
false
);
controllers
=
lxc_string_join
(
","
,
(
const
char
**
)
h
->
controllers
,
false
);
if
(
!
controllers
)
if
(
!
controllers
)
return
ret_errno
(
ENOMEM
);
return
ret_errno
(
ENOMEM
);
}
}
ret
=
mount_at
(
dfd_mnt_cgroupfs
,
NULL
,
hierarchy_mnt
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH
,
fstype
,
flags
,
controllers
);
if
(
ret
<
0
&&
errno
==
ENOSYS
)
{
__do_free
char
*
target
=
NULL
;
const
char
*
rootfs_mnt
;
rootfs_mnt
=
get_rootfs_mnt
(
rootfs
);
rootfs_mnt
=
get_rootfs_mnt
(
rootfs
);
ret
=
mnt_attributes_old
(
flags
,
&
old_flags
);
if
(
ret
)
return
log_error_errno
(
-
EINVAL
,
EINVAL
,
"Unsupported mount properties specified"
);
target
=
must_make_path
(
rootfs_mnt
,
DEFAULT_CGROUP_MOUNTPOINT
,
hierarchy_mnt
,
NULL
);
target
=
must_make_path
(
rootfs_mnt
,
DEFAULT_CGROUP_MOUNTPOINT
,
hierarchy_mnt
,
NULL
);
ret
=
safe_mount
(
NULL
,
target
,
fstype
,
flags
,
controllers
,
rootfs_mnt
);
ret
=
safe_mount
(
NULL
,
target
,
fstype
,
old_flags
,
controllers
,
rootfs_mnt
);
}
else
{
if
(
!
is_unified_hierarchy
(
h
))
{
for
(
const
char
**
it
=
(
const
char
**
)
h
->
controllers
;
it
&&
*
it
;
it
++
)
{
if
(
strncmp
(
*
it
,
"name="
,
STRLITERALLEN
(
"name="
))
==
0
)
ret
=
fs_set_property
(
fd_fs
,
"name"
,
*
it
+
STRLITERALLEN
(
"name="
));
else
ret
=
fs_set_property
(
fd_fs
,
*
it
,
""
);
if
(
ret
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to add %s controller to cgroup filesystem context %d(dev)"
,
*
it
,
fd_fs
);
}
}
ret
=
fs_attach
(
fd_fs
,
dfd_mnt_cgroupfs
,
hierarchy_mnt
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH
,
flags
);
}
}
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
ret
,
errno
,
"Failed to mount %s filesystem onto %d(%s)"
,
return
log_error_errno
(
ret
,
errno
,
"Failed to mount %s filesystem onto %d(%s)"
,
...
...
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