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
be835470
Unverified
Commit
be835470
authored
Feb 02, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: move functions after methods
This makes it more obvious that they are separate. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
69edb51d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
54 deletions
+54
-54
cgfsng.c
src/lxc/cgroups/cgfsng.c
+54
-54
No files found.
src/lxc/cgroups/cgfsng.c
View file @
be835470
...
@@ -2500,31 +2500,6 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops,
...
@@ -2500,31 +2500,6 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops,
return
true
;
return
true
;
}
}
int
cgroup_get
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
filename
,
char
*
buf
,
size_t
len
)
{
__do_close
int
unified_fd
=
-
EBADF
;
ssize_t
ret
;
if
(
!
conf
||
is_empty_string
(
filename
)
||
is_empty_string
(
name
)
||
is_empty_string
(
lxcpath
))
return
ret_errno
(
EINVAL
);
if
((
buf
&&
!
len
)
||
(
len
&&
!
buf
))
return
ret_errno
(
EINVAL
);
unified_fd
=
lxc_cmd_get_cgroup2_fd
(
name
,
lxcpath
);
if
(
unified_fd
<
0
)
return
ret_errno
(
ENOCGROUP2
);
ret
=
lxc_read_try_buf_at
(
unified_fd
,
filename
,
buf
,
len
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to read cgroup value"
);
return
ret
;
}
/* Called externally (i.e. from 'lxc-cgroup') to query cgroup limits. Here we
/* Called externally (i.e. from 'lxc-cgroup') to query cgroup limits. Here we
* don't have a cgroup_data set up, so we ask the running container through the
* don't have a cgroup_data set up, so we ask the running container through the
* commands API for the cgroup path.
* commands API for the cgroup path.
...
@@ -2675,35 +2650,6 @@ static int device_cgroup_rule_parse(struct device_item *device, const char *key,
...
@@ -2675,35 +2650,6 @@ static int device_cgroup_rule_parse(struct device_item *device, const char *key,
return
device_cgroup_parse_access
(
device
,
++
val
);
return
device_cgroup_parse_access
(
device
,
++
val
);
}
}
int
cgroup_set
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
filename
,
const
char
*
value
)
{
__do_close
int
unified_fd
=
-
EBADF
;
ssize_t
ret
;
if
(
!
conf
||
is_empty_string
(
filename
)
||
is_empty_string
(
value
)
||
is_empty_string
(
name
)
||
is_empty_string
(
lxcpath
))
return
ret_errno
(
EINVAL
);
unified_fd
=
lxc_cmd_get_cgroup2_fd
(
name
,
lxcpath
);
if
(
unified_fd
<
0
)
return
ret_errno
(
ENOCGROUP2
);
if
(
strncmp
(
filename
,
"devices."
,
STRLITERALLEN
(
"devices."
))
==
0
)
{
struct
device_item
device
=
{};
ret
=
device_cgroup_rule_parse
(
&
device
,
filename
,
value
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
EINVAL
,
"Failed to parse device string %s=%s"
,
filename
,
value
);
ret
=
lxc_cmd_add_bpf_device_cgroup
(
name
,
lxcpath
,
&
device
);
}
else
{
ret
=
lxc_writeat
(
unified_fd
,
filename
,
value
,
strlen
(
value
));
}
return
ret
;
}
/* Called externally (i.e. from 'lxc-cgroup') to set new cgroup limits. Here we
/* Called externally (i.e. from 'lxc-cgroup') to set new cgroup limits. Here we
* don't have a cgroup_data set up, so we ask the running container through the
* don't have a cgroup_data set up, so we ask the running container through the
* commands API for the cgroup path.
* commands API for the cgroup path.
...
@@ -3554,3 +3500,57 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
...
@@ -3554,3 +3500,57 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
return
move_ptr
(
cgfsng_ops
);
return
move_ptr
(
cgfsng_ops
);
}
}
int
cgroup_get
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
filename
,
char
*
buf
,
size_t
len
)
{
__do_close
int
unified_fd
=
-
EBADF
;
ssize_t
ret
;
if
(
!
conf
||
is_empty_string
(
filename
)
||
is_empty_string
(
name
)
||
is_empty_string
(
lxcpath
))
return
ret_errno
(
EINVAL
);
if
((
buf
&&
!
len
)
||
(
len
&&
!
buf
))
return
ret_errno
(
EINVAL
);
unified_fd
=
lxc_cmd_get_cgroup2_fd
(
name
,
lxcpath
);
if
(
unified_fd
<
0
)
return
ret_errno
(
ENOCGROUP2
);
ret
=
lxc_read_try_buf_at
(
unified_fd
,
filename
,
buf
,
len
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to read cgroup value"
);
return
ret
;
}
int
cgroup_set
(
struct
lxc_conf
*
conf
,
const
char
*
name
,
const
char
*
lxcpath
,
const
char
*
filename
,
const
char
*
value
)
{
__do_close
int
unified_fd
=
-
EBADF
;
ssize_t
ret
;
if
(
!
conf
||
is_empty_string
(
filename
)
||
is_empty_string
(
value
)
||
is_empty_string
(
name
)
||
is_empty_string
(
lxcpath
))
return
ret_errno
(
EINVAL
);
unified_fd
=
lxc_cmd_get_cgroup2_fd
(
name
,
lxcpath
);
if
(
unified_fd
<
0
)
return
ret_errno
(
ENOCGROUP2
);
if
(
strncmp
(
filename
,
"devices."
,
STRLITERALLEN
(
"devices."
))
==
0
)
{
struct
device_item
device
=
{};
ret
=
device_cgroup_rule_parse
(
&
device
,
filename
,
value
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
EINVAL
,
"Failed to parse device string %s=%s"
,
filename
,
value
);
ret
=
lxc_cmd_add_bpf_device_cgroup
(
name
,
lxcpath
,
&
device
);
}
else
{
ret
=
lxc_writeat
(
unified_fd
,
filename
,
value
,
strlen
(
value
));
}
return
ret
;
}
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