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