title: fseek fails on open file pointer
body: <p>I'm having trouble with fseek. I have a file pointer that contains fetched HTTP data. I then let libmagic determine the mime type of the file and want to rewind afterwards:</p>
  
  <pre><code>char *mime_type (int fd)
  {
      char *mime;
      magic_t magic;
  
      magic = magic_open(MAGIC_MIME_TYPE);
      magic_load(magic, MAGIC_FILE_NAME);
      mime = (char*)magic_descriptor(magic, fd);
  
      magic_close(magic);
      return (mime);
  }
  
  int fetch_pull() {
      fetch_state = fopen("/tmp/curl_0", "r");
      if (fetch_state == NULL) {
        perror("fetch_pull(): Could not open file handle");
        return (1);
      }
      fd = fileno(fetch_state);
      mime = mime_type(fd);
      if (fseek(fetch_state, 0L, SEEK_SET) != 0) {
        perror("fetch_pull(): Could not rewind file handle");
        return (1);
      }
      if (mime != NULL &amp;&amp; strstr(mime, "text/") != NULL) {
        /* do things */
      } else if (mime != NULL &amp;&amp; strstr(mime, "image/") != NULL) {
        /* do other things */
      }
      return (0);
  }
  </code></pre>
  
  <p>This throws "fetch_pull(): Could not rewind file handle: Bad file descriptor". What is wrong?</p>