From nobody Thu May 2 08:09:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539069122738688.1605219949627; Tue, 9 Oct 2018 00:12:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 504D4308213B; Tue, 9 Oct 2018 07:11:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CDE2F1001F41; Tue, 9 Oct 2018 07:11:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 58148180474F; Tue, 9 Oct 2018 07:11:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w997Alo0010851 for ; Tue, 9 Oct 2018 03:10:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id D9EE117AD9; Tue, 9 Oct 2018 07:10:47 +0000 (UTC) Received: from hansolo.pek2.redhat.com (wlc-trust-100.pek2.redhat.com [10.72.3.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D6DC6092D; Tue, 9 Oct 2018 07:10:44 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Tue, 9 Oct 2018 15:10:18 +0800 Message-Id: <20181009071017.23977-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v2] virFileIsSharedFixFUSE: Copy mnt_dir when browsing mount table X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 09 Oct 2018 07:12:00 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fix typos of function name in commit msg. v1 version: https://www.redhat.com/archives/libvir-list/2018-October/msg005= 11.html virFileIsSharedFixFUSE doesn't fix f_type when "fuse.glusterfs" is not the last row of mount table. For example, it doesn't works on the mount table like following: 10.XX.XX.XX:/gv0 /mnt fuse.glusterfs rw 0 0 root@XX.XX.XX:/tmp/mkdir /tmp/br0 fuse.sshfs rw 0 0 Copy mnt_dir of struct mntent in case its mnt_dir is changed by getmntent_r in the loop later. Signed-off-by: Han Han --- src/util/virfile.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 2a7e87102a..c503462633 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3469,7 +3469,7 @@ virFileIsSharedFixFUSE(const char *path, long *f_type) { char *dirpath =3D NULL; - const char **mounts =3D NULL; + char **mounts =3D NULL; size_t nmounts =3D 0; char *p; FILE *f =3D NULL; @@ -3491,8 +3491,12 @@ virFileIsSharedFixFUSE(const char *path, if (STRNEQ("fuse.glusterfs", mb.mnt_type)) continue; =20 - if (VIR_APPEND_ELEMENT_COPY(mounts, nmounts, mb.mnt_dir) < 0) + char *mnt_dir; + if (VIR_STRDUP(mnt_dir, mb.mnt_dir) < 0 || + VIR_APPEND_ELEMENT_COPY(mounts, nmounts, mnt_dir) < 0) { + VIR_FREE(mnt_dir); goto cleanup; + } } =20 /* Add NULL sentinel so that this is a virStringList */ @@ -3512,7 +3516,7 @@ virFileIsSharedFixFUSE(const char *path, else *p =3D '\0'; =20 - if (virStringListHasString(mounts, dirpath)) { + if (virStringListHasString((const char **)mounts, dirpath)) { VIR_DEBUG("Found gluster FUSE mountpoint=3D%s for path=3D%s. " "Fixing shared FS type", dirpath, path); *f_type =3D GFS2_MAGIC; @@ -3523,7 +3527,7 @@ virFileIsSharedFixFUSE(const char *path, ret =3D 0; cleanup: endmntent(f); - VIR_FREE(mounts); + virStringListFree(mounts); VIR_FREE(dirpath); return ret; } --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list