[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 4/5] Add lib/mmap.h file





--
Unix _IS_ user friendly - it's just
selective about who its friends are!
diff --git a/lib/mmap.h b/lib/mmap.h
index e69de29..9c54cdb 100644
--- a/lib/mmap.h
+++ b/lib/mmap.h
@@ -0,0 +1,67 @@
+/* mmap replacement for mingw.
+ *
+ * Copyright (C) 2011 by Daniel Gillen <gillen (dot) dan (at) pinguin (dot) lu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ */
+
+#ifndef hivex_mmap_h
+#define hivex_mmap_h
+
+#include <stdlib.h>
+#include <sys/types.h>
+
+// Supported map protections.
+#define PROT_READ   0x1  /* Page can be read.  */
+
+// Supported sharing types (must choose one and only one of these).
+#define MAP_SHARED  0x01 /* Share changes.  */
+
+// Value that is returned when mapping failed
+#define MAP_FAILED  NULL
+
+/*
+ * mmap
+ *
+ * Parameters:
+ *   void *p_addr     : Preferred starting address for the mapping. Unsupported
+ *                      and must be NULL.
+ *   size_t len       : Mapping length (From offset to offset+len-1).
+ *   int prot         : Flags that control what kind of access is permitted.
+ *                      Must be PROT_READ.
+ *   int flags        : Flags that control the nature of the map. Must be
+ *                      MAP_SHARED.
+ *   int fd           : File descriptor of file to be mapped.
+ *   off_t offset     : Mapping offset.
+ *   void **pp_winmap : Pointer to internal data that must be specified when
+ *                      calling munmap.
+ *
+ * Returns:
+ *   Map address on success or MAP_FAILED on error.
+ */
+void *mmap (void *p_addr, size_t len, int prot, int flags, int fd, off_t offset,
+            void **pp_winmap);
+
+/*
+ * munmap
+ *
+ * Parameters:
+ *   void *p_addr    : Startaddress of mapping created with mmap
+ *   size_t len      : Lenght of mapping to be unmapped. Unsupported. The whole
+ *                     mapping will always be unmapped.
+ *   void **p_winmap : Pointer to internal data received when mmap was called.
+ *
+ * Returns:
+ *   0 on success or -1 on error.
+ */
+int munmap (void *p_addr, size_t len, void **pp_winmap);
+
+#endif /* hivex_mmap_h */

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]