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
b095a8eb
Unverified
Commit
b095a8eb
authored
Feb 17, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgfsng: copy_parent_file()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
59ac3b88
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
cgfsng.c
src/lxc/cgroups/cgfsng.c
+14
-10
No files found.
src/lxc/cgroups/cgfsng.c
View file @
b095a8eb
...
@@ -648,13 +648,14 @@ on_error:
...
@@ -648,13 +648,14 @@ on_error:
/* Copy contents of parent(@path)/@file to @path/@file */
/* Copy contents of parent(@path)/@file to @path/@file */
static
bool
copy_parent_file
(
char
*
path
,
char
*
file
)
static
bool
copy_parent_file
(
char
*
path
,
char
*
file
)
{
{
char
*
lastslash
,
*
value
=
NULL
,
*
fpath
,
oldv
;
int
len
=
0
;
int
ret
;
int
ret
;
char
*
fpath
,
*
lastslash
,
oldv
;
int
len
=
0
;
char
*
value
=
NULL
;
lastslash
=
strrchr
(
path
,
'/'
);
lastslash
=
strrchr
(
path
,
'/'
);
if
(
!
lastslash
)
{
/* bug... this shouldn't be possible */
if
(
!
lastslash
)
{
ERROR
(
"
cgfsng:copy_parent_file: bad path %s
"
,
path
);
ERROR
(
"
Failed to detect
\"
/
\"
in
\"
%s
\"
"
,
path
);
return
false
;
return
false
;
}
}
oldv
=
*
lastslash
;
oldv
=
*
lastslash
;
...
@@ -662,22 +663,25 @@ static bool copy_parent_file(char *path, char *file)
...
@@ -662,22 +663,25 @@ static bool copy_parent_file(char *path, char *file)
fpath
=
must_make_path
(
path
,
file
,
NULL
);
fpath
=
must_make_path
(
path
,
file
,
NULL
);
len
=
lxc_read_from_file
(
fpath
,
NULL
,
0
);
len
=
lxc_read_from_file
(
fpath
,
NULL
,
0
);
if
(
len
<=
0
)
if
(
len
<=
0
)
goto
bad
;
goto
on_error
;
value
=
must_alloc
(
len
+
1
);
value
=
must_alloc
(
len
+
1
);
if
(
lxc_read_from_file
(
fpath
,
value
,
len
)
!=
len
)
ret
=
lxc_read_from_file
(
fpath
,
value
,
len
);
goto
bad
;
if
(
ret
!=
len
)
goto
on_error
;
free
(
fpath
);
free
(
fpath
);
*
lastslash
=
oldv
;
*
lastslash
=
oldv
;
fpath
=
must_make_path
(
path
,
file
,
NULL
);
fpath
=
must_make_path
(
path
,
file
,
NULL
);
ret
=
lxc_write_to_file
(
fpath
,
value
,
len
,
false
);
ret
=
lxc_write_to_file
(
fpath
,
value
,
len
,
false
);
if
(
ret
<
0
)
if
(
ret
<
0
)
SYSERROR
(
"
Unable to write %s to %s
"
,
value
,
fpath
);
SYSERROR
(
"
Failed to write
\"
%s
\"
to file
\"
%s
\"
"
,
value
,
fpath
);
free
(
fpath
);
free
(
fpath
);
free
(
value
);
free
(
value
);
return
ret
>=
0
;
return
ret
>=
0
;
bad
:
on_error
:
SYSERROR
(
"
Error reading '%s'
"
,
fpath
);
SYSERROR
(
"
Failed to read file
\"
%s
\"
"
,
fpath
);
free
(
fpath
);
free
(
fpath
);
free
(
value
);
free
(
value
);
return
false
;
return
false
;
...
...
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