提交 bf7d2a26 编写于 作者: D Daniel P. Berrangé

src: replace mdir_name() with g_path_get_dirname()

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 472cc394
......@@ -30,7 +30,6 @@
#include "virstring.h"
#include "node_device_conf.h"
#include "device_conf.h"
#include "dirname.h"
#include "virxml.h"
#include "virbuffer.h"
#include "viruuid.h"
......@@ -2445,8 +2444,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath,
VIR_DEBUG("Checking if '%s' is an FC remote port", scsi_target->name);
/* /sys/devices/[...]/host0/rport-0:0-0/target0:0:0 -> rport-0:0-0 */
if (!(dir = mdir_name(sysfsPath)))
return -1;
dir = g_path_get_dirname(sysfsPath);
rport = g_path_get_basename(dir);
......
......@@ -31,7 +31,6 @@
#include <sanlock_resource.h>
#include <sanlock_admin.h>
#include "dirname.h"
#include "lock_driver.h"
#include "virlog.h"
#include "virerror.h"
......@@ -239,10 +238,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
int perms = 0600;
VIR_DEBUG("Lockspace %s does not yet exist", path);
if (!(dir = mdir_name(path))) {
virReportOOMError();
goto error;
}
dir = g_path_get_dirname(path);
if (stat(dir, &st) < 0 || !S_ISDIR(st.st_mode)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to create lockspace %s: parent directory"
......
......@@ -99,7 +99,6 @@
#include "vircgroup.h"
#include "virperf.h"
#include "virnuma.h"
#include "dirname.h"
#include "netdev_bandwidth_conf.h"
#include "virqemu.h"
#include "virdomainsnapshotobjlist.h"
......@@ -850,10 +849,8 @@ qemuStateInitialize(bool privileged,
(int)cfg->group);
goto error;
}
if (!(channeldir = mdir_name(cfg->channelTargetDir))) {
virReportOOMError();
goto error;
}
channeldir = g_path_get_dirname(cfg->channelTargetDir);
if (chown(channeldir, cfg->user, cfg->group) < 0) {
virReportSystemError(errno,
_("unable to set ownership of '%s' to %d:%d"),
......
......@@ -40,7 +40,6 @@
#include "virstring.h"
#include "virpidfile.h"
#include "configmake.h"
#include "dirname.h"
#include "qemu_tpm.h"
#include "virtpm.h"
#include "secret_util.h"
......@@ -83,26 +82,6 @@ qemuTPMCreateEmulatorStoragePath(const char *swtpmStorageDir,
}
/*
* virtTPMGetTPMStorageDir:
*
* @storagepath: directory for swtpm's persistent state
*
* Derive the 'TPMStorageDir' from the storagepath by searching
* for the last '/'.
*/
static char *
qemuTPMGetTPMStorageDir(const char *storagepath)
{
char *ret = mdir_name(storagepath);
if (!ret)
virReportOOMError();
return ret;
}
/*
* qemuTPMEmulatorInitStorage
*
......@@ -147,10 +126,7 @@ qemuTPMCreateEmulatorStorage(const char *storagepath,
gid_t swtpm_group)
{
int ret = -1;
char *swtpmStorageDir = qemuTPMGetTPMStorageDir(storagepath);
if (!swtpmStorageDir)
return -1;
char *swtpmStorageDir = g_path_get_dirname(storagepath);
if (qemuTPMEmulatorInitStorage(swtpmStorageDir) < 0)
goto cleanup;
......@@ -183,12 +159,9 @@ qemuTPMCreateEmulatorStorage(const char *storagepath,
static void
qemuTPMDeleteEmulatorStorage(virDomainTPMDefPtr tpm)
{
char *path = qemuTPMGetTPMStorageDir(tpm->data.emulator.storagepath);
g_autofree char *path = g_path_get_dirname(tpm->data.emulator.storagepath);
if (path) {
ignore_value(virFileDeleteTree(path));
VIR_FREE(path);
}
ignore_value(virFileDeleteTree(path));
}
......
......@@ -33,7 +33,6 @@
#include "viralloc.h"
#include "vircommand.h"
#include "virlog.h"
#include "dirname.h"
#include "driver.h"
#include "security_driver.h"
......@@ -754,8 +753,7 @@ vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool recursi
*/
pathdir = g_strdup(path);
while (!virFileExists(pathdir)) {
if ((pathtmp = mdir_name(pathdir)) == NULL)
goto cleanup;
pathtmp = g_path_get_dirname(pathdir);
VIR_FREE(pathdir);
pathdir = g_steal_pointer(&pathtmp);
}
......
......@@ -37,7 +37,6 @@
#endif
#include <unistd.h>
#include <dirent.h>
#include <dirname.h>
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
# include <mntent.h>
#endif
......@@ -1886,10 +1885,7 @@ int virFileIsMountPoint(const char *file)
int ret;
struct stat sb1, sb2;
if (!(parent = mdir_name(file))) {
virReportOOMError();
return -1;
}
parent = g_path_get_dirname(file);
VIR_DEBUG("Comparing '%s' to '%s'", file, parent);
......
......@@ -36,7 +36,6 @@
#include "virstring.h"
#include "virutil.h"
#include "viruri.h"
#include "dirname.h"
#include "virbuffer.h"
#include "virjson.h"
#include "virstorageencryption.h"
......@@ -1690,15 +1689,10 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
if (nameIsFile && virStorageSourceIsLocalStorage(chain)) {
if (*parent && virStorageSourceIsLocalStorage(*parent))
parentDir = mdir_name((*parent)->path);
parentDir = g_path_get_dirname((*parent)->path);
else
parentDir = g_strdup(".");
if (!parentDir) {
virReportOOMError();
goto error;
}
int result = virFileRelLinkPointsTo(parentDir, name,
chain->path);
......@@ -2658,10 +2652,7 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
/* store relative name */
def->relPath = g_strdup(rel);
if (!(dirname = mdir_name(parent->path))) {
virReportOOMError();
return NULL;
}
dirname = g_path_get_dirname(parent->path);
if (STRNEQ(dirname, "/")) {
def->path = g_strdup_printf("%s/%s", dirname, rel);
......
......@@ -24,7 +24,6 @@
#include "vircommand.h"
#include "cpu/cpu.h"
#include "dirname.h"
#include "viralloc.h"
#include "virfile.h"
#include "viruuid.h"
......@@ -270,8 +269,7 @@ vmwareExtractVersion(struct vmware_driver *driver)
char *bin = NULL;
char *vmwarePath = NULL;
if ((vmwarePath = mdir_name(driver->vmrun)) == NULL)
goto cleanup;
vmwarePath = g_path_get_dirname(driver->vmrun);
switch (driver->type) {
case VMWARE_DRIVER_PLAYER:
......@@ -477,8 +475,7 @@ vmwareExtractPid(const char * vmxPath)
char *tmp = NULL;
int pid_value = -1;
if ((vmxDir = mdir_name(vmxPath)) == NULL)
goto cleanup;
vmxDir = g_path_get_dirname(vmxPath);
logFilePath = g_strdup_printf("%s/vmware.log", vmxDir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册