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
33c7c7fe
Unverified
Commit
33c7c7fe
authored
Apr 11, 2018
by
Serge Hallyn
Committed by
GitHub
Apr 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2259 from gjaekel/patch-1
rootfs pinning: On NFS, make file hidden but don't delete it
parents
3d435963
63fc76c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
conf.c
src/lxc/conf.c
+14
-3
No files found.
src/lxc/conf.c
View file @
33c7c7fe
...
@@ -539,10 +539,11 @@ int run_script(const char *name, const char *section, const char *script, ...)
...
@@ -539,10 +539,11 @@ int run_script(const char *name, const char *section, const char *script, ...)
}
}
/* pin_rootfs
/* pin_rootfs
* if rootfs is a directory, then open ${rootfs}/
lxc.hold
for writing for
* if rootfs is a directory, then open ${rootfs}/
.lxc-keep
for writing for
* the duration of the container run, to prevent the container from marking
* the duration of the container run, to prevent the container from marking
* the underlying fs readonly on shutdown. unlink the file immediately so
* the underlying fs readonly on shutdown. unlink the file immediately so
* no name pollution is happens
* no name pollution is happens.
* don't unlink on NFS to avoid random named stale handles.
* return -1 on error.
* return -1 on error.
* return -2 if nothing needed to be pinned.
* return -2 if nothing needed to be pinned.
* return an open fd (>=0) if we pinned it.
* return an open fd (>=0) if we pinned it.
...
@@ -552,6 +553,7 @@ int pin_rootfs(const char *rootfs)
...
@@ -552,6 +553,7 @@ int pin_rootfs(const char *rootfs)
int
fd
,
ret
;
int
fd
,
ret
;
char
absrootfs
[
MAXPATHLEN
],
absrootfspin
[
MAXPATHLEN
];
char
absrootfs
[
MAXPATHLEN
],
absrootfspin
[
MAXPATHLEN
];
struct
stat
s
;
struct
stat
s
;
struct
statfs
sfs
;
if
(
rootfs
==
NULL
||
strlen
(
rootfs
)
==
0
)
if
(
rootfs
==
NULL
||
strlen
(
rootfs
)
==
0
)
return
-
2
;
return
-
2
;
...
@@ -570,7 +572,7 @@ int pin_rootfs(const char *rootfs)
...
@@ -570,7 +572,7 @@ int pin_rootfs(const char *rootfs)
if
(
!
S_ISDIR
(
s
.
st_mode
))
if
(
!
S_ISDIR
(
s
.
st_mode
))
return
-
2
;
return
-
2
;
ret
=
snprintf
(
absrootfspin
,
MAXPATHLEN
,
"%s/
lxc.hold
"
,
absrootfs
);
ret
=
snprintf
(
absrootfspin
,
MAXPATHLEN
,
"%s/
.lxc-keep
"
,
absrootfs
);
if
(
ret
>=
MAXPATHLEN
)
if
(
ret
>=
MAXPATHLEN
)
return
-
1
;
return
-
1
;
...
@@ -578,6 +580,15 @@ int pin_rootfs(const char *rootfs)
...
@@ -578,6 +580,15 @@ int pin_rootfs(const char *rootfs)
if
(
fd
<
0
)
if
(
fd
<
0
)
return
fd
;
return
fd
;
if
(
fstatfs
(
fd
,
&
sfs
))
{
return
-
1
;
}
if
(
sfs
.
f_type
==
NFS_SUPER_MAGIC
)
{
DEBUG
(
"rootfs on NFS, not unlinking pin file
\"
%s
\"
."
,
absrootfspin
);
return
fd
;
}
(
void
)
unlink
(
absrootfspin
);
(
void
)
unlink
(
absrootfspin
);
return
fd
;
return
fd
;
...
...
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