static void yaffs_handle_chunk_wr_error(yaffs_dev_t *dev, int nand_chunk,
int erased_ok);
static void yaffs_handle_chunk_wr_ok(yaffs_dev_t *dev, int nand_chunk,
- const __u8 *data,
+ const u8 *data,
const yaffs_ext_tags *tags);
static void yaffs_handle_chunk_update(yaffs_dev_t *dev, int nand_chunk,
const yaffs_ext_tags *tags);
static int yaffs_obj_cache_dirty(yaffs_obj_t *obj);
static int yaffs_write_new_chunk(yaffs_dev_t *dev,
- const __u8 *buffer,
+ const u8 *buffer,
yaffs_ext_tags *tags,
int use_reserver);
static int yaffs_verify_chunk_written(yaffs_dev_t *dev,
int nand_chunk,
- const __u8 *data,
+ const u8 *data,
yaffs_ext_tags *tags);
/* Function to calculate chunk and offset */
static void yaffs_addr_to_chunk(yaffs_dev_t *dev, loff_t addr, int *chunk_out,
- __u32 *offset_out)
+ u32 *offset_out)
{
int chunk;
- __u32 offset;
+ u32 offset;
- chunk = (__u32)(addr >> dev->chunk_shift);
+ chunk = (u32)(addr >> dev->chunk_shift);
if (dev->chunk_div == 1) {
/* easy power of 2 case */
- offset = (__u32)(addr & dev->chunk_mask);
+ offset = (u32)(addr & dev->chunk_mask);
} else {
/* Non power-of-2 case */
chunk /= dev->chunk_div;
chunk_base = ((loff_t)chunk) * dev->data_bytes_per_chunk;
- offset = (__u32)(addr - chunk_base);
+ offset = (u32)(addr - chunk_base);
}
*chunk_out = chunk;
* be hellishly efficient.
*/
-static __u32 calc_shifts_ceiling(__u32 x)
+static u32 calc_shifts_ceiling(u32 x)
{
int extra_bits;
int shifts;
/* Function to return the number of shifts to get a 1 in bit 0
*/
-static __u32 calc_shifts(__u32 x)
+static u32 calc_shifts(u32 x)
{
- __u32 shifts;
+ u32 shifts;
shifts = 0;
static int yaffs_init_tmp_buffers(yaffs_dev_t *dev)
{
int i;
- __u8 *buf = (__u8 *)1;
+ u8 *buf = (u8 *)1;
memset(dev->temp_buffer, 0, sizeof(dev->temp_buffer));
return buf ? YAFFS_OK : YAFFS_FAIL;
}
-__u8 *yaffs_get_temp_buffer(yaffs_dev_t *dev, int line_no)
+u8 *yaffs_get_temp_buffer(yaffs_dev_t *dev, int line_no)
{
int i, j;
}
-void yaffs_release_temp_buffer(yaffs_dev_t *dev, __u8 *buffer,
+void yaffs_release_temp_buffer(yaffs_dev_t *dev, u8 *buffer,
int line_no)
{
int i;
/*
* Determine if we have a managed buffer.
*/
-int yaffs_is_managed_tmp_buffer(yaffs_dev_t *dev, const __u8 *buffer)
+int yaffs_is_managed_tmp_buffer(yaffs_dev_t *dev, const u8 *buffer)
{
int i;
* Erased NAND checking functions
*/
-int yaffs_check_ff(__u8 *buffer, int n_bytes)
+int yaffs_check_ff(u8 *buffer, int n_bytes)
{
/* Horrible, slow implementation */
while (n_bytes--) {
int nand_chunk)
{
int retval = YAFFS_OK;
- __u8 *data = yaffs_get_temp_buffer(dev, __LINE__);
+ u8 *data = yaffs_get_temp_buffer(dev, __LINE__);
yaffs_ext_tags tags;
int result;
static int yaffs_verify_chunk_written(yaffs_dev_t *dev,
int nand_chunk,
- const __u8 *data,
+ const u8 *data,
yaffs_ext_tags *tags)
{
int retval = YAFFS_OK;
yaffs_ext_tags temp_tags;
- __u8 *buffer = yaffs_get_temp_buffer(dev,__LINE__);
+ u8 *buffer = yaffs_get_temp_buffer(dev,__LINE__);
int result;
result = yaffs_rd_chunk_tags_nand(dev,nand_chunk,buffer,&temp_tags);
}
static int yaffs_write_new_chunk(struct yaffs_dev_s *dev,
- const __u8 *data,
+ const u8 *data,
yaffs_ext_tags *tags,
int use_reserver)
{
yaffs_ext_tags tags;
int chunk_id = flash_block * dev->param.chunks_per_block;
- __u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
+ u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
memset(buffer, 0xff, dev->data_bytes_per_chunk);
yaffs_init_tags(&tags);
*/
static void yaffs_handle_chunk_wr_ok(yaffs_dev_t *dev, int nand_chunk,
- const __u8 *data,
+ const u8 *data,
const yaffs_ext_tags *tags)
{
dev=dev;
/*---------------- Name handling functions ------------*/
-static __u16 yaffs_calc_name_sum(const YCHAR *name)
+static u16 yaffs_calc_name_sum(const YCHAR *name)
{
- __u16 sum = 0;
- __u16 i = 1;
+ u16 sum = 0;
+ u16 i = 1;
const YUCHAR *bname = (const YUCHAR *) name;
if (bname) {
while ((*bname) && (i < (YAFFS_MAX_NAME_LENGTH/2))) {
-#ifdef CONFIG_YAFFS_CASE_INSENSITIVE
- sum += yaffs_toupper(*bname) * i;
-#else
- sum += (*bname) * i;
-#endif
+ /* 0x1f mask is case insensitive */
+ sum += ((*bname) & 0x1f) * i;
i++;
bname++;
}
void yaffs_load_tnode_0(yaffs_dev_t *dev, yaffs_tnode_t *tn, unsigned pos,
unsigned val)
{
- __u32 *map = (__u32 *)tn;
- __u32 bit_in_map;
- __u32 bit_in_word;
- __u32 word_in_map;
- __u32 mask;
+ u32 *map = (u32 *)tn;
+ u32 bit_in_map;
+ u32 bit_in_word;
+ u32 word_in_map;
+ u32 mask;
pos &= YAFFS_TNODES_LEVEL0_MASK;
val >>= dev->chunk_grp_bits;
}
}
-__u32 yaffs_get_group_base(yaffs_dev_t *dev, yaffs_tnode_t *tn,
+u32 yaffs_get_group_base(yaffs_dev_t *dev, yaffs_tnode_t *tn,
unsigned pos)
{
- __u32 *map = (__u32 *)tn;
- __u32 bit_in_map;
- __u32 bit_in_word;
- __u32 word_in_map;
- __u32 val;
+ u32 *map = (u32 *)tn;
+ u32 bit_in_map;
+ u32 bit_in_word;
+ u32 word_in_map;
+ u32 val;
pos &= YAFFS_TNODES_LEVEL0_MASK;
/* FindLevel0Tnode finds the level 0 tnode, if one exists. */
yaffs_tnode_t *yaffs_find_tnode_0(yaffs_dev_t *dev,
yaffs_file_s *file_struct,
- __u32 chunk_id)
+ u32 chunk_id)
{
yaffs_tnode_t *tn = file_struct->top;
- __u32 i;
+ u32 i;
int required_depth;
int level = file_struct->top_level;
yaffs_tnode_t *yaffs_add_find_tnode_0(yaffs_dev_t *dev,
yaffs_file_s *file_struct,
- __u32 chunk_id,
+ u32 chunk_id,
yaffs_tnode_t *passed_tn)
{
int required_depth;
int l;
yaffs_tnode_t *tn;
- __u32 x;
+ u32 x;
/* Check sane level and page Id */
return -1;
}
-#if 0
-/* Experimental code not being used yet. Might speed up file deletion */
-/* DeleteWorker scans backwards through the tnode tree and deletes all the
- * chunks and tnodes in the file.
- * Returns 1 if the tree was deleted.
- * Returns 0 if it stopped early due to hitting the limit and the delete is incomplete.
- */
-
-static int yaffs_del_worker(yaffs_obj_t *in, yaffs_tnode_t *tn, __u32 level,
- int chunk_offset, int *limit)
-{
- int i;
- int inode_chunk;
- int the_chunk;
- yaffs_ext_tags tags;
- int found_chunk;
- yaffs_dev_t *dev = in->my_dev;
-
- int all_done = 1;
-
- if (tn) {
- if (level > 0) {
- for (i = YAFFS_NTNODES_INTERNAL - 1; all_done && i >= 0;
- i--) {
- if (tn->internal[i]) {
- if (limit && (*limit) < 0) {
- all_done = 0;
- } else {
- all_done =
- yaffs_del_worker(in,
- tn->
- internal
- [i],
- level -
- 1,
- (chunk_offset
- <<
- YAFFS_TNODES_INTERNAL_BITS)
- + i,
- limit);
- }
- if (all_done) {
- yaffs_free_tnode(dev,
- tn->
- internal[i]);
- tn->internal[i] = NULL;
- }
- }
- }
- return (all_done) ? 1 : 0;
- } else if (level == 0) {
- int hit_limit = 0;
-
- for (i = YAFFS_NTNODES_LEVEL0 - 1; i >= 0 && !hit_limit;
- i--) {
- the_chunk = yaffs_get_group_base(dev, tn, i);
- if (the_chunk) {
-
- inode_chunk = (chunk_offset <<
- YAFFS_TNODES_LEVEL0_BITS) + i;
-
- found_chunk =
- yaffs_find_chunk_in_group(dev,
- the_chunk,
- &tags,
- in->obj_id,
- inode_chunk);
-
- if (found_chunk > 0) {
- yaffs_chunk_del(dev,
- found_chunk, 1,
- __LINE__);
- in->n_data_chunks--;
- if (limit) {
- *limit = *limit - 1;
- if (*limit <= 0)
- hit_limit = 1;
- }
-
- }
-
- yaffs_load_tnode_0(dev, tn, i, 0);
- }
-
- }
- return (i < 0) ? 1 : 0;
-
- }
-
- }
-
- return 1;
-
-}
-
-#endif
static void yaffs_soft_del_chunk(yaffs_dev_t *dev, int chunk)
{
*/
static int yaffs_soft_del_worker(yaffs_obj_t *in, yaffs_tnode_t *tn,
- __u32 level, int chunk_offset)
+ u32 level, int chunk_offset)
{
int i;
int the_chunk;
*/
static yaffs_tnode_t *yaffs_prune_worker(yaffs_dev_t *dev, yaffs_tnode_t *tn,
- __u32 level, int del0)
+ u32 level, int del0)
{
int i;
int has_data;
has_data++;
}
} else {
- int tnode_size_u32 = dev->tnode_size/sizeof(__u32);
- __u32 *map = (__u32 *)tn;
+ int tnode_size_u32 = dev->tnode_size/sizeof(u32);
+ u32 *map = (u32 *)tn;
for(i = 0; !has_data && i < tnode_size_u32; i++){
if(map[i])
}
static yaffs_obj_t *yaffs_create_fake_dir(yaffs_dev_t *dev, int number,
- __u32 mode)
+ u32 mode)
{
yaffs_obj_t *obj =
int found = 0;
struct ylist_head *i;
- __u32 n = (__u32) bucket;
+ u32 n = (u32) bucket;
/* yaffs_check_obj_hash_sane(); */
dev->obj_bucket[bucket].count++;
}
-yaffs_obj_t *yaffs_find_by_number(yaffs_dev_t *dev, __u32 number)
+yaffs_obj_t *yaffs_find_by_number(yaffs_dev_t *dev, u32 number)
{
int bucket = yaffs_hash_fn(number);
struct ylist_head *i;
case YAFFS_OBJECT_TYPE_FILE:
the_obj->variant.file_variant.file_size = 0;
the_obj->variant.file_variant.scanned_size = 0;
- the_obj->variant.file_variant.shrink_size = 0xFFFFFFFF; /* max __u32 */
+ the_obj->variant.file_variant.shrink_size = 0xFFFFFFFF; /* max u32 */
the_obj->variant.file_variant.top_level = 0;
the_obj->variant.file_variant.top = tn;
break;
static yaffs_obj_t *yaffs_create_obj(yaffs_obj_type type,
yaffs_obj_t *parent,
const YCHAR *name,
- __u32 mode,
- __u32 uid,
- __u32 gid,
+ u32 mode,
+ u32 uid,
+ u32 gid,
yaffs_obj_t *equiv_obj,
- const YCHAR *alias_str, __u32 rdev)
+ const YCHAR *alias_str, u32 rdev)
{
yaffs_obj_t *in;
YCHAR *str = NULL;
}
yaffs_obj_t *yaffs_create_file(yaffs_obj_t *parent, const YCHAR *name,
- __u32 mode, __u32 uid, __u32 gid)
+ u32 mode, u32 uid, u32 gid)
{
return yaffs_create_obj(YAFFS_OBJECT_TYPE_FILE, parent, name, mode,
uid, gid, NULL, NULL, 0);
}
yaffs_obj_t *yaffs_create_dir(yaffs_obj_t *parent, const YCHAR *name,
- __u32 mode, __u32 uid, __u32 gid)
+ u32 mode, u32 uid, u32 gid)
{
return yaffs_create_obj(YAFFS_OBJECT_TYPE_DIRECTORY, parent, name,
mode, uid, gid, NULL, NULL, 0);
}
yaffs_obj_t *yaffs_create_special(yaffs_obj_t *parent, const YCHAR *name,
- __u32 mode, __u32 uid, __u32 gid, __u32 rdev)
+ u32 mode, u32 uid, u32 gid, u32 rdev)
{
return yaffs_create_obj(YAFFS_OBJECT_TYPE_SPECIAL, parent, name, mode,
uid, gid, NULL, NULL, rdev);
}
yaffs_obj_t *yaffs_create_symlink(yaffs_obj_t *parent, const YCHAR *name,
- __u32 mode, __u32 uid, __u32 gid,
+ u32 mode, u32 uid, u32 gid,
const YCHAR *alias)
{
return yaffs_create_obj(YAFFS_OBJECT_TYPE_SYMLINK, parent, name, mode,
yaffs_block_became_dirty(dev, block);
} else {
- __u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
+ u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
yaffs_verify_blk(dev, bi, block);
yaffs_verify_oh(object, oh, &tags, 1);
new_chunk =
- yaffs_write_new_chunk(dev,(__u8 *) oh, &tags, 1);
+ yaffs_write_new_chunk(dev,(u8 *) oh, &tags, 1);
} else
new_chunk =
yaffs_write_new_chunk(dev, buffer, &tags, 1);
}
static int yaffs_rd_data_obj(yaffs_obj_t *in, int inode_chunk,
- __u8 *buffer)
+ u8 *buffer)
{
int nand_chunk = yaffs_find_chunk_in_file(in, inode_chunk, NULL);
}
static int yaffs_wr_data_obj(yaffs_obj_t *in, int inode_chunk,
- const __u8 *buffer, int n_bytes,
+ const u8 *buffer, int n_bytes,
int use_reserve)
{
/* Find old chunk Need to do this to get serial number
yaffs_ext_tags old_tags;
const YCHAR *alias = NULL;
- __u8 *buffer = NULL;
+ u8 *buffer = NULL;
YCHAR old_name[YAFFS_MAX_NAME_LENGTH + 1];
yaffs_obj_header *oh = NULL;
* Curve-balls: the first chunk might also be the last chunk.
*/
-int yaffs_file_rd(yaffs_obj_t *in, __u8 *buffer, loff_t offset,
+int yaffs_file_rd(yaffs_obj_t *in, u8 *buffer, loff_t offset,
int n_bytes)
{
int chunk;
- __u32 start;
+ u32 start;
int n_copy;
int n = n_bytes;
int n_done = 0;
} else {
/* Read into the local buffer then copy..*/
- __u8 *local_buffer =
+ u8 *local_buffer =
yaffs_get_temp_buffer(dev, __LINE__);
yaffs_rd_data_obj(in, chunk,
local_buffer);
return n_done;
}
-int yaffs_do_file_wr(yaffs_obj_t *in, const __u8 *buffer, loff_t offset,
+int yaffs_do_file_wr(yaffs_obj_t *in, const u8 *buffer, loff_t offset,
int n_bytes, int write_trhrough)
{
int chunk;
- __u32 start;
+ u32 start;
int n_copy;
int n = n_bytes;
int n_done = 0;
int n_writeback;
int start_write = offset;
int chunk_written = 0;
- __u32 n_bytes_read;
- __u32 chunk_start;
+ u32 n_bytes_read;
+ u32 chunk_start;
yaffs_dev_t *dev;
* Read into the local buffer then copy, then copy over and write back.
*/
- __u8 *local_buffer =
+ u8 *local_buffer =
yaffs_get_temp_buffer(dev, __LINE__);
yaffs_rd_data_obj(in, chunk,
return n_done;
}
-int yaffs_wr_file(yaffs_obj_t *in, const __u8 *buffer, loff_t offset,
+int yaffs_wr_file(yaffs_obj_t *in, const u8 *buffer, loff_t offset,
int n_bytes, int write_trhrough)
{
yaffs2_handle_hole(in,offset);
void yaffs_resize_file_down( yaffs_obj_t *obj, loff_t new_size)
{
int new_full;
- __u32 new_partial;
+ u32 new_partial;
yaffs_dev_t *dev = obj->my_dev;
yaffs_addr_to_chunk(dev, new_size, &new_full, &new_partial);
if (new_partial != 0) {
int last_chunk = 1 + new_full;
- __u8 *local_buffer = yaffs_get_temp_buffer(dev, __LINE__);
+ u8 *local_buffer = yaffs_get_temp_buffer(dev, __LINE__);
/* Got to read and rewrite the last chunk with its new size and zero pad */
yaffs_rd_data_obj(obj, last_chunk, local_buffer);
static void yaffs_check_obj_details_loaded(yaffs_obj_t *in)
{
- __u8 *chunk_data;
+ u8 *chunk_data;
yaffs_obj_header *oh;
yaffs_dev_t *dev;
yaffs_ext_tags tags;
dev = in->my_dev;
-#if 0
- T(YAFFS_TRACE_SCAN, (TSTR("details for object %d %s loaded" TENDSTR),
- in->obj_id,
- in->lazy_loaded ? "not yet" : "already"));
-#endif
-
if (in->lazy_loaded && in->hdr_chunk > 0) {
in->lazy_loaded = 0;
chunk_data = yaffs_get_temp_buffer(dev, __LINE__);
}
-#if 0
-int yaffs_ApplyToDirectoryChildren(yaffs_obj_t *the_dir,
- int (*fn) (yaffs_obj_t *))
-{
- struct ylist_head *i;
- yaffs_obj_t *l;
-
- if (!the_dir) {
- T(YAFFS_TRACE_ALWAYS,
- (TSTR
- ("tragedy: yaffs_find_by_name: null pointer directory"
- TENDSTR)));
- YBUG();
- return YAFFS_FAIL;
- }
- if (the_dir->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) {
- T(YAFFS_TRACE_ALWAYS,
- (TSTR
- ("tragedy: yaffs_find_by_name: non-directory" TENDSTR)));
- YBUG();
- return YAFFS_FAIL;
- }
-
- ylist_for_each(i, &the_dir->variant.dir_variant.children) {
- if (i) {
- l = ylist_entry(i, yaffs_obj_t, siblings);
- if (l && !fn(l))
- return YAFFS_FAIL;
- }
- }
-
- return YAFFS_OK;
-
-}
-#endif
-
/* GetEquivalentObject dereferences any hard links to get to the
* actual object.
*/
#endif
else if(obj->hdr_chunk > 0) {
int result;
- __u8 *buffer = yaffs_get_temp_buffer(obj->my_dev, __LINE__);
+ u8 *buffer = yaffs_get_temp_buffer(obj->my_dev, __LINE__);
yaffs_obj_header *oh = (yaffs_obj_header *) buffer;
if(!buffer)
return -ENOMEM;
- result = yaffs_rd_chunk_tags_nand(dev,obj->hdr_chunk, (__u8 *)buffer, &tags);
+ result = yaffs_rd_chunk_tags_nand(dev,obj->hdr_chunk, (u8 *)buffer, &tags);
if(result != YAFFS_OK)
retval = -ENOENT;
else
retval = nval_list(x_buffer, x_size, value,size);
}
- yaffs_release_temp_buffer(dev,(__u8 *)buffer,__LINE__);
+ yaffs_release_temp_buffer(dev,(u8 *)buffer,__LINE__);
return retval;
}
return yaffs_do_xattrib_fetch(obj, NULL, buffer,size);
}
-
-
-#if 0
-int yaffs_dump_obj(yaffs_obj_t *obj)
-{
- YCHAR name[257];
-
- yaffs_get_obj_name(obj, name, YAFFS_MAX_NAME_LENGTH + 1);
-
- T(YAFFS_TRACE_ALWAYS,
- (TSTR
- ("Object %d, inode %d \"%s\"\n dirty %d valid %d serial %d sum %d"
- " chunk %d type %d size %d\n"
- TENDSTR), obj->obj_id, yaffs_get_obj_inode(obj), name,
- obj->dirty, obj->valid, obj->serial, obj->sum, obj->hdr_chunk,
- yaffs_get_obj_type(obj), yaffs_get_obj_length(obj)));
-
- return YAFFS_OK;
-}
-#endif
-
/*---------------------------- Initialisation code -------------------------------------- */
-static int yaffs_cehck_dev_fns(const yaffs_dev_t *dev)
+static int yaffs_check_dev_fns(const yaffs_dev_t *dev)
{
/* Common functions, gotta have */
dev->data_bytes_per_chunk = dev->param.total_bytes_per_chunk;
/* Got the right mix of functions? */
- if (!yaffs_cehck_dev_fns(dev)) {
+ if (!yaffs_check_dev_fns(dev)) {
/* Function missing */
T(YAFFS_TRACE_ALWAYS,
(TSTR
dev->cache = YMALLOC(cache_bytes);
- buf = (__u8 *) dev->cache;
+ buf = (u8 *) dev->cache;
if (dev->cache)
memset(dev->cache, 0, cache_bytes);
dev->cache_hits = 0;
if (!init_failed) {
- dev->gc_cleanup_list = YMALLOC(dev->param.chunks_per_block * sizeof(__u32));
+ dev->gc_cleanup_list = YMALLOC(dev->param.chunks_per_block * sizeof(u32));
if (!dev->gc_cleanup_list)
init_failed = 1;
}
int blocks_for_checkpt;
int i;
-#if 1
n_free = dev->n_free_chunks;
-#else
- n_free = yaffs_count_free_chunks(dev);
-#endif
-
n_free += dev->n_deleted_files;
/* Now count the number of dirty chunks in the cache and subtract those */