lib: Replace virFileMakePathWithMode() with g_mkdir_with_parents()

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>
This commit is contained in:
Michal Privoznik 2021-02-26 09:17:30 +01:00
parent 9386eadad4
commit b1e3728dec
16 changed files with 22 additions and 22 deletions

View 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;

View 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;

View 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;

View 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;
}

View 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;

View 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

View 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;
}

View 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 */

View 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);

View 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;

View 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

View 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);

View 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);

View 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;

View 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;
}

View 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));