From: Christoph Egger <Christoph.Egger@amd.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] blktap2: portability fixes
Date: Wed, 24 Jun 2009 15:57:13 +0200 [thread overview]
Message-ID: <200906241557.13912.Christoph.Egger@amd.com> (raw)
In-Reply-To: <C667E3B6.E0F2%keir.fraser@eu.citrix.com>
[-- Attachment #1: Type: text/plain, Size: 2668 bytes --]
Oh, indeed! It's always good to have a second pair of eyes over it.
Attached patch implements blk_uuid_to_string() for NetBSD correctly.
I hope, this is the last iteration over blktap2.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
On Wednesday 24 June 2009 15:07:50 Keir Fraser wrote:
> I changed this some and applied as c/s 19832. Of particular note is that
> your definition of blk_uuid_to_string() was very broken; all that could be
> said of it is that it builds, but it was fundamentally broken for both
> Linux and NetBSD. Note that uuid_to_string() itself allocates a string
> buffer and returns a pointer to it -- so you need to copy that string to
> the buffer passed to blk_uuid_to_string() and then free it. I didn't
> implement that bit for you, so you need to provide a patch to fix NetBSD's
> blk_uuid_to_string().
>
> -- Keir
>
> On 24/06/2009 13:24, "Christoph Egger" <Christoph.Egger@amd.com> wrote:
> > Patch is attached.
> > uuid is totally different in Linux and in NetBSD.
> > uuid_t is a char array in Linux and a struct in NetBSD.
> > Making NetBSD uuid look like Linux uuid doesn't work at all and
> > neither the other way around.
> > I renamed your uuid.h header to avoid a recursive inclusion
> > of the same header.
> > I created an uuid abstraction with a Linux and NetBSD implementation.
> >
> > I also fixed a bug in vhd_create_batmap() which slipped in previously.
> > iconv() is a bit nasty to make it compile on both NetBSD and Linux.
> >
> > Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
> >
> > On Tuesday 23 June 2009 18:25:19 Keir Fraser wrote:
> >> This didn't have a prayer of building on Linux. I fixed it up for Linux
> >> and applied as c/s 19817. It's probably broken for netbsd now, but you
> >> should be able to provide a small fixup patch for that.
> >>
> >> -- Keir
> >>
> >> On 23/06/2009 13:29, "Christoph Egger" <Christoph.Egger@amd.com> wrote:
> >>> Hi!
> >>>
> >>> Attached patch makes blktap2 build on NetBSD.
> >>>
> >>> - Use standard off_t and lseek() instead of non-portable off64_t and
> >>> lseek64() - Use uuid API as documented in DCE 1.1 RPC specification
> >>> - Add NetBSD implementation for blk_getimagesize() and
> >>> blk_getsectorsize() - Use blk_getimagesize() and blk_getsectorsize()
> >>> - Fix uuid header check
> >>>
> >>> Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
[-- Attachment #2: xen_blktap2.diff --]
[-- Type: text/x-diff, Size: 2782 bytes --]
diff -r f1fec38c8228 tools/blktap2/include/blk_uuid.h
--- a/tools/blktap2/include/blk_uuid.h Wed Jun 24 14:03:20 2009 +0100
+++ b/tools/blktap2/include/blk_uuid.h Wed Jun 24 15:45:27 2009 +0200
@@ -45,7 +45,7 @@ static inline void blk_uuid_generate(blk
uuid_generate(uuid->uuid);
}
-static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out)
+static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
{
uuid_unparse(uuid->uuid, out);
}
@@ -74,6 +74,7 @@ static inline int blk_uuid_compare(blk_u
#include <uuid.h>
#include <string.h>
+#include <stdlib.h>
typedef uuid_t blk_uuid_t;
@@ -89,10 +90,13 @@ static inline void blk_uuid_generate(blk
uuid_create((uuid_t *)uuid, &status);
}
-static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out)
+static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
{
uint32_t status;
- uuid_to_string((uuid_t *)uuid, &out, &status);
+ char *_out = NULL;
+ uuid_to_string((uuid_t *)uuid, &_out, &status);
+ strlcpy(out, _out, size);
+ free(_out);
}
static inline void blk_uuid_from_string(blk_uuid_t *uuid, const char *in)
diff -r f1fec38c8228 tools/blktap2/vhd/lib/libvhd.c
--- a/tools/blktap2/vhd/lib/libvhd.c Wed Jun 24 14:03:20 2009 +0100
+++ b/tools/blktap2/vhd/lib/libvhd.c Wed Jun 24 15:45:27 2009 +0200
@@ -1335,7 +1335,7 @@ vhd_macx_encode_location(char *name, cha
snprintf(uri, ibl+1, "file://%s", name);
if (iconv(cd,
-#if defined(__linux__) || (__Linux__)
+#if defined(__linux__) || defined(__Linux__)
(char **)
#endif
&urip, &ibl, &uri_utf8p, &obl) == (size_t)-1 ||
@@ -1425,7 +1425,7 @@ vhd_w2u_encode_location(char *name, char
}
if (iconv(cd,
-#if defined(__linux__) || (__Linux__)
+#if defined(__linux__) || defined(__Linux__)
(char **)
#endif
&urip, &ibl, &uri_utf16p, &obl) == (size_t)-1 ||
diff -r f1fec38c8228 tools/blktap2/vhd/lib/vhd-util-read.c
--- a/tools/blktap2/vhd/lib/vhd-util-read.c Wed Jun 24 14:03:20 2009 +0100
+++ b/tools/blktap2/vhd/lib/vhd-util-read.c Wed Jun 24 15:45:27 2009 +0200
@@ -78,7 +78,7 @@ vhd_print_header(vhd_context_t *vhd, vhd
(err ? "failed to read name" : name));
free(name);
- blk_uuid_to_string(&h->prt_uuid, uuid);
+ blk_uuid_to_string(&h->prt_uuid, uuid, sizeof(uuid));
printf("Parent UUID : %s\n", uuid);
vhd_time_to_string(h->prt_ts, time_str);
@@ -153,7 +153,7 @@ vhd_print_footer(vhd_footer_t *f, int he
printf("Checksum : 0x%x|0x%x (%s)\n", f->checksum, cksm,
f->checksum == cksm ? "Good!" : "Bad!");
- blk_uuid_to_string(&f->uuid, uuid);
+ blk_uuid_to_string(&f->uuid, uuid, sizeof(uuid));
printf("UUID : %s\n", uuid);
printf("Saved state : %s\n", f->saved == 0 ? "No" : "Yes");
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
prev parent reply other threads:[~2009-06-24 13:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-23 12:29 [PATCH] blktap2: portability fixes Christoph Egger
2009-06-23 16:25 ` Keir Fraser
2009-06-24 12:24 ` Christoph Egger
2009-06-24 13:07 ` Keir Fraser
2009-06-24 13:57 ` Christoph Egger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200906241557.13912.Christoph.Egger@amd.com \
--to=christoph.egger@amd.com \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.