diff mbox

[v4,07/32] blockdev: Move dmg probe to its own file

Message ID 1468523008-30013-8-git-send-email-clord@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

clord@redhat.com July 14, 2016, 7:03 p.m. UTC
Isolate dmg probe as part of the modularization process.

Signed-off-by: Colin Lord <clord@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block/Makefile.objs   |  2 +-
 block/dmg-probe.c     | 17 +++++++++++++++++
 block/dmg.c           | 16 +---------------
 include/block/probe.h |  1 +
 4 files changed, 20 insertions(+), 16 deletions(-)
 create mode 100644 block/dmg-probe.c
diff mbox

Patch

diff --git a/block/Makefile.objs b/block/Makefile.objs
index aca547f..09cc64c 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 += bochs-probe.o cloop-probe.o crypto-probe.o
+block-obj-y += bochs-probe.o cloop-probe.o crypto-probe.o dmg-probe.o
 
 common-obj-y += stream.o
 common-obj-y += backup.o
diff --git a/block/dmg-probe.c b/block/dmg-probe.c
new file mode 100644
index 0000000..a40281b
--- /dev/null
+++ b/block/dmg-probe.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/block/dmg.c b/block/dmg.c
index b0ed89b..4bbb079 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/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