From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKo5j-0004j1-NQ for qemu-devel@nongnu.org; Wed, 06 Jul 2016 10:46:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKo5h-000884-Fh for qemu-devel@nongnu.org; Wed, 06 Jul 2016 10:46:18 -0400 References: <1467732272-23368-1-git-send-email-clord@redhat.com> <1467732272-23368-9-git-send-email-clord@redhat.com> From: Max Reitz Message-ID: Date: Wed, 6 Jul 2016 16:46:06 +0200 MIME-Version: 1.0 In-Reply-To: <1467732272-23368-9-git-send-email-clord@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nQQx1kO1TUrSOmLQS9abRwd8L7VRRfP7r" Subject: Re: [Qemu-devel] [PATCH v3 08/32] blockdev: Move parallels probe to its own file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Colin Lord , qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --nQQx1kO1TUrSOmLQS9abRwd8L7VRRfP7r From: Max Reitz To: Colin Lord , qemu-devel@nongnu.org Cc: kwolf@redhat.com, qemu-block@nongnu.org Message-ID: Subject: Re: [PATCH v3 08/32] blockdev: Move parallels probe to its own file References: <1467732272-23368-1-git-send-email-clord@redhat.com> <1467732272-23368-9-git-send-email-clord@redhat.com> In-Reply-To: <1467732272-23368-9-git-send-email-clord@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 05.07.2016 17:24, Colin Lord wrote: > Isolate parallels probe as part of the modularization process. >=20 > Signed-off-by: Colin Lord > --- > block/Makefile.objs | 1 + > block/parallels.c | 43 ++------------------------------= -------- > block/probe/parallels.c | 22 ++++++++++++++++++++ > include/block/driver/parallels.h | 26 ++++++++++++++++++++++++ > include/block/probe.h | 1 + > 5 files changed, 52 insertions(+), 41 deletions(-) > create mode 100644 block/probe/parallels.c > create mode 100644 include/block/driver/parallels.h [...] > diff --git a/block/probe/parallels.c b/block/probe/parallels.c > new file mode 100644 > index 0000000..66cddea > --- /dev/null > +++ b/block/probe/parallels.c > @@ -0,0 +1,22 @@ > +#include "qemu/osdep.h" > +#include "block/block_int.h" > +#include "block/probe.h" > +#include "block/driver/parallels.h" > + > +int parallels_probe(const uint8_t *buf, int buf_size, > + const char *filename) This line should be aligned to the opening parenthesis; or you can just put it in on a single line. > +{ > + const ParallelsHeader *ph =3D (const void *)buf; > + > + if (buf_size < sizeof(ParallelsHeader)) { > + return 0; > + } > + > + if ((!memcmp(ph->magic, HEADER_MAGIC, 16) || > + !memcmp(ph->magic, HEADER_MAGIC2, 16)) && > + (le32_to_cpu(ph->version) =3D=3D HEADER_VERSION)) { So should these two lines probably, but I don't care much about them because this is a pre-existing issue. > + return 100; > + } > + > + return 0; > +} > diff --git a/include/block/driver/parallels.h b/include/block/driver/pa= rallels.h > new file mode 100644 > index 0000000..512ef5f > --- /dev/null > +++ b/include/block/driver/parallels.h > @@ -0,0 +1,26 @@ > +#ifndef PARALLELS_H > +#define PARALLELS_H > + > +#define HEADER_MAGIC "WithoutFreeSpace" > +#define HEADER_MAGIC2 "WithouFreSpacExt" I'm somehow very amused by this second magic string ("We want to append an Ext, but that means the buffer is three chars short... Thank god the rest of the magic string consists of exactly three words, so let's just strip a letter off of each!"). > +#define HEADER_VERSION 2 > +#define HEADER_INUSE_MAGIC (0x746F6E59) > + > +#define DEFAULT_CLUSTER_SIZE 1048576 /* 1 MiB */ > + > + > +// always little-endian > +typedef struct ParallelsHeader { > + char magic[16]; // "WithoutFreeSpace" checkpatch complains about the C++-style comments, but this is again the question of whether we have to fix pre-existing coding style issues here.= > + uint32_t version; > + uint32_t heads; > + uint32_t cylinders; > + uint32_t tracks; > + uint32_t bat_entries; > + uint64_t nb_sectors; > + uint32_t inuse; > + uint32_t data_off; > + char padding[12]; > +} QEMU_PACKED ParallelsHeader; > + > +#endif With the function header of parallels_probe() fixed: Reviewed-by: Max Reitz --nQQx1kO1TUrSOmLQS9abRwd8L7VRRfP7r Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEvBAEBCAAZBQJXfRmuEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrUWn B/9GN29vYTJJO0K4SQe7DAU8Kr7BLI9/l29fo5tzuCKzmTSTZk3Ih1uWwyaH5EDF 8ozFPsk5lL3VYOQ+0e1yBTRieLapYLD+aFSc1Ti3rpJ1xczW7JQwOxSsYpLvgMUC ufnXc5SSWC7kFGbHXNxfP27er6qICSyzz5kF2g5gPSRd5j5le2Rt4Vsi1YF1KcTd thewsXIOtwZVCJdvBrckJgs2xQ8tv2JBiSQrRJReliQR7IRVXBDtX8UKVWT50jQK 5NeKeBCUTUnGqPAm960kG6g8P4egF+Meixfk03FJ2qzhc6O8apzlINUGQWH8F7Uc znda2JkQSCWfT3j6SquZvrNH =nJPk -----END PGP SIGNATURE----- --nQQx1kO1TUrSOmLQS9abRwd8L7VRRfP7r--