From nobody Sun Feb 8 22:57:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486477248027220.89838766221578; Tue, 7 Feb 2017 06:20:48 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v17EHOO7031301; Tue, 7 Feb 2017 09:17:24 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v17EGmtw016018 for ; Tue, 7 Feb 2017 09:16:48 -0500 Received: from beluga.usersys.redhat.com (dhcp129-94.brq.redhat.com [10.34.129.94]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v17EGixT010056; Tue, 7 Feb 2017 09:16:47 -0500 From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 7 Feb 2017 15:16:38 +0100 Message-Id: <02cc2317b5dbc99810b53a4801e04750b3389074.1486476642.git.eskultet@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 3/3] storage: Fix checking whether source filesystem is mounted 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Right now, we use simple string comparison both on the source paths (mount's output vs pool's source) and the target (mount's mnt_dir vs pool's target). The problem are symlinks and mount indeed returns symlinks in its output, e.g. /dev/mappper/lvm_symlink. The same goes for the pool's source/target, so in order to successfully compare these two replace plain string comparison with virFileComparePaths which will resolve all symlinks and canonicalize the paths prior to comparison. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1417203 Signed-off-by: Erik Skultety --- src/storage/storage_backend_fs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index fe4705b..fae1c03 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -301,6 +301,7 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjP= tr pool) FILE *mtab; struct mntent ent; char buf[1024]; + int rc1, rc2; =20 if ((mtab =3D fopen(_PATH_MOUNTED, "r")) =3D=3D NULL) { virReportSystemError(errno, @@ -313,8 +314,15 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObj= Ptr pool) if (!(src =3D virStorageBackendFileSystemGetPoolSource(pool))) goto cleanup; =20 - if (STREQ(ent.mnt_dir, pool->def->target.path) && - STREQ(ent.mnt_fsname, src)) { + /* compare both mount destinations and sources to be sure the moun= ted + * FS pool is really the one we're looking for + */ + if ((rc1 =3D virFileComparePaths(ent.mnt_dir, + pool->def->target.path)) < 0 || + (rc2 =3D virFileComparePaths(ent.mnt_fsname, src)) < 0) + goto cleanup; + + if (rc1 =3D=3D 0 && rc2 =3D=3D 0) { ret =3D 1; goto cleanup; } --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list