cmdline: use mountAddMountPt in the remaining calls
authorRobert Swiecki <robert@swiecki.net>
Sat, 7 Oct 2017 22:14:24 +0000 (00:14 +0200)
committerRobert Swiecki <robert@swiecki.net>
Sat, 7 Oct 2017 22:14:24 +0000 (00:14 +0200)
cmdline.c

index ef112b6..eb70890 100644 (file)
--- a/cmdline.c
+++ b/cmdline.c
@@ -640,49 +640,41 @@ bool cmdlineParse(int argc, char *argv[], struct nsjconf_t * nsjconf)
                        }
                        break;
                case 'R':{
-                               struct mounts_t *p = utilMalloc(sizeof(struct mounts_t));
-                               p->src = optarg;
-                               p->src_content = NULL;
-                               p->src_content_len = 0;
                                const char *dst = cmdlineSplitStrByColon(optarg);
-                               p->dst = dst ? dst : optarg;
-                               p->flags = MS_BIND | MS_REC | MS_RDONLY;
-                               p->options = "";
-                               p->fs_type = "";
-                               p->isDir = mountIsDir(optarg);
-                               p->isSymlink = false;
-                               p->mandatory = true;
-                               TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
-                       } break;
+                               dst = dst ? dst : optarg;
+                               if (!mountAddMountPtTail(nsjconf, /* src= */ optarg, dst,
+                                                        /* fs_type= */ "", /* options= */ "",
+                                                        MS_BIND | MS_REC | MS_RDONLY, /* isDir= */
+                                                        NS_DIR_MAYBE,
+                                                        /* mandatory= */ true, NULL, NULL, NULL, 0,
+                                                        /* is_symlink= */ false)) {
+                                       return false;
+                               }
+                       };
+                       break;
                case 'B':{
-                               struct mounts_t *p = utilMalloc(sizeof(struct mounts_t));
-                               p->src = optarg;
-                               p->src_content = NULL;
-                               p->src_content_len = 0;
                                const char *dst = cmdlineSplitStrByColon(optarg);
-                               p->dst = dst ? dst : optarg;
-                               p->flags = MS_BIND | MS_REC;
-                               p->options = "";
-                               p->fs_type = "";
-                               p->isDir = mountIsDir(optarg);
-                               p->isSymlink = false;
-                               p->mandatory = true;
-                               TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
-                       } break;
+                               dst = dst ? dst : optarg;
+                               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= */ false)) {
+                                       return false;
+                               }
+                       };
+                       break;
                case 'T':{
-                               struct mounts_t *p = utilMalloc(sizeof(struct mounts_t));
-                               p->src = NULL;
-                               p->src_content = NULL;
-                               p->src_content_len = 0;
-                               p->dst = optarg;
-                               p->flags = 0;
-                               p->options = cmdlineTmpfsSz;
-                               p->fs_type = "tmpfs";
-                               p->isDir = true;
-                               p->isSymlink = false;
-                               p->mandatory = true;
-                               TAILQ_INSERT_TAIL(&nsjconf->mountpts, p, pointers);
-                       } break;
+                               if (!mountAddMountPtTail(nsjconf, /* src= */ NULL, optarg, "tmpfs", /* options= */ "", /* flags= */ 0,  /* isDir= */
+                                                        true,
+                                                        /* mandatory= */ true, NULL, NULL, NULL, 0,
+                                                        /* is_symlink= */
+                                                        false)) {
+                                       return false;
+                               }
+                       };
+                       break;
                case 'M':
                        switch (optarg[0]) {
                        case 'l':