File indexing completed on 2025-05-11 08:24:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifdef HAVE_CONFIG_H
0025 #include "config.h"
0026 #endif
0027
0028 #include <rtems/libio_.h>
0029 #include <rtems/dosfs.h>
0030 #include "msdos.h"
0031
0032 static int msdos_clone_node_info(rtems_filesystem_location_info_t *loc)
0033 {
0034 fat_file_fd_t *fat_fd = loc->node_access;
0035
0036 return fat_file_reopen(fat_fd);
0037 }
0038
0039 static int msdos_utimens(
0040 const rtems_filesystem_location_info_t *loc,
0041 struct timespec times[2]
0042 )
0043 {
0044 fat_file_fd_t *fat_fd = loc->node_access;
0045
0046 if (times[0].tv_sec != times[1].tv_sec)
0047 rtems_set_errno_and_return_minus_one( ENOTSUP );
0048
0049 fat_file_set_mtime(fat_fd, times[1].tv_sec);
0050
0051 return RC_OK;
0052 }
0053
0054 const rtems_filesystem_operations_table msdos_ops = {
0055 .lock_h = msdos_lock,
0056 .unlock_h = msdos_unlock,
0057 .eval_path_h = msdos_eval_path,
0058 .link_h = rtems_filesystem_default_link,
0059 .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal,
0060 .mknod_h = msdos_mknod,
0061 .rmnod_h = msdos_rmnod,
0062 .fchmod_h = rtems_filesystem_default_fchmod,
0063 .chown_h = rtems_filesystem_default_chown,
0064 .clonenod_h = msdos_clone_node_info,
0065 .freenod_h = msdos_free_node_info,
0066 .mount_h = rtems_filesystem_default_mount,
0067 .unmount_h = rtems_filesystem_default_unmount,
0068 .fsunmount_me_h = msdos_shut_down,
0069 .utimens_h = msdos_utimens,
0070 .symlink_h = rtems_filesystem_default_symlink,
0071 .readlink_h = rtems_filesystem_default_readlink,
0072 .rename_h = msdos_rename,
0073 .statvfs_h = msdos_statvfs
0074 };
0075
0076 void msdos_lock(const rtems_filesystem_mount_table_entry_t *mt_entry)
0077 {
0078 msdos_fs_lock(mt_entry->fs_info);
0079 }
0080
0081 void msdos_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry)
0082 {
0083 msdos_fs_unlock(mt_entry->fs_info);
0084 }
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 int rtems_dosfs_initialize(
0098 rtems_filesystem_mount_table_entry_t *mt_entry,
0099 const void *data
0100 )
0101 {
0102 int rc = 0;
0103 const rtems_dosfs_mount_options *mount_options = data;
0104 rtems_dosfs_convert_control *converter;
0105 bool converter_created = false;
0106
0107
0108 if (mount_options == NULL || mount_options->converter == NULL) {
0109 converter = rtems_dosfs_create_default_converter();
0110 converter_created = true;
0111 } else {
0112 converter = mount_options->converter;
0113 }
0114
0115 if (converter != NULL) {
0116 rc = msdos_initialize_support(mt_entry,
0117 &msdos_ops,
0118 &msdos_file_handlers,
0119 &msdos_dir_handlers,
0120 converter);
0121 if (rc != 0 && converter_created) {
0122 (*converter->handler->destroy)(converter);
0123 }
0124 } else {
0125 errno = ENOMEM;
0126 rc = -1;
0127 }
0128
0129 return rc;
0130 }