[Libguestfs] [PATCH 1/13] hivex: Store filename in hive handle.
Richard W.M. Jones
rjones at redhat.com
Thu Jan 28 10:16:18 UTC 2010
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-------------- next part --------------
>From 6a69ac7b31abc628f6fe52c8a241b699d3f98c07 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Mon, 18 Jan 2010 10:58:06 +0000
Subject: [PATCH 01/13] hivex: Store filename in hive handle.
---
hivex/hivex.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/hivex/hivex.c b/hivex/hivex.c
index 6129017..a760300 100644
--- a/hivex/hivex.c
+++ b/hivex/hivex.c
@@ -89,6 +89,7 @@
static char *windows_utf16_to_utf8 (/* const */ char *input, size_t len);
struct hive_h {
+ char *filename;
int fd;
size_t size;
int msglvl;
@@ -281,6 +282,10 @@ hivex_open (const char *filename, int flags)
if (h->msglvl >= 2)
fprintf (stderr, "hivex_open: created handle %p\n", h);
+ h->filename = strdup (filename);
+ if (h->filename == NULL)
+ goto error;
+
h->fd = open (filename, O_RDONLY);
if (h->fd == -1)
goto error;
@@ -482,6 +487,7 @@ hivex_open (const char *filename, int flags)
munmap (h->addr, h->size);
if (h->fd >= 0)
close (h->fd);
+ free (h->filename);
free (h);
}
errno = err;
@@ -496,6 +502,7 @@ hivex_close (hive_h *h)
free (h->bitmap);
munmap (h->addr, h->size);
r = close (h->fd);
+ free (h->filename);
free (h);
return r;
--
1.6.5.2
More information about the Libguestfs
mailing list