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
bd8357e2
Unverified
Commit
bd8357e2
authored
Nov 09, 2018
by
2xsec
Committed by
Christian Brauner
Nov 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgfs: remove redundancy utils
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
a64c59b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
26 deletions
+13
-26
cgfsng.c
src/lxc/cgroups/cgfsng.c
+7
-13
pam_cgfs.c
src/lxc/pam/pam_cgfs.c
+6
-13
No files found.
src/lxc/cgroups/cgfsng.c
View file @
bd8357e2
...
@@ -84,12 +84,6 @@ static void free_string_list(char **clist)
...
@@ -84,12 +84,6 @@ static void free_string_list(char **clist)
free
(
clist
);
free
(
clist
);
}
}
/* Allocate a pointer, do not fail. */
static
void
*
must_alloc
(
size_t
sz
)
{
return
must_realloc
(
NULL
,
sz
);
}
/* Given a pointer to a null-terminated array of pointers, realloc to add one
/* Given a pointer to a null-terminated array of pointers, realloc to add one
* entry, and point the new entry to NULL. Do not fail. Return the index to the
* entry, and point the new entry to NULL. Do not fail. Return the index to the
* second-to-last entry - that is, the one which is now available for use
* second-to-last entry - that is, the one which is now available for use
...
@@ -134,7 +128,7 @@ static char *cg_legacy_must_prefix_named(char *entry)
...
@@ -134,7 +128,7 @@ static char *cg_legacy_must_prefix_named(char *entry)
char
*
prefixed
;
char
*
prefixed
;
len
=
strlen
(
entry
);
len
=
strlen
(
entry
);
prefixed
=
must_
alloc
(
len
+
6
);
prefixed
=
must_
realloc
(
NULL
,
len
+
6
);
memcpy
(
prefixed
,
"name="
,
STRLITERALLEN
(
"name="
));
memcpy
(
prefixed
,
"name="
,
STRLITERALLEN
(
"name="
));
memcpy
(
prefixed
+
STRLITERALLEN
(
"name="
),
entry
,
len
);
memcpy
(
prefixed
+
STRLITERALLEN
(
"name="
),
entry
,
len
);
...
@@ -541,7 +535,7 @@ static bool copy_parent_file(char *path, char *file)
...
@@ -541,7 +535,7 @@ static bool copy_parent_file(char *path, char *file)
if
(
len
<=
0
)
if
(
len
<=
0
)
goto
on_error
;
goto
on_error
;
value
=
must_
alloc
(
len
+
1
);
value
=
must_
realloc
(
NULL
,
len
+
1
);
ret
=
lxc_read_from_file
(
fpath
,
value
,
len
);
ret
=
lxc_read_from_file
(
fpath
,
value
,
len
);
if
(
ret
!=
len
)
if
(
ret
!=
len
)
goto
on_error
;
goto
on_error
;
...
@@ -825,7 +819,7 @@ static struct hierarchy *add_hierarchy(struct hierarchy ***h, char **clist, char
...
@@ -825,7 +819,7 @@ static struct hierarchy *add_hierarchy(struct hierarchy ***h, char **clist, char
struct
hierarchy
*
new
;
struct
hierarchy
*
new
;
int
newentry
;
int
newentry
;
new
=
must_
alloc
(
sizeof
(
*
new
));
new
=
must_
realloc
(
NULL
,
sizeof
(
*
new
));
new
->
controllers
=
clist
;
new
->
controllers
=
clist
;
new
->
mountpoint
=
mountpoint
;
new
->
mountpoint
=
mountpoint
;
new
->
container_base_path
=
container_base_path
;
new
->
container_base_path
=
container_base_path
;
...
@@ -863,7 +857,7 @@ static char *cg_hybrid_get_mountpoint(char *line)
...
@@ -863,7 +857,7 @@ static char *cg_hybrid_get_mountpoint(char *line)
*
p2
=
'\0'
;
*
p2
=
'\0'
;
len
=
strlen
(
p
);
len
=
strlen
(
p
);
sret
=
must_
alloc
(
len
+
1
);
sret
=
must_
realloc
(
NULL
,
len
+
1
);
memcpy
(
sret
,
p
,
len
);
memcpy
(
sret
,
p
,
len
);
sret
[
len
]
=
'\0'
;
sret
[
len
]
=
'\0'
;
return
sret
;
return
sret
;
...
@@ -879,7 +873,7 @@ static char *copy_to_eol(char *p)
...
@@ -879,7 +873,7 @@ static char *copy_to_eol(char *p)
return
NULL
;
return
NULL
;
len
=
p2
-
p
;
len
=
p2
-
p
;
sret
=
must_
alloc
(
len
+
1
);
sret
=
must_
realloc
(
NULL
,
len
+
1
);
memcpy
(
sret
,
p
,
len
);
memcpy
(
sret
,
p
,
len
);
sret
[
len
]
=
'\0'
;
sret
[
len
]
=
'\0'
;
return
sret
;
return
sret
;
...
@@ -1300,7 +1294,7 @@ __cgfsng_ops static bool cgfsng_payload_create(struct cgroup_ops *ops,
...
@@ -1300,7 +1294,7 @@ __cgfsng_ops static bool cgfsng_payload_create(struct cgroup_ops *ops,
}
}
len
=
strlen
(
tmp
)
+
5
;
/* leave room for -NNN\0 */
len
=
strlen
(
tmp
)
+
5
;
/* leave room for -NNN\0 */
container_cgroup
=
must_
alloc
(
len
);
container_cgroup
=
must_
realloc
(
NULL
,
len
);
(
void
)
strlcpy
(
container_cgroup
,
tmp
,
len
);
(
void
)
strlcpy
(
container_cgroup
,
tmp
,
len
);
free
(
tmp
);
free
(
tmp
);
offset
=
container_cgroup
+
len
-
5
;
offset
=
container_cgroup
+
len
-
5
;
...
@@ -1928,7 +1922,7 @@ static int __cg_unified_attach(const struct hierarchy *h, const char *name,
...
@@ -1928,7 +1922,7 @@ static int __cg_unified_attach(const struct hierarchy *h, const char *name,
len
=
strlen
(
base_path
)
+
STRLITERALLEN
(
"/lxc-1000"
)
+
len
=
strlen
(
base_path
)
+
STRLITERALLEN
(
"/lxc-1000"
)
+
STRLITERALLEN
(
"/cgroup-procs"
);
STRLITERALLEN
(
"/cgroup-procs"
);
full_path
=
must_
alloc
(
len
+
1
);
full_path
=
must_
realloc
(
NULL
,
len
+
1
);
do
{
do
{
if
(
idx
)
if
(
idx
)
ret
=
snprintf
(
full_path
,
len
+
1
,
"%s/lxc-%d"
,
ret
=
snprintf
(
full_path
,
len
+
1
,
"%s/lxc-%d"
,
...
...
src/lxc/pam/pam_cgfs.c
View file @
bd8357e2
...
@@ -119,7 +119,6 @@ static inline bool is_set(unsigned bit, uint32_t *bitarr)
...
@@ -119,7 +119,6 @@ static inline bool is_set(unsigned bit, uint32_t *bitarr)
static
bool
is_lxcfs
(
const
char
*
line
);
static
bool
is_lxcfs
(
const
char
*
line
);
static
bool
is_cgv1
(
char
*
line
);
static
bool
is_cgv1
(
char
*
line
);
static
bool
is_cgv2
(
char
*
line
);
static
bool
is_cgv2
(
char
*
line
);
static
void
*
must_alloc
(
size_t
sz
);
static
void
must_add_to_list
(
char
***
clist
,
char
*
entry
);
static
void
must_add_to_list
(
char
***
clist
,
char
*
entry
);
static
void
must_append_controller
(
char
**
klist
,
char
**
nlist
,
char
***
clist
,
static
void
must_append_controller
(
char
**
klist
,
char
**
nlist
,
char
***
clist
,
char
*
entry
);
char
*
entry
);
...
@@ -388,12 +387,6 @@ static void trim(char *s)
...
@@ -388,12 +387,6 @@ static void trim(char *s)
s
[
--
len
]
=
'\0'
;
s
[
--
len
]
=
'\0'
;
}
}
/* Allocate pointer; do not fail. */
static
void
*
must_alloc
(
size_t
sz
)
{
return
must_realloc
(
NULL
,
sz
);
}
/* Make allocated copy of string. End of string is taken to be '\n'. */
/* Make allocated copy of string. End of string is taken to be '\n'. */
static
char
*
copy_to_eol
(
char
*
s
)
static
char
*
copy_to_eol
(
char
*
s
)
{
{
...
@@ -405,7 +398,7 @@ static char *copy_to_eol(char *s)
...
@@ -405,7 +398,7 @@ static char *copy_to_eol(char *s)
return
NULL
;
return
NULL
;
len
=
newline
-
s
;
len
=
newline
-
s
;
sret
=
must_
alloc
(
len
+
1
);
sret
=
must_
realloc
(
NULL
,
len
+
1
);
memcpy
(
sret
,
s
,
len
);
memcpy
(
sret
,
s
,
len
);
sret
[
len
]
=
'\0'
;
sret
[
len
]
=
'\0'
;
...
@@ -603,7 +596,7 @@ static char *get_mountpoint(char *line)
...
@@ -603,7 +596,7 @@ static char *get_mountpoint(char *line)
*
p2
=
'\0'
;
*
p2
=
'\0'
;
len
=
strlen
(
p
);
len
=
strlen
(
p
);
sret
=
must_
alloc
(
len
+
1
);
sret
=
must_
realloc
(
NULL
,
len
+
1
);
memcpy
(
sret
,
p
,
len
);
memcpy
(
sret
,
p
,
len
);
sret
[
len
]
=
'\0'
;
sret
[
len
]
=
'\0'
;
...
@@ -775,7 +768,7 @@ static char *cgv1_must_prefix_named(char *entry)
...
@@ -775,7 +768,7 @@ static char *cgv1_must_prefix_named(char *entry)
size_t
len
;
size_t
len
;
len
=
strlen
(
entry
);
len
=
strlen
(
entry
);
s
=
must_
alloc
(
len
+
6
);
s
=
must_
realloc
(
NULL
,
len
+
6
);
ret
=
snprintf
(
s
,
len
+
6
,
"name=%s"
,
entry
);
ret
=
snprintf
(
s
,
len
+
6
,
"name=%s"
,
entry
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
(
len
+
6
))
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
(
len
+
6
))
{
...
@@ -937,7 +930,7 @@ static void cgv1_add_controller(char **clist, char *mountpoint, char *base_cgrou
...
@@ -937,7 +930,7 @@ static void cgv1_add_controller(char **clist, char *mountpoint, char *base_cgrou
struct
cgv1_hierarchy
*
new
;
struct
cgv1_hierarchy
*
new
;
int
newentry
;
int
newentry
;
new
=
must_
alloc
(
sizeof
(
*
new
));
new
=
must_
realloc
(
NULL
,
sizeof
(
*
new
));
new
->
controllers
=
clist
;
new
->
controllers
=
clist
;
new
->
mountpoint
=
mountpoint
;
new
->
mountpoint
=
mountpoint
;
...
@@ -964,7 +957,7 @@ static void cgv2_add_controller(char **clist, char *mountpoint, char *base_cgrou
...
@@ -964,7 +957,7 @@ static void cgv2_add_controller(char **clist, char *mountpoint, char *base_cgrou
struct
cgv2_hierarchy
*
new
;
struct
cgv2_hierarchy
*
new
;
int
newentry
;
int
newentry
;
new
=
must_
alloc
(
sizeof
(
*
new
));
new
=
must_
realloc
(
NULL
,
sizeof
(
*
new
));
new
->
controllers
=
clist
;
new
->
controllers
=
clist
;
new
->
mountpoint
=
mountpoint
;
new
->
mountpoint
=
mountpoint
;
...
@@ -1905,7 +1898,7 @@ static bool cg_copy_parent_file(char *path, char *file)
...
@@ -1905,7 +1898,7 @@ static bool cg_copy_parent_file(char *path, char *file)
goto
bad
;
goto
bad
;
}
}
value
=
must_
alloc
(
len
+
1
);
value
=
must_
realloc
(
NULL
,
len
+
1
);
if
(
lxc_read_from_file
(
fpath
,
value
,
len
)
!=
len
)
{
if
(
lxc_read_from_file
(
fpath
,
value
,
len
)
!=
len
)
{
pam_cgfs_debug
(
"Failed to read %s: %s"
,
fpath
,
strerror
(
errno
));
pam_cgfs_debug
(
"Failed to read %s: %s"
,
fpath
,
strerror
(
errno
));
goto
bad
;
goto
bad
;
...
...
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