Beispiel #1
0
static void test_create_file_system(void)
{
  int rv;

  rv = mkdir(mnt, S_IRWXU | S_IRWXG | S_IRWXO);
  rtems_test_assert(rv == 0);

  rv = rtems_rfs_format(rda, &rfs_config);
  rtems_test_assert(rv == 0);

  test_mount(true);

  rv = mknod(file, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  rtems_test_assert(rv == 0);

  rv = unmount(mnt);
  rtems_test_assert(rv == 0);
}
Beispiel #2
0
static void test(void)
{
  int rv;
  const void *data = NULL;

  rv = mkdir(mnt, S_IRWXU | S_IRWXG | S_IRWXO);
  rtems_test_assert(rv == 0);

  rv = rtems_rfs_format(device, &rfs_config);
  rtems_test_assert(rv == 0);

  rv = mount(
    device,
    mnt,
    RTEMS_FILESYSTEM_TYPE_RFS,
    RTEMS_FILESYSTEM_READ_WRITE,
    data
  );
  rtems_test_assert(rv == 0);

  rv = mknod(file, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  rtems_test_assert(rv == 0);

  rv = unmount(mnt);
  rtems_test_assert(rv == 0);

  test_file_system_with_handler(
    0,
    device,
    mnt,
    &test_rfs_handler,
    NULL
  );

  flashdisk_print_status(device);
}
Beispiel #3
0
static int init_ide()
{
  int rc = 0;

  char buf[512];

#ifndef COMBO_RTEMS
  rtems_status_code sc = RTEMS_SUCCESSFUL;
  size_t abort_index = 0;

#ifndef FAT_BENCH
  rtems_rfs_format_config rfs_config =
  {
     .block_size = 0,        /* The size of a block. */
     .group_blocks = 0,      /* The number of blocks in a group. */
     .group_inodes = 0,      /* The number of inodes in a group. */
     .inode_overhead = 0,    /* The percentage overhead allocated to inodes. */
     .max_name_length = 0,   /* The maximum length of a name. */
     .initialise_inodes = 0, /* Initialise the inode tables to all ones. */
     .verbose = 1            /* Is the format verbose.  */
  };
#endif
#endif

#ifdef COMBO_RTEMS
  printk(".. COMBO RTEMS ..\n");
#else
  printk(".. VANILLA RTEMS ..\n");
#endif

#ifdef FAT_BENCH
  printk(".. FAT benchmarking. Preparing/formatting partition\n");
#ifdef FORMAT_ENABLE
  rc = msdos_format("/dev/hda", NULL);
  if (rc != 0)
     printk(".. msdos_format(/dev/hda) failed: %s\n", strerror(errno));
  else
     printk(".. msdos_format is OK\n");
#endif
#else
  printk(".. RFS benchmarking. Preparing/formatting disk\n");
#if 0
  {
      int i;

#define PARTITION_COUNT 1

      rtems_bdpart_partition created_partitions[PARTITION_COUNT];

      static const rtems_bdpart_format format = {
         .mbr = {
            .type = RTEMS_BDPART_FORMAT_MBR,
            .disk_id = 0xdeadbeef,
            .dos_compatibility = false
         }
      };

      static const unsigned distribution[PARTITION_COUNT] = {
            1
      };

      memset(&created_partitions[0], 0, sizeof(created_partitions));

      for (i = 0; i < PARTITION_COUNT; ++i) {
          rtems_bdpart_to_partition_type(RTEMS_BDPART_MBR_EMPTY,
                                         created_partitions[i].type);
      }

      sc = rtems_bdpart_create("/dev/hda", &format,
                               &created_partitions[0],
                               &distribution[0],
                               PARTITION_COUNT);
      if (sc != 0)
          printk(".. rtems_bdpart_create(/dev/hda) failed: %s\n", strerror(errno));
      else
          printk(".. rtems_bdpart_create() is OK\n");

      sc = rtems_bdpart_write("/dev/hda", &format,
                              &created_partitions[0],
                              PARTITION_COUNT);
      if (sc != 0)
          printk(".. rtems_bdpart_write(/dev/hda) failed: %s\n", strerror(errno));
      else
          printk(".. rtems_bdpart_write() is OK\n");
  }
#endif

#ifdef FORMAT_ENABLE
  rc = rtems_rfs_format("/dev/hda", &rfs_config);
  if (rc != 0)
     printk(".. rfs_format(/dev/hda) failed: %s\n", strerror(errno));
  else
     printk(".. rfs_format is OK\n");
#endif

#endif /* FAT_BENCH */

  /* Create a mount point folder */
  rc = mkdir("/mnt", 0777);
  if(rc == -1)
  {
    printk("mkdir failed: %s\n", strerror(errno));
    exit(3);
  }

#ifdef COMBO_RTEMS
  /* Some checking needed for combo version only */
  rc = open(DEVNAME, O_RDWR);
  if(rc == -1)
  {
    printk("dev open failed: %s\n", strerror(errno));
    exit(1);
  }
  if(read(rc, buf, 512) != 512)
  {
    printk("dev read failed: %s\n", strerror(errno));
    exit(2);
  }
  close(rc);
  /* end of checking */

#if 0
  rc = rtems_ide_part_table_initialize(DEVNAME);
  if(rc != RTEMS_SUCCESSFUL)
  {
    printk("ide_part_table failed: %i\n", rc);
    exit(4);
  }
#endif

  rc = rtems_fsmount(&fs_table, 1, NULL);
  if(rc != 1)
  {
    printk("rtems_fsmount failed: %i\n", rc);
    exit(5);
  }
#else

#if 0
  sc = rtems_bdpart_register_from_disk("/dev/hda");
  if (sc != RTEMS_SUCCESSFUL) {
    printk("read partition table failed: %s\n", rtems_status_text(sc));
    exit(4);
  }
  else
  {
    printk(".. partition table of \"/dev/hda\" is OK\n");
  }
#endif

  rc = rtems_fsmount(fstab, sizeof(fstab) / sizeof(fstab [0]), &abort_index);
  if (rc != 0) {
    printk("mount failed: %s\n", strerror(errno));
    exit(5);
  }
  else
  {
    printk(".. %s() returns OK\n", __FUNCTION__);
  }

  if (abort_index)
      printf("mount aborted at %zu\n", abort_index);
#endif

  printf(".. CompactFlash logical disk has been mounted\n");
  return 0;
}

static int iozone_func(int argc, char** argv)
{
  return main_iozone(argc, argv);
}

static rtems_shell_cmd_t iozone_cmd = {
  "iozone",         /* name */
  "execute iozone", /* help text */
  "misc",           /* topic */
  iozone_func,      /* function */
  NULL,             /* alias */
  NULL              /* next */
};

/* initialize shell, network and telnet */
static void init_telnetd()
{
  rtems_status_code rc;
  rtems_termios_initialize();
  rtems_initialize_network();
  rtems_telnetd_initialize();
#ifdef COMBO_RTEMS
  rc = rtems_shell_init("SHll", 32000, 100, "/dev/tty1", 1, 0);
#else
  rc = rtems_shell_init("SHll", 32000, 100, "/dev/tty1", 1, 0, NULL);
#endif
  if(rc != RTEMS_SUCCESSFUL)
    printk("init shell on console failed\n");
}
Beispiel #4
0
/*---------------------------------------------------------------------------------------
    Name: OS_mkfs

    Purpose: Makes a RAM disk on the target with the RTEMS RFS file system
    
    Returns: OS_FS_ERR_INVALID_POINTER if devname is NULL
             OS_FS_ERR_DRIVE_NOT_CREATED if the OS calls to create the the drive failed
             OS_FS_ERR_DEVICE_NOT_FREE if the volume table is full
             OS_FS_SUCCESS on creating the disk

    Note: if address == 0, then a malloc will be called to create the disk
---------------------------------------------------------------------------------------*/
int32 OS_mkfs (char *address, char *devname,char * volname, uint32 blocksize, 
               uint32 numblocks)
{
    int                     i;
    uint32                  ReturnCode;
    rtems_rfs_format_config config;
    rtems_status_code       rtems_sc;

    /*
    ** Check parameters
    */
    if ( devname == NULL || volname == NULL )
    {
        return OS_FS_ERR_INVALID_POINTER;
    }
 
    /*
    ** Lock 
    */
    rtems_sc = rtems_semaphore_obtain (OS_VolumeTableSem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);

    /* find an open entry in the Volume Table */
    for (i = 0; i < NUM_TABLE_ENTRIES; i++)
    {
        if (OS_VolumeTable[i].FreeFlag == TRUE && OS_VolumeTable[i].IsMounted == FALSE
            && strcmp(OS_VolumeTable[i].DeviceName, devname) == 0)
            break;
    }

    if (i >= NUM_TABLE_ENTRIES)
    {
        rtems_sc = rtems_semaphore_release (OS_VolumeTableSem);
        return OS_FS_ERR_DEVICE_NOT_FREE;
    }

    /*
    ** Create the RAM disk and format it with the RFS file system.
    ** This requires RTEMS 4.10
    */    
    if (OS_VolumeTable[i].VolumeType == RAM_DISK)
    {
        /*
        ** Create the RAM disk device 
        */
        ReturnCode = rtems_setup_ramdisk (OS_VolumeTable[i].PhysDevName, (uint32 *)address, 
                                          blocksize, numblocks);
        if ( ReturnCode == OS_FS_ERROR )
        {
           ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED;
        }
        else
        {
           /*
           ** Format the RAM disk with the RFS file system
           */
           memset (&config, 0, sizeof(rtems_rfs_format_config));
           if ( rtems_rfs_format ( OS_VolumeTable[i].PhysDevName, &config ) < 0 )
           {
              printf("OSAL: Error: RFS format of %s failed: %s\n",
                     OS_VolumeTable[i].PhysDevName, strerror(errno));
              ReturnCode = OS_FS_ERR_DRIVE_NOT_CREATED;
           }
           else
           {
              /*
              ** Success
              */
              OS_VolumeTable[i].FreeFlag = FALSE;
              strcpy(OS_VolumeTable[i].VolumeName, volname);
              OS_VolumeTable[i].BlockSize = blocksize;
              ReturnCode = OS_FS_SUCCESS;
           }
        }
    }
    else if (OS_VolumeTable[i].VolumeType == FS_BASED)
    {
       /*
       ** FS_BASED will map the OSAL Volume to an already mounted host filesystem
       */
       
       /* 
       ** Enter the info in the table 
       */
       OS_VolumeTable[i].FreeFlag = FALSE;
       strcpy(OS_VolumeTable[i].VolumeName, volname);
       OS_VolumeTable[i].BlockSize = blocksize;

       ReturnCode = OS_FS_SUCCESS;
    }
    else
    {
        /* 
        ** The VolumeType is something else that is not supported right now 
        */
        ReturnCode = OS_FS_ERROR;
    }

    /*
    ** Unlock
    */
    rtems_sc = rtems_semaphore_release (OS_VolumeTableSem);

    return ReturnCode; 
       
} /* end OS_mkfs */
Beispiel #5
0
int
rtems_shell_rfs_format (int argc, char* argv[])
{
  rtems_rfs_format_config config;
  const char*             driver = NULL;
  int                     arg;

  memset (&config, 0, sizeof (rtems_rfs_format_config));

  for (arg = 1; arg < argc; arg++)
  {
    if (argv[arg][0] == '-')
    {
      switch (argv[arg][1])
      {
        case 'v':
          config.verbose = true;
          break;
          
        case 's':
          arg++;
          if (arg >= argc)
          {
            printf ("error: block size needs an argument\n");
            return 1;
          }
          config.block_size = strtoul (argv[arg], 0, 0);
          break;
        
        case 'b':
          arg++;
          if (arg >= argc)
          {
            printf ("error: group block count needs an argument\n");
            return 1;
          }
          config.group_blocks = strtoul (argv[arg], 0, 0);
          break;
          
        case 'i':
          arg++;
          if (arg >= argc)
          {
            printf ("error: group inode count needs an argument\n");
            return 1;
          }
          config.group_inodes = strtoul (argv[arg], 0, 0);
          break;

        case 'I':
          config.initialise_inodes = true;
          break;
          
        case 'o':
          arg++;
          if (arg >= argc)
          {
            printf ("error: inode percentage overhead needs an argument\n");
            return 1;
          }
          config.inode_overhead = strtoul (argv[arg], 0, 0);
          break;
          
        default:
          printf ("error: invalid option: %s\n", argv[arg]);
          return 1;
      }
    }
    else
    {
      if (!driver)
        driver = argv[arg];
      else
      {
        printf ("error: only one driver name allowed: %s\n", argv[arg]);
        return 1;
      }
    }
  }

  if (!driver) {
    printf ("error: no driver name provided\n");
    return 1;
  }

  if (rtems_rfs_format (driver, &config) < 0)
  {
    printf ("error: format of %s failed: %s\n",
            driver, strerror (errno));
    return 1;
  }
  
  return 0;
}