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)
{
virStorageSourcePtr prev;
const char *start = chain->path;
- bool nameIsFile = virStorageIsFile(name);
+ bool nameIsFile = virStorageSourceBackinStoreStringIsFile(name);
if (!parent)
parent = &prev;
*src = NULL;
- if (virStorageIsFile(path)) {
+ if (virStorageSourceBackinStoreStringIsFile(path)) {
def->type = VIR_STORAGE_TYPE_FILE;
def->path = g_strdup(path);
*child = NULL;
- if (virStorageIsRelative(parentRaw)) {
+ if (virStorageSourceBackinStoreStringIsRelative(parentRaw)) {
if (!(def = virStorageSourceNewFromBackingRelative(parent, parentRaw)))
return -1;
} else {
if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0)
return -1;
- if (virStorageIsRelative(tmp->backingStoreRaw))
+ if (virStorageSourceBackinStoreStringIsRelative(tmp->backingStoreRaw))
*relPath = g_steal_pointer(&tmp->backingStoreRaw);
return 0;
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