Fix truncation of newly created map files.
authorVlad Brezae <brezaevlad@gmail.com>
Thu, 15 Jan 2015 01:56:25 +0000 (17:56 -0800)
committerVlad Brezae <brezaevlad@gmail.com>
Mon, 26 Jan 2015 23:06:53 +0000 (15:06 -0800)
File truncation could skip due to the fact that st_size field is only initialized for already existing files.

mono/metadata/file-mmap-posix.c

index c7836c7e66e3de4dddeeb994739e74f0e983b852..be9f740b8572df63433e40064e5a804896784f28 100644 (file)
@@ -280,7 +280,7 @@ open_file_map (MonoString *path, int input_fd, int mode, gint64 *capacity, int a
                goto done;
        }
 
-       if (*capacity > buf.st_size) {
+       if (result != 0 || *capacity > buf.st_size) {
                int unused G_GNUC_UNUSED = ftruncate (fd, (off_t)*capacity);
        }