From 05bc536c839a1dcba3dfd28d799e9e1a236bb2f4 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 17 Apr 2014 13:47:41 +0200 Subject: [PATCH] util: storagefile: Rename "canonPath" to "path" in virStorageFileMetadata As for the previous patch, this change is needed to achieve compatibility with all the existing code, where we expect a fully qualified path of local files to be present. --- src/util/virstoragefile.c | 20 +++++++------- src/util/virstoragefile.h | 2 +- tests/virstoragetest.c | 56 +++++++++++++++++++-------------------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 2441aed564..9ea3e4ff2d 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -949,12 +949,12 @@ virStorageFileMetadataNew(const char *path, goto error; if (virStorageIsFile(path)) { - if (!(ret->canonPath = canonicalize_file_name(path))) { + if (!(ret->path = canonicalize_file_name(path))) { virReportSystemError(errno, _("unable to resolve '%s'"), path); goto error; } } else { - if (VIR_STRDUP(ret->canonPath, path) < 0) + if (VIR_STRDUP(ret->path, path) < 0) goto error; } @@ -1047,7 +1047,7 @@ virStorageFileGetMetadataFromFDInternal(virStorageFileMetadataPtr meta, * file; therefore, no inclusion loop is possible, and we * don't need canonName or relDir. */ VIR_FREE(meta->relDir); - VIR_FREE(meta->canonPath); + VIR_FREE(meta->path); meta->type = VIR_STORAGE_TYPE_DIR; meta->format = VIR_STORAGE_FILE_DIR; ret = 0; @@ -1140,7 +1140,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, if (virStorageIsFile(path)) { if (VIR_STRDUP(meta->relPath, path) < 0) return -1; - if (VIR_STRDUP(meta->canonPath, canonPath) < 0) + if (VIR_STRDUP(meta->path, canonPath) < 0) return -1; if (VIR_STRDUP(meta->relDir, directory) < 0) return -1; @@ -1161,7 +1161,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath, * allow for non-raw images. */ if (VIR_STRDUP(meta->relPath, path) < 0) return -1; - if (VIR_STRDUP(meta->canonPath, path) < 0) + if (VIR_STRDUP(meta->path, path) < 0) return -1; meta->type = VIR_STORAGE_TYPE_NETWORK; meta->format = VIR_STORAGE_FILE_RAW; @@ -1322,7 +1322,7 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta) return; VIR_FREE(meta->relPath); - VIR_FREE(meta->canonPath); + VIR_FREE(meta->path); VIR_FREE(meta->relDir); virStorageFileFreeMetadata(meta->backingMeta); @@ -1539,7 +1539,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, const char *name, virStorageFileMetadataPtr *meta, const char **parent) { - const char *start = chain->canonPath; + const char *start = chain->path; const char *tmp; const char *parentDir = "."; bool nameIsFile = virStorageIsFile(name); @@ -1558,14 +1558,14 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, if (nameIsFile && (chain->type == VIR_STORAGE_TYPE_FILE || chain->type == VIR_STORAGE_TYPE_BLOCK)) { int result = virFileRelLinkPointsTo(parentDir, name, - chain->canonPath); + chain->path); if (result < 0) goto error; if (result > 0) break; } } - *parent = chain->canonPath; + *parent = chain->path; parentDir = chain->relDir; chain = chain->backingMeta; } @@ -1573,7 +1573,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, goto error; if (meta) *meta = chain; - return chain->canonPath; + return chain->path; error: if (name) diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 867214e1f5..3f072b6862 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -124,7 +124,7 @@ struct _virStorageFileMetadata { char *relPath; /* Canonical name of the current file, used to detect loops in the * backing store chain. */ - char *canonPath; + char *path; /* Directory to start from if backingStoreRaw is a relative file * name. */ char *relDir; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index b0de4383dc..dabaa996dc 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -237,7 +237,7 @@ struct _testFileData bool expEncrypted; const char *pathRel; const char *pathAbs; - const char *canonPath; + const char *path; const char *relDirRel; const char *relDirAbs; int type; @@ -323,24 +323,24 @@ testStorageChain(const void *args) : data->files[i]->relDirRel; if (virAsprintf(&expect, "store:%s\nraw:%s\nother:%lld %d\n" - "relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n", + "relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n", NULLSTR(data->files[i]->expBackingStore), NULLSTR(data->files[i]->expBackingStoreRaw), data->files[i]->expCapacity, data->files[i]->expEncrypted, NULLSTR(expPath), - NULLSTR(data->files[i]->canonPath), + NULLSTR(data->files[i]->path), NULLSTR(expRelDir), data->files[i]->type, data->files[i]->format) < 0 || virAsprintf(&actual, "store:%s\nraw:%s\nother:%lld %d\n" - "relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n", + "relPath:%s\npath:%s\nrelDir:%s\ntype:%d %d\n", NULLSTR(elt->backingStore), NULLSTR(elt->backingStoreRaw), elt->capacity, !!elt->encryption, NULLSTR(elt->relPath), - NULLSTR(elt->canonPath), + NULLSTR(elt->path), NULLSTR(elt->relDir), elt->type, elt->format) < 0) { VIR_FREE(expect); @@ -491,7 +491,7 @@ mymain(void) testFileData raw = { .pathRel = "raw", .pathAbs = canonraw, - .canonPath = canonraw, + .path = canonraw, .relDirRel = ".", .relDirAbs = datadir, .type = VIR_STORAGE_TYPE_FILE, @@ -516,7 +516,7 @@ mymain(void) .expCapacity = 1024, .pathRel = "qcow2", .pathAbs = canonqcow2, - .canonPath = canonqcow2, + .path = canonqcow2, .relDirRel = ".", .relDirAbs = datadir, .type = VIR_STORAGE_TYPE_FILE, @@ -525,7 +525,7 @@ mymain(void) testFileData qcow2_as_raw = { .pathRel = "qcow2", .pathAbs = canonqcow2, - .canonPath = canonqcow2, + .path = canonqcow2, .relDirRel = ".", .relDirAbs = datadir, .type = VIR_STORAGE_TYPE_FILE, @@ -572,7 +572,7 @@ mymain(void) .expCapacity = 1024, .pathRel = "wrap", .pathAbs = abswrap, - .canonPath = canonwrap, + .path = canonwrap, .relDirRel = ".", .relDirAbs = datadir, .type = VIR_STORAGE_TYPE_FILE, @@ -608,7 +608,7 @@ mymain(void) .expCapacity = 1024, .pathRel = "wrap", .pathAbs = abswrap, - .canonPath = canonwrap, + .path = canonwrap, .relDirRel = ".", .relDirAbs = datadir, .type = VIR_STORAGE_TYPE_FILE, @@ -667,7 +667,7 @@ mymain(void) testFileData nbd = { .pathRel = "nbd:example.org:6000", .pathAbs = "nbd:example.org:6000", - .canonPath = "nbd:example.org:6000", + .path = "nbd:example.org:6000", .type = VIR_STORAGE_TYPE_NETWORK, .format = VIR_STORAGE_FILE_RAW, }; @@ -684,7 +684,7 @@ mymain(void) .expCapacity = 1024, .pathRel = "qed", .pathAbs = absqed, - .canonPath = canonqed, + .path = canonqed, .relDirRel = ".", .relDirAbs = datadir, .type = VIR_STORAGE_TYPE_FILE, @@ -693,7 +693,7 @@ mymain(void) testFileData qed_as_raw = { .pathRel = "qed", .pathAbs = absqed, - .canonPath = canonqed, + .path = canonqed, .relDirRel = ".", .relDirAbs = datadir, .type = VIR_STORAGE_TYPE_FILE, @@ -746,7 +746,7 @@ mymain(void) .expCapacity = 1024, .pathRel = "../sub/link1", .pathAbs = "../sub/link1", - .canonPath = canonqcow2, + .path = canonqcow2, .relDirRel = "sub/../sub", .relDirAbs = datadir "/sub/../sub", .type = VIR_STORAGE_TYPE_FILE, @@ -758,7 +758,7 @@ mymain(void) .expCapacity = 1024, .pathRel = "sub/link2", .pathAbs = abslink2, - .canonPath = canonwrap, + .path = canonwrap, .relDirRel = "sub", .relDirAbs = datadir "/sub", .type = VIR_STORAGE_TYPE_FILE, @@ -839,12 +839,12 @@ mymain(void) } while (0) TEST_LOOKUP(0, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(1, "wrap", chain->canonPath, chain, NULL); - TEST_LOOKUP(2, abswrap, chain->canonPath, chain, NULL); + TEST_LOOKUP(1, "wrap", chain->path, chain, NULL); + TEST_LOOKUP(2, abswrap, chain->path, chain, NULL); TEST_LOOKUP(3, "qcow2", chain->backingStore, chain->backingMeta, - chain->canonPath); + chain->path); TEST_LOOKUP(4, absqcow2, chain->backingStore, chain->backingMeta, - chain->canonPath); + chain->path); TEST_LOOKUP(5, "raw", chain->backingMeta->backingStore, chain->backingMeta->backingMeta, chain->backingStore); TEST_LOOKUP(6, absraw, chain->backingMeta->backingStore, @@ -875,12 +875,12 @@ mymain(void) } TEST_LOOKUP(8, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(9, "wrap", chain->canonPath, chain, NULL); - TEST_LOOKUP(10, abswrap, chain->canonPath, chain, NULL); + TEST_LOOKUP(9, "wrap", chain->path, chain, NULL); + TEST_LOOKUP(10, abswrap, chain->path, chain, NULL); TEST_LOOKUP(11, "qcow2", chain->backingStore, chain->backingMeta, - chain->canonPath); + chain->path); TEST_LOOKUP(12, absqcow2, chain->backingStore, chain->backingMeta, - chain->canonPath); + chain->path); TEST_LOOKUP(13, "raw", chain->backingMeta->backingStore, chain->backingMeta->backingMeta, chain->backingStore); TEST_LOOKUP(14, absraw, chain->backingMeta->backingStore, @@ -905,14 +905,14 @@ mymain(void) } TEST_LOOKUP(16, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(17, "sub/link2", chain->canonPath, chain, NULL); - TEST_LOOKUP(18, "wrap", chain->canonPath, chain, NULL); - TEST_LOOKUP(19, abswrap, chain->canonPath, chain, NULL); + TEST_LOOKUP(17, "sub/link2", chain->path, chain, NULL); + TEST_LOOKUP(18, "wrap", chain->path, chain, NULL); + TEST_LOOKUP(19, abswrap, chain->path, chain, NULL); TEST_LOOKUP(20, "../qcow2", chain->backingStore, chain->backingMeta, - chain->canonPath); + chain->path); TEST_LOOKUP(21, "qcow2", NULL, NULL, NULL); TEST_LOOKUP(22, absqcow2, chain->backingStore, chain->backingMeta, - chain->canonPath); + chain->path); TEST_LOOKUP(23, "raw", chain->backingMeta->backingStore, chain->backingMeta->backingMeta, chain->backingStore); TEST_LOOKUP(24, absraw, chain->backingMeta->backingStore,