From nobody Mon Feb 9 19:06:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1614591400; cv=none; d=zohomail.com; s=zohoarc; b=Kzl1Y3nnV7Bz9DGosM/WvUmKod5IrC5NCQ00px+CJPyu30byW+sqwvesJJSTN5wuqgI1w3aSIHnrHLRxdvefEOXnQBRc9wv/oF7plVQxtDKvawFKDToAapdwcdnTYHVJra6fXBRgMGNOdpHZseUNDoLEbyc+Yp/6783BWd0GM5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614591400; 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=ZlQQGlW80pRWH3xXi/M0MmwEIhK2epcm2BUOoHC/LQ0=; b=enFF9LXtxqNJuBstlJDhBtqqHmwTX9lkcUEKQHuIPo0zsukre6P1b0MOfuOqUdeYzgH9fRmVYl0e2Ol5nnUIf81Rb1iu5+XFzCjCEx2e3C0AaQsfRlvCFMNpLTuVn7w6can1pkpSN8DRoiOAL09AhTj80WganwxkPXm0JNv+sTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 161459140075139.4701909323494; Mon, 1 Mar 2021 01:36:40 -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-501-s_QitmESOV-z5FFft-vQJQ-1; Mon, 01 Mar 2021 04:36:36 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB95F1E565; Mon, 1 Mar 2021 09:36:30 +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 2DA826E519; Mon, 1 Mar 2021 09:36:27 +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 3D7264EEEC; Mon, 1 Mar 2021 09:36:24 +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 1219aNTv013731 for ; Mon, 1 Mar 2021 04:36:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 288C160C13; Mon, 1 Mar 2021 09:36:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75B6F60BFA for ; Mon, 1 Mar 2021 09:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614591399; 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=ZlQQGlW80pRWH3xXi/M0MmwEIhK2epcm2BUOoHC/LQ0=; b=ENgUtvQZbrW6yUU62Di4mfIsiBU5lmHKFyOw/nOE06xGJKz/yV1GIYXrV24WpkTt3KugKK LVfQW3E87hJj1D/Igvs1XMv2xmexPISyuh9xEzUSddC54j+fH7F9TSjn/htoAjjDjzUDbi Xj7J742zUKyPYxwoMix5l9oBxlOqOYk= X-MC-Unique: s_QitmESOV-z5FFft-vQJQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] lib: Replace virFileMakePathWithMode() with g_mkdir_with_parents() Date: Mon, 1 Mar 2021 10:36:14 +0100 Message-Id: <8632e0a97e79977589a642ae6ae5868f4bcb87db.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.79 on 10.5.11.13 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" These functions are identical. Made using this spatch: @@ expression path, mode; @@ - virFileMakePathWithMode(path, mode) + g_mkdir_with_parents(path, mode) Signed-off-by: Michal Privoznik --- src/interface/interface_backend_netcf.c | 2 +- src/interface/interface_backend_udev.c | 2 +- src/node_device/node_device_udev.c | 2 +- src/nwfilter/nwfilter_dhcpsnoop.c | 2 +- src/nwfilter/nwfilter_driver.c | 6 +++--- src/qemu/qemu_namespace.c | 2 +- src/qemu/qemu_process.c | 4 ++-- src/qemu/qemu_tpm.c | 4 ++-- src/rpc/virnetsocket.c | 2 +- src/secret/secret_driver.c | 4 ++-- src/util/virfile.c | 2 +- src/util/virlockspace.c | 2 +- src/util/virpidfile.c | 2 +- src/vz/vz_driver.c | 2 +- tests/scsihosttest.c | 4 ++-- tools/vsh.c | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index e40a4cb108..891271cb35 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -117,7 +117,7 @@ netcfStateInitialize(bool privileged, driver->stateDir =3D g_strdup_printf("%s/interface/run", rundir); } =20 - if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->stateDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create state directory '%s'"= ), driver->stateDir); goto error; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 6a94a45044..e704400dc1 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1147,7 +1147,7 @@ udevStateInitialize(bool privileged, driver->stateDir =3D g_strdup_printf("%s/interface/run", rundir); } =20 - if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->stateDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create state directory '%s'"= ), driver->stateDir); goto cleanup; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 09048fb23f..fe25f8235e 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -2031,7 +2031,7 @@ nodeStateInitialize(bool privileged, driver->stateDir =3D g_strdup_printf("%s/nodedev/run", rundir); } =20 - if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->stateDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create state directory '%s'"= ), driver->stateDir); goto cleanup; diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index e64eb2c7ee..2e7190be1c 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1811,7 +1811,7 @@ virNWFilterSnoopLeaseFileRefresh(void) { int tfd; =20 - if (virFileMakePathWithMode(LEASEFILE_DIR, 0700) < 0) { + if (g_mkdir_with_parents(LEASEFILE_DIR, 0700) < 0) { virReportError(errno, _("mkdir(\"%s\")"), LEASEFILE_DIR); return; } diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 1b8e3dbad3..1541c44cf2 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -191,7 +191,7 @@ nwfilterStateInitialize(bool privileged, =20 driver->stateDir =3D g_strdup(RUNSTATEDIR "/libvirt/nwfilter"); =20 - if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->stateDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create state directory '%s'"= ), driver->stateDir); goto error; @@ -224,7 +224,7 @@ nwfilterStateInitialize(bool privileged, =20 driver->configDir =3D g_strdup(SYSCONFDIR "/libvirt/nwfilter"); =20 - if (virFileMakePathWithMode(driver->configDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->configDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create config directory '%s'= "), driver->configDir); goto error; @@ -232,7 +232,7 @@ nwfilterStateInitialize(bool privileged, =20 driver->bindingDir =3D g_strdup(RUNSTATEDIR "/libvirt/nwfilter-binding= "); =20 - if (virFileMakePathWithMode(driver->bindingDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->bindingDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create config directory '%s'= "), driver->bindingDir); goto error; diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 60543e845b..f4b4d4d9ec 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -985,7 +985,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItemPtr data) goto cleanup; } if ((isReg && virFileTouch(data->file, data->sb.st_mode) < 0) || - (isDir && virFileMakePathWithMode(data->file, data->sb.st_mode= ) < 0)) + (isDir && g_mkdir_with_parents(data->file, data->sb.st_mode) <= 0)) goto cleanup; delDevice =3D true; /* Just create the file here so that code below sets diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 398f63282e..944664ca28 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3937,7 +3937,7 @@ qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverP= tr driver, if (virFileExists(path)) return 0; =20 - if (virFileMakePathWithMode(path, 0700) < 0) { + if (g_mkdir_with_parents(path, 0700) < 0) { virReportSystemError(errno, _("Unable to create %s"), path); @@ -5164,7 +5164,7 @@ qemuProcessMakeDir(virQEMUDriverPtr driver, virDomainObjPtr vm, const char *path) { - if (virFileMakePathWithMode(path, 0750) < 0) { + if (g_mkdir_with_parents(path, 0750) < 0) { virReportSystemError(errno, _("Cannot create directory '%s'"), pat= h); return -1; } diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index f94cad8230..2635382f81 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -95,7 +95,7 @@ qemuTPMEmulatorInitStorage(const char *swtpmStorageDir) int rc =3D 0; =20 /* allow others to cd into this dir */ - if (virFileMakePathWithMode(swtpmStorageDir, 0711) < 0) { + if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) { virReportSystemError(errno, _("Could not create TPM directory %s"), swtpmStorageDir); @@ -276,7 +276,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm, return -1; =20 /* create log dir ... allow 'tss' user to cd into it */ - if (virFileMakePathWithMode(logDir, 0711) < 0) + if (g_mkdir_with_parents(logDir, 0711) < 0) return -1; =20 /* ... and adjust ownership */ diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 17aaf86ce3..872b8a3c46 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -700,7 +700,7 @@ int virNetSocketNewConnectUNIX(const char *path, binname =3D g_path_get_basename(binary); rundir =3D virGetUserRuntimeDirectory(); =20 - if (virFileMakePathWithMode(rundir, 0700) < 0) { + if (g_mkdir_with_parents(rundir, 0700) < 0) { virReportSystemError(errno, _("Cannot create user runtime directory '= %s'"), rundir); diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 45da09322b..c24aedbe1b 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -489,13 +489,13 @@ secretStateInitialize(bool privileged, driver->stateDir =3D g_strdup_printf("%s/secrets/run", rundir); } =20 - if (virFileMakePathWithMode(driver->configDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->configDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create config directory '%s'= "), driver->configDir); goto error; } =20 - if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) { + if (g_mkdir_with_parents(driver->stateDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create state directory '%s'"= ), driver->stateDir); goto error; diff --git a/src/util/virfile.c b/src/util/virfile.c index dc6ba8e5c0..bba0e892ea 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3046,7 +3046,7 @@ int virFileChownFiles(const char *name, int virFileMakePath(const char *path) { - return virFileMakePathWithMode(path, 0777); + return g_mkdir_with_parents(path, 0777); } =20 int diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 684a3320ed..f253091f39 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -263,7 +263,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory) goto error; } } else { - if (virFileMakePathWithMode(directory, 0700) < 0) { + if (g_mkdir_with_parents(directory, 0700) < 0) { virReportSystemError(errno, _("Unable to create lockspace %s"), directory); diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index b4d0059405..4c38ebe500 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -489,7 +489,7 @@ virPidFileConstructPath(bool privileged, } else { rundir =3D virGetUserRuntimeDirectory(); =20 - if (virFileMakePathWithMode(rundir, 0700) < 0) { + if (g_mkdir_with_parents(rundir, 0700) < 0) { virReportSystemError(errno, _("Cannot create user runtime directory '= %s'"), rundir); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 0ebcb06234..a9f774afd6 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -4116,7 +4116,7 @@ vzStateInitialize(bool privileged, =20 vz_driver_privileged =3D privileged; =20 - if (virFileMakePathWithMode(VZ_STATEDIR, S_IRWXU) < 0) { + if (g_mkdir_with_parents(VZ_STATEDIR, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create state directory '%s'"= ), VZ_STATEDIR); return VIR_DRV_STATE_INIT_ERROR; diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index 4b2779eabf..17825bba35 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -87,7 +87,7 @@ create_scsihost(const char *fakesysfsdir, const char *dev= icepath, } spot--; *spot =3D '\0'; - if (virFileMakePathWithMode(unique_id_path, 0755) < 0) { + if (g_mkdir_with_parents(unique_id_path, 0755) < 0) { fprintf(stderr, "Unable to make path to '%s'\n", unique_id_path); goto cleanup; } @@ -102,7 +102,7 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, } spot--; *spot =3D '\0'; - if (virFileMakePathWithMode(link_path, 0755) < 0) { + if (g_mkdir_with_parents(link_path, 0755) < 0) { fprintf(stderr, "Unable to make path to '%s'\n", link_path); goto cleanup; } diff --git a/tools/vsh.c b/tools/vsh.c index 68f04b2174..8fb033249e 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2870,7 +2870,7 @@ static void vshReadlineDeinit(vshControl *ctl) { if (ctl->historyfile !=3D NULL) { - if (virFileMakePathWithMode(ctl->historydir, 0755) < 0 && + if (g_mkdir_with_parents(ctl->historydir, 0755) < 0 && errno !=3D EEXIST) { vshError(ctl, _("Failed to create '%s': %s"), ctl->historydir, g_strerror(errno)); --=20 2.26.2