stats: Add an informational message for mmap failures
authorGrant Erickson <marathon96@gmail.com>
Thu, 3 Mar 2011 18:44:57 +0000 (10:44 -0800)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 4 Mar 2011 10:46:18 +0000 (11:46 +0100)
Added an informational message when mmap fails with EINVAL in
stats_file_remap.

src/stats.c

index 30c0169..c4aa24e 100644 (file)
@@ -293,9 +293,10 @@ static int stats_file_remap(struct stats_file *file, size_t size)
        if (file->addr == NULL) {
                /*
                 * Though the buffer is not shared between processes, we still
-                * have to take MAP_SHARED because MAP_PRIVATE does not guarantee
-                * that writes will hit the file eventually. For more details
-                * please read the mmap man pages.
+                * have to take MAP_SHARED because MAP_PRIVATE does not
+                * guarantee that writes will hit the file without an explicit
+                * call to munmap or msync. For more details please read the
+                * mmap man pages.
                 */
                addr = mmap(NULL, new_size, PROT_READ | PROT_WRITE,
                                MAP_SHARED, file->fd, 0);
@@ -306,6 +307,11 @@ static int stats_file_remap(struct stats_file *file, size_t size)
        if (addr == MAP_FAILED) {
                connman_error("mmap error %s for %s",
                                strerror(errno), file->name);
+               if (errno == EINVAL) {
+                       connman_error("%s might be on a file system, such as "
+                                       "JFFS2, that does not allow shared "
+                                       "writable mappings.", file->name);
+               }
                return -errno;
        }