/*
* YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
*
- * Copyright (C) 2002-2010 Aleph One Ltd.
- * for Toby Churchill Ltd and Brightstar Engineering
+ * Copyright (C) 2002-2018 Aleph One Ltd.
*
* Created by Charles Manning <charles@aleph1.co.uk>
*
int yaffs1_scan(struct yaffs_dev *dev)
{
+#ifdef CONFIG_YAFFS_NO_YAFFS1
+ return YAFFS_FAIL;
+#else
struct yaffs_ext_tags tags;
- int blk;
+ u32 blk;
int result;
int chunk;
- int c;
+ u32 c;
int deleted;
enum yaffs_block_state state;
- struct yaffs_obj *hard_list = NULL;
+ LIST_HEAD(hard_list);
struct yaffs_block_info *bi;
u32 seq_number;
struct yaffs_obj_hdr *oh;
"yaffs1_scan starts intstartblk %d intendblk %d...",
dev->internal_start_block, dev->internal_end_block);
- chunk_data = yaffs_get_temp_buffer(dev, __LINE__);
+ chunk_data = yaffs_get_temp_buffer(dev);
dev->seq_number = YAFFS_LOWEST_SEQUENCE_NUMBER;
deleted = 0;
/* For each chunk in each block that needs scanning.... */
- for (c = 0; !alloc_failed && c < dev->param.chunks_per_block &&
- state == YAFFS_BLOCK_STATE_NEEDS_SCANNING; c++) {
+ for (c = 0;
+ !alloc_failed && c < dev->param.chunks_per_block &&
+ state == YAFFS_BLOCK_STATE_NEEDS_SCAN; c++) {
/* Read the tags and decide what to do */
chunk = blk * dev->param.chunks_per_block + c;
result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL,
&tags);
+ if (result != YAFFS_OK)
+ continue;
/* Let's have a good look at this chunk... */
- if (tags.ecc_result == YAFFS_ECC_RESULT_UNFIXED
- || tags.is_deleted) {
+ if (tags.ecc_result == YAFFS_ECC_RESULT_UNFIXED ||
+ tags.is_deleted) {
/* YAFFS1 only...
* A deleted chunk
*/
tags.n_bytes;
if (in &&
in->variant_type ==
- YAFFS_OBJECT_TYPE_FILE &&
- in->variant.file_variant.scanned_size <
- endpos) {
- in->variant.file_variant.scanned_size =
+ YAFFS_OBJECT_TYPE_FILE &&
+ in->variant.file_variant.stored_size <
+ endpos) {
+ in->variant.file_variant.stored_size =
endpos;
if (!dev->param.use_header_file_size) {
in->variant.
file_variant.file_size =
in->variant.
- file_variant.scanned_size;
+ file_variant.stored_size;
}
}
case YAFFS_OBJECT_TYPE_FILE:
if (dev->param.
use_header_file_size)
-
in->variant.
- file_variant.file_size
- = oh->file_size;
-
+ file_variant.file_size
+ = yaffs_oh_to_size(dev, oh, 0);
break;
case YAFFS_OBJECT_TYPE_HARDLINK:
in->variant.
hardlink_variant.equiv_id =
oh->equiv_id;
- in->hard_links.next =
- (struct list_head *)
- hard_list;
- hard_list = in;
+ list_add(&in->hard_links,
+ &hard_list);
break;
case YAFFS_OBJECT_TYPE_DIRECTORY:
/* Do nothing */
}
}
- if (state == YAFFS_BLOCK_STATE_NEEDS_SCANNING) {
+ if (state == YAFFS_BLOCK_STATE_NEEDS_SCAN) {
/* If we got this far while scanning,
* then the block is fully allocated. */
state = YAFFS_BLOCK_STATE_FULL;
/* Now let's see if it was dirty */
if (bi->pages_in_use == 0 &&
!bi->has_shrink_hdr &&
- bi->block_state == YAFFS_BLOCK_STATE_FULL) {
+ bi->block_state == YAFFS_BLOCK_STATE_FULL)
yaffs_block_became_dirty(dev, blk);
- }
}
/* Ok, we've done all the scanning.
* these hardlinks.
*/
- yaffs_link_fixup(dev, hard_list);
+ yaffs_link_fixup(dev, &hard_list);
- /* Fix up any shadowed objects */
+ /*
+ * Fix up any shadowed objects.
+ * There should not be more than one of these.
+ */
{
struct yaffs_shadow_fixer *fixer;
struct yaffs_obj *obj;
}
}
- yaffs_release_temp_buffer(dev, chunk_data, __LINE__);
+ yaffs_release_temp_buffer(dev, chunk_data);
if (alloc_failed)
return YAFFS_FAIL;
yaffs_trace(YAFFS_TRACE_SCAN, "yaffs1_scan ends");
return YAFFS_OK;
+#endif
}