Isolate dmg probe as part of the modularization process.
Signed-off-by: Colin Lord <[email protected]>
---
block/Makefile.objs | 2 +-
block/dmg.c | 16 +---------------
block/probe/dmg.c | 17 +++++++++++++++++
include/block/probe.h | 1 +
4 files changed, 20 insertions(+), 16 deletions(-)
create mode 100644 block/probe/dmg.c
diff --git a/block/Makefile.objs b/block/Makefile.objs
index 28a7ec3..1d744eb 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -24,7 +24,7 @@ block-obj-y += accounting.o dirty-bitmap.o
block-obj-y += write-threshold.o
block-obj-y += crypto.o
-block-obj-y += probe/bochs.o probe/cloop.o probe/luks.o
+block-obj-y += probe/bochs.o probe/cloop.o probe/luks.o probe/dmg.o
common-obj-y += stream.o
common-obj-y += commit.o
diff --git a/block/dmg.c b/block/dmg.c
index 06eb513..2c70687 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -25,6 +25,7 @@
#include "qapi/error.h"
#include "qemu-common.h"
#include "block/block_int.h"
+#include "block/probe.h"
#include "qemu/bswap.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
@@ -66,21 +67,6 @@ typedef struct BDRVDMGState {
#endif
} BDRVDMGState;
-static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
-{
- int len;
-
- if (!filename) {
- return 0;
- }
-
- len = strlen(filename);
- if (len > 4 && !strcmp(filename + len - 4, ".dmg")) {
- return 2;
- }
- return 0;
-}
-
static int read_uint64(BlockDriverState *bs, int64_t offset, uint64_t *result)
{
uint64_t buffer;
diff --git a/block/probe/dmg.c b/block/probe/dmg.c
new file mode 100644
index 0000000..a40281b
--- /dev/null
+++ b/block/probe/dmg.c
@@ -0,0 +1,17 @@
+#include "qemu/osdep.h"
+#include "block/probe.h"
+
+int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+ int len;
+
+ if (!filename) {
+ return 0;
+ }
+
+ len = strlen(filename);
+ if (len > 4 && !strcmp(filename + len - 4, ".dmg")) {
+ return 2;
+ }
+ return 0;
+}
diff --git a/include/block/probe.h b/include/block/probe.h
index 35a8d00..267431d 100644
--- a/include/block/probe.h
+++ b/include/block/probe.h
@@ -5,5 +5,6 @@ int bochs_probe(const uint8_t *buf, int buf_size, const char
*filename);
int cloop_probe(const uint8_t *buf, int buf_size, const char *filename);
int block_crypto_probe_luks(const uint8_t *buf, int buf_size,
const char *filename);
+int dmg_probe(const uint8_t *buf, int buf_size, const char *filename);
#endif
--
2.5.5