[PATCH 03/12] util: virstoragefile: Move virStorageIs[File|Relative] to storage_source

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are no other files using it. Move it and make the functions
static.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/libvirt_private.syms          |  2 --
 src/storage_file/storage_source.c | 42 ++++++++++++++++++++++++++++---
 src/util/virstoragefile.c         | 34 -------------------------
 src/util/virstoragefile.h         |  3 ---
 4 files changed, 38 insertions(+), 43 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c03b769c37..0a2a54dfdf 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3218,8 +3218,6 @@ virStorageFileGetNPIVKey;
 virStorageFileGetSCSIKey;
 virStorageFileParseBackingStoreStr;
 virStorageFileParseChainIndex;
-virStorageIsFile;
-virStorageIsRelative;


 # util/virstring.h
diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c
index 23d36507ea..df9fb6c055 100644
--- a/src/storage_file/storage_source.c
+++ b/src/storage_file/storage_source.c
@@ -45,6 +45,40 @@
 VIR_LOG_INIT("storage_source");


+static bool
+virStorageSourceBackinStoreStringIsFile(const char *backing)
+{
+    char *colon;
+    char *slash;
+
+    if (!backing)
+        return false;
+
+    colon = strchr(backing, ':');
+    slash = strchr(backing, '/');
+
+    /* Reject anything that looks like a protocol (such as nbd: or
+     * rbd:); if someone really does want a relative file name that
+     * includes ':', they can always prefix './'.  */
+    if (colon && (!slash || colon < slash))
+        return false;
+    return true;
+}
+
+
+static bool
+virStorageSourceBackinStoreStringIsRelative(const char *backing)
+{
+    if (backing[0] == '/')
+        return false;
+
+    if (!virStorageSourceBackinStoreStringIsFile(backing))
+        return false;
+
+    return true;
+}
+
+
 static virStorageSourcePtr
 virStorageSourceMetadataNew(const char *path,
                             int format)
@@ -185,7 +219,7 @@ virStorageSourceChainLookup(virStorageSourcePtr chain,
 {
     virStorageSourcePtr prev;
     const char *start = chain->path;
-    bool nameIsFile = virStorageIsFile(name);
+    bool nameIsFile = virStorageSourceBackinStoreStringIsFile(name);

     if (!parent)
         parent = &prev;
@@ -1532,7 +1566,7 @@ virStorageSourceNewFromBackingAbsolute(const char *path,

     *src = NULL;

-    if (virStorageIsFile(path)) {
+    if (virStorageSourceBackinStoreStringIsFile(path)) {
         def->type = VIR_STORAGE_TYPE_FILE;

         def->path = g_strdup(path);
@@ -1604,7 +1638,7 @@ virStorageSourceNewFromChild(virStorageSourcePtr parent,

     *child = NULL;

-    if (virStorageIsRelative(parentRaw)) {
+    if (virStorageSourceBackinStoreStringIsRelative(parentRaw)) {
         if (!(def = virStorageSourceNewFromBackingRelative(parent, parentRaw)))
             return -1;
     } else {
@@ -1927,7 +1961,7 @@ virStorageSourceFetchRelativeBackingPath(virStorageSourcePtr src,
     if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0)
         return -1;

-    if (virStorageIsRelative(tmp->backingStoreRaw))
+    if (virStorageSourceBackinStoreStringIsRelative(tmp->backingStoreRaw))
         *relPath = g_steal_pointer(&tmp->backingStoreRaw);

     return 0;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 85ccd9f52c..d1e56db708 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -37,40 +37,6 @@
 VIR_LOG_INIT("util.storagefile");


-bool
-virStorageIsFile(const char *backing)
-{
-    char *colon;
-    char *slash;
-
-    if (!backing)
-        return false;
-
-    colon = strchr(backing, ':');
-    slash = strchr(backing, '/');
-
-    /* Reject anything that looks like a protocol (such as nbd: or
-     * rbd:); if someone really does want a relative file name that
-     * includes ':', they can always prefix './'.  */
-    if (colon && (!slash || colon < slash))
-        return false;
-    return true;
-}
-
-
-bool
-virStorageIsRelative(const char *backing)
-{
-    if (backing[0] == '/')
-        return false;
-
-    if (!virStorageIsFile(backing))
-        return false;
-
-    return true;
-}
-
-
 #ifdef WITH_UDEV
 /* virStorageFileGetSCSIKey
  * @path: Path to the SCSI device
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 2c1a250f20..455a978a8d 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -33,9 +33,6 @@ int virStorageFileParseBackingStoreStr(const char *str,
                                        unsigned int *chainIndex)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);

-bool virStorageIsFile(const char *path);
-bool virStorageIsRelative(const char *backing);
-
 int virStorageFileGetSCSIKey(const char *path,
                              char **key,
                              bool ignoreError);
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux