mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
util: virstoragefile: Move virStorageIs[File|Relative] to storage_source
There are no other files using it. Move it and make the functions static. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
db4d7a37ca
commit
04489d9fca
@ -3218,8 +3218,6 @@ virStorageFileGetNPIVKey;
|
||||
virStorageFileGetSCSIKey;
|
||||
virStorageFileParseBackingStoreStr;
|
||||
virStorageFileParseChainIndex;
|
||||
virStorageIsFile;
|
||||
virStorageIsRelative;
|
||||
|
||||
|
||||
# util/virstring.h
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user