62 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright 2023 Red Hat4 */5 6#ifndef UDS_CHAPTER_INDEX_H7#define UDS_CHAPTER_INDEX_H8 9#include <linux/limits.h>10 11#include "delta-index.h"12#include "geometry.h"13 14/*15 * A chapter index for an open chapter is a mutable structure that tracks all the records that have16 * been added to the chapter. A chapter index for a closed chapter is similar except that it is17 * immutable because the contents of a closed chapter can never change, and the immutable structure18 * is more efficient. Both types of chapter index are implemented with a delta index.19 */20 21/* The value returned when no entry is found in the chapter index. */22#define NO_CHAPTER_INDEX_ENTRY U16_MAX23 24struct open_chapter_index {25 const struct index_geometry *geometry;26 struct delta_index delta_index;27 u64 virtual_chapter_number;28 u64 volume_nonce;29 size_t memory_size;30};31 32int __must_check uds_make_open_chapter_index(struct open_chapter_index **chapter_index,33 const struct index_geometry *geometry,34 u64 volume_nonce);35 36void uds_free_open_chapter_index(struct open_chapter_index *chapter_index);37 38void uds_empty_open_chapter_index(struct open_chapter_index *chapter_index,39 u64 virtual_chapter_number);40 41int __must_check uds_put_open_chapter_index_record(struct open_chapter_index *chapter_index,42 const struct uds_record_name *name,43 u32 page_number);44 45int __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);48 49int __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);52 53int __must_check uds_validate_chapter_index_page(const struct delta_index_page *index_page,54 const struct index_geometry *geometry);55 56int __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);60 61#endif /* UDS_CHAPTER_INDEX_H */62