1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#ifndef __SFS_FLASH_FS_DBLOCK_H__
#define __SFS_FLASH_FS_DBLOCK_H__
#include <stddef.h>
#include <stdint.h>
#include <protocols/service/psa/packed-c/status.h>
#include "sfs_flash_fs_mblock.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief Compacts block data for the given logical block.
*
* \param[in,out] fs_ctx Filesystem context
* \param[in] lblock Logical data block to compact
* \param[in] free_size Available data size to compact
* \param[in] src_offset Offset in the current data block which points to
* the data position to reallocate
* \param[in] dst_offset Offset in the scratch block which points to the
* data position to store the data to be reallocated
* \param[in] size Number of bytes to be reallocated
*
* \return Returns error code as specified in \ref psa_status_t
*/
psa_status_t sfs_flash_fs_dblock_compact_block(
struct sfs_flash_fs_ctx_t *fs_ctx,
uint32_t lblock,
size_t free_size,
size_t src_offset,
size_t dst_offset,
size_t size);
/**
* \brief Reads the file content.
*
* \param[in,out] fs_ctx Filesystem context
* \param[in] file_meta File metadata
* \param[in] offset Offset in the file
* \param[in] size Size to be read
* \param[out] buf Buffer pointer to store the data
*
* \return Returns error code as specified in \ref psa_status_t
*/
psa_status_t sfs_flash_fs_dblock_read_file(
struct sfs_flash_fs_ctx_t *fs_ctx,
const struct sfs_file_meta_t *file_meta,
size_t offset,
size_t size,
uint8_t *buf);
/**
* \brief Writes scratch data block content with requested data and the rest of
* the data from the given logical block.
*
* \param[in,out] fs_ctx Filesystem context
* \param[in] block_meta Block metadata
* \param[in] file_meta File metadata
* \param[in] offset Offset in the scratch data block where to start
* the copy of the incoming data
* \param[in] size Size of the incoming data
* \param[in] data Pointer to data buffer to copy in the scratch data
* block
*
* \return Returns error code as specified in \ref psa_status_t
*/
psa_status_t sfs_flash_fs_dblock_write_file(
struct sfs_flash_fs_ctx_t *fs_ctx,
const struct sfs_block_meta_t *block_meta,
const struct sfs_file_meta_t *file_meta,
size_t offset,
size_t size,
const uint8_t *data);
#ifdef __cplusplus
}
#endif
#endif /* __SFS_FLASH_FS_DBLOCK_H__ */
|