p->options = "";
p->fs_type = "";
p->isDir = mountIsDir(optarg);
+ p->isSymlink = false;
p->mandatory = true;
TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
} break;
p->options = "";
p->fs_type = "";
p->isDir = mountIsDir(optarg);
+ p->isSymlink = false;
p->mandatory = true;
TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
} break;
p->options = cmdlineTmpfsSz;
p->fs_type = "tmpfs";
p->isDir = true;
+ p->isSymlink = false;
p->mandatory = true;
TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
} break;
p->options = "";
p->fs_type = "proc";
p->isDir = true;
+ p->isSymlink = false;
p->mandatory = true;
TAILQ_INSERT_HEAD(&nsjconf->mountpts, p, pointers);
}
p->options = "";
p->fs_type = "";
p->isDir = true;
+ p->isSymlink = false;
p->mandatory = true;
TAILQ_INSERT_HEAD(&nsjconf->mountpts, p, pointers);
} else {
p->options = "";
p->fs_type = "tmpfs";
p->isDir = true;
+ p->isSymlink = false;
p->mandatory = true;
TAILQ_INSERT_HEAD(&nsjconf->mountpts, p, pointers);
}
if (mountAddMountPt
(nsjconf, src, dst, fstype, options, flags, isDir, mandatory, src_env,
- dst_env, src_content, src_content_len) == false) {
+ dst_env, src_content, src_content_len, njc->mount[i]->is_symlink) == false) {
LOG_E("Couldn't add mountpoint for src:'%s' dst:'%s'", src, dst);
return false;
}
char dst[PATH_MAX];
snprintf(dst, sizeof(dst), "%s/%s", newroot, mpt->dst);
- LOG_D("Mounting '%s'", mountDescribeMountPt(mpt));
+ LOG_D("mounting '%s'", mountDescribeMountPt(mpt));
char srcpath[PATH_MAX];
if (mpt->src != NULL && strlen(mpt->src) > 0) {
snprintf(srcpath, sizeof(srcpath), "none");
}
- if (mpt->isDir == true) {
+ if (mpt->isSymlink == true) {
+ if (utilCreateDirRecursively(dst) == false) {
+ LOG_W("Couldn't create upper directories for '%s'", dst);
+ return false;
+ }
+ } else if (mpt->isDir == true) {
if (utilCreateDirRecursively(dst) == false) {
LOG_W("Couldn't create upper directories for '%s'", dst);
return false;
}
}
+ if (mpt->isSymlink == true) {
+ LOG_D("symlink('%s', '%s')", srcpath, dst);
+ if (symlink(srcpath, dst) == -1) {
+ PLOG_W("symlink('%s', '%s')", srcpath, dst);
+ return false;
+ }
+ return true;
+ }
+
if (mpt->src_content) {
snprintf(srcpath, sizeof(srcpath), "%s/file.XXXXXX", tmpdir);
int fd = mkostemp(srcpath, O_CLOEXEC);
static bool mountRemountRO(struct mounts_t *mpt)
{
+ if (mpt->isSymlink == true) {
+ return true;
+ }
if (!(mpt->flags & MS_RDONLY)) {
return true;
}
bool mountAddMountPt(struct nsjconf_t * nsjconf, const char *src, const char *dst,
const char *fstype, const char *options, uintptr_t flags, const bool * isDir,
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, bool is_symlink)
{
struct mounts_t *p = utilCalloc(sizeof(struct mounts_t));
p->options = utilStrDup(options);
p->flags = flags;
p->isDir = true;
+ p->isSymlink = is_symlink;
p->mandatory = mandatory;
if (isDir) {
utilSSnPrintf(mount_pt_descr, sizeof(mount_pt_descr), " src_content_len:%zu",
mpt->src_content_len);
}
+ if (mpt->isSymlink) {
+ utilSSnPrintf(mount_pt_descr, sizeof(mount_pt_descr), " symlink:true");
+ }
return mount_pt_descr;
}
bool mountAddMountPt(struct nsjconf_t *nsjconf, const char *src, const char *dst,
const char *fstype, const char *options, uintptr_t flags, const bool * isDir,
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, bool is_symlink);
const char *mountDescribeMountPt(struct mounts_t *mpt);
#endif /* NS_MOUNT_H */