title: write file by mmap, but when I use fread, the second time read error data
body: <p>When I use mmap and memcpy to write a file, and then I use fread to read the data.
  Below is my code, The problem is the first time i can read the <strong>a</strong>, but the second time i can't read a. 
  I guess there is something like seek position in fread function, when I use memcpy to write file, It may change the seek position.</p>
  
  <pre><code>#include &lt;dirent.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;pthread.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;sys/mman.h&gt;
  #include &lt;unistd.h&gt;
  
  int main()
  {
  
  
      int fd = open("./aa", O_CREAT | O_RDWR | O_TRUNC, 0644);
      FILE* f = fopen("./aa", "r");
      if (ftruncate(fd, 1024) &lt; 0) {
          printf("ftruncate error\n");
      }
      void* base;
      if ((base = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
          printf("mmap error\n");
      }
      char* file_ptr = (char *)base;
      char buffer[256];
      char scratch[256];
      buffer[0] = 'a';
      memcpy(file_ptr, buffer, 1);
      file_ptr += 1;
      size_t n = fread(scratch, 1, 1, f);
      printf("size n %zu\n", n); // this output size n 1
      printf("scratch %c\n", scratch[0]); // this output scratch a
      memcpy(file_ptr, buffer, 1);
      file_ptr += 1;
      n = fread(scratch, 1, 1, f);
      printf("size n %zu\n", n); // this output size n 1
      printf("scratch %c\n", scratch[0]); // but this output scratch  
      return 0;
  }
  </code></pre>
  
  <p>The output is :
  size n 1
  scratch a
  size n 1
  scratch</p>