Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/bfd/bfdio.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by monamour, Thu Dec 4 05:12:56 2008 UTC revision 21 by monamour, Mon Jul 27 20:34:36 2009 UTC
# Line 102  real_fopen (const char *filename, const Line 102  real_fopen (const char *filename, const
102      }      }
103    else    else
104      {      {
105        /* Attribute found - rebuild modes.  */        /* Attributes found.  Split.  */
106        size_t modes_len = vms_attr - modes;        size_t modes_len = strlen (modes) + 1;
107          char attrs[modes_len + 1];
108        BFD_ASSERT (modes_len < sizeof (vms_modes));        char *at[3];
109        memcpy (vms_modes, modes, modes_len);        int i;
110        vms_modes[modes_len] = 0;  
111        return close_on_exec (fopen (filename, vms_modes, vms_attr + 1));        memcpy (attrs, modes, modes_len);
112          at[0] = attrs;
113          for (i = 0; i < 2; i++)
114            {
115              at[i + 1] = strchr (at[i], ',');
116              BFD_ASSERT (at[i + 1] != NULL);
117              *(at[i + 1]++) = 0; /* Replace ',' with a nul, and skip it.  */
118            }
119          return close_on_exec (fopen (filename, at[0], at[1], at[2]));
120      }      }
121  #else /* !VMS */  #else /* !VMS */
122  #if defined (HAVE_FOPEN64)  #if defined (HAVE_FOPEN64)
# Line 150  DESCRIPTION Line 158  DESCRIPTION
158  .  int (*bclose) (struct bfd *abfd);  .  int (*bclose) (struct bfd *abfd);
159  .  int (*bflush) (struct bfd *abfd);  .  int (*bflush) (struct bfd *abfd);
160  .  int (*bstat) (struct bfd *abfd, struct stat *sb);  .  int (*bstat) (struct bfd *abfd, struct stat *sb);
161    .  {* Just like mmap: (void*)-1 on failure, mmapped address on success.  *}
162    .  void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
163    .                  int prot, int flags, file_ptr offset);
164  .};  .};
165    
166  */  */
# Line 227  bfd_bwrite (const void *ptr, bfd_size_ty Line 238  bfd_bwrite (const void *ptr, bfd_size_ty
238                    bim->size = 0;                    bim->size = 0;
239                    return 0;                    return 0;
240                  }                  }
241                  if (newsize > bim->size)
242                    memset (bim->buffer + bim->size, 0, newsize - bim->size);
243              }              }
244          }          }
245        memcpy (bim->buffer + abfd->where, ptr, (size_t) size);        memcpy (bim->buffer + abfd->where, ptr, (size_t) size);
# Line 334  bfd_seek (bfd *abfd, file_ptr position, Line 347  bfd_seek (bfd *abfd, file_ptr position,
347    
348        if (abfd->where > bim->size)        if (abfd->where > bim->size)
349          {          {
350            if ((abfd->direction == write_direction) ||            if (abfd->direction == write_direction
351                (abfd->direction == both_direction))                || abfd->direction == both_direction)
352              {              {
353                bfd_size_type newsize, oldsize;                bfd_size_type newsize, oldsize;
354    
# Line 351  bfd_seek (bfd *abfd, file_ptr position, Line 364  bfd_seek (bfd *abfd, file_ptr position,
364                        bim->size = 0;                        bim->size = 0;
365                        return -1;                        return -1;
366                      }                      }
367                      memset (bim->buffer + oldsize, 0, newsize - oldsize);
368                  }                  }
369              }              }
370            else            else
# Line 500  bfd_get_size (bfd *abfd) Line 514  bfd_get_size (bfd *abfd)
514    
515    return buf.st_size;    return buf.st_size;
516  }  }
517    
518    
519    /*
520    FUNCTION
521            bfd_mmap
522    
523    SYNOPSIS
524            void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
525                            int prot, int flags, file_ptr offset);
526    
527    DESCRIPTION
528            Return mmap()ed region of the file, if possible and implemented.
529    
530    */
531    
532    void *
533    bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
534              int prot, int flags, file_ptr offset)
535    {
536      void *ret = (void *)-1;
537      if ((abfd->flags & BFD_IN_MEMORY) != 0)
538        return ret;
539    
540      if (abfd->iovec == NULL)
541        return ret;
542    
543      return abfd->iovec->bmmap (abfd, addr, len, prot, flags, offset);
544    }

Legend:
Removed from v.20  
changed lines
  Added in v.21

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26