]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lib: Replace virFileMakePathWithMode() with g_mkdir_with_parents()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 26 Feb 2021 08:17:30 +0000 (09:17 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Mar 2021 19:52:23 +0000 (20:52 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
16 files changed:
src/interface/interface_backend_netcf.c
src/interface/interface_backend_udev.c
src/node_device/node_device_udev.c
src/nwfilter/nwfilter_dhcpsnoop.c
src/nwfilter/nwfilter_driver.c
src/qemu/qemu_namespace.c
src/qemu/qemu_process.c
src/qemu/qemu_tpm.c
src/rpc/virnetsocket.c
src/secret/secret_driver.c
src/util/virfile.c
src/util/virlockspace.c
src/util/virpidfile.c
src/vz/vz_driver.c
tests/scsihosttest.c
tools/vsh.c

index f8613fea86c88e67d542774f00f91f2e99d9171f..7c0edfae637459b2fdc501cf34d0d9d8c1bb1964 100644 (file)
@@ -117,7 +117,7 @@ netcfStateInitialize(bool privileged,
         driver->stateDir = g_strdup_printf("%s/interface/run", rundir);
     }
 
-    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;
index ab95b2e3ff00cf6dab03e0f07788949780ca8ccd..b6809a45f30291ff2c0b863e46fd06cede916800 100644 (file)
@@ -1146,7 +1146,7 @@ udevStateInitialize(bool privileged,
         driver->stateDir = g_strdup_printf("%s/interface/run", rundir);
     }
 
-    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;
index 09048fb23f481029eb0219f3fcdb86474526f756..fe25f8235e15f65c69b8be552ee4a5b49a3abf67 100644 (file)
@@ -2031,7 +2031,7 @@ nodeStateInitialize(bool privileged,
         driver->stateDir = g_strdup_printf("%s/nodedev/run", rundir);
     }
 
-    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;
index e64eb2c7ee62847370f6fd9f1e29699fa7bac112..2e7190be1c0ae24696ba3c47f534b9773f1eca4d 100644 (file)
@@ -1811,7 +1811,7 @@ virNWFilterSnoopLeaseFileRefresh(void)
 {
     int tfd;
 
-    if (virFileMakePathWithMode(LEASEFILE_DIR, 0700) < 0) {
+    if (g_mkdir_with_parents(LEASEFILE_DIR, 0700) < 0) {
         virReportError(errno, _("mkdir(\"%s\")"), LEASEFILE_DIR);
         return;
     }
index 1b8e3dbad32bfffc1d287fc6d8066b61e025d8ac..1541c44cf286d93bd6646299ae7a3166e5d4ad1b 100644 (file)
@@ -191,7 +191,7 @@ nwfilterStateInitialize(bool privileged,
 
     driver->stateDir = g_strdup(RUNSTATEDIR "/libvirt/nwfilter");
 
-    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,
 
     driver->configDir = g_strdup(SYSCONFDIR "/libvirt/nwfilter");
 
-    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,
 
     driver->bindingDir = g_strdup(RUNSTATEDIR "/libvirt/nwfilter-binding");
 
-    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;
index 60543e845bfd564b590607e7119c388fdf7e2b07..f4b4d4d9ec4b39c7b7a343ac463681b9ca59c069 100644 (file)
@@ -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 = true;
         /* Just create the file here so that code below sets
index 398f63282e97a4936f7119bd3c356a37c875810d..944664ca28e0376b046e822d1318de20e511eca6 100644 (file)
@@ -3937,7 +3937,7 @@ qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverPtr driver,
         if (virFileExists(path))
             return 0;
 
-        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'"), path);
         return -1;
     }
index d9948164840271799b53d2d789b6f7841dc86c43..e00313543c405b6cb8bfd665b3e00e5c97d99359 100644 (file)
@@ -110,7 +110,7 @@ qemuTPMEmulatorInitStorage(const char *swtpmStorageDir)
     int rc = 0;
 
     /* 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);
@@ -298,7 +298,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
         return -1;
 
     /* 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;
 
     /* ... and adjust ownership */
index 17aaf86ce3a6da92b3f4ef3e4965c674ae80b645..872b8a3c46c6fc2ee7df789fb63a0341c1dfa9b9 100644 (file)
@@ -700,7 +700,7 @@ int virNetSocketNewConnectUNIX(const char *path,
         binname = g_path_get_basename(binary);
         rundir = virGetUserRuntimeDirectory();
 
-        if (virFileMakePathWithMode(rundir, 0700) < 0) {
+        if (g_mkdir_with_parents(rundir, 0700) < 0) {
             virReportSystemError(errno,
                                  _("Cannot create user runtime directory '%s'"),
                                  rundir);
index 45da09322bfec9771efd37eb3a36ceca112a25f6..c24aedbe1b96f33b84f35bb6df94422d246c808a 100644 (file)
@@ -489,13 +489,13 @@ secretStateInitialize(bool privileged,
         driver->stateDir = g_strdup_printf("%s/secrets/run", rundir);
     }
 
-    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;
     }
 
-    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;
index 841a0f4e002580e07d882d77d58a30557fdf6335..afa3f015f549304a909431f0ecea47fe092b46a3 100644 (file)
@@ -3079,7 +3079,7 @@ virFileMakePathHelper(char *path, mode_t mode)
 int
 virFileMakePath(const char *path)
 {
-    return virFileMakePathWithMode(path, 0777);
+    return g_mkdir_with_parents(path, 0777);
 }
 
 int
index 684a3320ed4ca08f8875cc390bdfc00dbae04f52..f253091f39a565f6bb0d36f2ec39556c694c6751 100644 (file)
@@ -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);
index b4d0059405c951a4a227320ca5cd694f4aa36b28..4c38ebe50028da5db61511ce7c1c4ab9c2921827 100644 (file)
@@ -489,7 +489,7 @@ virPidFileConstructPath(bool privileged,
     } else {
         rundir = virGetUserRuntimeDirectory();
 
-        if (virFileMakePathWithMode(rundir, 0700) < 0) {
+        if (g_mkdir_with_parents(rundir, 0700) < 0) {
             virReportSystemError(errno,
                                  _("Cannot create user runtime directory '%s'"),
                                  rundir);
index 60ed286ceedcf1a286f1599222ac3f8a4afaeeea..520ef871e97f65583612a42f12eefb0143952539 100644 (file)
@@ -4115,7 +4115,7 @@ vzStateInitialize(bool privileged,
 
     vz_driver_privileged = privileged;
 
-    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;
index 4b2779eabf6c832f23333f2294166ef23b161868..17825bba354bdea09bba5c3a5d3ae400e7b4ad30 100644 (file)
@@ -87,7 +87,7 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
     }
     spot--;
     *spot = '\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 *devicepath,
     }
     spot--;
     *spot = '\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;
     }
index 68f04b21741eca67a8c9eb43495d47f78b8779d8..8fb033249ed524bdcf8e1f5d2df6cc5ec57ea6a2 100644 (file)
@@ -2870,7 +2870,7 @@ static void
 vshReadlineDeinit(vshControl *ctl)
 {
     if (ctl->historyfile != NULL) {
-        if (virFileMakePathWithMode(ctl->historydir, 0755) < 0 &&
+        if (g_mkdir_with_parents(ctl->historydir, 0755) < 0 &&
             errno != EEXIST) {
             vshError(ctl, _("Failed to create '%s': %s"),
                      ctl->historydir, g_strerror(errno));