From nobody Sun Feb 8 18:31:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1607961441; cv=none; d=zohomail.com; s=zohoarc; b=Fu9oHSOvx8lG4M3tunKHHb2p2BQE0XxZabFU2qQPq1S8IOhdcxpSXulgXtj72TOp/Nk0Z5Hh1bcPUo+U/2TPsoOLzYJooRLjxJvikL66WomWXHVoHl9ZZ/fK2fQbDnfZx8GKHmP4GmASpnJ+7O/UyZGgPhCsmhAu6ayneC+N4QY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607961441; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bv3eJuamD0cD6VgH7sGJtmDKoyoALWk0NAHOaVisj5w=; b=TFTsZTaTlRa66u/wKaIGHtLDTD5Ee13Ea0R09b5LUHbW0oJYaf1N8jezA29Y5t2IHMQ3c28ECOHKeZ5WGAjqchErcOQqZ3BISEHFnmq8JvTmajr6dva64mF4LFp8EtPxUlEPQV93lMNeb6/B390s+oq/C27pDxih0+xjlIXSoQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1607961441622814.8489828117534; Mon, 14 Dec 2020 07:57:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-T5XDrelVNuOfgyFGRBSDpw-1; Mon, 14 Dec 2020 10:56:22 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADEC3801AAA; Mon, 14 Dec 2020 15:56:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88AFB173EA; Mon, 14 Dec 2020 15:56:16 +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 004AB5003C; Mon, 14 Dec 2020 15:56:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BEFtpIQ028580 for ; Mon, 14 Dec 2020 10:55:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46EBA17B77; Mon, 14 Dec 2020 15:55:51 +0000 (UTC) Received: from antique-work.lan (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id B86165D6D5 for ; Mon, 14 Dec 2020 15:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607961438; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Bv3eJuamD0cD6VgH7sGJtmDKoyoALWk0NAHOaVisj5w=; b=cTl9aoWPnjljNMMwkm6lKe7fW8PryHAFqLCUhRLRZFgmUpBkCazi7NbF/7q2swy/mcQlgK U/0jMvBFk7vtY8kILOP0rfJzKTjEwwFX0PZ0yHhm8dIgglcp34kgUB7pqn3uqARXisrwSr Qo1iQ1eGneGtwyNjEWbqe3jKnbksUFU= X-MC-Unique: T5XDrelVNuOfgyFGRBSDpw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 09/17] virstoragefile: move virStorageIsFile into virfile Date: Mon, 14 Dec 2020 16:55:29 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 2 +- src/util/virfile.c | 21 +++++++++++++++++++++ src/util/virfile.h | 1 + src/util/virstoragefile.c | 26 +++----------------------- src/util/virstoragefile.h | 1 - 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 57f3b12000..0b560dfe45 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2090,6 +2090,7 @@ virFileIsCDROM; virFileIsClusterFS; virFileIsDir; virFileIsExecutable; +virFileIsFile; virFileIsLink; virFileIsMountPoint; virFileIsRegular; @@ -3156,7 +3157,6 @@ virStorageFileSupportsBackingChainTraversal; virStorageFileSupportsCreate; virStorageFileSupportsSecurityDriver; virStorageFileUnlink; -virStorageIsFile; virStorageIsRelative; virStorageNetHostDefClear; virStorageNetHostDefCopy; diff --git a/src/util/virfile.c b/src/util/virfile.c index 3f58b98248..7a7468b202 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1995,6 +1995,27 @@ virFileIsCDROM(const char *path) #endif /* defined(__linux__) */ =20 =20 +bool +virFileIsFile(const char *backing) +{ + char *colon; + char *slash; + + if (!backing) + return false; + + colon =3D strchr(backing, ':'); + slash =3D strchr(backing, '/'); + + /* Reject anything that looks like a protocol (such as nbd: or + * rbd:); if someone really does want a relative file name that + * includes ':', they can always prefix './'. */ + if (colon && (!slash || colon < slash)) + return false; + return true; +} + + #if defined WITH_MNTENT_H && defined WITH_GETMNTENT_R static int virFileGetMountSubtreeImpl(const char *mtabpath, diff --git a/src/util/virfile.h b/src/util/virfile.h index 733d652ac9..dfd3188ff2 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -227,6 +227,7 @@ int virFileIsClusterFS(const char *path) ATTRIBUTE_NONN= ULL(1); int virFileIsMountPoint(const char *file) ATTRIBUTE_NONNULL(1); int virFileIsCDROM(const char *path) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; +bool virFileIsFile(const char *path); =20 int virFileGetMountSubtree(const char *mtabpath, const char *prefix, diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3db85d8b89..f37802260b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -756,26 +756,6 @@ virStorageFileMatchesVersion(int versionOffset, return false; } =20 -bool -virStorageIsFile(const char *backing) -{ - char *colon; - char *slash; - - if (!backing) - return false; - - colon =3D strchr(backing, ':'); - slash =3D strchr(backing, '/'); - - /* Reject anything that looks like a protocol (such as nbd: or - * rbd:); if someone really does want a relative file name that - * includes ':', they can always prefix './'. */ - if (colon && (!slash || colon < slash)) - return false; - return true; -} - =20 bool virStorageIsRelative(const char *backing) @@ -783,7 +763,7 @@ virStorageIsRelative(const char *backing) if (backing[0] =3D=3D '/') return false; =20 - if (!virStorageIsFile(backing)) + if (!virFileIsFile(backing)) return false; =20 return true; @@ -1450,7 +1430,7 @@ virStorageFileChainLookup(virStorageSourcePtr chain, { virStorageSourcePtr prev; const char *start =3D chain->path; - bool nameIsFile =3D virStorageIsFile(name); + bool nameIsFile =3D virFileIsFile(name); =20 if (!parent) parent =3D &prev; @@ -3794,7 +3774,7 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th, =20 *src =3D NULL; =20 - if (virStorageIsFile(path)) { + if (virFileIsFile(path)) { def->type =3D VIR_STORAGE_TYPE_FILE; =20 def->path =3D g_strdup(path); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2452b967b2..2a44a535a1 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -420,7 +420,6 @@ virStorageSourcePtr virStorageFileChainLookup(virStorag= eSourcePtr chain, virStorageSourcePtr *parent) ATTRIBUTE_NONNULL(1); =20 -bool virStorageIsFile(const char *path); bool virStorageIsRelative(const char *backing); =20 int virStorageFileGetSCSIKey(const char *path, --=20 2.28.0