From: Nikhilkumar Shelke Date: Wed, 19 Jan 2022 07:10:49 +0000 (+0530) Subject: mount: add option to supports fake mounts in mount.ceph X-Git-Tag: v18.0.0~1419^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db2d057c2de28be9a325dcc3f8dd0103fed12830;p=ceph.git mount: add option to supports fake mounts in mount.ceph Fixes: https://tracker.ceph.com/issues/53903 Signed-off-by: Nikhilkumar Shelke --- diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 14b979e12b1..abbbe80cb93 100644 --- a/src/mount/mount.ceph.c +++ b/src/mount/mount.ceph.c @@ -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);