mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
parent
9386eadad4
commit
b1e3728dec
@ -117,7 +117,7 @@ netcfStateInitialize(bool privileged,
|
|||||||
driver->stateDir = g_strdup_printf("%s/interface/run", rundir);
|
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'"),
|
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
||||||
driver->stateDir);
|
driver->stateDir);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1146,7 +1146,7 @@ udevStateInitialize(bool privileged,
|
|||||||
driver->stateDir = g_strdup_printf("%s/interface/run", rundir);
|
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'"),
|
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
||||||
driver->stateDir);
|
driver->stateDir);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -2031,7 +2031,7 @@ nodeStateInitialize(bool privileged,
|
|||||||
driver->stateDir = g_strdup_printf("%s/nodedev/run", rundir);
|
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'"),
|
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
||||||
driver->stateDir);
|
driver->stateDir);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1811,7 +1811,7 @@ virNWFilterSnoopLeaseFileRefresh(void)
|
|||||||
{
|
{
|
||||||
int tfd;
|
int tfd;
|
||||||
|
|
||||||
if (virFileMakePathWithMode(LEASEFILE_DIR, 0700) < 0) {
|
if (g_mkdir_with_parents(LEASEFILE_DIR, 0700) < 0) {
|
||||||
virReportError(errno, _("mkdir(\"%s\")"), LEASEFILE_DIR);
|
virReportError(errno, _("mkdir(\"%s\")"), LEASEFILE_DIR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
|
|
||||||
driver->stateDir = g_strdup(RUNSTATEDIR "/libvirt/nwfilter");
|
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'"),
|
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
||||||
driver->stateDir);
|
driver->stateDir);
|
||||||
goto error;
|
goto error;
|
||||||
@ -224,7 +224,7 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
|
|
||||||
driver->configDir = g_strdup(SYSCONFDIR "/libvirt/nwfilter");
|
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'"),
|
virReportSystemError(errno, _("cannot create config directory '%s'"),
|
||||||
driver->configDir);
|
driver->configDir);
|
||||||
goto error;
|
goto error;
|
||||||
@ -232,7 +232,7 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
|
|
||||||
driver->bindingDir = g_strdup(RUNSTATEDIR "/libvirt/nwfilter-binding");
|
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'"),
|
virReportSystemError(errno, _("cannot create config directory '%s'"),
|
||||||
driver->bindingDir);
|
driver->bindingDir);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -985,7 +985,7 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItemPtr data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if ((isReg && virFileTouch(data->file, data->sb.st_mode) < 0) ||
|
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;
|
goto cleanup;
|
||||||
delDevice = true;
|
delDevice = true;
|
||||||
/* Just create the file here so that code below sets
|
/* Just create the file here so that code below sets
|
||||||
|
@ -3937,7 +3937,7 @@ qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverPtr driver,
|
|||||||
if (virFileExists(path))
|
if (virFileExists(path))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (virFileMakePathWithMode(path, 0700) < 0) {
|
if (g_mkdir_with_parents(path, 0700) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to create %s"),
|
_("Unable to create %s"),
|
||||||
path);
|
path);
|
||||||
@ -5164,7 +5164,7 @@ qemuProcessMakeDir(virQEMUDriverPtr driver,
|
|||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
if (virFileMakePathWithMode(path, 0750) < 0) {
|
if (g_mkdir_with_parents(path, 0750) < 0) {
|
||||||
virReportSystemError(errno, _("Cannot create directory '%s'"), path);
|
virReportSystemError(errno, _("Cannot create directory '%s'"), path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ qemuTPMEmulatorInitStorage(const char *swtpmStorageDir)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/* allow others to cd into this dir */
|
/* allow others to cd into this dir */
|
||||||
if (virFileMakePathWithMode(swtpmStorageDir, 0711) < 0) {
|
if (g_mkdir_with_parents(swtpmStorageDir, 0711) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Could not create TPM directory %s"),
|
_("Could not create TPM directory %s"),
|
||||||
swtpmStorageDir);
|
swtpmStorageDir);
|
||||||
@ -298,7 +298,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* create log dir ... allow 'tss' user to cd into it */
|
/* 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;
|
return -1;
|
||||||
|
|
||||||
/* ... and adjust ownership */
|
/* ... and adjust ownership */
|
||||||
|
@ -700,7 +700,7 @@ int virNetSocketNewConnectUNIX(const char *path,
|
|||||||
binname = g_path_get_basename(binary);
|
binname = g_path_get_basename(binary);
|
||||||
rundir = virGetUserRuntimeDirectory();
|
rundir = virGetUserRuntimeDirectory();
|
||||||
|
|
||||||
if (virFileMakePathWithMode(rundir, 0700) < 0) {
|
if (g_mkdir_with_parents(rundir, 0700) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Cannot create user runtime directory '%s'"),
|
_("Cannot create user runtime directory '%s'"),
|
||||||
rundir);
|
rundir);
|
||||||
|
@ -489,13 +489,13 @@ secretStateInitialize(bool privileged,
|
|||||||
driver->stateDir = g_strdup_printf("%s/secrets/run", rundir);
|
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'"),
|
virReportSystemError(errno, _("cannot create config directory '%s'"),
|
||||||
driver->configDir);
|
driver->configDir);
|
||||||
goto error;
|
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'"),
|
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
||||||
driver->stateDir);
|
driver->stateDir);
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -3079,7 +3079,7 @@ virFileMakePathHelper(char *path, mode_t mode)
|
|||||||
int
|
int
|
||||||
virFileMakePath(const char *path)
|
virFileMakePath(const char *path)
|
||||||
{
|
{
|
||||||
return virFileMakePathWithMode(path, 0777);
|
return g_mkdir_with_parents(path, 0777);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -263,7 +263,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (virFileMakePathWithMode(directory, 0700) < 0) {
|
if (g_mkdir_with_parents(directory, 0700) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to create lockspace %s"),
|
_("Unable to create lockspace %s"),
|
||||||
directory);
|
directory);
|
||||||
|
@ -489,7 +489,7 @@ virPidFileConstructPath(bool privileged,
|
|||||||
} else {
|
} else {
|
||||||
rundir = virGetUserRuntimeDirectory();
|
rundir = virGetUserRuntimeDirectory();
|
||||||
|
|
||||||
if (virFileMakePathWithMode(rundir, 0700) < 0) {
|
if (g_mkdir_with_parents(rundir, 0700) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Cannot create user runtime directory '%s'"),
|
_("Cannot create user runtime directory '%s'"),
|
||||||
rundir);
|
rundir);
|
||||||
|
@ -4115,7 +4115,7 @@ vzStateInitialize(bool privileged,
|
|||||||
|
|
||||||
vz_driver_privileged = 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'"),
|
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
||||||
VZ_STATEDIR);
|
VZ_STATEDIR);
|
||||||
return VIR_DRV_STATE_INIT_ERROR;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
@ -87,7 +87,7 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
|
|||||||
}
|
}
|
||||||
spot--;
|
spot--;
|
||||||
*spot = '\0';
|
*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);
|
fprintf(stderr, "Unable to make path to '%s'\n", unique_id_path);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
|
|||||||
}
|
}
|
||||||
spot--;
|
spot--;
|
||||||
*spot = '\0';
|
*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);
|
fprintf(stderr, "Unable to make path to '%s'\n", link_path);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -2870,7 +2870,7 @@ static void
|
|||||||
vshReadlineDeinit(vshControl *ctl)
|
vshReadlineDeinit(vshControl *ctl)
|
||||||
{
|
{
|
||||||
if (ctl->historyfile != NULL) {
|
if (ctl->historyfile != NULL) {
|
||||||
if (virFileMakePathWithMode(ctl->historydir, 0755) < 0 &&
|
if (g_mkdir_with_parents(ctl->historydir, 0755) < 0 &&
|
||||||
errno != EEXIST) {
|
errno != EEXIST) {
|
||||||
vshError(ctl, _("Failed to create '%s': %s"),
|
vshError(ctl, _("Failed to create '%s': %s"),
|
||||||
ctl->historydir, g_strerror(errno));
|
ctl->historydir, g_strerror(errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user