Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / tests / multiop.c
index 1152dc0..e906af6 100755 (executable)
@@ -187,6 +187,7 @@ int main(int argc, char **argv)
                 exit(1);
         }
 
                 exit(1);
         }
 
+        memset(&st, 0, sizeof(st));
         signal(SIGUSR1, usr1_handler);
 
         fname = argv[1];
         signal(SIGUSR1, usr1_handler);
 
         fname = argv[1];
@@ -265,6 +266,11 @@ int main(int argc, char **argv)
                         }
                         break;
                 case 'M':
                         }
                         break;
                 case 'M':
+                        if (st.st_size == 0) {
+                                fprintf(stderr, "mmap without preceeding stat, or on"
+                                        " zero length file.\n");
+                                exit(-1);
+                        }
                         mmap_len = st.st_size;
                         mmap_ptr = mmap(NULL, mmap_len, PROT_WRITE | PROT_READ,
                                         MAP_SHARED, fd, 0);
                         mmap_len = st.st_size;
                         mmap_ptr = mmap(NULL, mmap_len, PROT_WRITE | PROT_READ,
                                         MAP_SHARED, fd, 0);