Changeset 83a4cbb in rtems


Ignore:
Timestamp:
May 23, 2013, 1:48:54 PM (7 years ago)
Author:
Ralf Kirchner <ralf.kirchner@…>
Branches:
4.11, master
Children:
52f3aa0
Parents:
2ee8b15
git-author:
Ralf Kirchner <ralf.kirchner@…> (05/23/13 13:48:54)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/03/13 15:28:41)
Message:

dosfs: UTF-8 Support: Multibyte conversions

Add optional conversion methods for multibyte strings. With these
conversions which make use of iconv and utf8proc it becomes possible to
use strings from any language (Czech, Chinese, Arabian, Hebrew, Corean,
...) for file names and directory names.

NOTE: Iconv support must be activated during the build of the tool chain
for these conversion methods (options --enable-newlib-iconv
--enable-newlib-iconv-encodings=[ENCODINGS_YOU_WANT]). Alternatively
you can provide your own conversion methods.

Location:
cpukit/libfs
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/Makefile.am

    r2ee8b15 r83a4cbb  
    8383    src/dosfs/msdos_rmnod.c src/dosfs/msdos_statvfs.c \
    8484    src/dosfs/msdos_conv_default.c \
     85    src/dosfs/msdos_conv_utf8.c \
    8586    src/dosfs/msdos_conv.c src/dosfs/msdos.h src/dosfs/msdos_format.c \
    8687    src/dosfs/dosfs.h src/dosfs/msdos_rename.c
  • cpukit/libfs/src/dosfs/dosfs.h

    r2ee8b15 r83a4cbb  
    207207   * @brief Converter implementation for new filesystem instance.
    208208   *
    209    * @see rtems_dosfs_create_default_converter().
     209   * @see rtems_dosfs_create_default_converter() and
     210   * rtems_dosfs_create_utf8_converter().
    210211   */
    211212  rtems_dosfs_convert_control *converter;
     
    221222 */
    222223rtems_dosfs_convert_control *rtems_dosfs_create_default_converter(void);
     224
     225/**
     226 * @brief Allocates and initializes a UTF-8 converter.
     227 *
     228 * @param[in] codepage The iconv() identification string for the used codepage.
     229 *
     230 * @retval NULL Something failed.
     231 * @retval other Pointer to initialized converter.
     232 *
     233 * @see rtems_dosfs_mount_options and mount().
     234 */
     235rtems_dosfs_convert_control *rtems_dosfs_create_utf8_converter(
     236  const char *codepage
     237);
    223238
    224239#define MSDOS_FMT_INFO_LEVEL_NONE   (0)
  • cpukit/libfs/src/dosfs/msdos_misc.c

    r2ee8b15 r83a4cbb  
    4242
    4343#include <stdio.h>
     44
     45#define MSDOS_LFN_ENTRY_SIZE \
     46  (MSDOS_LFN_LEN_PER_ENTRY * MSDOS_NAME_LFN_BYTES_PER_CHAR)
     47
     48#define MSDOS_LFN_ENTRY_SIZE_UTF8 \
     49  ((MSDOS_LFN_LEN_PER_ENTRY + 1 ) * MSDOS_NAME_LFN_BYTES_PER_CHAR \
     50    * MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR)
    4451
    4552/*
     
    10201027    ssize_t chars_in_entry;
    10211028
    1022     if (buf_size >= MSDOS_LFN_LEN_PER_ENTRY * MSDOS_NAME_LFN_BYTES_PER_CHAR) {
     1029    if (buf_size >= MSDOS_LFN_ENTRY_SIZE) {
    10231030        memcpy (&entry_string_buf[0],  &entry[1],  10 );
    10241031        memcpy (&entry_string_buf[5],  &entry[14], 12 );
     
    11961203  ssize_t      size_remaining = filename_size_remaining;
    11971204  int          eno            = 0;
    1198   uint8_t      entry_normalized[( MSDOS_LFN_LEN_PER_ENTRY + 1 ) * MSDOS_NAME_LFN_BYTES_PER_CHAR * MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR];
     1205  uint8_t      entry_normalized[MSDOS_LFN_ENTRY_SIZE_UTF8];
    11991206  size_t       bytes_in_entry_normalized = sizeof ( entry_normalized );
    12001207
     
    12641271    uint32_t          entries_per_block = bts2rd / MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE;
    12651272    int               lfn_entry         = 0;
    1266     uint8_t           entry_utf8_normalized[(MSDOS_LFN_LEN_PER_ENTRY + 1 ) * MSDOS_NAME_LFN_BYTES_PER_CHAR * MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR/*MSDOS_ENTRY_LFN_UTF8_BYTES*/];
     1273    uint8_t           entry_utf8_normalized[MSDOS_LFN_ENTRY_SIZE_UTF8];
    12671274    size_t            bytes_in_entry;
    12681275    bool              filename_matched  = false;
     
    18011808
    18021809            p = entry + 1;
    1803             n = name_converted + (fat_entries - lfn_entry) * MSDOS_LFN_LEN_PER_ENTRY * MSDOS_NAME_LFN_BYTES_PER_CHAR;
     1810            n = name_converted + (fat_entries - lfn_entry) * MSDOS_LFN_ENTRY_SIZE;
    18041811
    18051812#if MSDOS_FIND_PRINT
     
    19201927                buffer_size);
    19211928            if (name_len_for_save > 0) {
    1922                 fat_entries = (name_len_for_save -1
    1923                                + (MSDOS_LFN_LEN_PER_ENTRY * MSDOS_NAME_LFN_BYTES_PER_CHAR)) / (MSDOS_LFN_LEN_PER_ENTRY * MSDOS_NAME_LFN_BYTES_PER_CHAR);
     1929                fat_entries = (name_len_for_save + MSDOS_LFN_ENTRY_SIZE - 1)
     1930                    / MSDOS_LFN_ENTRY_SIZE;
    19241931                name_len_for_compare = msdos_filename_utf8_to_long_name_for_compare (
    19251932                  converter,
     
    19851992                  buffer_size);
    19861993              if (name_len_for_save > 0) {
    1987                 fat_entries = (name_len_for_save -1
    1988                                + (MSDOS_LFN_LEN_PER_ENTRY * MSDOS_NAME_LFN_BYTES_PER_CHAR)) / (MSDOS_LFN_LEN_PER_ENTRY * MSDOS_NAME_LFN_BYTES_PER_CHAR);
    1989 
     1994                  fat_entries = (name_len_for_save + MSDOS_LFN_ENTRY_SIZE - 1)
     1995                    / MSDOS_LFN_ENTRY_SIZE;
    19901996              }
    19911997              else
Note: See TracChangeset for help on using the changeset viewer.