Changeset 01c5b9d7 in rtems


Ignore:
Timestamp:
Mar 25, 2003, 5:01:56 PM (17 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Children:
bf71e25e
Parents:
2742cc3
Message:

2003-03-25 Thomas Doerfler <Thomas.Doerfler@…>

PR 367/filesystem

  • src/dosfs/Makefile.am, src/dosfs/fat.c, src/dosfs/fat.h, src/dosfs/fat_fat_operations.c, src/dosfs/fat_file.c, src/dosfs/msdos.h, src/dosfs/msdos_dir.c: Some bugs were still present in the DOSFS implementation:
    • FAT12 did not work properly on Big-Endian machines
    • Some synchronization and error handling problems were present
    • Some legal codings for EOC were not recognized
Location:
cpukit/libfs
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/ChangeLog

    r2742cc3 r01c5b9d7  
     12003-03-25      Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
     2
     3        PR 367/filesystem
     4        * src/dosfs/Makefile.am, src/dosfs/fat.c, src/dosfs/fat.h,
     5        src/dosfs/fat_fat_operations.c, src/dosfs/fat_file.c,
     6        src/dosfs/msdos.h, src/dosfs/msdos_dir.c: Some bugs were still
     7        present in the DOSFS implementation:
     8            - FAT12 did not work properly on Big-Endian machines
     9            - Some synchronization and error handling problems were present
     10            - Some legal codings for EOC were not recognized
     11
     12
    1132003-03-06      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    214
  • cpukit/libfs/src/dosfs/Makefile.am

    r2742cc3 r01c5b9d7  
    2828    $(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
    2929
     30PREINSTALL_FILES = $(PROJECT_INCLUDE) \
     31    $(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
     32
     33
    3034$(PROJECT_INCLUDE):
    3135        @$(mkinstalldirs) $@
  • cpukit/libfs/src/dosfs/fat.c

    r2742cc3 r01c5b9d7  
    261261
    262262    vol->spc = FAT_BR_SECTORS_PER_CLUSTER(boot_rec);
     263    /*
     264     * "sectors per cluster" of zero is invalid
     265     * (and would hang the following loop)
     266     */
     267    if (vol->spc == 0)
     268    {
     269        rtems_disk_release(vol->dd);
     270        set_errno_and_return_minus_one(EINVAL);
     271    }   
     272
    263273    for (vol->spc_log2 = 0, i = vol->spc; (i & 1) == 0;
    264274         i >>= 1, vol->spc_log2++);
     
    527537        set_errno_and_return_minus_one( EIO );
    528538
    529     while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
     539    while ((cur_cln & fs_info->vol.mask) < fs_info->vol.eoc_val)
    530540    {
    531541        ret = fat_cluster_write(mt_entry, cur_cln, buf);
  • cpukit/libfs/src/dosfs/fat.h

    r2742cc3 r01c5b9d7  
    8484#define FAT_UNDEFINED_VALUE     (unsigned32)0xFFFFFFFF
    8585
    86 #define FAT_FAT12_EOC          0x0FFF
    87 #define FAT_FAT16_EOC          0xFFFF
    88 #define FAT_FAT32_EOC          (unsigned32)0x0FFFFFFF
     86#define FAT_FAT12_EOC          0x0FF8
     87#define FAT_FAT16_EOC          0xFFF8
     88#define FAT_FAT32_EOC          (unsigned32)0x0FFFFFF8
    8989
    9090#define FAT_FAT12_FREE         0x0000
     
    307307            set_errno_and_return_minus_one(EIO);
    308308        fs_info->c.blk_num = blk;   
     309        fs_info->c.modified = 0;   
    309310        fs_info->c.state = FAT_CACHE_ACTUAL;   
    310311    }
     
    322323           
    323324            sc = rtems_bdbuf_release_modified(fs_info->c.buf);
     325            fs_info->c.state = FAT_CACHE_EMPTY;
     326            fs_info->c.modified = 0;   
    324327            if (sc != RTEMS_SUCCESSFUL)
    325328                set_errno_and_return_minus_one(EIO);
    326             fs_info->c.modified = 0;   
    327329           
    328330            if (sec_of_fat && !fs_info->vol.mirror)
     
    348350        {
    349351            sc = rtems_bdbuf_release(fs_info->c.buf);
     352            fs_info->c.state = FAT_CACHE_EMPTY;
    350353            if (sc != RTEMS_SUCCESSFUL)
    351354                set_errno_and_return_minus_one(EIO);
     
    359362            set_errno_and_return_minus_one(EIO);
    360363        fs_info->c.blk_num = blk;
     364        fs_info->c.state = FAT_CACHE_ACTUAL;
    361365    }
    362366    *buf = fs_info->c.buf;
  • cpukit/libfs/src/dosfs/fat_fat_operations.c

    r2742cc3 r01c5b9d7  
    7979        }   
    8080
    81         if ((next_cln & fs_info->vol.mask) == FAT_GENFAT_FREE)
     81        /*if ((next_cln & fs_info->vol.mask) == FAT_GENFAT_FREE)*/
     82        if (next_cln == FAT_GENFAT_FREE)
    8283        {
    8384            /*
     
    178179    unsigned32     freed_cls_cnt = 0;
    179180   
    180     while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
     181    while ((cur_cln & fs_info->vol.mask) < fs_info->vol.eoc_val)
    181182    {
    182183        rc = fat_get_fat_cluster(mt_entry, cur_cln, &next_cln);
     
    277278            else
    278279                *ret_val = (*ret_val) & FAT_FAT12_MASK;
    279 
    280280            break;
    281281
     
    343343            if ( FAT_CLUSTER_IS_ODD(cln) )
    344344            {
     345#if 0
     346              /*
     347               * do not perform endian conversion explicitely,
     348               * because following code will enforce little
     349               * endian format implicitly!
     350               */               
    345351                fat16_clv = CT_LE_W((((unsigned16)in_val) << FAT_FAT12_SHIFT));
    346 
     352#else
     353                fat16_clv = ((unsigned16)in_val) << FAT_FAT12_SHIFT;
     354#endif
    347355                *((unsigned8 *)(block0->buffer + ofs)) =
    348356                        (*((unsigned8 *)(block0->buffer + ofs))) & 0x0F;
     
    380388            else
    381389            {
     390#if 0
     391              /*
     392               * do not perform endian conversion explicitely,
     393               * because following code will enforce little
     394               * endian format implicitly!
     395               */               
    382396                fat16_clv = CT_LE_W((((unsigned16)in_val) & FAT_FAT12_MASK));
    383 
     397#else
     398                fat16_clv = ((unsigned16)in_val) & FAT_FAT12_MASK;
     399#endif
    384400                *((unsigned8 *)(block0->buffer + ofs)) &= 0x00;
    385401
  • cpukit/libfs/src/dosfs/fat_file.c

    r2742cc3 r01c5b9d7  
    771771       
    772772    /* for each cluster of the file ... */
    773     while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
     773    while ((cur_cln & fs_info->vol.mask) < fs_info->vol.eoc_val)
    774774    {
    775775        sec = fat_cluster_num_to_sector_num(mt_entry, cur_cln);
     
    831831    fat_fd->fat_file_size = 0;
    832832 
    833     while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
     833    while ((cur_cln & fs_info->vol.mask) < fs_info->vol.eoc_val)
    834834    {
    835835        save_cln = cur_cln;
  • cpukit/libfs/src/dosfs/msdos.h

    r2742cc3 r01c5b9d7  
    139139#define msdos_is_separator(_ch)          rtems_filesystem_is_separator(_ch)
    140140
    141 #define MSDOS_SHORT_NAME_LEN             11 /* 11 characters */
     141#define MSDOS_SHORT_BASE_LEN             8  /* 8 characters */
     142#define MSDOS_SHORT_EXT_LEN              3  /* 3 characters */
     143#define MSDOS_SHORT_NAME_LEN             (MSDOS_SHORT_BASE_LEN+\
     144                                          MSDOS_SHORT_EXT_LEN) /* 11 chars */
    142145#define MSDOS_NAME_MAX                   MSDOS_SHORT_NAME_LEN
    143146#define MSDOS_NAME_MAX_WITH_DOT          (MSDOS_NAME_MAX + 1)
  • cpukit/libfs/src/dosfs/msdos_dir.c

    r2742cc3 r01c5b9d7  
    103103    rtems_semaphore_release(fs_info->vol_sema);
    104104    return RC_OK;
     105}
     106
     107/*  msdos_format_dirent_with_dot --
     108 *      This routine convert a (short) MSDOS filename as present on disk
     109 *      (fixed 8+3 characters, filled with blanks, without separator dot)
     110 *      to a "normal" format, with between 0 and 8 name chars,
     111 *      a separating dot and up to 3 extension characters
     112 *   Rules to work:
     113 *      - copy any (0-8) "name" part characters that are non-blank
     114 *      - if an extension exists, append a dot
     115 *      - copy any (0-3) non-blank extension characters
     116 *      - append a '\0' (dont count it for the rturn code
     117 *
     118 * PARAMETERS:
     119 *     dst: pointer to destination char array (must be big enough)
     120 *     src: pointer to source characters
     121 *
     122 *
     123 * RETURNS:
     124 *     the number of bytes (without trailing '\0'(written to destination
     125 */
     126static ssize_t
     127msdos_format_dirent_with_dot(char *dst,const char *src)
     128{
     129  ssize_t len;
     130  int i;
     131  const char *src_tmp;
     132
     133  /*
     134   * find last non-blank character of base name
     135   */
     136  for ((i       =       MSDOS_SHORT_BASE_LEN  ,
     137        src_tmp = src + MSDOS_SHORT_BASE_LEN-1);
     138       ((i > 0) &&
     139        (*src_tmp == ' '));
     140       i--,src_tmp--)
     141    {};
     142  /*
     143   * copy base name to destination
     144   */
     145  src_tmp = src;
     146  len = i;
     147  while (i-- > 0) {
     148    *dst++ = *src_tmp++;
     149  }
     150  /*
     151   * find last non-blank character of extension
     152   */
     153  for ((i       =                            MSDOS_SHORT_EXT_LEN  ,
     154        src_tmp = src + MSDOS_SHORT_BASE_LEN+MSDOS_SHORT_EXT_LEN-1);
     155       ((i > 0) &&
     156        (*src_tmp == ' '));
     157       i--,src_tmp--)
     158    {};
     159  /*
     160   * extension is not empty
     161   */
     162  if (i > 0) {
     163    *dst++ = '.'; /* append dot */
     164    len += i + 1; /* extension + dot */
     165    src_tmp = src + MSDOS_SHORT_BASE_LEN;
     166    while (i-- > 0) {
     167      *dst++ = *src_tmp++;
     168      len++;
     169    }
     170  }
     171  *dst = '\0'; /* terminate string */
     172
     173  return len;
    105174}
    106175
     
    237306            tmp_dirent.d_reclen = sizeof(struct dirent);
    238307            tmp_dirent.d_ino = tmp_fat_fd->ino;
    239             tmp_dirent.d_namlen = MSDOS_SHORT_NAME_LEN;
    240             memcpy(tmp_dirent.d_name, MSDOS_DIR_NAME((fs_info->cl_buf + i)),
    241                    MSDOS_SHORT_NAME_LEN);
    242      
    243             /* d_name is null-terminated */
    244             tmp_dirent.d_name[MSDOS_SHORT_NAME_LEN] = 0;       
     308            /*
     309             * convert dir entry from fixed 8+3 format (without dot)
     310             * to 0..8 + 1dot + 0..3 format
     311             */
     312            tmp_dirent.d_namlen =
     313              msdos_format_dirent_with_dot(tmp_dirent.d_name,
     314                                         fs_info->cl_buf + i); /* src text */
    245315            memcpy(buffer + cmpltd, &tmp_dirent, sizeof(struct dirent));
    246316   
Note: See TracChangeset for help on using the changeset viewer.