Patch to build hivex lib on Windows
Hi I'm just posting this here in case someone is interested in building hivex on Windows (mingw32). The attached patch allows building the lib but not the tools (hivexsh etc..) as there are some more problems to solve. In short terms, this patch replaces file i/o functions and mmap(), munmap() with their win32api pendants. cu -- Unix _IS_ user friendly - it's just selective about who its friends are!
On Sat, Sep 03, 2011 at 04:45:28PM +0200, Gillen Daniel wrote:
Hi
I'm just posting this here in case someone is interested in building hivex on Windows (mingw32). The attached patch allows building the lib but not the tools (hivexsh etc..) as there are some more problems to solve.
In short terms, this patch replaces file i/o functions and mmap(), munmap() with their win32api pendants.
NACK ... This patch is too invasive. We are already linking with gnulib, which ought to provide a degree of platform independence. By adding the right gnulib modules (see the file 'bootstrap' in the toplevel directory) it should be possible to make hivex compile directly on Windows, while requiring fewer source code changes. gnulib can almost certainly do all the file things. I don't see a gnulib module for mmap, which could be a problem, but a less invasive change should still be possible for that. Rich.
diff --git a/lib/hivex.c b/lib/hivex.c index 4b9fcf0..986bdeb 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -30,13 +30,19 @@ #include <unistd.h> #include <errno.h> #include <iconv.h> -#include <sys/mman.h> +#ifndef __MINGW32__ + #include <sys/mman.h> +#else + #include <windows.h> +#endif #include <sys/stat.h> #include <assert.h>
#include "c-ctype.h" -#include "full-read.h" -#include "full-write.h" +#ifndef __MINGW32__ + #include "full-read.h" + #include "full-write.h" +#endif
#define STREQ(a,b) (strcmp((a),(b)) == 0) #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0) @@ -62,7 +68,13 @@ static size_t utf16_string_len_in_bytes_max (const char *str, size_t len);
struct hive_h { char *filename; +#ifndef __MINGW32__ int fd; +#else + HANDLE fd; + HANDLE winmap; +#endif + size_t size; int msglvl; int writable; @@ -294,28 +306,48 @@ hivex_open (const char *filename, int flags) if (h->filename == NULL) goto error;
-#ifdef O_CLOEXEC - h->fd = open (filename, O_RDONLY | O_CLOEXEC); -#else - h->fd = open (filename, O_RDONLY); -#endif - if (h->fd == -1) - goto error; -#ifndef O_CLOEXEC - fcntl (h->fd, F_SETFD, FD_CLOEXEC); -#endif - +#ifndef __MINGW32__ + #ifdef O_CLOEXEC + h->fd = open (filename, O_RDONLY | O_CLOEXEC); + #else + h->fd = open (filename, O_RDONLY); + #endif + if (h->fd == -1) + goto error; + #ifndef O_CLOEXEC + fcntl (h->fd, F_SETFD, FD_CLOEXEC); + #endif + struct stat statbuf; if (fstat (h->fd, &statbuf) == -1) goto error;
h->size = statbuf.st_size; +#else + h->fd = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h->fd == INVALID_HANDLE_VALUE) + goto error; + + // XXX: There might be a problem if hive > 2^32 bytes + h->size = GetFileSize (h->fd, NULL); +#endif
if (!h->writable) { +#ifndef __MINGW32__ h->addr = mmap (NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0); if (h->addr == MAP_FAILED) goto error; - +#else + // Mingw does not support mmap, we have to use native API + // Create file mapping + h->winmap = CreateFileMapping (h->fd, NULL, PAGE_READONLY, 0, 0, NULL); + if (h->winmap == NULL) + goto error; + // Create map view + h->addr = MapViewOfFile (h->winmap, FILE_MAP_READ, 0, 0, h->size); + if (h->addr == NULL) + goto error; +#endif if (h->msglvl >= 2) fprintf (stderr, "hivex_open: mapped file at %p\n", h->addr); } else { @@ -323,15 +355,29 @@ hivex_open (const char *filename, int flags) if (h->addr == NULL) goto error;
+#ifndef __MINGW32__ if (full_read (h->fd, h->addr, h->size) < h->size) goto error; +#else + DWORD bytes_read=0; + if (!ReadFile (h->fd, h->addr, h->size, &bytes_read, NULL)) + goto error; + if (bytes_read != h->size) + goto error; +#endif
/* We don't need the file descriptor along this path, since we * have read all the data. */ +#ifndef __MINGW32__ if (close (h->fd) == -1) goto error; h->fd = -1; +#else + if (!CloseHandle (h->fd)) + goto error; + h->fd = INVALID_HANDLE_VALUE; +#endif }
/* Check header. */ @@ -532,14 +578,28 @@ hivex_open (const char *filename, int flags) int err = errno; if (h) { free (h->bitmap); +#ifndef __MINGW32__ if (h->addr && h->size && h->addr != MAP_FAILED) { - if (!h->writable) +#else + if (h->addr && h->size && h->addr != NULL) { +#endif + if (!h->writable) { +#ifndef __MINGW32__ munmap (h->addr, h->size); - else +#else + UnmapViewOfFile (h->addr); + CloseHandle (h->winmap); +#endif + } else free (h->addr); } +#ifndef __MINGW32__ if (h->fd >= 0) close (h->fd); +#else + if (h->fd != INVALID_HANDLE_VALUE) + CloseHandle (h->fd); +#endif free (h->filename); free (h); } @@ -556,12 +616,22 @@ hivex_close (hive_h *h) fprintf (stderr, "hivex_close\n");
free (h->bitmap); - if (!h->writable) + if (!h->writable) { +#ifndef __MINGW32__ munmap (h->addr, h->size); - else +#else + UnmapViewOfFile (h->addr); + CloseHandle (h->winmap); +#endif + } else free (h->addr); +#ifndef __MINGW32__ if (h->fd >= 0) r = close (h->fd); +#else + if (h->fd != INVALID_HANDLE_VALUE) + r = CloseHandle (h->fd) ? 0 : 1; +#endif else r = 0; free (h->filename); @@ -2100,9 +2170,15 @@ hivex_commit (hive_h *h, const char *filename, int flags) }
filename = filename ? : h->filename; +#ifndef __MINGW32__ int fd = open (filename, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0666); if (fd == -1) return -1; +#else + HANDLE fd = CreateFile (filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (fd == INVALID_HANDLE_VALUE) + return -1; +#endif
/* Update the header fields. */ uint32_t sequence = le32toh (h->hdr->sequence1); @@ -2119,6 +2195,7 @@ hivex_commit (hive_h *h, const char *filename, int flags) if (h->msglvl >= 2) fprintf (stderr, "hivex_commit: new header checksum: 0x%x\n", sum);
+#ifndef __MINGW32__ if (full_write (fd, h->addr, h->size) != h->size) { int err = errno; close (fd); @@ -2128,6 +2205,20 @@ hivex_commit (hive_h *h, const char *filename, int flags)
if (close (fd) == -1) return -1; +#else + DWORD bytes_written; + if (!WriteFile (fd, h->addr, h->size, &bytes_written, NULL)) { + CloseHandle (fd); + return -1; + } + if (bytes_written != h->size) { + CloseHandle (fd); + return -1; + } + + if (!CloseHandle (fd)) + return -1; +#endif
return 0; }
_______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
Richard W.M. Jones wrote:
On Sat, Sep 03, 2011 at 04:45:28PM +0200, Gillen Daniel wrote:
I'm just posting this here in case someone is interested in building hivex on Windows (mingw32). The attached patch allows building the lib but not the tools (hivexsh etc..) as there are some more problems to solve.
In short terms, this patch replaces file i/o functions and mmap(), munmap() with their win32api pendants.
NACK ... This patch is too invasive.
We are already linking with gnulib, which ought to provide a degree of platform independence. By adding the right gnulib modules (see the file 'bootstrap' in the toplevel directory) it should be possible to make hivex compile directly on Windows, while requiring fewer source code changes.
gnulib can almost certainly do all the file things. I don't see a gnulib module for mmap, which could be a problem, but a less invasive change should still be possible for that.
Rich.
diff --git a/lib/hivex.c b/lib/hivex.c index 4b9fcf0..986bdeb 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -30,13 +30,19 @@ #include <unistd.h> #include <errno.h> #include <iconv.h> -#include <sys/mman.h> +#ifndef __MINGW32__ + #include <sys/mman.h> +#else + #include <windows.h> +#endif #include <sys/stat.h> #include <assert.h>
#include "c-ctype.h" -#include "full-read.h" -#include "full-write.h" +#ifndef __MINGW32__ + #include "full-read.h" + #include "full-write.h" +#endif
#define STREQ(a,b) (strcmp((a),(b)) == 0) #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0) @@ -62,7 +68,13 @@ static size_t utf16_string_len_in_bytes_max (const char *str, size_t len);
struct hive_h { char *filename; +#ifndef __MINGW32__ int fd; +#else + HANDLE fd; + HANDLE winmap; +#endif + size_t size; int msglvl; int writable; @@ -294,28 +306,48 @@ hivex_open (const char *filename, int flags) if (h->filename == NULL) goto error;
-#ifdef O_CLOEXEC - h->fd = open (filename, O_RDONLY | O_CLOEXEC); -#else - h->fd = open (filename, O_RDONLY); -#endif - if (h->fd == -1) - goto error; -#ifndef O_CLOEXEC - fcntl (h->fd, F_SETFD, FD_CLOEXEC); -#endif - +#ifndef __MINGW32__ + #ifdef O_CLOEXEC + h->fd = open (filename, O_RDONLY | O_CLOEXEC); + #else + h->fd = open (filename, O_RDONLY); + #endif + if (h->fd == -1) + goto error; + #ifndef O_CLOEXEC + fcntl (h->fd, F_SETFD, FD_CLOEXEC); + #endif + struct stat statbuf; if (fstat (h->fd, &statbuf) == -1) goto error;
h->size = statbuf.st_size; +#else + h->fd = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h->fd == INVALID_HANDLE_VALUE) + goto error; + + // XXX: There might be a problem if hive > 2^32 bytes + h->size = GetFileSize (h->fd, NULL); +#endif
if (!h->writable) { +#ifndef __MINGW32__ h->addr = mmap (NULL, h->size, PROT_READ, MAP_SHARED, h->fd, 0); if (h->addr == MAP_FAILED) goto error; - +#else + // Mingw does not support mmap, we have to use native API + // Create file mapping + h->winmap = CreateFileMapping (h->fd, NULL, PAGE_READONLY, 0, 0, NULL); + if (h->winmap == NULL) + goto error; + // Create map view + h->addr = MapViewOfFile (h->winmap, FILE_MAP_READ, 0, 0, h->size); + if (h->addr == NULL) + goto error; +#endif if (h->msglvl >= 2) fprintf (stderr, "hivex_open: mapped file at %p\n", h->addr); } else { @@ -323,15 +355,29 @@ hivex_open (const char *filename, int flags) if (h->addr == NULL) goto error;
+#ifndef __MINGW32__ if (full_read (h->fd, h->addr, h->size) < h->size) goto error; +#else + DWORD bytes_read=0; + if (!ReadFile (h->fd, h->addr, h->size, &bytes_read, NULL)) + goto error; + if (bytes_read != h->size) + goto error; +#endif
/* We don't need the file descriptor along this path, since we * have read all the data. */ +#ifndef __MINGW32__ if (close (h->fd) == -1) goto error; h->fd = -1; +#else + if (!CloseHandle (h->fd)) + goto error; + h->fd = INVALID_HANDLE_VALUE; +#endif }
/* Check header. */ @@ -532,14 +578,28 @@ hivex_open (const char *filename, int flags) int err = errno; if (h) { free (h->bitmap); +#ifndef __MINGW32__ if (h->addr && h->size && h->addr != MAP_FAILED) { - if (!h->writable) +#else + if (h->addr && h->size && h->addr != NULL) { +#endif + if (!h->writable) { +#ifndef __MINGW32__ munmap (h->addr, h->size); - else +#else + UnmapViewOfFile (h->addr); + CloseHandle (h->winmap); +#endif + } else free (h->addr); } +#ifndef __MINGW32__ if (h->fd >= 0) close (h->fd); +#else + if (h->fd != INVALID_HANDLE_VALUE) + CloseHandle (h->fd); +#endif free (h->filename); free (h); } @@ -556,12 +616,22 @@ hivex_close (hive_h *h) fprintf (stderr, "hivex_close\n");
free (h->bitmap); - if (!h->writable) + if (!h->writable) { +#ifndef __MINGW32__ munmap (h->addr, h->size); - else +#else + UnmapViewOfFile (h->addr); + CloseHandle (h->winmap); +#endif + } else free (h->addr); +#ifndef __MINGW32__ if (h->fd >= 0) r = close (h->fd); +#else + if (h->fd != INVALID_HANDLE_VALUE) + r = CloseHandle (h->fd) ? 0 : 1; +#endif else r = 0; free (h->filename); @@ -2100,9 +2170,15 @@ hivex_commit (hive_h *h, const char *filename, int flags) }
filename = filename ? : h->filename; +#ifndef __MINGW32__ int fd = open (filename, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0666); if (fd == -1) return -1; +#else + HANDLE fd = CreateFile (filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (fd == INVALID_HANDLE_VALUE) + return -1; +#endif
/* Update the header fields. */ uint32_t sequence = le32toh (h->hdr->sequence1); @@ -2119,6 +2195,7 @@ hivex_commit (hive_h *h, const char *filename, int flags) if (h->msglvl >= 2) fprintf (stderr, "hivex_commit: new header checksum: 0x%x\n", sum);
+#ifndef __MINGW32__ if (full_write (fd, h->addr, h->size) != h->size) { int err = errno; close (fd); @@ -2128,6 +2205,20 @@ hivex_commit (hive_h *h, const char *filename, int flags)
if (close (fd) == -1) return -1; +#else + DWORD bytes_written; + if (!WriteFile (fd, h->addr, h->size, &bytes_written, NULL)) { + CloseHandle (fd); + return -1; + } + if (bytes_written != h->size) { + CloseHandle (fd); + return -1; + } + + if (!CloseHandle (fd)) + return -1; +#endif
return 0; }
Thanks for the patch, Gillen, but as Rich says, parts look unnecessary. In particular, why do you ifdef the uses of full_read and full_write? I've Cc'd bug-gnulib.
On 09/03/2011 07:35 PM, Richard W.M. Jones wrote:
On Sat, Sep 03, 2011 at 04:45:28PM +0200, Gillen Daniel wrote:
Hi
I'm just posting this here in case someone is interested in building hivex on Windows (mingw32). The attached patch allows building the lib but not the tools (hivexsh etc..) as there are some more problems to solve.
In short terms, this patch replaces file i/o functions and mmap(), munmap() with their win32api pendants.
NACK ... This patch is too invasive.
We are already linking with gnulib, which ought to provide a degree of platform independence. By adding the right gnulib modules (see the file 'bootstrap' in the toplevel directory) it should be possible to make hivex compile directly on Windows, while requiring fewer source code changes.
gnulib can almost certainly do all the file things. I don't see a gnulib module for mmap, which could be a problem, but a less invasive change should still be possible for that.
Rich.
mmap is exactly the problem. I didn't find it in gnulib or somewhere else. I did some more research on how it could be done and I came up with the following. Definitely less invasive :) and full_read and full_write can be used again. What do you think about that one? Oh, and there is another problem which I encountered while building on Windows and on Osx 10.7. In Linux, "include/bits/byteswap.h" define __bswap_* functions and "include/byteswap.h" define those as bswap_*. Your "lib/byte_conversions.h" file uses the __bswap_* functions but when compiling on a system where byteswap.h does not exist and the gnulib byteswap.h file is used, there are no __bswap_* functions defined anymore resulting in the lib not being able to link. Is there a special reason the __bswap_* functions were used and not the bswap_* ones? -- Unix _IS_ user friendly - it's just selective about who its friends are!
On Sat, Sep 03, 2011 at 10:46:30PM +0200, Gillen Daniel wrote:
mmap is exactly the problem. I didn't find it in gnulib or somewhere else.
I did some more research on how it could be done and I came up with the following. Definitely less invasive :) and full_read and full_write can be used again.
What do you think about that one?
From upstream (ie. our) point of view, it means the replacement is stuffed into another file that is only used on Windows and that we don't have to worry about. From your point of view the advantage is
The way to do this [mmap] patch less invasively is to use an autoconf replacement function. (Well actually a better way would be to add the needed features to gnulib, but I'll assume that you don't want to do that). It's all documented here: https://www.gnu.org/s/hello/manual/autoconf/Generic-Functions.html https://www.gnu.org/s/hello/manual/automake/LIBOBJS.html (see AC_LIBOBJ, AC_REPLACE_FUNCS etc). that you can [in the replacement file] go wild with whatever Windows specific includes and Win32 APIs you want.
Oh, and there is another problem which I encountered while building on Windows and on Osx 10.7.
In Linux, "include/bits/byteswap.h" define __bswap_* functions and "include/byteswap.h" define those as bswap_*. Your "lib/byte_conversions.h" file uses the __bswap_* functions but when compiling on a system where byteswap.h does not exist and the gnulib byteswap.h file is used, there are no __bswap_* functions defined anymore resulting in the lib not being able to link.
Is there a special reason the __bswap_* functions were used and not the bswap_* ones?
The "reason" is probably "because it worked on Linux" :-) I'll have a look at the other patch you posted. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On 09/06/2011 02:51 PM, Richard W.M. Jones wrote:
On Sat, Sep 03, 2011 at 10:46:30PM +0200, Gillen Daniel wrote:
mmap is exactly the problem. I didn't find it in gnulib or somewhere else.
I did some more research on how it could be done and I came up with the following. Definitely less invasive :) and full_read and full_write can be used again.
What do you think about that one?
The way to do this [mmap] patch less invasively is to use an autoconf replacement function. (Well actually a better way would be to add the needed features to gnulib, but I'll assume that you don't want to do that).
It's all documented here:
https://www.gnu.org/s/hello/manual/autoconf/Generic-Functions.html https://www.gnu.org/s/hello/manual/automake/LIBOBJS.html
(see AC_LIBOBJ, AC_REPLACE_FUNCS etc).
From upstream (ie. our) point of view, it means the replacement is stuffed into another file that is only used on Windows and that we don't have to worry about. From your point of view the advantage is that you can [in the replacement file] go wild with whatever Windows specific includes and Win32 APIs you want.
Ok, thx for pointing me in that direction. I'm willing to do it like that but I have two further questions. 1. This damn windows MapViewOfFile function needs a handle to a file map object that has to be saved somewhere to be able to close it when calling munmap. The only way I currently see to save it would be in your hive_h structure. But this would incorporate that on windows, when calling mmap and munmap, an additional parameter would have to be passed. Would that be ok for you or do you have an idea how this could be solved nicer? 2. What do you request from the mmap / munmap replacement? Should it only support the functionality currently used in the lib or should it implement as far as possible all features from the libc mmap / munmap functions? -- Unix _IS_ user friendly - it's just selective about who its friends are!
On Tue, Sep 06, 2011 at 07:19:32PM +0200, Gillen Daniel wrote:
On 09/06/2011 02:51 PM, Richard W.M. Jones wrote:
On Sat, Sep 03, 2011 at 10:46:30PM +0200, Gillen Daniel wrote:
mmap is exactly the problem. I didn't find it in gnulib or somewhere else.
I did some more research on how it could be done and I came up with the following. Definitely less invasive :) and full_read and full_write can be used again.
What do you think about that one?
The way to do this [mmap] patch less invasively is to use an autoconf replacement function. (Well actually a better way would be to add the needed features to gnulib, but I'll assume that you don't want to do that).
It's all documented here:
https://www.gnu.org/s/hello/manual/autoconf/Generic-Functions.html https://www.gnu.org/s/hello/manual/automake/LIBOBJS.html
(see AC_LIBOBJ, AC_REPLACE_FUNCS etc).
From upstream (ie. our) point of view, it means the replacement is stuffed into another file that is only used on Windows and that we don't have to worry about. From your point of view the advantage is that you can [in the replacement file] go wild with whatever Windows specific includes and Win32 APIs you want.
Ok, thx for pointing me in that direction. I'm willing to do it like that but I have two further questions.
1. This damn windows MapViewOfFile function needs a handle to a file map object that has to be saved somewhere to be able to close it when calling munmap. The only way I currently see to save it would be in your hive_h structure. But this would incorporate that on windows, when calling mmap and munmap, an additional parameter would have to be passed. Would that be ok for you or do you have an idea how this could be solved nicer?
It's fine to store a few extra things in the hive_h struct. That would not be too invasive.
2. What do you request from the mmap / munmap replacement? Should it only support the functionality currently used in the lib or should it implement as far as possible all features from the libc mmap / munmap functions?
For replacement functions, you only need to support just enough to make the hivex library work. Anything above that is actually bad -- more code == more maintenance :-( Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
This patch series adds mmap / munmap replacement functions to be able to build hivex library on Windows (mingw) -- Unix _IS_ user friendly - it's just selective about who its friends are!
On Tue, Sep 06, 2011 at 11:31:11PM +0200, Gillen Daniel wrote:
This patch series adds mmap / munmap replacement functions to be able to build hivex library on Windows (mingw)
Preliminary ACK to all of them. I'll take a proper look tomorrow and push it. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
On Tue, Sep 06, 2011 at 11:31:11PM +0200, Gillen Daniel wrote:
This patch series adds mmap / munmap replacement functions to be able to build hivex library on Windows (mingw)
I've applied an equivalent patch: http://git.annexia.org/?p=hivex.git;a=commitdiff;h=085707078097f6def993b20a7... I tested it using the Fedora Windows cross-compiler. Please check it still works in your environment. Some comments: Lots of small patches are easier to review. However each patch still needs to be an atomic, consistent commit, which wasn't the case here. 'git format-patch' or 'git send-email' makes it simpler both for you to send, and for me to apply, patches. We had some discussion on IRC about how to reduce the impact on the main code further. There were two proposals: either to implement a hashtable in the Windows mmap code to map <something> to hive handles. Or to do what we did (which is a bit of a hack): #define mmap(...) mmap (h, ...) This isn't the best solution, but it'll do til we think of something better. Files not listed in *_SOURCES so make dist would have failed. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
On 09/07/2011 01:45 PM, Richard W.M. Jones wrote:
On Tue, Sep 06, 2011 at 11:31:11PM +0200, Gillen Daniel wrote:
This patch series adds mmap / munmap replacement functions to be able to build hivex library on Windows (mingw)
I've applied an equivalent patch: http://git.annexia.org/?p=hivex.git;a=commitdiff;h=085707078097f6def993b20a7...
I tested it using the Fedora Windows cross-compiler. Please check it still works in your environment.
Some comments:
Lots of small patches are easier to review. However each patch still needs to be an atomic, consistent commit, which wasn't the case here. 'git format-patch' or 'git send-email' makes it simpler both for you to send, and for me to apply, patches.
We had some discussion on IRC about how to reduce the impact on the main code further. There were two proposals: either to implement a hashtable in the Windows mmap code to map<something> to hive handles. Or to do what we did (which is a bit of a hack): #define mmap(...) mmap (h, ...) This isn't the best solution, but it'll do til we think of something better.
Files not listed in *_SOURCES so make dist would have failed.
Rich.
Works fine for me using MinGW 3.18 (gcc 4.5.2) on Win XP. Many thx for adding. -- Unix _IS_ user friendly - it's just selective about who its friends are!
-- Unix _IS_ user friendly - it's just selective about who its friends are!
-- Unix _IS_ user friendly - it's just selective about who its friends are!
-- Unix _IS_ user friendly - it's just selective about who its friends are!
-- Unix _IS_ user friendly - it's just selective about who its friends are!
-- Unix _IS_ user friendly - it's just selective about who its friends are!
participants (3)
-
Gillen Daniel -
Jim Meyering -
Richard W.M. Jones