yaffs: More clean up
[yaffs2.git] / yaffs_yaffs1.c
index cc717461c66c3887590c9efb66189faa14e87a1b..059d12515eb89b5431ff7ca6b087ee8ee32968c1 100644 (file)
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
 #include "yaffs_yaffs1.h"
 #include "yportenv.h"
 #include "yaffs_trace.h"
 #include "yaffs_bitmap.h"
 #include "yaffs_getblockinfo.h"
 #include "yaffs_nand.h"
+#include "yaffs_attribs.h"
 
-
-int yaffs1_scan(yaffs_dev_t *dev)
+int yaffs1_scan(struct yaffs_dev *dev)
 {
-       yaffs_ext_tags tags;
+       struct yaffs_ext_tags tags;
        int blk;
-       int blockIterator;
-       int startIterator;
-       int endIterator;
        int result;
 
        int chunk;
        int c;
        int deleted;
-       yaffs_block_state_t state;
-       yaffs_obj_t *hard_list = NULL;
-       yaffs_block_info_t *bi;
-       __u32 seq_number;
-       yaffs_obj_header *oh;
-       yaffs_obj_t *in;
-       yaffs_obj_t *parent;
+       enum yaffs_block_state state;
+       struct yaffs_obj *hard_list = NULL;
+       struct yaffs_block_info *bi;
+       u32 seq_number;
+       struct yaffs_obj_hdr *oh;
+       struct yaffs_obj *in;
+       struct yaffs_obj *parent;
 
        int alloc_failed = 0;
 
-       struct yaffs_shadow_fixer_s *shadowFixerList = NULL;
+       struct yaffs_shadow_fixer *shadow_fixers = NULL;
 
 
-       __u8 *chunkData;
+       u8 *chunk_data;
 
 
 
@@ -51,7 +49,7 @@ int yaffs1_scan(yaffs_dev_t *dev)
          (TSTR("yaffs1_scan starts  intstartblk %d intendblk %d..." TENDSTR),
           dev->internal_start_block, dev->internal_end_block));
 
-       chunkData = yaffs_get_temp_buffer(dev, __LINE__);
+       chunk_data = yaffs_get_temp_buffer(dev, __LINE__);
 
        dev->seq_number = YAFFS_LOWEST_SEQUENCE_NUMBER;
 
@@ -86,19 +84,13 @@ int yaffs1_scan(yaffs_dev_t *dev)
                bi++;
        }
 
-       startIterator = dev->internal_start_block;
-       endIterator = dev->internal_end_block;
-
        /* For each block.... */
