From nobody Mon Feb 9 07:06:26 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=1614591420; cv=none; d=zohomail.com; s=zohoarc; b=Ugs4DT/iVSA5HWthm4woIQIRm6hkxjkmVY7TQgw1vJfWIwapq1dC31FNYe19bYpxPpaFZXhzwL4vSvuePxtcWg/Yvy2ylVWWrdCGFluMsjcHtNnE+XJOlE6Lo9Gn0K4NXw9CAdSqpmXkTbjspdr4LPoI2SAR8s03vct2fB+h8Iw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614591420; 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=fkpoLCXlj19j2OmA5Gz6CQuFNppgQoFPQ8DZ1ERcbMk=; b=Fzg0wPF66J6Yn7Z5Wv+GFrFfa1OgBCPj2xwO3JIWT+e6OR04/lg0sbHPksw5ij1YV597X17afn58CgazLz1d+DVCRKeHtMrGxjKs8I9ZtGuvuwTri3LZOeR6yx/9uIPi1T76SMpVIcJyih54565QWvtQ7duEqFFCLjJ+YJVuqd0= 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 1614591420531706.6586351096305; Mon, 1 Mar 2021 01:37:00 -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-166-8F_li2GOOYSSCiNxurELqQ-1; Mon, 01 Mar 2021 04:36:57 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF1158710EC; Mon, 1 Mar 2021 09:36:51 +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 985CB1A44A; Mon, 1 Mar 2021 09:36:51 +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 5DB0A18095CD; Mon, 1 Mar 2021 09:36:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1219aMpQ013723 for ; Mon, 1 Mar 2021 04:36:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 54F0B60C04; Mon, 1 Mar 2021 09:36:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B08A60BFA for ; Mon, 1 Mar 2021 09:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614591419; 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=fkpoLCXlj19j2OmA5Gz6CQuFNppgQoFPQ8DZ1ERcbMk=; b=Vzb59iZgUcC7Fec5xaKKXVylHPaJs2npGbo/9bogvzorcRPr4iOy96s0J2VXUlR7VYXEDD uRBJVdIJqx4yIbndk/tuCuOV/CBV5evpGXNZr+Ca3lJRE6LzCv1T4u1+XI3McJxHkXrVao XOjOt2+BuSm9WPSvsRSgDQKXzz4DHvo= X-MC-Unique: 8F_li2GOOYSSCiNxurELqQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] virfile: Replace virFileMakePathHelper() with g_mkdir_with_parents() Date: Mon, 1 Mar 2021 10:36:13 +0100 Message-Id: <21374454fff3193206fdab54ab4308669d6baf8c.1614589944.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.84 on 10.5.11.23 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" Our virFileMakePathHelper() does exactly the same as g_mkdir_with_parents() except for printing a debug message. Well, tough luck. Replace the former with the latter. Signed-off-by: Michal Privoznik --- src/util/virfile.c | 47 ++-------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 5710495bbf..dc6ba8e5c0 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3037,45 +3037,6 @@ int virFileChownFiles(const char *name, } #endif /* WIN32 */ =20 -static int -virFileMakePathHelper(char *path, mode_t mode) -{ - struct stat st; - char *p; - - VIR_DEBUG("path=3D%s mode=3D0%o", path, mode); - - if (stat(path, &st) >=3D 0) { - if (S_ISDIR(st.st_mode)) - return 0; - - errno =3D ENOTDIR; - return -1; - } - - if (errno !=3D ENOENT) - return -1; - - if ((p =3D strrchr(path, '/')) =3D=3D NULL) { - errno =3D EINVAL; - return -1; - } - - if (p !=3D path) { - *p =3D '\0'; - - if (virFileMakePathHelper(path, mode) < 0) - return -1; - - *p =3D '/'; - } - - if (g_mkdir(path, mode) < 0 && errno !=3D EEXIST) - return -1; - - return 0; -} - /** * Creates the given directory with mode 0777 if it's not already existing. * @@ -3092,11 +3053,7 @@ int virFileMakePathWithMode(const char *path, mode_t mode) { - g_autofree char *tmp =3D NULL; - - tmp =3D g_strdup(path); - - return virFileMakePathHelper(tmp, mode); + return g_mkdir_with_parents(path, mode); } =20 =20 @@ -3116,7 +3073,7 @@ virFileMakeParentPath(const char *path) } *p =3D '\0'; =20 - return virFileMakePathHelper(tmp, 0777); + return g_mkdir_with_parents(tmp, 0777); } =20 =20 --=20 2.26.2