Port fix: Windows does not allow read-only mappings > file's size
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 22 Aug 2017 18:35:13 +0000 (14:35 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 29 Aug 2017 18:31:25 +0000 (14:31 -0400)
Reported-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/compat/mman-internal.h
plugins/ctf/fs-src/data-stream-file.c
plugins/ctf/fs-src/data-stream-file.h

index 5e4ac9231cb7f5ae7c7e5adbfa55edc6bcd7f6ab..fdbfd2cf0844cc22f256d07a296be034b86d9379 100644 (file)
 #define MAP_ANON       MAP_ANONYMOUS
 #define MAP_FAILED     ((void *) -1)
 
+/*
+ * Note that some platforms (e.g. Windows) do not allow read-only
+ * mappings to exceed the file's size (even within a page).
+ */
 void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
        off_t offset);
 
index 76ea9ad502939758176908b41e15c09a54650901..bae0bd14bdda1eca1a9849500c582412944c7b87 100644 (file)
@@ -92,6 +92,11 @@ enum bt_ctf_notif_iter_medium_status ds_file_mmap_next(
                        goto error;
                }
 
+               /*
+                * mmap_valid_len is guaranteed to be page-aligned except on the
+                * last mapping where it may not be possible (since the file's
+                * size itself may not be a page multiple).
+                */
                ds_file->mmap_offset += ds_file->mmap_valid_len;
                ds_file->request_offset = 0;
        }
index 8b2d7247fb91797ee3b759a567916cbb698c4cc7..56397dff46d31c351be035119ad14967706b9049 100644 (file)
@@ -99,7 +99,10 @@ struct ctf_fs_ds_file {
 
        void *mmap_addr;
 
-       /* Max length of chunk to mmap() when updating the current mapping. */
+       /*
+        * Max length of chunk to mmap() when updating the current mapping.
+        * This value must be page-aligned.
+        */
        size_t mmap_max_len;
 
        /* Length of the current mapping. */
This page took 0.025991 seconds and 4 git commands to generate.