1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
6 #ifndef UDS_CHAPTER_INDEX_H
7 #define UDS_CHAPTER_INDEX_H
9 #include <linux/limits.h>
11 #include "delta-index.h"
15 * A chapter index for an open chapter is a mutable structure that tracks all the records that have
16 * been added to the chapter. A chapter index for a closed chapter is similar except that it is
17 * immutable because the contents of a closed chapter can never change, and the immutable structure
18 * is more efficient. Both types of chapter index are implemented with a delta index.
21 /* The value returned when no entry is found in the chapter index. */
22 #define NO_CHAPTER_INDEX_ENTRY U16_MAX
24 struct open_chapter_index
{
25 const struct index_geometry
*geometry
;
26 struct delta_index delta_index
;
27 u64 virtual_chapter_number
;
32 int __must_check
uds_make_open_chapter_index(struct open_chapter_index
**chapter_index
,
33 const struct index_geometry
*geometry
,
36 void uds_free_open_chapter_index(struct open_chapter_index
*chapter_index
);
38 void uds_empty_open_chapter_index(struct open_chapter_index
*chapter_index
,
39 u64 virtual_chapter_number
);
41 int __must_check
uds_put_open_chapter_index_record(struct open_chapter_index
*chapter_index
,
42 const struct uds_record_name
*name
,
45 int __must_check
uds_pack_open_chapter_index_page(struct open_chapter_index
*chapter_index
,
46 u8
*memory
, u32 first_list
,
47 bool last_page
, u32
*lists_packed
);
49 int __must_check
uds_initialize_chapter_index_page(struct delta_index_page
*index_page
,
50 const struct index_geometry
*geometry
,
51 u8
*page_buffer
, u64 volume_nonce
);
53 int __must_check
uds_validate_chapter_index_page(const struct delta_index_page
*index_page
,
54 const struct index_geometry
*geometry
);
56 int __must_check
uds_search_chapter_index_page(struct delta_index_page
*index_page
,
57 const struct index_geometry
*geometry
,
58 const struct uds_record_name
*name
,
59 u16
*record_page_ptr
);
61 #endif /* UDS_CHAPTER_INDEX_H */