]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mount: add option to supports fake mounts in mount.ceph
authorNikhilkumar Shelke <nshelke@redhat.com>
Wed, 19 Jan 2022 07:10:49 +0000 (12:40 +0530)
committerNikhilkumar Shelke <nshelke@redhat.com>
Wed, 19 Jan 2022 09:03:53 +0000 (14:33 +0530)
Fixes: https://tracker.ceph.com/issues/53903
Signed-off-by: Nikhilkumar Shelke <nshelke@redhat.com>
src/mount/mount.ceph.c

index 14b979e12b125d652b18c64f2dc8e1c32ae1684e..abbbe80cb932f07c50f6b86528676326a6c96867 100644 (file)
@@ -18,6 +18,7 @@
 #endif
 
 bool verboseflag = false;
+bool fakeflag = false;
 bool skip_mtab_flag = false;
 bool v2_addrs = false;
 bool no_fallback = false;
@@ -645,6 +646,8 @@ static int parse_arguments(int argc, char *const *const argv,
                        skip_mtab_flag = true;
                else if (!strcmp("-v", argv[i]))
                        verboseflag = true;
+               else if (!strcmp("-f", argv[i]))
+                       fakeflag = true;
                else if (!strcmp("-o", argv[i])) {
                        ++i;
                        if (i >= argc) {
@@ -679,6 +682,7 @@ static void usage(const char *prog_name)
        printf("\t-h: Print this help\n");
        printf("\t-n: Do not update /etc/mtab\n");
        printf("\t-v: Verbose\n");
+       printf("\t-f: Fake mount, do not actually mount\n");
        printf("\tceph-options: refer to mount.ceph(8)\n");
        printf("\n");
 }
@@ -698,6 +702,15 @@ static void ceph_mount_info_free(struct ceph_mount_info *cmi)
        free(cmi->cmi_conf);
 }
 
+static int call_mount_system_call(const char *rsrc, const char *node, struct ceph_mount_info *cmi)
+{
+       int r = 0;
+       if (!fakeflag) {
+               r = mount(rsrc, node, "ceph", cmi->cmi_flags, cmi->cmi_opts);
+       }
+       return r;
+}
+
 static int mount_new_device_format(const char *node, struct ceph_mount_info *cmi)
 {
        int r;
@@ -724,7 +737,7 @@ static int mount_new_device_format(const char *node, struct ceph_mount_info *cmi
        if (cmi->cmi_opts)
                mount_ceph_debug("mount.ceph: options \"%s\" will pass to kernel\n",
                                 cmi->cmi_opts);
-       r = mount(rsrc, node, "ceph", cmi->cmi_flags, cmi->cmi_opts);
+       r = call_mount_system_call(rsrc, node, cmi);
        if (r)
                r = -errno;
        free(rsrc);
@@ -764,7 +777,7 @@ static int mount_old_device_format(const char *node, struct ceph_mount_info *cmi
                mount_ceph_debug("mount.ceph: options \"%s\" will pass to kernel\n",
                                 cmi->cmi_opts);
 
-       r = mount(rsrc, node, "ceph", cmi->cmi_flags, cmi->cmi_opts);
+       r = call_mount_system_call(rsrc, node, cmi);
        free(mon_addr);
        free(rsrc);