// SPDX-License-Identifier: GPL-2.0-only /* * This file is part of UBIFS. * * Copyright (C) 2006-2008 Nokia Corporation * * Authors: Adrian Hunter * Artem Bityutskiy (Битюцкий Артём) */ /* * This file implements the scan which is a general-purpose function for * determining what nodes are in an eraseblock. The scan is used to replay the * journal, to do garbage collection. for the TNC in-the-gaps method, and by * debugging functions. */ #include "ubifs.h" /** * scan_padding_bytes - scan for padding bytes. * @buf: buffer to scan * @len: length of buffer * * This function returns the number of padding bytes on success and * %SCANNED_GARBAGE on failure. */ static int scan_padding_bytes(void *buf, int len) { … } /** * ubifs_scan_a_node - scan for a node or padding. * @c: UBIFS file-system description object * @buf: buffer to scan * @len: length of buffer * @lnum: logical eraseblock number * @offs: offset within the logical eraseblock * @quiet: print no messages * * This function returns a scanning code to indicate what was scanned. */ int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum, int offs, int quiet) { … } /** * ubifs_start_scan - create LEB scanning information at start of scan. * @c: UBIFS file-system description object * @lnum: logical eraseblock number * @offs: offset to start at (usually zero) * @sbuf: scan buffer (must be c->leb_size) * * This function returns the scanned information on success and a negative error * code on failure. */ struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum, int offs, void *sbuf) { … } /** * ubifs_end_scan - update LEB scanning information at end of scan. * @c: UBIFS file-system description object * @sleb: scanning information * @lnum: logical eraseblock number * @offs: offset to start at (usually zero) */ void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, int lnum, int offs) { … } /** * ubifs_add_snod - add a scanned node to LEB scanning information. * @c: UBIFS file-system description object * @sleb: scanning information * @buf: buffer containing node * @offs: offset of node on flash * * This function returns %0 on success and a negative error code on failure. */ int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb, void *buf, int offs) { … } /** * ubifs_scanned_corruption - print information after UBIFS scanned corruption. * @c: UBIFS file-system description object * @lnum: LEB number of corruption * @offs: offset of corruption * @buf: buffer containing corruption */ void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs, void *buf) { … } /** * ubifs_scan - scan a logical eraseblock. * @c: UBIFS file-system description object * @lnum: logical eraseblock number * @offs: offset to start at (usually zero) * @sbuf: scan buffer (must be of @c->leb_size bytes in size) * @quiet: print no messages * * This function scans LEB number @lnum and returns complete information about * its contents. Returns the scanned information in case of success and, * %-EUCLEAN if the LEB neads recovery, and other negative error codes in case * of failure. * * If @quiet is non-zero, this function does not print large and scary * error messages and flash dumps in case of errors. */ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, int offs, void *sbuf, int quiet) { … } /** * ubifs_scan_destroy - destroy LEB scanning information. * @sleb: scanning information to free */ void ubifs_scan_destroy(struct ubifs_scan_leb *sleb) { … }