提交 5e4946d4 编写于 作者: E Eric Blake

storage: rearrange functions

No semantic change; done so the next patch doesn't need a forward
declaration of a static function.

* src/util/virstoragefile.c (virStorageFileProbeFormatFromBuf):
Hoist earlier.
上级 c51c3e45
...@@ -616,6 +616,47 @@ virBackingStoreIsFile(const char *backing) ...@@ -616,6 +616,47 @@ virBackingStoreIsFile(const char *backing)
return true; return true;
} }
static int
virStorageFileProbeFormatFromBuf(const char *path,
unsigned char *buf,
size_t buflen)
{
int format = VIR_STORAGE_FILE_RAW;
int i;
int possibleFormat = VIR_STORAGE_FILE_RAW;
VIR_DEBUG("path=%s", path);
/* First check file magic */
for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
if (virStorageFileMatchesMagic(i, buf, buflen)) {
if (!virStorageFileMatchesVersion(i, buf, buflen)) {
possibleFormat = i;
continue;
}
format = i;
goto cleanup;
}
}
if (possibleFormat != VIR_STORAGE_FILE_RAW)
VIR_WARN("File %s matches %s magic, but version is wrong. "
"Please report new version to libvir-list@redhat.com",
path, virStorageFileFormatTypeToString(possibleFormat));
/* No magic, so check file extension */
for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
if (virStorageFileMatchesExtension(i, path)) {
format = i;
goto cleanup;
}
}
cleanup:
VIR_DEBUG("format=%d", format);
return format;
}
static int static int
virStorageFileGetMetadataFromBuf(int format, virStorageFileGetMetadataFromBuf(int format,
const char *path, const char *path,
...@@ -707,47 +748,6 @@ virStorageFileGetMetadataFromBuf(int format, ...@@ -707,47 +748,6 @@ virStorageFileGetMetadataFromBuf(int format,
} }
static int
virStorageFileProbeFormatFromBuf(const char *path,
unsigned char *buf,
size_t buflen)
{
int format = VIR_STORAGE_FILE_RAW;
int i;
int possibleFormat = VIR_STORAGE_FILE_RAW;
VIR_DEBUG("path=%s", path);
/* First check file magic */
for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
if (virStorageFileMatchesMagic(i, buf, buflen)) {
if (!virStorageFileMatchesVersion(i, buf, buflen)) {
possibleFormat = i;
continue;
}
format = i;
goto cleanup;
}
}
if (possibleFormat != VIR_STORAGE_FILE_RAW)
VIR_WARN("File %s matches %s magic, but version is wrong. "
"Please report new version to libvir-list@redhat.com",
path, virStorageFileFormatTypeToString(possibleFormat));
/* No magic, so check file extension */
for (i = 0 ; i < VIR_STORAGE_FILE_LAST ; i++) {
if (virStorageFileMatchesExtension(i, path)) {
format = i;
goto cleanup;
}
}
cleanup:
VIR_DEBUG("format=%d", format);
return format;
}
/** /**
* virStorageFileProbeFormatFromFD: * virStorageFileProbeFormatFromFD:
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册