X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_guts.c;h=8acb59ba655bae1b3029c037e14acc1dd4e70a03;hp=ae37c3fe1c140a844360d7bcd10496fab676ed6b;hb=1658295946bc589b4d351e75a59bd697630cd9e1;hpb=a7ae50c6ee8de56afbdae3176a355da54f45b21a diff --git a/yaffs_guts.c b/yaffs_guts.c index ae37c3f..8acb59b 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -280,7 +280,8 @@ static void yaffs_handle_chunk_wr_error(struct yaffs_dev *dev, int nand_chunk, static inline int yaffs_hash_fn(int n) { - n = abs(n); + if(n < 0) + n = -n; return n % YAFFS_NOBJECT_BUCKETS; } @@ -3687,17 +3688,26 @@ int yaffs_wr_file(struct yaffs_obj *in, const u8 *buffer, loff_t offset, /* ---------------------- File resizing stuff ------------------ */ -static void yaffs_prune_chunks(struct yaffs_obj *in, int new_size) +static void yaffs_prune_chunks(struct yaffs_obj *in, loff_t new_size) { struct yaffs_dev *dev = in->my_dev; - int old_size = in->variant.file_variant.file_size; + loff_t old_size = in->variant.file_variant.file_size; int i; int chunk_id; - int last_del = 1 + (old_size - 1) / dev->data_bytes_per_chunk; - int start_del = 1 + (new_size + dev->data_bytes_per_chunk - 1) / - dev->data_bytes_per_chunk; + u32 dummy; + int last_del; + int start_del; + + if(old_size > 0) + yaffs_addr_to_chunk(dev, old_size - 1, &last_del, &dummy); + else + last_del = 0; + yaffs_addr_to_chunk(dev, new_size + dev->data_bytes_per_chunk - 1, + &start_del, &dummy); + last_del++; + start_del++; /* Delete backwards so that we don't end up with holes if * power is lost part-way through the operation.