mount: don't R/O remount mounts which were not mounted (not mandatory)
This commit is contained in:
parent
6d29c196ac
commit
b7def79d90
12
cmdline.c
12
cmdline.c
@ -644,8 +644,7 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
|
||||
dst = dst ? dst : optarg;
|
||||
if (!mountAddMountPtTail
|
||||
(nsjconf, /* src= */ optarg, dst, /* fs_type= */ "",
|
||||
/* options= */ "", MS_BIND | MS_REC | MS_RDONLY,
|
||||
/* isDir= */
|
||||
/* options= */ "", MS_BIND | MS_REC | MS_RDONLY, /* isDir= */
|
||||
NS_DIR_MAYBE, /* mandatory= */ true, NULL, NULL, NULL, 0,
|
||||
/* is_symlink= */ false)) {
|
||||
return false;
|
||||
@ -658,8 +657,7 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
|
||||
if (!mountAddMountPtTail
|
||||
(nsjconf, /* src= */ optarg, dst, /* fs_type= */ "",
|
||||
/* options= */ "", MS_BIND | MS_REC, /* isDir= */ NS_DIR_MAYBE,
|
||||
/* mandatory= */ true, NULL, NULL, NULL, 0,
|
||||
/* is_symlink= */
|
||||
/* mandatory= */ true, NULL, NULL, NULL, 0, /* is_symlink= */
|
||||
false)) {
|
||||
return false;
|
||||
}
|
||||
@ -763,9 +761,9 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!mountAddMountPtHead(nsjconf, /* src= */ NULL, "/", "tmpfs", /* options= */ "",
|
||||
nsjconf->is_root_rw ? 0 : MS_RDONLY, /* isDir= */ true,
|
||||
/* mandatory= */ true,
|
||||
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;
|
||||
}
|
||||
|
1
common.h
1
common.h
@ -76,6 +76,7 @@ struct mounts_t {
|
||||
bool isDir;
|
||||
bool isSymlink;
|
||||
bool mandatory;
|
||||
bool mounted;
|
||||
TAILQ_ENTRY(mounts_t)
|
||||
pointers;
|
||||
};
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
bool containSetupFD(struct nsjconf_t * nsjconf, int fd_in, int fd_out, int fd_err);
|
||||
bool containSetupFD(struct nsjconf_t *nsjconf, int fd_in, int fd_out, int fd_err);
|
||||
bool containContain(struct nsjconf_t *nsjconf);
|
||||
|
||||
#endif /* NS_CONTAIN_H */
|
||||
|
6
mount.c
6
mount.c
@ -207,6 +207,8 @@ static bool mountMount(struct mounts_t *mpt, const char *newroot, const char *tm
|
||||
PLOG_W("mount('%s') src:'%s' dst:'%s' failed", mountDescribeMountPt(mpt),
|
||||
srcpath, dst);
|
||||
}
|
||||
} else {
|
||||
mpt->mounted = true;
|
||||
}
|
||||
|
||||
if (mpt->src_content && unlink(srcpath) == -1) {
|
||||
@ -217,6 +219,9 @@ static bool mountMount(struct mounts_t *mpt, const char *newroot, const char *tm
|
||||
|
||||
static bool mountRemountRO(struct mounts_t *mpt)
|
||||
{
|
||||
if (!mpt->mounted) {
|
||||
return true;
|
||||
}
|
||||
if (mpt->isSymlink == true) {
|
||||
return true;
|
||||
}
|
||||
@ -451,6 +456,7 @@ static bool mountAddMountPt(struct nsjconf_t *nsjconf, bool head, const char *sr
|
||||
p->isDir = true;
|
||||
p->isSymlink = is_symlink;
|
||||
p->mandatory = mandatory;
|
||||
p->mounted = false;
|
||||
|
||||
switch (isDir) {
|
||||
case NS_DIR_YES:
|
||||
|
Loading…
Reference in New Issue
Block a user