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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.