yaffs: More clean up
[yaffs2.git] / yaffs_yaffs2.c
index 0bac099728540221eac9d16cf8b2faee747b1fc9..debb56d98bd931b15c8309a0532ca3e273cb87d4 100644 (file)
 #include "yaffs_yaffs2.h"
 #include "yaffs_checkptrw.h"
 #include "yaffs_bitmap.h"
-#include "yaffs_qsort.h"
 #include "yaffs_nand.h"
 #include "yaffs_getblockinfo.h"
 #include "yaffs_verify.h"
+#include "yaffs_attribs.h"
 
 /*
  * Checkpoints are really no benefit on very small partitions.
@@ -892,18 +892,18 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size)
 }
 
 
-typedef struct {
+struct yaffs_block_index{
        int seq;
        int block;
-} yaffs_block_index;
+};
 
 
 static int yaffs2_ybicmp(const void *a, const void *b)
 {
-       register int aseq = ((yaffs_block_index *)a)->seq;
-       register int bseq = ((yaffs_block_index *)b)->seq;
-       register int ablock = ((yaffs_block_index *)a)->block;
-       register int bblock = ((yaffs_block_index *)b)->block;
+       int aseq = ((struct yaffs_block_index *)a)->seq;
+       int bseq = ((struct yaffs_block_index *)b)->seq;
+       int ablock = ((struct yaffs_block_index *)a)->block;
+       int bblock = ((struct yaffs_block_index *)b)->block;
        if (aseq == bseq)
                return ablock - bblock;
        else
@@ -941,7 +941,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
        int alloc_failed = 0;
 
 
-       yaffs_block_index *block_index = NULL;
+       struct yaffs_block_index *block_index = NULL;
        int alt_block_index = 0;
 
        T(YAFFS_TRACE_SCAN,
@@ -952,10 +952,10 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
 
        dev->seq_number = YAFFS_LOWEST_SEQUENCE_NUMBER;
 
-       block_index = YMALLOC(n_blocks * sizeof(yaffs_block_index));
+       block_index = YMALLOC(n_blocks * sizeof(struct yaffs_block_index));
 
        if (!block_index) {
-               block_index = YMALLOC_ALT(n_blocks * sizeof(yaffs_block_index));
+               block_index = YMALLOC_ALT(n_blocks * sizeof(struct yaffs_block_index));
                alt_block_index = 1;
        }
 
@@ -1035,7 +1035,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
        YYIELD();
 
        /* Sort the blocks by sequence number*/
-       yaffs_qsort(block_index, n_to_scan, sizeof(yaffs_block_index), yaffs2_ybicmp);
+       yaffs_sort(block_index, n_to_scan, sizeof(struct yaffs_block_index), yaffs2_ybicmp);
 
        YYIELD();
 
@@ -1319,24 +1319,8 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev)
                                        if (oh) {
 
                                                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;
-
+                                               yaffs_load_attribs(in, oh);
                                                in->lazy_loaded = 0;
-
-#endif
                                        } else
                                                in->lazy_loaded = 1;
 
@@ -1352,21 +1336,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *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);
 
                                                if (oh->shadows_obj > 0)
                                                        yaffs_handle_shadowed_obj(dev,