summaryrefslogtreecommitdiffstats
path: root/hivex/hivex.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-01-18 10:58:06 +0000
committerRichard Jones <rjones@redhat.com>2010-01-28 11:25:30 +0000
commit1e4614ca8f8d2b3d758fef733f1294c611502b94 (patch)
treee60ef2b48bbb7da34d24d01b46acb9dcae895fce /hivex/hivex.c
parent5eb38569991a3e932ee474921775b0a49fd69980 (diff)
downloadlibguestfs-1e4614ca8f8d2b3d758fef733f1294c611502b94.tar.gz
libguestfs-1e4614ca8f8d2b3d758fef733f1294c611502b94.tar.xz
libguestfs-1e4614ca8f8d2b3d758fef733f1294c611502b94.zip
hivex: Store filename in hive handle.
Diffstat (limited to 'hivex/hivex.c')
-rw-r--r--hivex/hivex.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hivex/hivex.c b/hivex/hivex.c
index 6129017d..a7603007 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;