mikroSDK Reference Manual
fs_common.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
44#ifndef _FS_COMMON_H_
45#define _FS_COMMON_H_
46
47
48#define FILE_SYSTEM_VALIDATE_UNINITIALIZATION ((uint8_t)0)
49#define FILE_SYSTEM_VALIDATE_INITIALIZATION ((uint8_t)1)
50
51#define FILE_SYSTEM_OBJECT_NOT_FOUND FS_MAX_OBJECTS
52
53#define FILE_SYSTEM_VALIDATE_OBJECT(__obj__) (void *)(__obj__) ? FSS_OK : FSS_GENERAL_ERROR
54#define FILE_SYSTEM_VALIDATE_LOGICAL_DRIVE FILE_SYSTEM_VALIDATE_OBJECT
55#define FILE_SYSTEM_VALIDATE_PHYSICAL_DRIVE FILE_SYSTEM_VALIDATE_OBJECT
56#define FILE_SYSTEM_VALIDATE_FILE FILE_SYSTEM_VALIDATE_OBJECT
57#define FILE_SYSTEM_VALIDATE_DIRECTORY FILE_SYSTEM_VALIDATE_OBJECT
58
59#ifdef __cplusplus
60extern "C"{
61#endif
62
63typedef uint8_t file_system_validation_t;
64
74
75 fs_status_t (* format)(logical_drive_t * const ptr_this);
76 fs_status_t (* mount)(logical_drive_t * const ptr_this, physical_drive_t * const physical_drive);
77 fs_status_t (* unmount)(logical_drive_t * const ptr_this);
78 fs_status_t (* remove)(logical_drive_t * const ptr_this, const char * __generic_ptr path);
79 fs_status_t (* rename)(logical_drive_t * const ptr_this, const char * __generic_ptr old_path, const char * __generic_ptr new_path);
80 fs_status_t (* mkdir)(logical_drive_t * const ptr_this, const char * __generic_ptr path);
81 fs_status_t (* chdir)(logical_drive_t * const ptr_this, const char * __generic_ptr path); // TODO This function is diabled
82
83 fs_status_t (* f_open)(logical_drive_t * const ptr_this, fs_file_t file, const char * __generic_ptr path, int flags);
84 fs_status_t (* f_close)(logical_drive_t * const ptr_this, fs_file_t file);
85 fs_status_t (* f_read)(logical_drive_t * const ptr_this, fs_file_t file, void * buffer, uint32_t bttes_to_read);
86 fs_status_t (* f_write)(logical_drive_t * const ptr_this, fs_file_t file, void * buffer, uint32_t bytes_to_write);
87 fs_status_t (* f_sync)(logical_drive_t * const ptr_this, fs_file_t file);
88 fs_status_t (* f_seek)(logical_drive_t * const ptr_this, fs_file_t file, int32_t offset, fs_file_rw_pointer_t starting_position);
89 uint32_t (* f_tell)(logical_drive_t * const ptr_this, fs_file_t file);
90 fs_status_t (* f_rewind)(logical_drive_t * const ptr_this, fs_file_t file);
91 uint32_t (* f_size)(logical_drive_t * const ptr_this, fs_file_t file);
92 fs_status_t (* f_truncate)(logical_drive_t * const ptr_this, fs_file_t file, int length);
93
94 fs_status_t (* d_open)(logical_drive_t * const ptr_this, fs_dir_t dir, const char * __generic_ptr path);
95 fs_status_t (* d_close)(logical_drive_t * const ptr_this, fs_dir_t dir);
96 fs_status_t (* d_read)(logical_drive_t * const ptr_this, fs_dir_t dir, void * file_information);
97 fs_status_t (* d_rewind)(logical_drive_t * const ptr_this, fs_dir_t dir);
98};
99
100void file_system_initialize(logical_drive_t * ldrive_base);
101
102logical_drive_t * file_system_get_registred_volume(const uint8_t volume);
103fs_status_t file_system_get_drive_id(const char * __generic_ptr path, uint8_t * const drive_number);
104
105uint8_t file_system_check_object_registration(void * obj);
106fs_status_t file_system_validate_object_opening(void * obj);
107fs_status_t file_system_validate_object_closing(void * obj, uint8_t * found_object_index);
108void file_system_register_object(void * obj);
109void file_system_unregister_object(void * obj, uint8_t registred_object_index);
110
111#ifdef __cplusplus
112}
113#endif
114
115#endif // !_FS_COMMON_H_
fs_file_rw_pointer_t
: file_seek API Starting Offset
Definition file_system.h:188
void * fs_file_t
: File data specific to a particular file system.
Definition file_system.h:200
void * fs_dir_t
: Directory Data specific to a particular File System.
Definition file_system.h:209
int8_t fs_status_t
: File System API return value
Definition file_system.h:181
Logical Drive Base Data Structure.
Definition file_system.h:246
Logical Drive Vector Table.
Definition fs_common.h:73
Physical Drive Base Data Structure Reference.
Definition physical_drive.h:127