* published by the Free Software Foundation.
*/
-
#include "yaffs_guts.h"
#include "yaffs_trace.h"
#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.
#define YAFFS_SMALL_HOLE_THRESHOLD 4
-
/*
* Oldest Dirty Sequence Number handling.
*/
-
+
/* yaffs_calc_oldest_dirty_seq()
* yaffs2_find_oldest_dirty_seq()
* Calculate the oldest dirty sequence number if we don't know it.
unsigned block_no = 0;
struct yaffs_block_info *b;
- if(!dev->param.is_yaffs2)
+ if (!dev->param.is_yaffs2)
return;
/* Find the oldest dirty sequence number. */
b = dev->block_info;
for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
if (b->block_state == YAFFS_BLOCK_STATE_FULL &&
- (b->pages_in_use - b->soft_del_pages) < dev->param.chunks_per_block &&
- b->seq_number < seq) {
+ (b->pages_in_use - b->soft_del_pages) <
+ dev->param.chunks_per_block && b->seq_number < seq) {
seq = b->seq_number;
block_no = i;
}
b++;
}
- if(block_no){
+ if (block_no) {
dev->oldest_dirty_seq = seq;
dev->oldest_dirty_block = block_no;
}
}
-
void yaffs2_find_oldest_dirty_seq(struct yaffs_dev *dev)
{
- if(!dev->param.is_yaffs2)
+ if (!dev->param.is_yaffs2)
return;
- if(!dev->oldest_dirty_seq)
+ if (!dev->oldest_dirty_seq)
yaffs_calc_oldest_dirty_seq(dev);
}
* becomes invalid). If the value matches the oldest then we clear
* dev->oldest_dirty_seq to force its recomputation.
*/
-void yaffs2_clear_oldest_dirty_seq(struct yaffs_dev *dev, struct yaffs_block_info *bi)
+void yaffs2_clear_oldest_dirty_seq(struct yaffs_dev *dev,
+ struct yaffs_block_info *bi)
{
- if(!dev->param.is_yaffs2)
+ if (!dev->param.is_yaffs2)
return;
- if(!bi || bi->seq_number == dev->oldest_dirty_seq){
+ if (!bi || bi->seq_number == dev->oldest_dirty_seq) {
dev->oldest_dirty_seq = 0;
dev->oldest_dirty_block = 0;
}
* Update the oldest dirty sequence number whenever we dirty a block.
* Only do this if the oldest_dirty_seq is actually being tracked.
*/
-void yaffs2_update_oldest_dirty_seq(struct yaffs_dev *dev, unsigned block_no, struct yaffs_block_info *bi)
+void yaffs2_update_oldest_dirty_seq(struct yaffs_dev *dev, unsigned block_no,
+ struct yaffs_block_info *bi)
{
- if(!dev->param.is_yaffs2)
+ if (!dev->param.is_yaffs2)
return;
- if(dev->oldest_dirty_seq){
- if(dev->oldest_dirty_seq > bi->seq_number){
+ if (dev->oldest_dirty_seq) {
+ if (dev->oldest_dirty_seq > bi->seq_number) {
dev->oldest_dirty_seq = bi->seq_number;
dev->oldest_dirty_block = block_no;
}
}
}
-int yaffs_block_ok_for_gc(struct yaffs_dev *dev,
- struct yaffs_block_info *bi)
+int yaffs_block_ok_for_gc(struct yaffs_dev *dev, struct yaffs_block_info *bi)
{
if (!dev->param.is_yaffs2)
* periodically finds the oldest full block by sequence number for refreshing.
* Only for yaffs2.
*/
-u32 yaffs2_find_refresh_block(struct yaffs_dev *dev)
+u32 yaffs2_find_refresh_block(struct yaffs_dev * dev)
{
- u32 b ;
+ u32 b;
u32 oldest = 0;
u32 oldest_seq = 0;
struct yaffs_block_info *bi;
- if(!dev->param.is_yaffs2)
+ if (!dev->param.is_yaffs2)
return oldest;
/*
* If refresh period < 10 then refreshing is disabled.
*/
- if(dev->param.refresh_period < 10)
- return oldest;
+ if (dev->param.refresh_period < 10)
+ return oldest;
- /*
- * Fix broken values.
- */
- if(dev->refresh_skip > dev->param.refresh_period)
- dev->refresh_skip = dev->param.refresh_period;
+ /*
+ * Fix broken values.
+ */
+ if (dev->refresh_skip > dev->param.refresh_period)
+ dev->refresh_skip = dev->param.refresh_period;
- if(dev->refresh_skip > 0)
- return oldest;
+ if (dev->refresh_skip > 0)
+ return oldest;
/*
* Refresh skip is now zero.
dev->refresh_skip = dev->param.refresh_period;
dev->refresh_count++;
bi = dev->block_info;
- for (b = dev->internal_start_block; b <=dev->internal_end_block; b++){
+ for (b = dev->internal_start_block; b <= dev->internal_end_block; b++) {
- if (bi->block_state == YAFFS_BLOCK_STATE_FULL){
+ if (bi->block_state == YAFFS_BLOCK_STATE_FULL) {
- if(oldest < 1 ||
- bi->seq_number < oldest_seq){
- oldest = b;
- oldest_seq = bi->seq_number;
- }
+ if (oldest < 1 || bi->seq_number < oldest_seq) {
+ oldest = b;
+ oldest_seq = bi->seq_number;
+ }
}
bi++;
}
if (oldest > 0) {
T(YAFFS_TRACE_GC,
- (TSTR("GC refresh count %d selected block %d with seq_number %d" TENDSTR),
- dev->refresh_count, oldest, oldest_seq));
+ (TSTR
+ ("GC refresh count %d selected block %d with seq_number %d"
+ TENDSTR), dev->refresh_count, oldest, oldest_seq));
}
return oldest;
int yaffs2_checkpt_required(struct yaffs_dev *dev)
{
int nblocks;
-
- if(!dev->param.is_yaffs2)
+
+ if (!dev->param.is_yaffs2)
return 0;
-
- nblocks = dev->internal_end_block - dev->internal_start_block + 1 ;
- return !dev->param.skip_checkpt_wr &&
- !dev->read_only &&
- (nblocks >= YAFFS_CHECKPOINT_MIN_BLOCKS);
+ nblocks = dev->internal_end_block - dev->internal_start_block + 1;
+
+ return !dev->param.skip_checkpt_wr &&
+ !dev->read_only && (nblocks >= YAFFS_CHECKPOINT_MIN_BLOCKS);
}
int yaffs_calc_checkpt_blocks_required(struct yaffs_dev *dev)
{
int retval;
- if(!dev->param.is_yaffs2)
+ if (!dev->param.is_yaffs2)
return 0;
- if (!dev->checkpoint_blocks_required &&
- yaffs2_checkpt_required(dev)){
+ if (!dev->checkpoint_blocks_required && yaffs2_checkpt_required(dev)) {
/* Not a valid value so recalculate */
int n_bytes = 0;
int n_blocks;
- int dev_blocks = (dev->param.end_block - dev->param.start_block + 1);
+ int dev_blocks =
+ (dev->param.end_block - dev->param.start_block + 1);
n_bytes += sizeof(struct yaffs_checkpt_validity);
n_bytes += sizeof(struct yaffs_checkpt_dev);
n_bytes += dev_blocks * sizeof(struct yaffs_block_info);
n_bytes += dev_blocks * dev->chunk_bit_stride;
- n_bytes += (sizeof(struct yaffs_checkpt_obj) + sizeof(u32)) * (dev->n_obj);
+ n_bytes +=
+ (sizeof(struct yaffs_checkpt_obj) +
+ sizeof(u32)) * (dev->n_obj);
n_bytes += (dev->tnode_size + sizeof(u32)) * (dev->n_tnodes);
n_bytes += sizeof(struct yaffs_checkpt_validity);
- n_bytes += sizeof(u32); /* checksum*/
+ n_bytes += sizeof(u32); /* checksum */
/* Round up and add 2 blocks to allow for some bad blocks, so add 3 */
- n_blocks = (n_bytes/(dev->data_bytes_per_chunk * dev->param.chunks_per_block)) + 3;
+ n_blocks =
+ (n_bytes /
+ (dev->data_bytes_per_chunk *
+ dev->param.chunks_per_block)) + 3;
dev->checkpoint_blocks_required = n_blocks;
}
retval = dev->checkpoint_blocks_required - dev->blocks_in_checkpt;
- if(retval < 0)
+ if (retval < 0)
retval = 0;
return retval;
}
/*--------------------- Checkpointing --------------------*/
-
static int yaffs2_wr_checkpt_validity_marker(struct yaffs_dev *dev, int head)
{
struct yaffs_checkpt_validity cp;
cp.version = YAFFS_CHECKPOINT_VERSION;
cp.head = (head) ? 1 : 0;
- return (yaffs2_checkpt_wr(dev, &cp, sizeof(cp)) == sizeof(cp)) ?
- 1 : 0;
+ return (yaffs2_checkpt_wr(dev, &cp, sizeof(cp)) == sizeof(cp)) ? 1 : 0;
}
static int yaffs2_rd_checkpt_validity_marker(struct yaffs_dev *dev, int head)
if (ok)
ok = (cp.struct_type == sizeof(cp)) &&
- (cp.magic == YAFFS_MAGIC) &&
- (cp.version == YAFFS_CHECKPOINT_VERSION) &&
- (cp.head == ((head) ? 1 : 0));
+ (cp.magic == YAFFS_MAGIC) &&
+ (cp.version == YAFFS_CHECKPOINT_VERSION) &&
+ (cp.head == ((head) ? 1 : 0));
return ok ? 1 : 0;
}
static void yaffs2_dev_to_checkpt_dev(struct yaffs_checkpt_dev *cp,
- struct yaffs_dev *dev)
+ struct yaffs_dev *dev)
{
cp->n_erased_blocks = dev->n_erased_blocks;
cp->alloc_block = dev->alloc_block;
}
static void yaffs_checkpt_dev_to_dev(struct yaffs_dev *dev,
- struct yaffs_checkpt_dev *cp)
+ struct yaffs_checkpt_dev *cp)
{
dev->n_erased_blocks = cp->n_erased_blocks;
dev->alloc_block = cp->alloc_block;
dev->seq_number = cp->seq_number;
}
-
static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev)
{
struct yaffs_checkpt_dev cp;
u32 n_bytes;
- u32 n_blocks = (dev->internal_end_block - dev->internal_start_block + 1);
+ u32 n_blocks =
+ (dev->internal_end_block - dev->internal_start_block + 1);
int ok;
- /* Write device runtime values*/
+ /* Write device runtime values */
yaffs2_dev_to_checkpt_dev(&cp, dev);
cp.struct_type = sizeof(cp);
/* Write block info */
if (ok) {
n_bytes = n_blocks * sizeof(struct yaffs_block_info);
- ok = (yaffs2_checkpt_wr(dev, dev->block_info, n_bytes) == n_bytes);
+ ok = (yaffs2_checkpt_wr(dev, dev->block_info, n_bytes) ==
+ n_bytes);
}
/* Write chunk bits */
if (ok) {
n_bytes = n_blocks * dev->chunk_bit_stride;
- ok = (yaffs2_checkpt_wr(dev, dev->chunk_bits, n_bytes) == n_bytes);
+ ok = (yaffs2_checkpt_wr(dev, dev->chunk_bits, n_bytes) ==
+ n_bytes);
}
- return ok ? 1 : 0;
+ return ok ? 1 : 0;
}
{
struct yaffs_checkpt_dev cp;
u32 n_bytes;
- u32 n_blocks = (dev->internal_end_block - dev->internal_start_block + 1);
+ u32 n_blocks =
+ (dev->internal_end_block - dev->internal_start_block + 1);
int ok;
if (cp.struct_type != sizeof(cp))
return 0;
-
yaffs_checkpt_dev_to_dev(dev, &cp);
n_bytes = n_blocks * sizeof(struct yaffs_block_info);
}
static void yaffs2_obj_checkpt_obj(struct yaffs_checkpt_obj *cp,
- struct yaffs_obj *obj)
+ struct yaffs_obj *obj)
{
cp->obj_id = obj->obj_id;
cp->size_or_equiv_obj = obj->variant.hardlink_variant.equiv_id;
}
-static int taffs2_checkpt_obj_to_obj(struct yaffs_obj *obj, struct yaffs_checkpt_obj *cp)
+static int taffs2_checkpt_obj_to_obj(struct yaffs_obj *obj,
+ struct yaffs_checkpt_obj *cp)
{
struct yaffs_obj *parent;
if (obj->variant_type != cp->variant_type) {
T(YAFFS_TRACE_ERROR, (TSTR("Checkpoint read object %d type %d "
- TCONT("chunk %d does not match existing object type %d")
- TENDSTR), cp->obj_id, cp->variant_type, cp->hdr_chunk,
- obj->variant_type));
+ TCONT
+ ("chunk %d does not match existing object type %d")
+ TENDSTR), cp->obj_id,
+ cp->variant_type, cp->hdr_chunk,
+ obj->variant_type));
return 0;
}
obj->obj_id = cp->obj_id;
if (cp->parent_id)
- parent = yaffs_find_or_create_by_number(
- obj->my_dev,
- cp->parent_id,
- YAFFS_OBJECT_TYPE_DIRECTORY);
+ parent = yaffs_find_or_create_by_number(obj->my_dev,
+ cp->parent_id,
+ YAFFS_OBJECT_TYPE_DIRECTORY);
else
parent = NULL;
if (parent) {
if (parent->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) {
- T(YAFFS_TRACE_ALWAYS, (TSTR("Checkpoint read object %d parent %d type %d"
- TCONT(" chunk %d Parent type, %d, not directory")
- TENDSTR),
- cp->obj_id, cp->parent_id, cp->variant_type,
- cp->hdr_chunk, parent->variant_type));
+ T(YAFFS_TRACE_ALWAYS,
+ (TSTR
+ ("Checkpoint read object %d parent %d type %d"
+ TCONT(" chunk %d Parent type, %d, not directory")
+ TENDSTR), cp->obj_id, cp->parent_id,
+ cp->variant_type, cp->hdr_chunk,
+ parent->variant_type));
return 0;
}
yaffs_add_obj_to_dir(parent, obj);
return 1;
}
-
-
-static int yaffs2_checkpt_tnode_worker(struct yaffs_obj *in, struct yaffs_tnode *tn,
- u32 level, int chunk_offset)
+static int yaffs2_checkpt_tnode_worker(struct yaffs_obj *in,
+ struct yaffs_tnode *tn, u32 level,
+ int chunk_offset)
{
int i;
struct yaffs_dev *dev = in->my_dev;
for (i = 0; i < YAFFS_NTNODES_INTERNAL && ok; i++) {
if (tn->internal[i]) {
ok = yaffs2_checkpt_tnode_worker(in,
- tn->internal[i],
- level - 1,
- (chunk_offset<<YAFFS_TNODES_INTERNAL_BITS) + i);
+ tn->
+ internal
+ [i],
+ level -
+ 1,
+ (chunk_offset
+ <<
+ YAFFS_TNODES_INTERNAL_BITS)
+ + i);
}
}
} else if (level == 0) {
- u32 base_offset = chunk_offset << YAFFS_TNODES_LEVEL0_BITS;
- ok = (yaffs2_checkpt_wr(dev, &base_offset, sizeof(base_offset)) ==
- sizeof(base_offset));
+ u32 base_offset =
+ chunk_offset << YAFFS_TNODES_LEVEL0_BITS;
+ ok = (yaffs2_checkpt_wr
+ (dev, &base_offset,
+ sizeof(base_offset)) == sizeof(base_offset));
if (ok)
- ok = (yaffs2_checkpt_wr(dev, tn, dev->tnode_size) == dev->tnode_size);
+ ok = (yaffs2_checkpt_wr
+ (dev, tn,
+ dev->tnode_size) == dev->tnode_size);
}
}
if (obj->variant_type == YAFFS_OBJECT_TYPE_FILE) {
ok = yaffs2_checkpt_tnode_worker(obj,
- obj->variant.file_variant.top,
- obj->variant.file_variant.top_level,
- 0);
+ obj->variant.file_variant.top,
+ obj->variant.file_variant.
+ top_level, 0);
if (ok)
- ok = (yaffs2_checkpt_wr(obj->my_dev, &end_marker, sizeof(end_marker)) ==
- sizeof(end_marker));
+ ok = (yaffs2_checkpt_wr
+ (obj->my_dev, &end_marker,
+ sizeof(end_marker)) == sizeof(end_marker));
}
return ok ? 1 : 0;
struct yaffs_tnode *tn;
int nread = 0;
- ok = (yaffs2_checkpt_rd(dev, &base_chunk, sizeof(base_chunk)) == sizeof(base_chunk));
+ ok = (yaffs2_checkpt_rd(dev, &base_chunk, sizeof(base_chunk)) ==
+ sizeof(base_chunk));
while (ok && (~base_chunk)) {
nread++;
/* Read level 0 tnode */
-
tn = yaffs_get_tnode(dev);
- if (tn){
- ok = (yaffs2_checkpt_rd(dev, tn, dev->tnode_size) == dev->tnode_size);
- } else
+ if (tn) {
+ ok = (yaffs2_checkpt_rd(dev, tn, dev->tnode_size) ==
+ dev->tnode_size);
+ } else {
ok = 0;
+ }
if (tn && ok)
ok = yaffs_add_find_tnode_0(dev,
- file_stuct_ptr,
- base_chunk,
- tn) ? 1 : 0;
+ file_stuct_ptr,
+ base_chunk, tn) ? 1 : 0;
if (ok)
- ok = (yaffs2_checkpt_rd(dev, &base_chunk, sizeof(base_chunk)) == sizeof(base_chunk));
+ ok = (yaffs2_checkpt_rd
+ (dev, &base_chunk,
+ sizeof(base_chunk)) == sizeof(base_chunk));
}
- T(YAFFS_TRACE_CHECKPOINT, (
- TSTR("Checkpoint read tnodes %d records, last %d. ok %d" TENDSTR),
- nread, base_chunk, ok));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("Checkpoint read tnodes %d records, last %d. ok %d" TENDSTR),
+ nread, base_chunk, ok));
return ok ? 1 : 0;
}
-
static int yaffs2_wr_checkpt_objs(struct yaffs_dev *dev)
{
struct yaffs_obj *obj;
int ok = 1;
struct list_head *lh;
-
/* Iterate through the objects in each hash entry,
* dumping them to the checkpointing stream.
*/
- for (i = 0; ok && i < YAFFS_NOBJECT_BUCKETS; i++) {
+ for (i = 0; ok && i < YAFFS_NOBJECT_BUCKETS; i++) {
list_for_each(lh, &dev->obj_bucket[i].list) {
if (lh) {
- obj = list_entry(lh, struct yaffs_obj, hash_link);
+ obj =
+ list_entry(lh, struct yaffs_obj, hash_link);
if (!obj->defered_free) {
yaffs2_obj_checkpt_obj(&cp, obj);
cp.struct_type = sizeof(cp);
- T(YAFFS_TRACE_CHECKPOINT, (
- TSTR("Checkpoint write object %d parent %d type %d chunk %d obj addr %p" TENDSTR),
- cp.obj_id, cp.parent_id, cp.variant_type, cp.hdr_chunk, obj));
-
- ok = (yaffs2_checkpt_wr(dev, &cp, sizeof(cp)) == sizeof(cp));
-
- if (ok && obj->variant_type == YAFFS_OBJECT_TYPE_FILE)
- ok = yaffs2_wr_checkpt_tnodes(obj);
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR
+ ("Checkpoint write object %d parent %d type %d chunk %d obj addr %p"
+ TENDSTR), cp.obj_id, cp.parent_id,
+ cp.variant_type, cp.hdr_chunk, obj));
+
+ ok = (yaffs2_checkpt_wr
+ (dev, &cp,
+ sizeof(cp)) == sizeof(cp));
+
+ if (ok
+ && obj->variant_type ==
+ YAFFS_OBJECT_TYPE_FILE)
+ ok = yaffs2_wr_checkpt_tnodes
+ (obj);
}
}
}
while (ok && !done) {
ok = (yaffs2_checkpt_rd(dev, &cp, sizeof(cp)) == sizeof(cp));
if (cp.struct_type != sizeof(cp)) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("struct size %d instead of %d ok %d"TENDSTR),
- cp.struct_type, (int)sizeof(cp), ok));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("struct size %d instead of %d ok %d" TENDSTR),
+ cp.struct_type, (int)sizeof(cp), ok));
ok = 0;
}
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("Checkpoint read object %d parent %d type %d chunk %d " TENDSTR),
- cp.obj_id, cp.parent_id, cp.variant_type, cp.hdr_chunk));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR
+ ("Checkpoint read object %d parent %d type %d chunk %d "
+ TENDSTR), cp.obj_id, cp.parent_id, cp.variant_type,
+ cp.hdr_chunk));
- if (ok && cp.obj_id == ~0)
+ if (ok && cp.obj_id == ~0) {
done = 1;
- else if (ok) {
- obj = yaffs_find_or_create_by_number(dev, cp.obj_id, cp.variant_type);
+ } else if (ok) {
+ obj =
+ yaffs_find_or_create_by_number(dev, cp.obj_id,
+ cp.variant_type);
if (obj) {
ok = taffs2_checkpt_obj_to_obj(obj, &cp);
if (!ok)
break;
if (obj->variant_type == YAFFS_OBJECT_TYPE_FILE) {
ok = yaffs2_rd_checkpt_tnodes(obj);
- } else if (obj->variant_type == YAFFS_OBJECT_TYPE_HARDLINK) {
+ } else if (obj->variant_type ==
+ YAFFS_OBJECT_TYPE_HARDLINK) {
obj->hard_links.next =
- (struct list_head *) hard_list;
+ (struct list_head *)hard_list;
hard_list = obj;
}
- } else
+ } else {
ok = 0;
+ }
}
}
yaffs2_get_checkpt_sum(dev, &checkpt_sum);
- ok = (yaffs2_checkpt_wr(dev, &checkpt_sum, sizeof(checkpt_sum)) == sizeof(checkpt_sum));
+ ok = (yaffs2_checkpt_wr(dev, &checkpt_sum, sizeof(checkpt_sum)) ==
+ sizeof(checkpt_sum));
if (!ok)
return 0;
yaffs2_get_checkpt_sum(dev, &checkpt_sum0);
- ok = (yaffs2_checkpt_rd(dev, &checkpt_sum1, sizeof(checkpt_sum1)) == sizeof(checkpt_sum1));
+ ok = (yaffs2_checkpt_rd(dev, &checkpt_sum1, sizeof(checkpt_sum1)) ==
+ sizeof(checkpt_sum1));
if (!ok)
return 0;
return 1;
}
-
static int yaffs2_wr_checkpt_data(struct yaffs_dev *dev)
{
int ok = 1;
if (!yaffs2_checkpt_required(dev)) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("skipping checkpoint write" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("skipping checkpoint write" TENDSTR)));
ok = 0;
}
ok = yaffs2_checkpt_open(dev, 1);
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("write checkpoint validity" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("write checkpoint validity" TENDSTR)));
ok = yaffs2_wr_checkpt_validity_marker(dev, 1);
}
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("write checkpoint device" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("write checkpoint device" TENDSTR)));
ok = yaffs2_wr_checkpt_dev(dev);
}
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("write checkpoint objects" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("write checkpoint objects" TENDSTR)));
ok = yaffs2_wr_checkpt_objs(dev);
}
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("write checkpoint validity" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("write checkpoint validity" TENDSTR)));
ok = yaffs2_wr_checkpt_validity_marker(dev, 0);
}
static int yaffs2_rd_checkpt_data(struct yaffs_dev *dev)
{
int ok = 1;
-
- if(!dev->param.is_yaffs2)
+
+ if (!dev->param.is_yaffs2)
ok = 0;
if (ok && dev->param.skip_checkpt_rd) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("skipping checkpoint read" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("skipping checkpoint read" TENDSTR)));
ok = 0;
}
if (ok)
- ok = yaffs2_checkpt_open(dev, 0); /* open for read */
+ ok = yaffs2_checkpt_open(dev, 0); /* open for read */
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("read checkpoint validity" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("read checkpoint validity" TENDSTR)));
ok = yaffs2_rd_checkpt_validity_marker(dev, 1);
}
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("read checkpoint device" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("read checkpoint device" TENDSTR)));
ok = yaffs2_rd_checkpt_dev(dev);
}
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("read checkpoint objects" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("read checkpoint objects" TENDSTR)));
ok = yaffs2_rd_checkpt_objs(dev);
}
if (ok) {
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("read checkpoint validity" TENDSTR)));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("read checkpoint validity" TENDSTR)));
ok = yaffs2_rd_checkpt_validity_marker(dev, 0);
}
if (ok) {
ok = yaffs2_rd_checkpt_sum(dev);
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("read checkpoint checksum %d" TENDSTR), ok));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("read checkpoint checksum %d" TENDSTR), ok));
}
if (!yaffs_checkpt_close(dev))
void yaffs2_checkpt_invalidate(struct yaffs_dev *dev)
{
- if (dev->is_checkpointed ||
- dev->blocks_in_checkpt > 0) {
+ if (dev->is_checkpointed || dev->blocks_in_checkpt > 0) {
dev->is_checkpointed = 0;
yaffs2_checkpt_invalidate_stream(dev);
}
dev->param.sb_dirty_fn(dev);
}
-
int yaffs_checkpoint_save(struct yaffs_dev *dev)
{
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("save entry: is_checkpointed %d"TENDSTR), dev->is_checkpointed));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("save entry: is_checkpointed %d" TENDSTR),
+ dev->is_checkpointed));
yaffs_verify_objects(dev);
yaffs_verify_blocks(dev);
yaffs2_wr_checkpt_data(dev);
}
- T(YAFFS_TRACE_ALWAYS, (TSTR("save exit: is_checkpointed %d"TENDSTR), dev->is_checkpointed));
+ T(YAFFS_TRACE_CHECKPOINT | YAFFS_TRACE_MOUNT,
+ (TSTR("save exit: is_checkpointed %d" TENDSTR),
+ dev->is_checkpointed));
return dev->is_checkpointed;
}
int yaffs2_checkpt_restore(struct yaffs_dev *dev)
{
int retval;
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("restore entry: is_checkpointed %d"TENDSTR), dev->is_checkpointed));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("restore entry: is_checkpointed %d" TENDSTR),
+ dev->is_checkpointed));
retval = yaffs2_rd_checkpt_data(dev);
yaffs_verify_free_chunks(dev);
}
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("restore exit: is_checkpointed %d"TENDSTR), dev->is_checkpointed));
+ T(YAFFS_TRACE_CHECKPOINT,
+ (TSTR("restore exit: is_checkpointed %d" TENDSTR),
+ dev->is_checkpointed));
return retval;
}
* We're going to be writing a hole.
* If the hole is small then write zeros otherwise write a start of hole marker.
*/
-
loff_t old_file_size;
int increase;
- int small_hole ;
+ int small_hole;
int result = YAFFS_OK;
struct yaffs_dev *dev = NULL;
u8 *local_buffer = NULL;
-
+
int small_increase_ok = 0;
-
- if(!obj)
+
+ if (!obj)
return YAFFS_FAIL;
- if(obj->variant_type != YAFFS_OBJECT_TYPE_FILE)
+ if (obj->variant_type != YAFFS_OBJECT_TYPE_FILE)
return YAFFS_FAIL;
-
+
dev = obj->my_dev;
-
+
/* Bail out if not yaffs2 mode */
- if(!dev->param.is_yaffs2)
+ if (!dev->param.is_yaffs2)
return YAFFS_OK;
old_file_size = obj->variant.file_variant.file_size;
increase = new_size - old_file_size;
- if(increase < YAFFS_SMALL_HOLE_THRESHOLD * dev->data_bytes_per_chunk &&
- yaffs_check_alloc_available(dev, YAFFS_SMALL_HOLE_THRESHOLD + 1))
+ if (increase < YAFFS_SMALL_HOLE_THRESHOLD * dev->data_bytes_per_chunk &&
+ yaffs_check_alloc_available(dev, YAFFS_SMALL_HOLE_THRESHOLD + 1))
small_hole = 1;
else
small_hole = 0;
- if(small_hole)
- local_buffer= yaffs_get_temp_buffer(dev, __LINE__);
-
- if(local_buffer){
+ if (small_hole)
+ local_buffer = yaffs_get_temp_buffer(dev, __LINE__);
+
+ if (local_buffer) {
/* fill hole with zero bytes */
int pos = old_file_size;
int this_write;
int written;
- memset(local_buffer,0,dev->data_bytes_per_chunk);
+ memset(local_buffer, 0, dev->data_bytes_per_chunk);
small_increase_ok = 1;
- while(increase > 0 && small_increase_ok){
+ while (increase > 0 && small_increase_ok) {
this_write = increase;
- if(this_write > dev->data_bytes_per_chunk)
+ if (this_write > dev->data_bytes_per_chunk)
this_write = dev->data_bytes_per_chunk;
- written = yaffs_do_file_wr(obj,local_buffer,pos,this_write,0);
- if(written == this_write){
+ written =
+ yaffs_do_file_wr(obj, local_buffer, pos, this_write,
+ 0);
+ if (written == this_write) {
pos += this_write;
increase -= this_write;
- } else
+ } else {
small_increase_ok = 0;
+ }
}
- yaffs_release_temp_buffer(dev,local_buffer,__LINE__);
+ yaffs_release_temp_buffer(dev, local_buffer, __LINE__);
- /* If we were out of space then reverse any chunks we've added */
- if(!small_increase_ok)
+ /* If we were out of space then reverse any chunks we've added */
+ if (!small_increase_ok)
yaffs_resize_file_down(obj, old_file_size);
}
-
+
if (!small_increase_ok &&
- obj->parent &&
- obj->parent->obj_id != YAFFS_OBJECTID_UNLINKED &&
- obj->parent->obj_id != YAFFS_OBJECTID_DELETED){
+ obj->parent &&
+ obj->parent->obj_id != YAFFS_OBJECTID_UNLINKED &&
+ obj->parent->obj_id != YAFFS_OBJECTID_DELETED) {
/* Write a hole start header with the old file size */
yaffs_update_oh(obj, NULL, 0, 1, 0, NULL);
}
}
-
-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
int equiv_id;
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,
("yaffs2_scan_backwards starts intstartblk %d intendblk %d..."
TENDSTR), dev->internal_start_block, dev->internal_end_block));
-
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;
}
if (!block_index) {
T(YAFFS_TRACE_SCAN,
- (TSTR("yaffs2_scan_backwards() could not allocate block index!" TENDSTR)));
+ (TSTR
+ ("yaffs2_scan_backwards() could not allocate block index!"
+ TENDSTR)));
return YAFFS_FAIL;
}
/* Scan all the blocks to determine their state */
bi = dev->block_info;
- for (blk = dev->internal_start_block; blk <= dev->internal_end_block; blk++) {
+ for (blk = dev->internal_start_block; blk <= dev->internal_end_block;
+ blk++) {
yaffs_clear_chunk_bits(dev, blk);
bi->pages_in_use = 0;
bi->soft_del_pages = 0;
(TSTR("Block scanning block %d state %d seq %d" TENDSTR), blk,
state, seq_number));
-
if (state == YAFFS_BLOCK_STATE_CHECKPOINT) {
dev->blocks_in_checkpt++;
}
T(YAFFS_TRACE_SCAN,
- (TSTR("%d blocks to be sorted..." TENDSTR), n_to_scan));
-
-
+ (TSTR("%d blocks to be sorted..." TENDSTR), n_to_scan));
YYIELD();
- /* Sort the blocks by sequence number*/
- yaffs_qsort(block_index, n_to_scan, sizeof(yaffs_block_index), yaffs2_ybicmp);
+ /* Sort the blocks by sequence number */
+ yaffs_sort(block_index, n_to_scan, sizeof(struct yaffs_block_index),
+ yaffs2_ybicmp);
YYIELD();
/* For each block.... backwards */
for (block_iter = end_iter; !alloc_failed && block_iter >= start_iter;
- block_iter--) {
+ block_iter--) {
/* Cooperative multitasking! This loop can run for so
long that watchdog timers expire. */
YYIELD();
bi = yaffs_get_block_info(dev, blk);
-
state = bi->block_state;
deleted = 0;
chunk = blk * dev->param.chunks_per_block + c;
result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL,
- &tags);
+ &tags);
/* Let's have a good look at this chunk... */
state = YAFFS_BLOCK_STATE_EMPTY;
dev->n_erased_blocks++;
} else {
- if (state == YAFFS_BLOCK_STATE_NEEDS_SCANNING ||
- state == YAFFS_BLOCK_STATE_ALLOCATING) {
- if (dev->seq_number == bi->seq_number) {
+ if (state ==
+ YAFFS_BLOCK_STATE_NEEDS_SCANNING
+ || state ==
+ YAFFS_BLOCK_STATE_ALLOCATING) {
+ if (dev->seq_number ==
+ bi->seq_number) {
/* this is the block being allocated from */
T(YAFFS_TRACE_SCAN,
(" Allocating from %d %d"
TENDSTR), blk, c));
- state = YAFFS_BLOCK_STATE_ALLOCATING;
+ state =
+ YAFFS_BLOCK_STATE_ALLOCATING;
dev->alloc_block = blk;
dev->alloc_page = c;
- dev->alloc_block_finder = blk;
+ dev->
+ alloc_block_finder =
+ blk;
} else {
/* This is a partially written block that is not
* the current allocation block.
*/
- T(YAFFS_TRACE_SCAN,
- (TSTR("Partially written block %d detected" TENDSTR),
- blk));
+ T(YAFFS_TRACE_SCAN,
+ (TSTR
+ ("Partially written block %d detected"
+ TENDSTR), blk));
}
}
}
} else if (tags.ecc_result == YAFFS_ECC_RESULT_UNFIXED) {
T(YAFFS_TRACE_SCAN,
- (TSTR(" Unfixed ECC in chunk(%d:%d), chunk ignored"TENDSTR),
- blk, c));
+ (TSTR
+ (" Unfixed ECC in chunk(%d:%d), chunk ignored"
+ TENDSTR), blk, c));
- dev->n_free_chunks++;
+ dev->n_free_chunks++;
} else if (tags.obj_id > YAFFS_MAX_OBJECT_ID ||
- tags.chunk_id > YAFFS_MAX_CHUNK_ID ||
- (tags.chunk_id > 0 && tags.n_bytes > dev->data_bytes_per_chunk) ||
- tags.seq_number != bi->seq_number ) {
+ tags.chunk_id > YAFFS_MAX_CHUNK_ID ||
+ (tags.chunk_id > 0
+ && tags.n_bytes > dev->data_bytes_per_chunk)
+ || tags.seq_number != bi->seq_number) {
T(YAFFS_TRACE_SCAN,
- (TSTR("Chunk (%d:%d) with bad tags:obj = %d, chunk_id = %d, n_bytes = %d, ignored"TENDSTR),
- blk, c,tags.obj_id, tags.chunk_id, tags.n_bytes));
+ (TSTR
+ ("Chunk (%d:%d) with bad tags:obj = %d, chunk_id = %d, n_bytes = %d, ignored"
+ TENDSTR), blk, c, tags.obj_id,
+ tags.chunk_id, tags.n_bytes));
- dev->n_free_chunks++;
+ dev->n_free_chunks++;
} else if (tags.chunk_id > 0) {
/* chunk_id > 0 so it is a data chunk... */
unsigned int endpos;
u32 chunk_base =
- (tags.chunk_id - 1) * dev->data_bytes_per_chunk;
+ (tags.chunk_id -
+ 1) * dev->data_bytes_per_chunk;
found_chunks = 1;
-
yaffs_set_chunk_bit(dev, blk, c);
bi->pages_in_use++;
in = yaffs_find_or_create_by_number(dev,
- tags.
- obj_id,
- YAFFS_OBJECT_TYPE_FILE);
+ tags.obj_id,
+ YAFFS_OBJECT_TYPE_FILE);
if (!in) {
/* Out of memory */
alloc_failed = 1;
if (in &&
in->variant_type == YAFFS_OBJECT_TYPE_FILE
- && chunk_base < in->variant.file_variant.shrink_size) {
+ && chunk_base <
+ in->variant.file_variant.shrink_size) {
/* This has not been invalidated by a resize */
- if (!yaffs_put_chunk_in_file(in, tags.chunk_id, chunk, -1)) {
+ if (!yaffs_put_chunk_in_file
+ (in, tags.chunk_id, chunk, -1)) {
alloc_failed = 1;
}
endpos = chunk_base + tags.n_bytes;
if (!in->valid && /* have not got an object header yet */
- in->variant.file_variant.scanned_size < endpos) {
- in->variant.file_variant.scanned_size = endpos;
- in->variant.file_variant.file_size = endpos;
+ in->variant.file_variant.
+ scanned_size < endpos) {
+ in->variant.file_variant.
+ scanned_size = endpos;
+ in->variant.file_variant.
+ file_size = endpos;
}
} else if (in) {
/* This chunk has been invalidated by a resize, or a past file deletion
* so delete the chunk*/
- yaffs_chunk_del(dev, chunk, 1, __LINE__);
+ yaffs_chunk_del(dev, chunk, 1,
+ __LINE__);
}
} else {
if (tags.extra_available) {
in = yaffs_find_or_create_by_number(dev,
- tags.obj_id,
- tags.extra_obj_type);
+ tags.
+ obj_id,
+ tags.
+ extra_obj_type);
if (!in)
alloc_failed = 1;
}
if (!in ||
- (!in->valid && dev->param.disable_lazy_load) ||
- tags.extra_shadows ||
- (!in->valid &&
- (tags.obj_id == YAFFS_OBJECTID_ROOT ||
- tags.obj_id == YAFFS_OBJECTID_LOSTNFOUND))) {
+ (!in->valid && dev->param.disable_lazy_load)
+ || tags.extra_shadows || (!in->valid
+ && (tags.obj_id ==
+ YAFFS_OBJECTID_ROOT
+ || tags.
+ obj_id ==
+ YAFFS_OBJECTID_LOSTNFOUND)))
+ {
/* If we don't have valid info then we need to read the chunk
* TODO In future we can probably defer reading the chunk and
*/
result = yaffs_rd_chunk_tags_nand(dev,
- chunk,
- chunk_data,
- NULL);
+ chunk,
+ chunk_data,
+ NULL);
- oh = (struct yaffs_obj_hdr *) chunk_data;
+ oh = (struct yaffs_obj_hdr *)chunk_data;
if (dev->param.inband_tags) {
/* Fix up the header if they got corrupted by inband tags */
- oh->shadows_obj = oh->inband_shadowed_obj_id;
- oh->is_shrink = oh->inband_is_shrink;
+ oh->shadows_obj =
+ oh->inband_shadowed_obj_id;
+ oh->is_shrink =
+ oh->inband_is_shrink;
}
if (!in) {
* we first have to suck out resize info if it is a file.
*/
- if ((in->variant_type == YAFFS_OBJECT_TYPE_FILE) &&
- ((oh &&
- oh->type == YAFFS_OBJECT_TYPE_FILE) ||
- (tags.extra_available &&
- tags.extra_obj_type == YAFFS_OBJECT_TYPE_FILE))) {
+ if ((in->variant_type ==
+ YAFFS_OBJECT_TYPE_FILE) && ((oh
+ &&
+ oh->
+ type
+ ==
+ YAFFS_OBJECT_TYPE_FILE)
+ ||
+ (tags.
+ extra_available
+ &&
+ tags.
+ extra_obj_type
+ ==
+ YAFFS_OBJECT_TYPE_FILE)))
+ {
u32 this_size =
- (oh) ? oh->file_size : tags.
- extra_length;
- u32 parent_obj_id =
(oh) ? oh->
- parent_obj_id : tags.
- extra_parent_id;
-
+ file_size :
+ tags.extra_length;
+ u32 parent_obj_id =
+ (oh) ? oh->parent_obj_id :
+ tags.extra_parent_id;
is_shrink =
- (oh) ? oh->is_shrink : tags.
- extra_is_shrink;
+ (oh) ? oh->
+ is_shrink :
+ tags.extra_is_shrink;
/* If it is deleted (unlinked at start also means deleted)
* we treat the file size as being zeroed at this point.
is_shrink = 1;
}
- if (is_shrink && in->variant.file_variant.shrink_size > this_size)
- in->variant.file_variant.shrink_size = this_size;
+ if (is_shrink
+ && in->variant.file_variant.
+ shrink_size > this_size)
+ in->variant.
+ file_variant.
+ shrink_size =
+ this_size;
if (is_shrink)
bi->has_shrink_hdr = 1;
}
/* Use existing - destroy this one. */
- yaffs_chunk_del(dev, chunk, 1, __LINE__);
+ yaffs_chunk_del(dev, chunk, 1,
+ __LINE__);
}
if (!in->valid && in->variant_type !=
(oh ? oh->type : tags.extra_obj_type))
- T(YAFFS_TRACE_ERROR, (
- TSTR("yaffs tragedy: Bad object type, "
- TCONT("%d != %d, for object %d at chunk ")
+ T(YAFFS_TRACE_ERROR,
+ (TSTR
+ ("yaffs tragedy: Bad object type, "
+ TCONT
+ ("%d != %d, for object %d at chunk ")
TCONT("%d during scan")
- TENDSTR), oh ?
- oh->type : tags.extra_obj_type,
- in->variant_type, tags.obj_id,
- chunk));
+ TENDSTR), oh ?
+ oh->type : tags.extra_obj_type,
+ in->variant_type, tags.obj_id,
+ chunk));
if (!in->valid &&
(tags.obj_id == YAFFS_OBJECTID_ROOT ||
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
+ } else {
in->lazy_loaded = 1;
-
+ }
in->hdr_chunk = chunk;
} else if (!in->valid) {
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,
- oh->
- shadows_obj,
- 1);
-
-
+ yaffs_handle_shadowed_obj
+ (dev,
+ oh->shadows_obj,
+ 1);
- yaffs_set_obj_name_from_oh(in, oh);
+ yaffs_set_obj_name_from_oh(in,
+ oh);
parent =
yaffs_find_or_create_by_number
- (dev, oh->parent_obj_id,
- YAFFS_OBJECT_TYPE_DIRECTORY);
+ (dev, oh->parent_obj_id,
+ YAFFS_OBJECT_TYPE_DIRECTORY);
- file_size = oh->file_size;
- is_shrink = oh->is_shrink;
- equiv_id = oh->equiv_id;
+ file_size = oh->file_size;
+ is_shrink = oh->is_shrink;
+ equiv_id = oh->equiv_id;
} else {
- in->variant_type = tags.extra_obj_type;
+ in->variant_type =
+ tags.extra_obj_type;
parent =
yaffs_find_or_create_by_number
- (dev, tags.extra_parent_id,
- YAFFS_OBJECT_TYPE_DIRECTORY);
- file_size = tags.extra_length;
- is_shrink = tags.extra_is_shrink;
- equiv_id = tags.extra_equiv_id;
+ (dev, tags.extra_parent_id,
+ YAFFS_OBJECT_TYPE_DIRECTORY);
+ file_size = tags.extra_length;
+ is_shrink =
+ tags.extra_is_shrink;
+ equiv_id = tags.extra_equiv_id;
in->lazy_loaded = 1;
}
YAFFS_OBJECT_TYPE_UNKNOWN) {
/* Set up as a directory */
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;
+ 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
yaffs_add_obj_to_dir(parent, in);
- is_unlinked = (parent == dev->del_dir) ||
- (parent == dev->unlinked_dir);
+ is_unlinked = (parent == dev->del_dir)
+ || (parent == dev->unlinked_dir);
if (is_shrink) {
/* Mark the block as having a shrink header */
break;
case YAFFS_OBJECT_TYPE_FILE:
- if (in->variant.file_variant.
- scanned_size < file_size) {
+ if (in->variant.
+ file_variant.scanned_size <
+ file_size) {
/* This covers the case where the file size is greater
* than where the data is
* This will happen if the file is resized to be larger
* than its current data extents.
*/
- in->variant.file_variant.file_size = file_size;
- in->variant.file_variant.scanned_size = file_size;
+ in->variant.
+ file_variant.
+ file_size =
+ file_size;
+ in->variant.
+ file_variant.
+ scanned_size =
+ file_size;
}
- if (in->variant.file_variant.shrink_size > file_size)
- in->variant.file_variant.shrink_size = file_size;
-
+ if (in->variant.file_variant.
+ shrink_size > file_size)
+ in->variant.
+ file_variant.
+ shrink_size =
+ file_size;
break;
case YAFFS_OBJECT_TYPE_HARDLINK:
if (!is_unlinked) {
- in->variant.hardlink_variant.equiv_id =
- equiv_id;
+ in->variant.
+ hardlink_variant.
+ equiv_id = equiv_id;
in->hard_links.next =
- (struct list_head *) hard_list;
+ (struct list_head *)
+ hard_list;
hard_list = in;
}
break;
break;
case YAFFS_OBJECT_TYPE_SYMLINK:
if (oh) {
- in->variant.symlink_variant.alias =
- yaffs_clone_str(oh->alias);
- if (!in->variant.symlink_variant.alias)
- alloc_failed = 1;
+ in->variant.
+ symlink_variant.
+ alias =
+ yaffs_clone_str(oh->
+ alias);
+ if (!in->variant.
+ symlink_variant.
+ alias)
+ alloc_failed =
+ 1;
}
break;
}
}
- } /* End of scanning for each chunk */
+ } /* End of scanning for each chunk */
if (state == YAFFS_BLOCK_STATE_NEEDS_SCANNING) {
/* If we got this far while scanning, then the block is fully allocated. */
state = YAFFS_BLOCK_STATE_FULL;
}
-
bi->block_state = state;
/* Now let's see if it was dirty */
}
}
-
+
yaffs_skip_rest_of_block(dev);
if (alt_block_index)
*/
yaffs_link_fixup(dev, hard_list);
-
yaffs_release_temp_buffer(dev, chunk_data, __LINE__);
if (alloc_failed)