-       for (blockIterator = startIterator; !alloc_failed && blockIterator <= endIterator;
-            blockIterator++) {
+       for (blk= dev->internal_start_block; 
+               !alloc_failed && blk <= dev->internal_end_block;
+               blk++) {
 
                YYIELD();
 
-               YYIELD();
-
-               blk = blockIterator;
-
                bi = yaffs_get_block_info(dev, blk);
                state = bi->block_state;
 
@@ -196,10 +188,10 @@ int yaffs1_scan(yaffs_dev_t *dev)
                                bi->pages_in_use++;
 
                                result = yaffs_rd_chunk_tags_nand(dev, chunk,
-                                                               chunkData,
+                                                               chunk_data,
                                                                NULL);
 
-                               oh = (yaffs_obj_header *) chunkData;
+                               oh = (struct yaffs_obj_hdr *) chunk_data;
 
                                in = yaffs_find_by_number(dev,
                                                              tags.obj_id);
@@ -224,11 +216,11 @@ int yaffs1_scan(yaffs_dev_t *dev)
 
                                if (in && oh->shadows_obj > 0) {
 
-                                       struct yaffs_shadow_fixer_s *fixer;
-                                       fixer = YMALLOC(sizeof(struct yaffs_shadow_fixer_s));
+                                       struct yaffs_shadow_fixer *fixer;
+                                       fixer = YMALLOC(sizeof(struct yaffs_shadow_fixer));
                                        if (fixer) {
-                                               fixer->next = shadowFixerList;
-                                               shadowFixerList = fixer;
+                                               fixer->next = shadow_fixers;
+                                               shadow_fixers = fixer;
                                                fixer->obj_id = tags.obj_id;
                                                fixer->shadowed_id = oh->shadows_obj;
                                                T(YAFFS_TRACE_SCAN,
@@ -243,10 +235,10 @@ int yaffs1_scan(yaffs_dev_t *dev)
                                if (in && in->valid) {
                                        /* We have already filled this one. We have a duplicate and need to resolve it. */
 
-                                       unsigned existingSerial = in->serial;
-                                       unsigned newSerial = tags.serial_number;
+                                       unsigned existing_serial = in->serial;
+                                       unsigned new_serial = tags.serial_number;
 
-                                       if (((existingSerial + 1) & 3) == newSerial) {
+                                       if (((existing_serial + 1) & 3) == new_serial) {
                                                /* Use new one - destroy the exisiting one */
                                                yaffs_chunk_del(dev,
                                                                  in->hdr_chunk,
@@ -267,21 +259,7 @@ int yaffs1_scan(yaffs_dev_t *dev)
                                        in->variant_type = oh->type;
 
                                        in->yst_mode = oh->yst_mode;
-#ifdef CONFIG_YAFFS_WINCE
-                                       in->win_atime[0] = oh->win_atime[0];
-                                       in->win_ctime[0] = oh->win_ctime[0];
-                                       in->win_mtime[0] = oh->win_mtime[0];
-                                       in->win_atime[1] = oh->win_atime[1];
-                                       in->win_ctime[1] = oh->win_ctime[1];
-                                       in->win_mtime[1] = oh->win_mtime[1];
-#else
-                                       in->yst_uid = oh->yst_uid;
-                                       in->yst_gid = oh->yst_gid;
-                                       in->yst_atime = oh->yst_atime;
-                                       in->yst_mtime = oh->yst_mtime;
-                                       in->yst_ctime = oh->yst_ctime;
-                                       in->yst_rdev = oh->yst_rdev;
-#endif
+                                       yaffs_load_attribs(in, oh);
                                        in->hdr_chunk = chunk;
                                        in->serial = tags.serial_number;
 
@@ -292,21 +270,7 @@ int yaffs1_scan(yaffs_dev_t *dev)
                                        in->variant_type = oh->type;
 
                                        in->yst_mode = oh->yst_mode;
-#ifdef CONFIG_YAFFS_WINCE
-                                       in->win_atime[0] = oh->win_atime[0];
-                                       in->win_ctime[0] = oh->win_ctime[0];
-                                       in->win_mtime[0] = oh->win_mtime[0];
-                                       in->win_atime[1] = oh->win_atime[1];
-                                       in->win_ctime[1] = oh->win_ctime[1];
-                                       in->win_mtime[1] = oh->win_mtime[1];
-#else
-                                       in->yst_uid = oh->yst_uid;
-                                       in->yst_gid = oh->yst_gid;
-                                       in->yst_atime = oh->yst_atime;
-                                       in->yst_mtime = oh->yst_mtime;
-                                       in->yst_ctime = oh->yst_ctime;
-                                       in->yst_rdev = oh->yst_rdev;
-#endif
+                                       yaffs_load_attribs(in, oh);
                                        in->hdr_chunk = chunk;
                                        in->serial = tags.serial_number;
 
@@ -328,7 +292,7 @@ int yaffs1_scan(yaffs_dev_t *dev)
                                                /* Set up as a directory */
                                                parent->variant_type =
                                                        YAFFS_OBJECT_TYPE_DIRECTORY;
-                                               YINIT_LIST_HEAD(&parent->variant.
+                                               INIT_LIST_HEAD(&parent->variant.
                                                                dir_variant.
                                                                children);
                                        } else if (!parent || parent->variant_type !=
@@ -375,7 +339,7 @@ int yaffs1_scan(yaffs_dev_t *dev)
                                                        equiv_id =
                                                        oh->equiv_id;
                                                in->hard_links.next =
-                                                       (struct ylist_head *)
+                                                       (struct list_head *)
                                                        hard_list;
                                                hard_list = in;
                                                break;
@@ -430,12 +394,12 @@ int yaffs1_scan(yaffs_dev_t *dev)
 
        /* Fix up any shadowed objects */
        {
-               struct yaffs_shadow_fixer_s *fixer;
-               yaffs_obj_t *obj;
+               struct yaffs_shadow_fixer *fixer;
+               struct yaffs_obj *obj;
 
-               while (shadowFixerList) {
-                       fixer = shadowFixerList;
-                       shadowFixerList = fixer->next;
+               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.
                         */
@@ -452,7 +416,7 @@ int yaffs1_scan(yaffs_dev_t *dev)
                }
        }
 
-       yaffs_release_temp_buffer(dev, chunkData, __LINE__);
+       yaffs_release_temp_buffer(dev, chunk_data, __LINE__);
 
        if (alloc_failed)
                return YAFFS_FAIL;