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
5429ec24
Commit
5429ec24
authored
Jul 22, 2016
by
Stéphane Graber
Committed by
GitHub
Jul 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1094 from brauner/2016-07-22/fix_android_lxc_copy
lxc-copy: do not use mkostemp and dprintf
parents
bdf278a1
a8e279fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
lxc_copy.c
src/lxc/lxc_copy.c
+18
-4
No files found.
src/lxc/lxc_copy.c
View file @
5429ec24
...
@@ -805,6 +805,7 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
...
@@ -805,6 +805,7 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
int
ret
,
fd
;
int
ret
,
fd
;
size_t
len
;
size_t
len
;
char
*
premount
=
NULL
;
char
*
premount
=
NULL
;
FILE
*
fp
;
if
(
arg
->
tmpfs
&&
arg
->
keepdata
)
{
if
(
arg
->
tmpfs
&&
arg
->
keepdata
)
{
fprintf
(
stderr
,
"%s
\n
"
,
"A container can only be placed on a "
fprintf
(
stderr
,
"%s
\n
"
,
"A container can only be placed on a "
...
@@ -831,21 +832,31 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
...
@@ -831,21 +832,31 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
goto
err_free
;
goto
err_free
;
fd
=
mk
ostemp
(
premount
,
O_CLOEXEC
);
fd
=
mk
stemp
(
premount
);
if
(
fd
<
0
)
if
(
fd
<
0
)
goto
err_free
;
goto
err_free
;
if
(
fcntl
(
fd
,
F_SETFD
,
FD_CLOEXEC
))
{
SYSERROR
(
"Failed to set close-on-exec on file descriptor."
);
goto
err_close
;
}
if
(
chmod
(
premount
,
0755
)
<
0
)
if
(
chmod
(
premount
,
0755
)
<
0
)
goto
err_close
;
goto
err_close
;
ret
=
dprintf
(
fd
,
"#! /bin/sh
\n
"
fp
=
fdopen
(
fd
,
"r+"
);
if
(
!
fp
)
goto
err_close
;
fd
=
-
1
;
ret
=
fprintf
(
fp
,
"#! /bin/sh
\n
"
"mount -n -t tmpfs -o mode=0755 none %s/%s
\n
"
,
"mount -n -t tmpfs -o mode=0755 none %s/%s
\n
"
,
path
,
newname
);
path
,
newname
);
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
err_close
;
goto
err_close
;
if
(
!
arg
->
keepname
)
{
if
(
!
arg
->
keepname
)
{
ret
=
dprintf
(
fd
,
"mkdir -p %s/%s/delta0/etc
\n
"
ret
=
fprintf
(
fp
,
"mkdir -p %s/%s/delta0/etc
\n
"
"echo %s > %s/%s/delta0/etc/hostname
\n
"
,
"echo %s > %s/%s/delta0/etc/hostname
\n
"
,
path
,
newname
,
newname
,
path
,
newname
);
path
,
newname
,
newname
,
path
,
newname
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -856,7 +867,10 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
...
@@ -856,7 +867,10 @@ static char *mount_tmpfs(const char *oldname, const char *newname,
return
premount
;
return
premount
;
err_close:
err_close:
close
(
fd
);
if
(
fd
>
0
)
close
(
fd
);
else
fclose
(
fp
);
err_free:
err_free:
free
(
premount
);
free
(
premount
);
return
NULL
;
return
NULL
;
...
...
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