From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSDS-0005zH-4N for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKSDM-0008Qi-JI for qemu-devel@nongnu.org; Tue, 05 Jul 2016 11:24:48 -0400 From: Colin Lord Date: Tue, 5 Jul 2016 11:24:07 -0400 Message-Id: <1467732272-23368-8-git-send-email-clord@redhat.com> In-Reply-To: <1467732272-23368-1-git-send-email-clord@redhat.com> References: <1467732272-23368-1-git-send-email-clord@redhat.com> Subject: [Qemu-devel] [PATCH v3 07/32] blockdev: Move dmg probe to its own file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com, Colin Lord Isolate dmg probe as part of the modularization process. Signed-off-by: Colin Lord --- 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