source: rtems/cpukit/libfs/src/dosfs/msdos_init.c @ 3c96bee

4.115
Last change on this file since 3c96bee was d2e0bb3, checked in by Ralf Kirchner <ralf.kirchner@…>, on 05/22/13 at 10:16:18

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.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Init Routine for MSDOS
5 * @ingroup libfs
6 */
7
8/*
9 *  Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
10 *  Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
11 *
12 *  Modifications to support reference counting in the file system are
13 *  Copyright (c) 2012 embedded brains GmbH.
14 *
15 *  Modifications to support UTF-8 in the file system are
16 *  Copyright (c) 2013 embedded brains GmbH.
17 *
18 *  The license and distribution terms for this file may be
19 *  found in the file LICENSE in this distribution or at
20 *  http://www.rtems.com/license/LICENSE.
21 */
22
23#if HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <rtems/libio_.h>
28#include "dosfs.h"
29#include "msdos.h"
30
31static int msdos_clone_node_info(rtems_filesystem_location_info_t *loc)
32{
33    fat_file_fd_t *fat_fd = loc->node_access;
34
35    return fat_file_reopen(fat_fd);
36}
37
38const rtems_filesystem_operations_table  msdos_ops = {
39  .lock_h         =  msdos_lock,
40  .unlock_h       =  msdos_unlock,
41  .eval_path_h    =  msdos_eval_path,
42  .link_h         =  rtems_filesystem_default_link,
43  .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal,
44  .node_type_h    =  msdos_node_type,
45  .mknod_h        =  msdos_mknod,
46  .rmnod_h        =  msdos_rmnod,
47  .fchmod_h       =  rtems_filesystem_default_fchmod,
48  .chown_h        =  rtems_filesystem_default_chown,
49  .clonenod_h     =  msdos_clone_node_info,
50  .freenod_h      =  msdos_free_node_info,
51  .mount_h        =  rtems_filesystem_default_mount,
52  .fsmount_me_h   =  rtems_dosfs_initialize,
53  .unmount_h      =  rtems_filesystem_default_unmount,
54  .fsunmount_me_h =  msdos_shut_down,
55  .utime_h        =  rtems_filesystem_default_utime,
56  .symlink_h      =  rtems_filesystem_default_symlink,
57  .readlink_h     =  rtems_filesystem_default_readlink,
58  .rename_h       =  msdos_rename,
59  .statvfs_h      =  msdos_statvfs
60};
61
62void msdos_lock(const rtems_filesystem_mount_table_entry_t *mt_entry)
63{
64  msdos_fs_info_t *fs_info = mt_entry->fs_info;
65  rtems_status_code sc = rtems_semaphore_obtain(
66    fs_info->vol_sema,
67    RTEMS_WAIT,
68    RTEMS_NO_TIMEOUT
69  );
70  if (sc != RTEMS_SUCCESSFUL) {
71    rtems_fatal_error_occurred(0xdeadbeef);
72  }
73}
74
75void msdos_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry)
76{
77  msdos_fs_info_t *fs_info = mt_entry->fs_info;
78  rtems_status_code sc = rtems_semaphore_release(fs_info->vol_sema);
79  if (sc != RTEMS_SUCCESSFUL) {
80    rtems_fatal_error_occurred(0xdeadbeef);
81  }
82}
83
84/* msdos_initialize --
85 *     MSDOS filesystem initialization. Called when mounting an
86 *     MSDOS filesystem.
87 *
88 * PARAMETERS:
89 *     temp_mt_entry - mount table entry
90 *
91 * RETURNS:
92 *     RC_OK on success, or -1 if error occured (errno set apropriately).
93 *
94 */
95int rtems_dosfs_initialize(
96  rtems_filesystem_mount_table_entry_t *mt_entry,
97  const void                           *data
98)
99{
100    int                                rc = 0;
101    const rtems_dosfs_mount_options   *mount_options = data;
102    rtems_dosfs_convert_control       *converter;
103
104
105    if (mount_options == NULL || mount_options->converter == NULL) {
106        converter = rtems_dosfs_create_default_converter();
107    } else {
108        converter = mount_options->converter;
109    }
110
111    if (converter != NULL) {
112        rc = msdos_initialize_support(mt_entry,
113                                      &msdos_ops,
114                                      &msdos_file_handlers,
115                                      &msdos_dir_handlers,
116                                      converter);
117    } else {
118        errno = ENOMEM;
119        rc = -1;
120    }
121
122    return rc;
123}
Note: See TracBrowser for help on using the repository browser.