X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_yaffs1.c;h=6ee91a139e1ae508acec7fc26a091d740fdeefb0;hp=c879f57f921116e14243c87692ee079aaf7737da;hb=46eb953ecab322d3385ccf84c75d969de8542317;hpb=05f5305b2d17b0e2889338724b864cf80f309437 diff --git a/yaffs_yaffs1.c b/yaffs_yaffs1.c index c879f57..6ee91a1 100644 --- a/yaffs_yaffs1.c +++ b/yaffs_yaffs1.c @@ -24,7 +24,6 @@ int yaffs1_scan(struct yaffs_dev *dev) struct yaffs_ext_tags tags; int blk; int result; - int chunk; int c; int deleted; @@ -35,11 +34,8 @@ int yaffs1_scan(struct yaffs_dev *dev) struct yaffs_obj_hdr *oh; struct yaffs_obj *in; struct yaffs_obj *parent; - int alloc_failed = 0; - struct yaffs_shadow_fixer *shadow_fixers = NULL; - u8 *chunk_data; yaffs_trace(YAFFS_TRACE_SCAN, @@ -117,11 +113,12 @@ int yaffs1_scan(struct yaffs_dev *dev) */ if (c == 0) { - /* We're looking at the first chunk in the block so the block is unused */ + /* We're looking at the first chunk in + *the block so the block is unused */ state = YAFFS_BLOCK_STATE_EMPTY; dev->n_erased_blocks++; } else { - /* this is the block being allocated from */ + /* this is the block being allocated */ yaffs_trace(YAFFS_TRACE_SCAN, " Allocating from %d %d", blk, c); @@ -129,7 +126,6 @@ int yaffs1_scan(struct yaffs_dev *dev) dev->alloc_block = blk; dev->alloc_page = c; dev->alloc_block_finder = blk; - /* Set block finder here to encourage the allocator to go forth from here. */ } @@ -143,10 +139,10 @@ int yaffs1_scan(struct yaffs_dev *dev) bi->pages_in_use++; in = yaffs_find_or_create_by_number(dev, - tags.obj_id, - YAFFS_OBJECT_TYPE_FILE); - /* PutChunkIntoFile checks for a clash (two data chunks with - * the same chunk_id). + tags.obj_id, + YAFFS_OBJECT_TYPE_FILE); + /* PutChunkIntoFile checks for a clash + * (two data chunks with the same chunk_id). */ if (!in) @@ -159,13 +155,13 @@ int yaffs1_scan(struct yaffs_dev *dev) } endpos = - (tags.chunk_id - - 1) * dev->data_bytes_per_chunk + + (tags.chunk_id - 1) * + dev->data_bytes_per_chunk + tags.n_bytes; - if (in - && in->variant_type == - YAFFS_OBJECT_TYPE_FILE - && in->variant.file_variant.scanned_size < + if (in && + in->variant_type == + YAFFS_OBJECT_TYPE_FILE && + in->variant.file_variant.scanned_size < endpos) { in->variant.file_variant.scanned_size = endpos; @@ -179,7 +175,7 @@ int yaffs1_scan(struct yaffs_dev *dev) } } else { /* chunk_id == 0, so it is an ObjectHeader. - * Thus, we read in the object header and make the object + * Make the object */ yaffs_set_chunk_bit(dev, blk, c); bi->pages_in_use++; @@ -193,18 +189,19 @@ int yaffs1_scan(struct yaffs_dev *dev) in = yaffs_find_by_number(dev, tags.obj_id); if (in && in->variant_type != oh->type) { /* This should not happen, but somehow - * Wev'e ended up with an obj_id that has been reused but not yet - * deleted, and worse still it has changed type. Delete the old object. + * Wev'e ended up with an obj_id that + * has been reused but not yet deleted, + * and worse still it has changed type. + * Delete the old object. */ yaffs_del_obj(in); - - in = 0; + in = NULL; } in = yaffs_find_or_create_by_number(dev, - tags.obj_id, - oh->type); + tags.obj_id, + oh->type); if (!in) alloc_failed = 1; @@ -232,7 +229,9 @@ int yaffs1_scan(struct yaffs_dev *dev) } if (in && in->valid) { - /* We have already filled this one. We have a duplicate and need to resolve it. */ + /* We have already filled this one. + * We have a duplicate and need to + * resolve it. */ unsigned existing_serial = in->serial; unsigned new_serial = @@ -240,13 +239,15 @@ int yaffs1_scan(struct yaffs_dev *dev) if (((existing_serial + 1) & 3) == new_serial) { - /* Use new one - destroy the exisiting one */ + /* Use new one - destroy the + * exisiting one */ yaffs_chunk_del(dev, in->hdr_chunk, 1, __LINE__); in->valid = 0; } else { - /* Use existing - destroy this one. */ + /* Use existing - destroy + * this one. */ yaffs_chunk_del(dev, chunk, 1, __LINE__); } @@ -256,7 +257,8 @@ int yaffs1_scan(struct yaffs_dev *dev) (tags.obj_id == YAFFS_OBJECTID_ROOT || tags.obj_id == YAFFS_OBJECTID_LOSTNFOUND)) { - /* We only load some info, don't fiddle with directory structure */ + /* We only load some info, don't fiddle + * with directory structure */ in->valid = 1; in->variant_type = oh->type; @@ -295,12 +297,14 @@ int yaffs1_scan(struct yaffs_dev *dev) parent->variant_type = YAFFS_OBJECT_TYPE_DIRECTORY; INIT_LIST_HEAD(&parent-> - variant.dir_variant.children); - } else if (!parent - || parent->variant_type != - YAFFS_OBJECT_TYPE_DIRECTORY) { - /* Hoosterman, another problem.... - * We're trying to use a non-directory as a directory + variant.dir_variant. + children); + } else if (!parent || + parent->variant_type != + YAFFS_OBJECT_TYPE_DIRECTORY) { + /* Hoosterman, a problem.... + * We're trying to use a + * non-directory as a directory */ yaffs_trace(YAFFS_TRACE_ERROR, @@ -311,19 +315,6 @@ int yaffs1_scan(struct yaffs_dev *dev) yaffs_add_obj_to_dir(parent, in); - if (0 && (parent == dev->del_dir || - parent == - dev->unlinked_dir)) { - in->deleted = 1; /* If it is unlinked at start up then it wants deleting */ - dev->n_deleted_files++; - } - /* Note re hardlinks. - * Since we might scan a hardlink before its equivalent object is scanned - * we put them all in a list. - * After scanning is complete, we should have all the objects, so we run through this - * list and fix up all the chains. - */ - switch (in->variant_type) { case YAFFS_OBJECT_TYPE_UNKNOWN: /* Todo got a problem */ @@ -333,7 +324,7 @@ int yaffs1_scan(struct yaffs_dev *dev) use_header_file_size) in->variant. - file_variant.file_size + file_variant.file_size = oh->file_size; break; @@ -361,18 +352,19 @@ int yaffs1_scan(struct yaffs_dev *dev) alloc_failed = 1; break; } - } } } if (state == YAFFS_BLOCK_STATE_NEEDS_SCANNING) { - /* If we got this far while scanning, then the block is fully allocated. */ + /* If we got this far while scanning, + * then the block is fully allocated. */ state = YAFFS_BLOCK_STATE_FULL; } if (state == YAFFS_BLOCK_STATE_ALLOCATING) { - /* If the block was partially allocated then treat it as fully allocated. */ + /* If the block was partially allocated then + * treat it as fully allocated. */ state = YAFFS_BLOCK_STATE_FULL; dev->alloc_block = -1; } @@ -385,13 +377,12 @@ int yaffs1_scan(struct yaffs_dev *dev) bi->block_state == YAFFS_BLOCK_STATE_FULL) { yaffs_block_became_dirty(dev, blk); } - } /* Ok, we've done all the scanning. * Fix up the hard link chains. - * We should now have scanned all the objects, now it's time to add these - * hardlinks. + * We should now have scanned all the objects, now it's time to add + * these hardlinks. */ yaffs_link_fixup(dev, hard_list); @@ -404,8 +395,9 @@ int yaffs1_scan(struct yaffs_dev *dev) while (shadow_fixers) { fixer = shadow_fixers; shadow_fixers = fixer->next; - /* Complete the rename transaction by deleting the shadowed object - * then setting the object header to unshadowed. + /* Complete the rename transaction by deleting the + * shadowed object then setting the object header + to unshadowed. */ obj = yaffs_find_by_number(dev, fixer->shadowed_id); if (obj)