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
64e1ae63
Commit
64e1ae63
authored
May 28, 2009
by
Daniel Lezcano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make use of the copy file function
Now we have specific function to copy the files, make use of it and remove the old code. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
e3642c43
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
60 deletions
+4
-60
conf.c
src/lxc/conf.c
+4
-60
No files found.
src/lxc/conf.c
View file @
64e1ae63
...
@@ -644,71 +644,15 @@ static int configure_pts(const char *name, int pts)
...
@@ -644,71 +644,15 @@ static int configure_pts(const char *name, int pts)
static
int
configure_mount
(
const
char
*
name
,
const
char
*
fstab
)
static
int
configure_mount
(
const
char
*
name
,
const
char
*
fstab
)
{
{
char
path
[
MAXPATHLEN
];
char
path
[
MAXPATHLEN
];
struct
stat
stat
;
int
infd
,
outfd
;
void
*
src
,
*
dst
;
char
c
=
'\0'
;
int
ret
=
-
1
;
snprintf
(
path
,
MAXPATHLEN
,
LXCPATH
"/%s/fstab"
,
name
);
snprintf
(
path
,
MAXPATHLEN
,
LXCPATH
"/%s/fstab"
,
name
);
outfd
=
open
(
path
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0640
);
if
(
lxc_copy_file
(
fstab
,
path
))
{
if
(
outfd
<
0
)
{
ERROR
(
"failed to copy the fstab file"
);
SYSERROR
(
"failed to creat '%s'"
,
path
);
return
-
1
;
goto
out
;
}
infd
=
open
(
fstab
,
O_RDONLY
);
if
(
infd
<
0
)
{
SYSERROR
(
"failed to open '%s'"
,
fstab
);
goto
out_open
;
}
if
(
fstat
(
infd
,
&
stat
))
{
SYSERROR
(
"failed to stat '%s'"
,
fstab
);
goto
out_open2
;
}
if
(
lseek
(
outfd
,
stat
.
st_size
-
1
,
SEEK_SET
)
<
0
)
{
SYSERROR
(
"failed to seek dest file '%s'"
,
path
);
goto
out_open2
;
}
/* fixup length */
if
(
write
(
outfd
,
&
c
,
1
)
<
0
)
{
SYSERROR
(
"failed to write to '%s'"
,
path
);
goto
out_open2
;
}
src
=
mmap
(
NULL
,
stat
.
st_size
,
PROT_READ
,
MAP_SHARED
,
infd
,
0L
);
if
(
src
==
MAP_FAILED
)
{
SYSERROR
(
"failed to mmap '%s'"
,
fstab
);
goto
out_open2
;
}
dst
=
mmap
(
NULL
,
stat
.
st_size
,
PROT_WRITE
,
MAP_SHARED
,
outfd
,
0L
);
if
(
dst
==
MAP_FAILED
)
{
SYSERROR
(
"failed to mmap '%s'"
,
path
);
goto
out_mmap
;
}
}
memcpy
(
dst
,
src
,
stat
.
st_size
);
return
0
;
munmap
(
src
,
stat
.
st_size
);
munmap
(
dst
,
stat
.
st_size
);
ret
=
0
;
out:
return
ret
;
out_mmap:
munmap
(
src
,
stat
.
st_size
);
out_open2:
close
(
infd
);
out_open:
unlink
(
path
);
close
(
outfd
);
goto
out
;
}
}
static
int
unconfigure_ip_addresses
(
const
char
*
directory
)
static
int
unconfigure_ip_addresses
(
const
char
*
directory
)
...
...
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