case 'T':
{
struct mounts_t *p = utilMalloc(sizeof(struct mounts_t));
- p->src = "/";
+ p->src = NULL;
p->dst = optarg;
p->flags = 0;
p->options = cmdlineTmpfsSz;
if (nsjconf->mount_proc == true) {
struct mounts_t *p = utilMalloc(sizeof(struct mounts_t));
- p->src = "/proc";
+ p->src = NULL;
p->dst = "/proc";
p->flags = 0;
p->options = "";
p->flags |= MS_RDONLY;
}
TAILQ_INSERT_HEAD(&nsjconf->mountpts, p, pointers);
+ } else {
+ struct mounts_t *p = utilMalloc(sizeof(struct mounts_t));
+ p->src = NULL;
+ p->dst = "/";
+ p->flags = 0;
+ p->options = "";
+ p->fs_type = "tmpfs";
+ if (nsjconf->is_root_rw == false) {
+ p->flags |= MS_RDONLY;
+ }
+ TAILQ_INSERT_HEAD(&nsjconf->mountpts, p, pointers);
}
if (logInitLogFile(nsjconf, logfile, nsjconf->verbose) == false) {
static bool mountIsDir(const char *path)
{
- if (path == NULL || strcmp(path, "none") == 0) {
- return false;
+ /*
+ * If the source dir is NULL, we assume it's a dir (for /proc and tmpfs)
+ */
+ if (path == NULL) {
+ return true;
}
struct stat st;
if (stat(path, &st) == -1) {
// stat() failure
static bool mountNotIsDir(const char *path)
{
- if (path == NULL || strcmp(path, "none") == 0) {
+ if (path == NULL) {
return false;
}
struct stat st;
}
}
- if (mount(mpt->src, dst, mpt->fs_type, mpt->flags, mpt->options) == -1) {
+ /*
+ * Initially mount it as RW, it will be remounted later on if needed
+ */
+ unsigned long flags = mpt->flags & ~(MS_RDONLY);
+ if (mount(mpt->src, dst, mpt->fs_type, flags, mpt->options) == -1) {
if (errno == EACCES) {
PLOG_E
("mount('%s', '%s', type='%s') failed. Try fixing this problem by applying 'chmod o+x' to the '%s' directory and its ancestors",
}
const char *const destdir = "/tmp";
- if (mount("none", destdir, "tmpfs", 0, NULL) == -1) {
+ if (mount(NULL, destdir, "tmpfs", 0, NULL) == -1) {
PLOG_E("mount('%s', 'tmpfs'", destdir);
return false;
}