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
f6310f18
Unverified
Commit
f6310f18
authored
May 02, 2018
by
Liza Tretyakova
Committed by
Christian Brauner
Jul 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add shared mount point detection
Signed-off-by:
Liza Tretyakova
<
elizabet.tretyakova@gmail.com
>
parent
0d190408
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
utils.c
src/lxc/utils.c
+20
-13
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
f6310f18
...
@@ -1219,19 +1219,12 @@ uint64_t fnv_64a_buf(void *buf, size_t len, uint64_t hval)
...
@@ -1219,19 +1219,12 @@ uint64_t fnv_64a_buf(void *buf, size_t len, uint64_t hval)
return
hval
;
return
hval
;
}
}
/*
bool
is_shared_mountpoint
(
const
char
*
path
)
* Detect whether / is mounted MS_SHARED. The only way I know of to
* check that is through /proc/self/mountinfo.
* I'm only checking for /. If the container rootfs or mount location
* is MS_SHARED, but not '/', then you're out of luck - figuring that
* out would be too much work to be worth it.
*/
int
detect_shared_rootfs
(
void
)
{
{
char
buf
[
LXC_LINELEN
]
,
*
p
;
char
buf
[
LXC_LINELEN
];
FILE
*
f
;
FILE
*
f
;
int
i
;
int
i
;
char
*
p2
;
char
*
p
,
*
p
2
;
f
=
fopen
(
"/proc/self/mountinfo"
,
"r"
);
f
=
fopen
(
"/proc/self/mountinfo"
,
"r"
);
if
(
!
f
)
if
(
!
f
)
...
@@ -1248,17 +1241,31 @@ int detect_shared_rootfs(void)
...
@@ -1248,17 +1241,31 @@ int detect_shared_rootfs(void)
continue
;
continue
;
*
p2
=
'\0'
;
*
p2
=
'\0'
;
if
(
strcmp
(
p
+
1
,
"/"
)
==
0
)
{
if
(
strcmp
(
p
+
1
,
path
)
==
0
)
{
/* This is
'/'
. Is it shared? */
/* This is
the path
. Is it shared? */
p
=
strchr
(
p2
+
1
,
' '
);
p
=
strchr
(
p2
+
1
,
' '
);
if
(
p
&&
strstr
(
p
,
"shared:"
))
{
if
(
p
&&
strstr
(
p
,
"shared:"
))
{
fclose
(
f
);
fclose
(
f
);
return
1
;
return
true
;
}
}
}
}
}
}
fclose
(
f
);
fclose
(
f
);
return
false
;
}
/*
* Detect whether / is mounted MS_SHARED. The only way I know of to
* check that is through /proc/self/mountinfo.
* I'm only checking for /. If the container rootfs or mount location
* is MS_SHARED, but not '/', then you're out of luck - figuring that
* out would be too much work to be worth it.
*/
int
detect_shared_rootfs
(
void
)
{
if
(
is_shared_mountpoint
(
"/"
))
return
1
;
return
0
;
return
0
;
}
}
...
...
src/lxc/utils.h
View file @
f6310f18
...
@@ -502,6 +502,7 @@ extern bool dir_exists(const char *path);
...
@@ -502,6 +502,7 @@ extern bool dir_exists(const char *path);
#define FNV1A_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
#define FNV1A_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
extern
uint64_t
fnv_64a_buf
(
void
*
buf
,
size_t
len
,
uint64_t
hval
);
extern
uint64_t
fnv_64a_buf
(
void
*
buf
,
size_t
len
,
uint64_t
hval
);
extern
bool
is_shared_mountpoint
(
const
char
*
path
);
extern
int
detect_shared_rootfs
(
void
);
extern
int
detect_shared_rootfs
(
void
);
extern
bool
detect_ramfs_rootfs
(
void
);
extern
bool
detect_ramfs_rootfs
(
void
);
extern
char
*
on_path
(
const
char
*
cmd
,
const
char
*
rootfs
);
extern
char
*
on_path
(
const
char
*
cmd
,
const
char
*
rootfs
);
...
...
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