Changeset 624867b in rtems


Ignore:
Timestamp:
Feb 8, 2005, 5:12:54 PM (16 years ago)
Author:
Eric Norum <WENorum@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
46f507f
Parents:
babf575
Message:

Add copy-on-write semantics to rtems_tarfs_load().

Location:
cpukit
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rbabf575 r624867b  
     12005-02-09      Eric Norum <norum@aps.anl.gov>
     2
     3        * libfs/Makefile.am, libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c,
     4        libfs/src/imfs/imfs_fchmod.c, libfs/src/imfs/imfs_handlers_memfile.c,
     5        libfs/src/imfs/imfs_init.c, libfs/src/imfs/imfs_initsupp.c,
     6        libfs/src/imfs/imfs_load_tar.c, libfs/src/imfs/linearfile.c,
     7        libfs/src/imfs/memfile.c, libfs/src/imfs/miniimfs_init.c: Add
     8        'copy-on-write' semantics to rtems_tarfs_load().
     9
    1102005-02-08      Ralf Corsepius <ralf.corsepius@rtems.org>
    211
  • cpukit/libfs/Makefile.am

    rbabf575 r624867b  
    2222    src/imfs/imfs_unlink.c src/imfs/imfs_unmount.c src/imfs/imfs_utime.c \
    2323    src/imfs/imfs_ntype.c src/imfs/imfs_stat.c src/imfs/imfs_getchild.c \
    24     src/imfs/memfile.c src/imfs/linearfile.c src/imfs/deviceio.c \
     24    src/imfs/memfile.c src/imfs/deviceio.c \
    2525    src/imfs/imfs_handlers_device.c src/imfs/imfs_handlers_directory.c \
    2626    src/imfs/imfs_handlers_link.c src/imfs/imfs_handlers_memfile.c \
  • cpukit/libfs/src/imfs/imfs.h

    rbabf575 r624867b  
    203203typedef struct {
    204204  ino_t                             ino_count;
    205   rtems_filesystem_file_handlers_r *linearfile_handlers;
    206205  rtems_filesystem_file_handlers_r *memfile_handlers;
    207206  rtems_filesystem_file_handlers_r *directory_handlers;
     
    238237extern rtems_filesystem_file_handlers_r       IMFS_device_handlers;
    239238extern rtems_filesystem_file_handlers_r       IMFS_link_handlers;
    240 extern rtems_filesystem_file_handlers_r       IMFS_linearfile_handlers;
    241239extern rtems_filesystem_file_handlers_r       IMFS_memfile_handlers;
    242240extern rtems_filesystem_operations_table      IMFS_ops;
     
    259257   rtems_filesystem_mount_table_entry_t *mt_entry,
    260258   rtems_filesystem_operations_table    *op_table,
    261    rtems_filesystem_file_handlers_r     *linearfile_handlers,
    262259   rtems_filesystem_file_handlers_r     *memfile_handlers,
    263260   rtems_filesystem_file_handlers_r     *directory_handlers
     
    417414);
    418415
    419 int linearfile_read(
    420   rtems_libio_t *iop,             /* IN  */
    421   void          *buffer,          /* IN  */
    422   uint32_t       count            /* IN  */
    423 );
    424 
    425 int linearfile_lseek(
    426   rtems_libio_t        *iop,        /* IN  */
    427   off_t                 offset,     /* IN  */
    428   int                   whence      /* IN  */
    429 );
    430 
    431416int memfile_open(
    432417  rtems_libio_t *iop,             /* IN  */
  • cpukit/libfs/src/imfs/imfs_eval.c

    rbabf575 r624867b  
    5353      break;
    5454    case IMFS_LINEAR_FILE:
    55       loc->handlers = fs_info->linearfile_handlers;
     55      loc->handlers = fs_info->memfile_handlers;
    5656      break;
    5757    case IMFS_MEMORY_FILE:
  • cpukit/libfs/src/imfs/imfs_fchmod.c

    rbabf575 r624867b  
    5757    rtems_set_errno_and_return_minus_one( EPERM );
    5858
    59   /*
    60    * If we make a linear-file writeable, construct a block file
    61    * from it first.
    62    */
    63   if ( (jnode->type == IMFS_LINEAR_FILE) &&
    64        (mode & (S_IWUSR | S_IWGRP | S_IWOTH)) )
    65   {
    66     uint32_t   count = jnode->info.linearfile.size;
    67     const unsigned char *buffer = jnode->info.linearfile.direct;
    68 
    69     jnode->type = IMFS_MEMORY_FILE;
    70     jnode->info.file.size            = 0;
    71     jnode->info.file.indirect        = 0;
    72     jnode->info.file.doubly_indirect = 0;
    73     jnode->info.file.triply_indirect = 0;
    74     if (IMFS_memfile_write(jnode, 0, buffer, count) == -1)
    75        return(-1);
    76   }
    77 
    7859  jnode->st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
    7960  jnode->st_mode |= mode;
  • cpukit/libfs/src/imfs/imfs_handlers_memfile.c

    rbabf575 r624867b  
    2424 */
    2525
    26 rtems_filesystem_file_handlers_r IMFS_linearfile_handlers = {
    27   memfile_open,
    28   memfile_close,
    29   memfile_read,
    30   NULL,                /* write */
    31   memfile_ioctl,
    32   memfile_lseek,
    33   IMFS_stat,
    34   IMFS_fchmod,
    35   NULL,                /* ftruncate */
    36   NULL,                /* fpathconf */
    37   IMFS_fdatasync,      /* fsync */
    38   IMFS_fdatasync,
    39   IMFS_fcntl,
    40   memfile_rmnod
    41 };
    42 
    4326rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
    4427  memfile_open,
  • cpukit/libfs/src/imfs/imfs_init.c

    rbabf575 r624867b  
    6464     temp_mt_entry,
    6565     &IMFS_ops,
    66      &IMFS_linearfile_handlers,
    6766     &IMFS_memfile_handlers,
    6867     &IMFS_directory_handlers
  • cpukit/libfs/src/imfs/imfs_initsupp.c

    rbabf575 r624867b  
    3838  rtems_filesystem_mount_table_entry_t *temp_mt_entry,
    3939   rtems_filesystem_operations_table    *op_table,
    40    rtems_filesystem_file_handlers_r     *linearfile_handlers,
    4140   rtems_filesystem_file_handlers_r     *memfile_handlers,
    4241   rtems_filesystem_file_handlers_r     *directory_handlers
     
    7978
    8079  fs_info->ino_count             = 1;
    81   fs_info->linearfile_handlers   = linearfile_handlers;
    8280  fs_info->memfile_handlers      = memfile_handlers;
    8381  fs_info->directory_handlers    = directory_handlers;
  • cpukit/libfs/src/imfs/imfs_load_tar.c

    rbabf575 r624867b  
    2626#include <rtems/imfs.h>
    2727#include <rtems/untar.h>
     28#include <rtems/tar.h>
    2829
    2930/**************************************************************************
     
    142143      }
    143144      /******************************************************************
    144        * Create a LINEAR_FILE node if no user write permission.
     145       * Create a LINEAR_FILE node
    145146       *****************************************************************/
    146       else if ((linkflag == REGTYPE) &&
    147                ((file_mode & 0200) == 0000))
     147      else if (linkflag == REGTYPE)
    148148      {
    149149         const char  *name;
     
    153153         {
    154154            node = IMFS_create_node(&loc,
    155                                     IMFS_LINEAR_FILE, (char *)name,
    156                                     (S_IRUSR | S_IRGRP | S_IROTH) | S_IFREG,
    157                                     NULL);
     155                        IMFS_LINEAR_FILE, (char *)name,
     156                        (file_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG,
     157                        NULL);
    158158            node->info.linearfile.size   = file_size;
    159159            node->info.linearfile.direct = &tar_image[offset];
    160          }
    161 
    162          nblocks = (((file_size) + 511) & ~511) / 512;
    163          offset += 512 * nblocks;
    164       }
    165       /******************************************************************
    166        * Create a regular MEMORY_FILE if write permission exists.
    167        *****************************************************************/
    168       else if ((linkflag == REGTYPE) &&
    169                ((file_mode & 0200) == 0200))
    170       {
    171          int fd;
    172          int n, left, ptr;
    173 
    174          strcpy(full_filename, mountpoint);
    175          if (full_filename[strlen(full_filename)-1] != '/')
    176             strcat(full_filename, "/");
    177          strcat(full_filename, filename);
    178 
    179          fd = creat(full_filename, S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP);
    180          if (fd != -1)
    181          {
    182             left = file_size;
    183             ptr  = offset;
    184             while ((n = write(fd, &tar_image[ptr], left)) > 0)
    185             {
    186                left -= n;
    187                ptr += n;
    188             }
    189             close(fd);
    190160         }
    191161
  • cpukit/libfs/src/imfs/memfile.c

    rbabf575 r624867b  
    100100  the_jnode = iop->file_info;
    101101
     102  /*
     103   * Perform 'copy on write' for linear files
     104   */
     105  if ((iop->flags & (LIBIO_FLAGS_WRITE | LIBIO_FLAGS_APPEND))
     106   && (the_jnode->type == IMFS_LINEAR_FILE)) {
     107    uint32_t   count = the_jnode->info.linearfile.size;
     108    const unsigned char *buffer = the_jnode->info.linearfile.direct;
     109
     110    the_jnode->type = IMFS_MEMORY_FILE;
     111    the_jnode->info.file.size            = 0;
     112    the_jnode->info.file.indirect        = 0;
     113    the_jnode->info.file.doubly_indirect = 0;
     114    the_jnode->info.file.triply_indirect = 0;
     115    if ((count != 0)
     116     && (IMFS_memfile_write(the_jnode, 0, buffer, count) == -1))
     117        return -1;
     118  }
    102119  if (iop->flags & LIBIO_FLAGS_APPEND)
    103120    iop->offset = the_jnode->info.file.size;
  • cpukit/libfs/src/imfs/miniimfs_init.c

    rbabf575 r624867b  
    6464      temp_mt_entry,
    6565      &miniIMFS_ops,
    66       &rtems_filesystem_null_handlers,  /* for linearfiles */
    6766      &rtems_filesystem_null_handlers,  /* for memfiles */
    6867      &rtems_filesystem_null_handlers   /* for directories */
Note: See TracChangeset for help on using the changeset viewer.