summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/msdos.h
diff options
context:
space:
mode:
authorRalf Kirchner <ralf.kirchner@embedded-brains.de>2013-05-22 12:16:18 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-03 17:28:40 +0200
commitd2e0bb36e34f1fe45641f26b8b8d6ef615963854 (patch)
tree3975c03a1f0b0caff9d837ba1d989794f8537639 /cpukit/libfs/src/dosfs/msdos.h
parentbsp/lm3s69xx: Typos (diff)
downloadrtems-d2e0bb36e34f1fe45641f26b8b8d6ef615963854.tar.bz2
dosfs: UTF-8 Support: UI, backwards compatibility
User interface and backwards compatibility for UTF-8 support in the FAT file system. Purpose of UTF-8 support is to permit file names and directory names with characters from all kinds of languages (Czech, Chinese, Arabian, Hebrew, Korean, ...). This commit does not yet support multibyte characters. It only contains the user interface and the backwards compatibility.
Diffstat (limited to 'cpukit/libfs/src/dosfs/msdos.h')
-rw-r--r--cpukit/libfs/src/dosfs/msdos.h70
1 files changed, 66 insertions, 4 deletions
diff --git a/cpukit/libfs/src/dosfs/msdos.h b/cpukit/libfs/src/dosfs/msdos.h
index 78eda9b226..6da47cc5e2 100644
--- a/cpukit/libfs/src/dosfs/msdos.h
+++ b/cpukit/libfs/src/dosfs/msdos.h
@@ -10,6 +10,9 @@
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
+ * Modifications to support UTF-8 in the file system are
+ * Copyright (c) 2013 embedded brains GmbH.
+ *
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
@@ -20,6 +23,7 @@
#include <rtems.h>
#include <rtems/libio_.h>
+#include <rtems/dosfs.h>
#include "fat.h"
#include "fat_file.h"
@@ -67,6 +71,8 @@ typedef struct msdos_fs_info_s
* just placeholder
* for anything
*/
+
+ rtems_dosfs_convert_control *converter;
} msdos_fs_info_t;
/* a set of routines that handle the nodes which are directories */
@@ -183,6 +189,8 @@ typedef rtems_filesystem_node_types_t msdos_node_type_t;
/*
* Macros for names parsing and formatting
*/
+#define MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR 4
+#define MSDOS_NAME_MIN_UTF8_BYTES_PER_CHAR 1
#define MSDOS_SHORT_BASE_LEN 8 /* 8 characters */
#define MSDOS_SHORT_EXT_LEN 3 /* 3 characters */
@@ -190,9 +198,20 @@ typedef rtems_filesystem_node_types_t msdos_node_type_t;
MSDOS_SHORT_EXT_LEN) /* 11 chars */
#define MSDOS_NAME_MAX_LNF_LEN (255)
#define MSDOS_NAME_MAX MSDOS_SHORT_NAME_LEN
+#define MSDOS_NAME_MAX_UTF8_SFN_BYTES (MSDOS_NAME_MAX *\
+ MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR)
#define MSDOS_NAME_MAX_WITH_DOT (MSDOS_NAME_MAX + 1)
+#define MSDOS_SFN_MAX_WITH_DOT_UTF8_BYTES (MSDOS_NAME_MAX_WITH_DOT *\
+ MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR)
#define MSDOS_NAME_MAX_LFN_WITH_DOT (260)
+#define MSDOS_NAME_LFN_BYTES_PER_CHAR (2)
+#define MSDOS_NAME_MAX_LFN_BYTES (MSDOS_NAME_MAX_LFN_WITH_DOT *\
+ MSDOS_NAME_LFN_BYTES_PER_CHAR)
+#define MSDOS_NAME_MAX_UTF8_LFN_BYTES (MSDOS_NAME_MAX_LFN_WITH_DOT *\
+ MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR)
+#define MSDOS_ENTRY_LFN_UTF8_BYTES (MSDOS_LFN_LEN_PER_ENTRY *\
+ MSDOS_NAME_MAX_UTF8_BYTES_PER_CHAR)
extern const char *const MSDOS_DOT_NAME; /* ".", padded to MSDOS_NAME chars */
extern const char *const MSDOS_DOTDOT_NAME; /* ".", padded to MSDOS_NAME chars */
@@ -309,7 +328,8 @@ int msdos_initialize_support(
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
const rtems_filesystem_operations_table *op_table,
const rtems_filesystem_file_handlers_r *file_handlers,
- const rtems_filesystem_file_handlers_r *directory_handlers
+ const rtems_filesystem_file_handlers_r *directory_handlers,
+ rtems_dosfs_convert_control *converter
);
int msdos_file_close(rtems_libio_t *iop /* IN */);
@@ -387,10 +407,52 @@ int msdos_get_name_node(
int msdos_dir_info_remove(rtems_filesystem_location_info_t *pathloc);
-msdos_name_type_t msdos_long_to_short(const char *lfn, int lfn_len,
+ssize_t
+msdos_format_dirent_with_dot(char *dst,const char *src);
+
+msdos_name_type_t msdos_long_to_short(rtems_dosfs_convert_control *converter,
+ const char *lfn, int lfn_len,
char* sfn, int sfn_len);
-int msdos_filename_unix2dos(const char *un, int unlen, char *dn);
+ssize_t
+msdos_filename_utf8_to_short_name_for_compare (
+ rtems_dosfs_convert_control *converter,
+ const uint8_t *utf8_name,
+ const size_t utf8_name_size,
+ void *short_name,
+ const size_t short_name_size);
+
+ssize_t
+msdos_filename_utf8_to_short_name_for_save (
+ rtems_dosfs_convert_control *converter,
+ const uint8_t *utf8_name,
+ const size_t utf8_name_size,
+ void *short_name,
+ const size_t short_name_size);
+
+ssize_t
+msdos_filename_utf8_to_long_name_for_compare (
+ rtems_dosfs_convert_control *converter,
+ const uint8_t *utf8_name,
+ const size_t utf8_name_size,
+ uint8_t *long_name,
+ const size_t long_name_size);
+
+ssize_t
+msdos_filename_utf8_to_long_name_for_save (
+ rtems_dosfs_convert_control *converter,
+ const uint8_t *utf8_name,
+ const size_t utf8_name_size,
+ uint16_t *long_name,
+ const size_t long_name_size);
+
+ssize_t
+msdos_get_utf16_string_from_long_entry (
+ const char *entry,
+ uint16_t *entry_string_buf,
+ const size_t buf_size,
+ bool is_first_entry
+);
void msdos_date_unix2dos(
unsigned int tsp, uint16_t *ddp,
@@ -430,7 +492,7 @@ int msdos_find_name_in_fat_file(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
bool create_node,
- const char *name,
+ const uint8_t *name_utf8,
int name_len,
msdos_name_type_t name_type,
fat_dir_pos_t *dir_pos,