source: rtems/cpukit/libfs/src/dosfs/msdos_init.c @ 183af89

4.115
Last change on this file since 183af89 was 3b7c123, checked in by Sebastian Huber <sebastian.huber@…>, on 03/13/12 at 10:33:51

Filesystem: Reference counting for locations

o A new data structure rtems_filesystem_global_location_t was

introduced to be used for

o the mount point location in the mount table entry,
o the file system root location in the mount table entry,
o the root directory location in the user environment, and
o the current directory location in the user environment.

During the path evaluation global start locations are obtained to
ensure that the current file system instance will be not unmounted in
the meantime.

o The user environment uses now reference counting and is protected

from concurrent access.

o The path evaluation process was completely rewritten and simplified.

The IMFS, RFS, NFS, and DOSFS use now a generic path evaluation
method. Recursive calls in the path evaluation have been replaced
with iteration to avoid stack overflows. Only the evaluation of
symbolic links is recursive. No dynamic memory allocations and
intermediate buffers are used in the high level path evaluation. No
global locks are held during the file system instance specific path
evaluation process.

o Recursive symbolic link evaluation is now limited by

RTEMS_FILESYSTEM_SYMLOOP_MAX. Applications can retrieve this value
via sysconf().

o The device file system (devFS) uses now no global variables and

allocation from the workspace. Node names are allocated from the
heap.

o The upper layer lseek() performs now some parameter checks.
o The upper layer ftruncate() performs now some parameter checks.
o unmask() is now restricted to the RWX flags and protected from

concurrent access.

o The fchmod_h and rmnod_h file system node handlers are now a file

system operation.

o The unlink_h operation has been removed. All nodes are now destroyed

with the rmnod_h operation.

o New lock_h, unlock_h, clonenod_h, and are_nodes_equal_h file system

operations.

o The path evaluation and file system operations are now protected by

per file system instance lock and unlock operations.

o Fix and test file descriptor duplicate in fcntl().
o New test fstests/fsnofs01.

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