Changeset fae59c9 in rtems


Ignore:
Timestamp:
Sep 6, 2017, 8:12:06 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
34dda604
Parents:
731e68a3
git-author:
Sebastian Huber <sebastian.huber@…> (09/06/17 08:12:06)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/06/17 08:20:46)
Message:

dosfs: Support a cluster size of 64KiB

Close #3003.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/dosfs/fat.c

    r731e68a3 rfae59c9  
    567567         i >>= 1, vol->spc_log2++);
    568568
    569     /*
    570      * "bytes per cluster" value greater than 32K is invalid
    571      */
    572     if (vol->bps > (MS_BYTES_PER_CLUSTER_LIMIT >> vol->spc_log2))
     569    /* Sectors per cluster must be a power of two */
     570    if (vol->spc != UINT32_C(1) << vol->spc_log2)
    573571    {
    574572        close(vol->fd);
     
    576574    }
    577575
    578     vol->bpc = vol->bps << vol->spc_log2;
     576    vol->bpc = ((uint32_t) vol->bps) << vol->spc_log2;
    579577
    580578    for (vol->bpc_log2 = 0, i = vol->bpc; (i & 1) == 0;
  • cpukit/libfs/src/dosfs/fat.h

    r731e68a3 rfae59c9  
    275275#define FAT_TOTAL_FSINFO_SIZE               512
    276276
    277 #define MS_BYTES_PER_CLUSTER_LIMIT           0x8000     /* 32K */
     277#define MS_BYTES_PER_CLUSTER_LIMIT           0x10000    /* 64K */
    278278#define MS_BYTES_PER_CLUSTER_LIMIT_FAT12     0x1000     /*  4K */
    279279
     
    301301    uint8_t            spc;            /* sectors per cluster */
    302302    uint8_t            spc_log2;       /* log2 of spc */
    303     uint16_t           bpc;            /* bytes per cluster */
     303    uint32_t           bpc;            /* bytes per cluster */
    304304    uint8_t            bpc_log2;       /* log2 of bytes per cluster */
    305305    uint8_t            sectors_per_block;    /* sectors per bdbuf block */
    306     uint16_t           bytes_per_block;      /* number of bytes for the bduf block device handling */
     306    uint32_t           bytes_per_block;      /* number of bytes for the bduf block device handling */
    307307    uint8_t            bytes_per_block_log2; /* log2 of bytes_per_block */
    308308    uint8_t            fats;           /* number of FATs */
  • cpukit/libfs/src/dosfs/msdos_format.c

    r731e68a3 rfae59c9  
    317317  uint32_t fat_sectors_cnt;
    318318  /*
    319    * ensure, that maximum cluster size (32KByte) is not exceeded
     319   * ensure, that maximum cluster size (64KiB) is not exceeded
    320320   */
    321321  while (MS_BYTES_PER_CLUSTER_LIMIT / bytes_per_sector < sectors_per_cluster) {
     
    398398    ( MS_BYTES_PER_CLUSTER_LIMIT_FAT12 +1 ) / bytes_per_sector;
    399399  uint32_t ms_sectors_per_cluster_limit_FAT16 =
    400     ( MS_BYTES_PER_CLUSTER_LIMIT +1 ) / bytes_per_sector;
     400    ( 0x8000 +1 ) / bytes_per_sector;
    401401  uint8_t fattype = FAT_FAT32;
    402402
     
    428428   * must be power of 2
    429429   * must be smaller than or equal to 128
    430    * sectors_per_cluster*bytes_per_sector must not be bigger than 32K
     430   * sectors_per_cluster*bytes_per_sector must not be bigger than 64K
    431431   */
    432432  for ( onebit = 128; onebit >= 1; onebit = onebit >> 1 ) {
     
    434434      fmt_params->sectors_per_cluster = onebit;
    435435      if (   fmt_params->sectors_per_cluster
    436           <= 32768L / fmt_params->bytes_per_sector ) {
     436          <= MS_BYTES_PER_CLUSTER_LIMIT / fmt_params->bytes_per_sector ) {
    437437        /* value is small enough so this value is ok */
    438438        onebit = 1;
  • testsuites/fstests/fsdosfsformat01/init.c

    r731e68a3 rfae59c9  
    470470  rv = unlink( dev_name );
    471471  rtems_test_assert( rv == 0 );
     472
     473  /* FAT32 with cluster size of 64KiB */
     474
     475  sc = rtems_sparse_disk_create_and_register(
     476    dev_name,
     477    SECTOR_SIZE,
     478    1024,
     479    16777216, /* 8GiB */
     480    0
     481  );
     482  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
     483
     484  memset( &rqdata, 0, sizeof( rqdata ) );
     485  rqdata.sectors_per_cluster = 128;
     486  rqdata.quick_format = true;
     487  rv = msdos_format( dev_name, &rqdata );
     488  rtems_test_assert( rv == 0 );
     489
     490  test_disk_params(
     491    dev_name,
     492    mount_dir,
     493    SECTOR_SIZE,
     494    SECTOR_SIZE * rqdata.sectors_per_cluster,
     495    rqdata.sectors_per_cluster
     496  );
     497
     498  rv = unlink( dev_name );
     499  rtems_test_assert( rv == 0 );
    472500}
    473501
Note: See TracChangeset for help on using the changeset viewer.