From: Xiubo Li Date: Mon, 14 Nov 2022 10:11:39 +0000 (+0800) Subject: mount: fix mount failure with old kernels X-Git-Tag: v17.2.6~88^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F49404%2Fhead;p=ceph.git mount: fix mount failure with old kernels If the 'cmi->cmi_opts' has only one option and there is no any comma in it, when removing the 'mon_addr' it will fail. And will pass the 'mon_addr' option to the old kernels. Fixes: https://tracker.ceph.com/issues/58018 Signed-off-by: Xiubo Li (cherry picked from commit 3180332ec48596794e2ff4fff305119c4ec2caf7) --- diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 032c22e6c23f..ff1b12c474e5 100644 --- a/src/mount/mount.ceph.c +++ b/src/mount/mount.ceph.c @@ -164,7 +164,9 @@ static int remove_opt(struct ceph_mount_info *cmi, const char *key, char **value memmove(key_start, value_end, len2); } else { /* last kv pair - swallow the comma */ - --key_start; + if (*(key_start - 1) == ',') { + --key_start; + } *key_start = '\0'; }