From nobody Tue Sep 9 03:19:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1748941730; cv=none; d=zohomail.com; s=zohoarc; b=WZTyPh8MgCDiiqo7MF2Qwuvh14x/e9zeOhzu/R5K9EUAduqjvA0KNAssAZ3rKWBiTgi5h8vZu/uerTwYmKKXT3yAuH9Fbe/VxIiGwhYEziKKMSv7InKVpJsJZgxI+Fqk1+Ls3p3MJtLssalR0TWG2jzycuA69RpypFltA9JSO6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748941730; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=Xi+lv1kRA12m13PFJVDsdn0Y54rR2VLT+S4lz7r2TEg=; b=kzoaBnKQzIxveUVKFKqtRChz2OxkAYceu65fXxAQJsZ970o95F2wMiMVAY+QSmTUYkw+WMEiP82I9GUxQj7bNr+cxF2Xc3qjjskH0M4vw+0RjXC1ImZ5zup48mh5iZWqbzVW/6j6BEeCqKSY4YSnJYUf/zIia4n/HTPiJLAVfX0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1748941730770562.2399793298541; Tue, 3 Jun 2025 02:08:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A57821393; Tue, 3 Jun 2025 05:08:49 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 136B81403; Tue, 3 Jun 2025 05:08:04 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1DA2C1542; Tue, 3 Jun 2025 05:08:00 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B1BE51542 for ; Tue, 3 Jun 2025 05:07:53 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-443-M628VQDxMAW_LVQxYi3kJA-1; Tue, 03 Jun 2025 05:07:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E09AC19560B1 for ; Tue, 3 Jun 2025 09:07:50 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C39C19560AB for ; Tue, 3 Jun 2025 09:07:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748941673; h=from:from: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; bh=nD8wRSRxQW9uve/8/XR6p34DP4JdwNJbEmvKxEVku9U=; b=H8e/jtMGqNiknBe+EIKIOEr3k/VUHuO+zEaryEm+fhV01+Jcqb7dIgpiIbWco8y5O/zUwb LH8bOsXeBYiCz/RLuQM2hnN5YcKgm9OpbiYCZoy5hYHDMbrVK/87BrbGkjOvtrG4y1Qwq0 hESm/MkzKr9pJ9Pvnrh8MRFImdIKgkE= X-MC-Unique: M628VQDxMAW_LVQxYi3kJA-1 X-Mimecast-MFC-AGG-ID: M628VQDxMAW_LVQxYi3kJA_1748941671 To: devel@lists.libvirt.org Subject: [PATCH 2/2] util: Move virFileGetExistingParent out of ifdef __linux__ Date: Tue, 3 Jun 2025 11:07:44 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: DDrITzTF-Q_Ga2Nh8QLz-TcBJN735NYSbR8oog51ZXc_1748941671 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7KYBDKZVBGUHTA4DL6537XX2YPFWMFBP X-Message-ID-Hash: 7KYBDKZVBGUHTA4DL6537XX2YPFWMFBP X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1748941732034116600 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark The function is called by virFileIsSharedFSOverride which is not Linux specific and thus building on anything but Linux failes. Fixes: 94fb348d670f612c0b58901c9829b4eec81faa50 Signed-off-by: Jiri Denemark --- src/util/virfile.c | 55 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index d79a60baee..1b3f37db7a 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3444,6 +3444,34 @@ virFileRemoveLastComponent(char *path) path[0] =3D '\0'; } =20 + +static char * +virFileGetExistingParent(const char *path) +{ + g_autofree char *dirpath =3D g_strdup(path); + char *p =3D NULL; + + /* Try less and less of the path until we get to a directory we can st= at. + * Even if we don't have 'x' permission on any directory in the path o= n the + * NFS server (assuming it's NFS), we will be able to stat the mount p= oint. + */ + while (!virFileExists(dirpath) && p !=3D dirpath) { + if (!(p =3D strrchr(dirpath, '/'))) { + virReportSystemError(EINVAL, + _("Invalid relative path '%1$s'"), path); + return NULL; + } + + if (p =3D=3D dirpath) + *(p + 1) =3D '\0'; + else + *p =3D '\0'; + } + + return g_steal_pointer(&dirpath); +} + + #ifdef __linux__ =20 # ifndef NFS_SUPER_MAGIC @@ -3557,33 +3585,6 @@ virFileIsSharedFsFUSE(const char *path, } =20 =20 -static char * -virFileGetExistingParent(const char *path) -{ - g_autofree char *dirpath =3D g_strdup(path); - char *p =3D NULL; - - /* Try less and less of the path until we get to a directory we can st= at. - * Even if we don't have 'x' permission on any directory in the path o= n the - * NFS server (assuming it's NFS), we will be able to stat the mount p= oint. - */ - while (!virFileExists(dirpath) && p !=3D dirpath) { - if (!(p =3D strrchr(dirpath, '/'))) { - virReportSystemError(EINVAL, - _("Invalid relative path '%1$s'"), path); - return NULL; - } - - if (p =3D=3D dirpath) - *(p + 1) =3D '\0'; - else - *p =3D '\0'; - } - - return g_steal_pointer(&dirpath); -} - - static const struct virFileSharedFsData virFileSharedFs[] =3D { { .fstype =3D VIR_FILE_SHFS_NFS, .magic =3D NFS_SUPER_MAGIC }, { .fstype =3D VIR_FILE_SHFS_GFS2, .magic =3D GFS2_MAGIC }, --=20 2.49.0