}
if (nsjconf->mount_proc == true) {
- if (!mountAddMountPt(nsjconf, /* src= */ NULL, "/proc", "proc", "",
- nsjconf->is_root_rw ? 0 : MS_RDONLY, /* isDir= */
- true,
- /* mandatory= */ true, NULL, NULL, NULL, 0,
- /* is_symlink= */
- false)) {
+ if (!mountAddMountPtHead(nsjconf, /* src= */ NULL, "/proc", "proc", "",
+ nsjconf->is_root_rw ? 0 : MS_RDONLY, /* isDir= */
+ true,
+ /* mandatory= */ true, NULL, NULL, NULL, 0,
+ /* is_symlink= */
+ false)) {
return false;
}
}
if (nsjconf->chroot != NULL) {
- if (!mountAddMountPt
+ if (!mountAddMountPtHead
(nsjconf, nsjconf->chroot, "/", /* fs_type= */ "", /* options= */ "",
nsjconf->is_root_rw ? (MS_BIND | MS_REC) : (MS_BIND | MS_REC | MS_RDONLY),
/* isDir= */ true,
return false;
}
} else {
- if (!mountAddMountPt(nsjconf, /* src= */ NULL, "/", "tmpfs", /* options= */ "",
- nsjconf->is_root_rw ? 0 : MS_RDONLY, /* isDir= */
- true,
- /* mandatory= */ true, NULL, NULL, NULL, 0,
- /* is_symlink= */
- false)) {
+ if (!mountAddMountPtHead(nsjconf, /* src= */ NULL, "/", "tmpfs", /* options= */ "",
+ nsjconf->is_root_rw ? 0 : MS_RDONLY, /* isDir= */
+ true,
+ /* mandatory= */ true, NULL, NULL, NULL, 0,
+ /* is_symlink= */
+ false)) {
return false;
}
}
src_content_len = njc.mount(i).src_content().size();
}
- if (mountAddMountPt(nsjconf, src, dst, fstype, options, flags, isDir,
+ if (mountAddMountPtTail(nsjconf, src, dst, fstype, options, flags, isDir,
mandatory, src_env, dst_env, src_content,
src_content_len, njc.mount(i).is_symlink())
== false) {
return false;
}
-bool mountAddMountPt(struct nsjconf_t * nsjconf, const char *src, const char *dst,
- const char *fstype, const char *options, uintptr_t flags, isDir_t isDir,
- bool mandatory, const char *src_env, const char *dst_env,
- const char *src_content, size_t src_content_len, bool is_symlink)
+static bool mountAddMountPt(struct nsjconf_t *nsjconf, bool head, const char *src, const char *dst,
+ const char *fstype, const char *options, uintptr_t flags, isDir_t isDir,
+ bool mandatory, const char *src_env, const char *dst_env,
+ const char *src_content, size_t src_content_len, bool is_symlink)
{
struct mounts_t *p = utilCalloc(sizeof(struct mounts_t));
p->src_content = utilMemDup((const uint8_t *)src_content, src_content_len);
p->src_content_len = src_content_len;
- TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
+ if (head) {
+ TAILQ_INSERT_HEAD(&nsjconf->mountpts, p, pointers);
+ } else {
+ TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
+ }
return true;
}
+bool mountAddMountPtHead(struct nsjconf_t * nsjconf, const char *src, const char *dst,
+ const char *fstype, const char *options, uintptr_t flags, isDir_t isDir,
+ bool mandatory, const char *src_env, const char *dst_env,
+ const char *src_content, size_t src_content_len, bool is_symlink)
+{
+ return mountAddMountPt(nsjconf, /* head= */ true, src, dst, fstype, options, flags, isDir,
+ mandatory, src_env, dst_env, src_content, src_content_len,
+ is_symlink);
+}
+
+bool mountAddMountPtTail(struct nsjconf_t * nsjconf, const char *src, const char *dst,
+ const char *fstype, const char *options, uintptr_t flags, isDir_t isDir,
+ bool mandatory, const char *src_env, const char *dst_env,
+ const char *src_content, size_t src_content_len, bool is_symlink)
+{
+ return mountAddMountPt(nsjconf, /* head= */ false, src, dst, fstype, options, flags, isDir,
+ mandatory, src_env, dst_env, src_content, src_content_len,
+ is_symlink);
+}
+
const char *mountDescribeMountPt(struct mounts_t *mpt)
{
static __thread char mount_pt_descr[4096];
const char *mountFlagsToStr(uintptr_t flags);
bool mountIsDir(const char *path);
bool mountInitNs(struct nsjconf_t *nsjconf);
-bool mountAddMountPt(struct nsjconf_t *nsjconf, const char *src, const char *dst,
- const char *fstype, const char *options, uintptr_t flags, isDir_t isDir,
- bool mandatory, const char *src_env, const char *dst_env,
- const char *src_content, size_t src_content_len, bool is_symlink);
+bool mountAddMountPtHead(struct nsjconf_t *nsjconf, const char *src, const char *dst,
+ const char *fstype, const char *options, uintptr_t flags, isDir_t isDir,
+ bool mandatory, const char *src_env, const char *dst_env,
+ const char *src_content, size_t src_content_len, bool is_symlink);
+bool mountAddMountPtTail(struct nsjconf_t *nsjconf, const char *src, const char *dst,
+ const char *fstype, const char *options, uintptr_t flags, isDir_t isDir,
+ bool mandatory, const char *src_env, const char *dst_env,
+ const char *src_content, size_t src_content_len, bool is_symlink);
const char *mountDescribeMountPt(struct mounts_t *mpt);
#endif /* NS_MOUNT_H */