mount: introduce mountDescribeMountPt
This commit is contained in:
parent
aeb2e998b8
commit
9519f1038b
@ -223,12 +223,7 @@ void cmdlineLogParams(struct nsjconf_t *nsjconf)
|
|||||||
{
|
{
|
||||||
struct mounts_t *p;
|
struct mounts_t *p;
|
||||||
TAILQ_FOREACH(p, &nsjconf->mountpts, pointers) {
|
TAILQ_FOREACH(p, &nsjconf->mountpts, pointers) {
|
||||||
LOG_I
|
LOG_I("Mount point: %s", mountDescribeMountPt(p));
|
||||||
("Mount point: src:'%s' dst:'%s' type:'%s' flags:%s options:'%s' isDir:%s mandatory:%s src_content:%s (size:%zu)",
|
|
||||||
p->src ? p->src : "[NULL]", p->dst, p->fs_type ? p->fs_type : "[NULL]",
|
|
||||||
mountFlagsToStr(p->flags), p->options ? p->options : "[NULL]",
|
|
||||||
p->isDir ? "true" : "false", p->mandatory ? "true" : "false",
|
|
||||||
p->src_content ? "true" : "false", p->src_content_len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
48
mount.c
48
mount.c
@ -122,10 +122,7 @@ static bool mountMount(struct mounts_t *mpt, const char *newroot, const char *tm
|
|||||||
char dst[PATH_MAX];
|
char dst[PATH_MAX];
|
||||||
snprintf(dst, sizeof(dst), "%s/%s", newroot, mpt->dst);
|
snprintf(dst, sizeof(dst), "%s/%s", newroot, mpt->dst);
|
||||||
|
|
||||||
LOG_D("Mounting '%s' on '%s' (fstype:'%s', flags:%s, options:'%s', is_dir:%s)",
|
LOG_D("Mounting '%s'", mountDescribeMountPt(mpt));
|
||||||
mpt->src ? mpt->src : "[NULL]", dst, mpt->fs_type ? mpt->fs_type : "[NULL]",
|
|
||||||
mountFlagsToStr(mpt->flags), mpt->options ? mpt->options : "[NULL]",
|
|
||||||
mpt->isDir ? "True" : "False");
|
|
||||||
|
|
||||||
char srcpath[PATH_MAX];
|
char srcpath[PATH_MAX];
|
||||||
if (mpt->src != NULL && strlen(mpt->src) > 0) {
|
if (mpt->src != NULL && strlen(mpt->src) > 0) {
|
||||||
@ -178,23 +175,15 @@ static bool mountMount(struct mounts_t *mpt, const char *newroot, const char *tm
|
|||||||
unsigned long flags = mpt->flags & ~(MS_RDONLY);
|
unsigned long flags = mpt->flags & ~(MS_RDONLY);
|
||||||
if (mount(srcpath, dst, mpt->fs_type, flags, mpt->options) == -1) {
|
if (mount(srcpath, dst, mpt->fs_type, flags, mpt->options) == -1) {
|
||||||
if (mpt->mandatory == false) {
|
if (mpt->mandatory == false) {
|
||||||
PLOG_D
|
PLOG_D("mount('%s') src:'%s' dst:'%s' failed", mountDescribeMountPt(mpt),
|
||||||
("mount(src:'%s', dst:'%s', fstype:'%s', flags:'%s', mandatory:%s) failed. "
|
srcpath, dst);
|
||||||
"Skipping this mount as it's non-mandatory", srcpath, dst,
|
|
||||||
mpt->fs_type ? mpt->fs_type : "[NULL]", mountFlagsToStr(mpt->flags),
|
|
||||||
mpt->mandatory ? "true" : "false");
|
|
||||||
} else if (errno == EACCES) {
|
} else if (errno == EACCES) {
|
||||||
PLOG_E
|
PLOG_E("mount('%s') src:'%s' dst:'%s' failed. "
|
||||||
("mount(src:'%s', dst:'%s', fstype:'%s', flags:'%s', mandatory:%s) failed. "
|
"Try fixing this problem by applying 'chmod o+x' to the '%s' directory and "
|
||||||
"Try fixing this problem by applying 'chmod o+x' to the '%s' directory and "
|
"its ancestors", mountDescribeMountPt(mpt), srcpath, dst, srcpath);
|
||||||
"its ancestors", srcpath, dst, mpt->fs_type ? mpt->fs_type : "[NULL]",
|
|
||||||
mountFlagsToStr(mpt->flags), mpt->src,
|
|
||||||
mpt->mandatory ? "true" : "false");
|
|
||||||
} else {
|
} else {
|
||||||
PLOG_E
|
PLOG_E("mount('%s') src:'%s' dst:'%s' failed", mountDescribeMountPt(mpt),
|
||||||
("mount(src:'%s', dst:'%s', fstype:'%s', flags:'%s' mandatory:%s) failed",
|
srcpath, dst);
|
||||||
srcpath, dst, mpt->fs_type ? mpt->fs_type : "[NULL]",
|
|
||||||
mountFlagsToStr(mpt->flags), mpt->mandatory ? "true" : "false");
|
|
||||||
}
|
}
|
||||||
if (mpt->mandatory) {
|
if (mpt->mandatory) {
|
||||||
return false;
|
return false;
|
||||||
@ -422,3 +411,24 @@ bool mountAddMountPt(struct nsjconf_t * nsjconf, const char *src, const char *ds
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *mountDescribeMountPt(struct mounts_t *mpt)
|
||||||
|
{
|
||||||
|
static __thread char mount_pt_descr[4096];
|
||||||
|
|
||||||
|
snprintf(mount_pt_descr, sizeof(mount_pt_descr),
|
||||||
|
"src:'%s' dst:'%s' type:'%s' flags:%s options:'%s' isDir:%s",
|
||||||
|
mpt->src ? mpt->src : "[NULL]", mpt->dst, mpt->fs_type ? mpt->fs_type : "[NULL]",
|
||||||
|
mountFlagsToStr(mpt->flags), mpt->options ? mpt->options : "[NULL]",
|
||||||
|
mpt->isDir ? "true" : "false");
|
||||||
|
|
||||||
|
if (mpt->mandatory == false) {
|
||||||
|
utilSSnPrintf(mount_pt_descr, sizeof(mount_pt_descr), " mandatory:false");
|
||||||
|
}
|
||||||
|
if (mpt->src_content) {
|
||||||
|
utilSSnPrintf(mount_pt_descr, sizeof(mount_pt_descr), " src_content_len:%zu",
|
||||||
|
mpt->src_content_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mount_pt_descr;
|
||||||
|
}
|
||||||
|
1
mount.h
1
mount.h
@ -33,5 +33,6 @@ bool mountAddMountPt(struct nsjconf_t *nsjconf, const char *src, const char *dst
|
|||||||
const char *fstype, const char *options, uintptr_t flags, const bool * isDir,
|
const char *fstype, const char *options, uintptr_t flags, const bool * isDir,
|
||||||
bool mandatory, const char *src_env, const char *dst_env,
|
bool mandatory, const char *src_env, const char *dst_env,
|
||||||
const uint8_t * src_content, size_t src_content_len);
|
const uint8_t * src_content, size_t src_content_len);
|
||||||
|
const char *mountDescribeMountPt(struct mounts_t *mpt);
|
||||||
|
|
||||||
#endif /* NS_MOUNT_H */
|
#endif /* NS_MOUNT_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user