X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_guts.h;h=fe6e934497caf7bd710aba715d40586ee1565ff3;hp=4e4e6b17fd5cd77ff3ca05a5aaf3c9f4ba4792b7;hb=a8016f937633b0d356be4d2195d93f1742a3de0d;hpb=976dbeae825b18e6759f3903073a6784248cc244 diff --git a/yaffs_guts.h b/yaffs_guts.h index 4e4e6b1..fe6e934 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -17,8 +17,6 @@ #define __YAFFS_GUTS_H__ #include "yportenv.h" -#include "devextras.h" -#include "yaffs_list.h" #define YAFFS_OK 1 #define YAFFS_FAIL 0 @@ -112,7 +110,7 @@ #define YAFFS_SEQUENCE_BAD_BLOCK 0xFFFF0000 /* ChunkCache is used for short read/write operations.*/ -typedef struct { +struct yaffs_cache { struct yaffs_obj *object; int chunk_id; int last_use; @@ -120,7 +118,7 @@ typedef struct { int n_bytes; /* Only valid if the cache is dirty */ int locked; /* Can't push out or flush while locked. */ u8 *data; -} yaffs_cache_t; +} ; @@ -139,21 +137,21 @@ struct yaffs_tags { unsigned n_bytes_msb:2; }; -typedef union { +union yaffs_tags_union{ struct yaffs_tags as_tags; u8 as_bytes[8]; -} yaffs_tags_union_t; +} ; #endif /* Stuff used for extended tags in YAFFS2 */ -typedef enum { +enum yaffs_ecc_result { YAFFS_ECC_RESULT_UNKNOWN, YAFFS_ECC_RESULT_NO_ERROR, YAFFS_ECC_RESULT_FIXED, YAFFS_ECC_RESULT_UNFIXED -} yaffs_ecc_result; +} ; enum yaffs_obj_type { YAFFS_OBJECT_TYPE_UNKNOWN, @@ -168,14 +166,14 @@ enum yaffs_obj_type { struct yaffs_ext_tags{ - unsigned validity1; + unsigned validity0; unsigned chunk_used; /* Status of the chunk: used or unused */ unsigned obj_id; /* If 0 then this is not part of an object (unused) */ unsigned chunk_id; /* If 0 then this is a header, else a data chunk */ unsigned n_bytes; /* Only valid for data chunks */ /* The following stuff only has meaning when we read */ - yaffs_ecc_result ecc_result; + enum yaffs_ecc_result ecc_result; unsigned block_bad; /* YAFFS 1 stuff */ @@ -197,12 +195,12 @@ struct yaffs_ext_tags{ unsigned extra_length; /* Length if it is a file */ unsigned extra_equiv_id; /* Equivalent object Id if it is a hard link */ - unsigned validty1; + unsigned validity1; }; /* Spare structure for YAFFS1 */ -typedef struct { +struct yaffs_spare{ u8 tb0; u8 tb1; u8 tb2; @@ -215,18 +213,18 @@ typedef struct { u8 tb6; u8 tb7; u8 ecc2[3]; -} yaffs_spare; +} ; /*Special structure for passing through to mtd */ struct yaffs_nand_spare { - yaffs_spare spare; + struct yaffs_spare spare; int eccres1; int eccres2; }; /* Block data in RAM */ -typedef enum { +enum yaffs_block_state{ YAFFS_BLOCK_STATE_UNKNOWN = 0, YAFFS_BLOCK_STATE_SCANNING, @@ -270,12 +268,12 @@ typedef enum { YAFFS_BLOCK_STATE_DEAD /* This block has failed and is not in use */ -} yaffs_block_state_t; +}; #define YAFFS_NUMBER_OF_BLOCK_STATES (YAFFS_BLOCK_STATE_DEAD + 1) -typedef struct { +struct yaffs_block_info{ int soft_del_pages:10; /* number of soft deleted pages */ int pages_in_use:10; /* number of pages in use */ @@ -292,7 +290,7 @@ typedef struct { u32 seq_number; /* block sequence number for yaffs2 */ #endif -} yaffs_block_info_t; +} ; /* -------------------------- Object structure -------------------------------*/ /* This is the object structure as stored on NAND */ @@ -308,15 +306,11 @@ struct yaffs_obj_hdr { /* The following apply to directories, files, symlinks - not hard links */ u32 yst_mode; /* protection */ -#ifdef CONFIG_YAFFS_WINCE - u32 not_for_wince[5]; -#else u32 yst_uid; u32 yst_gid; u32 yst_atime; u32 yst_mtime; u32 yst_ctime; -#endif /* File size applies to files only */ int file_size; @@ -329,14 +323,10 @@ struct yaffs_obj_hdr { u32 yst_rdev; /* device stuff for block and char devices (major/min) */ -#ifdef CONFIG_YAFFS_WINCE u32 win_ctime[2]; u32 win_atime[2]; u32 win_mtime[2]; -#else - u32 room_to_grow[6]; -#endif u32 inband_shadowed_obj_id; u32 inband_is_shrink; @@ -350,12 +340,10 @@ struct yaffs_obj_hdr { /*--------------------------- Tnode -------------------------- */ -union yaffs_tnode_union { - union yaffs_tnode_union *internal[YAFFS_NTNODES_INTERNAL]; - +struct yaffs_tnode { + struct yaffs_tnode *internal[YAFFS_NTNODES_INTERNAL]; }; -typedef union yaffs_tnode_union yaffs_tnode_t; /*------------------------ Object -----------------------------*/ @@ -366,34 +354,34 @@ typedef union yaffs_tnode_union yaffs_tnode_t; * - a hard link */ -typedef struct { +struct yaffs_file_var { u32 file_size; u32 scanned_size; u32 shrink_size; int top_level; - yaffs_tnode_t *top; -} yaffs_file_s; + struct yaffs_tnode *top; +} ; -typedef struct { - struct ylist_head children; /* list of child links */ - struct ylist_head dirty; /* Entry for list of dirty directories */ -} yaffs_dir_s; +struct yaffs_dir_var{ + struct list_head children; /* list of child links */ + struct list_head dirty; /* Entry for list of dirty directories */ +}; -typedef struct { +struct yaffs_symlink_var{ YCHAR *alias; -} yaffs_symlink_t; +}; -typedef struct { +struct yaffs_hardlink_var{ struct yaffs_obj *equiv_obj; u32 equiv_id; -} yaffs_hard_link_s; +}; -typedef union { - yaffs_file_s file_variant; - yaffs_dir_s dir_variant; - yaffs_symlink_t symlink_variant; - yaffs_hard_link_s hardlink_variant; -} yaffs_obj_variant; +union yaffs_obj_var{ + struct yaffs_file_var file_variant; + struct yaffs_dir_var dir_variant; + struct yaffs_symlink_var symlink_variant; + struct yaffs_hardlink_var hardlink_variant; +}; @@ -426,14 +414,14 @@ struct yaffs_obj { struct yaffs_dev *my_dev; /* The device I'm on */ - struct ylist_head hash_link; /* list of objects in this hash bucket */ + struct list_head hash_link; /* list of objects in this hash bucket */ - struct ylist_head hard_links; /* all the equivalent hard linked objects */ + struct list_head hard_links; /* all the equivalent hard linked objects */ /* directory structure stuff */ /* also used for linking up the free list */ struct yaffs_obj *parent; - struct ylist_head siblings; + struct list_head siblings; /* Where's my object header in NAND? */ int hdr_chunk; @@ -466,21 +454,21 @@ struct yaffs_obj { enum yaffs_obj_type variant_type; - yaffs_obj_variant variant; + union yaffs_obj_var variant; }; struct yaffs_obj_bucket { - struct ylist_head list; + struct list_head list; int count; } ; -/* yaffs_checkpt_obj_t holds the definition of an object as dumped +/* yaffs_checkpt_obj holds the definition of an object as dumped * by checkpointing. */ -typedef struct { +struct yaffs_checkpt_obj{ int struct_type; u32 obj_id; u32 parent_id; @@ -495,18 +483,18 @@ typedef struct { u8 serial; int n_data_chunks; u32 size_or_equiv_obj; -} yaffs_checkpt_obj_t; +}; /*--------------------- Temporary buffers ---------------- * * These are chunk-sized working buffers. Each device has a few */ -typedef struct { +struct yaffs_buffer { u8 *buffer; int line; /* track from whence this buffer was allocated */ int max_line; -} yaffs_buffer_t; +} ; /*----------------- Device ---------------------------------*/ @@ -553,10 +541,10 @@ struct yaffs_param { int (*write_chunk_fn) (struct yaffs_dev *dev, int nand_chunk, const u8 *data, - const yaffs_spare *spare); + const struct yaffs_spare *spare); int (*read_chunk_fn) (struct yaffs_dev *dev, int nand_chunk, u8 *data, - yaffs_spare *spare); + struct yaffs_spare *spare); int (*erase_fn) (struct yaffs_dev *dev, int flash_block); int (*initialise_flash_fn) (struct yaffs_dev *dev); @@ -571,7 +559,7 @@ struct yaffs_param { struct yaffs_ext_tags *tags); int (*bad_block_fn) (struct yaffs_dev *dev, int block_no); int (*query_block_fn) (struct yaffs_dev *dev, int block_no, - yaffs_block_state_t *state, u32 *seq_number); + enum yaffs_block_state *state, u32 *seq_number); #endif /* The remove_obj_fn function must be supplied by OS flavours that @@ -610,7 +598,7 @@ struct yaffs_dev { void *os_context; void *driver_context; - struct ylist_head dev_list; + struct list_head dev_list; /* Runtime parameters. Set up by YAFFS. */ int data_bytes_per_chunk; @@ -663,7 +651,7 @@ struct yaffs_dev { int checkpoint_blocks_required; /* Number of blocks needed to store current checkpoint set */ /* Block Info */ - yaffs_block_info_t *block_info; + struct yaffs_block_info *block_info; u8 *chunk_bits; /* bitmap of chunks in use */ unsigned block_info_alt:1; /* was allocated using alternative strategy */ unsigned chunk_bits_alt:1; /* was allocated using alternative strategy */ @@ -708,13 +696,13 @@ struct yaffs_dev { /* Buffer areas for storing data to recover from write failures TODO * u8 buffered_data[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK]; - * yaffs_spare buffered_spare[YAFFS_CHUNKS_PER_BLOCK]; + * struct yaffs_spare buffered_spare[YAFFS_CHUNKS_PER_BLOCK]; */ int buffered_block; /* Which block is buffered here? */ int doing_buffered_block_rewrite; - yaffs_cache_t *cache; + struct yaffs_cache *cache; int cache_last_use; /* Stuff for background deletion and unlinked files.*/ @@ -726,7 +714,7 @@ struct yaffs_dev { int n_bg_deletions; /* Count of background deletions. */ /* Temporary buffer management */ - yaffs_buffer_t temp_buffer[YAFFS_N_TEMP_BUFFERS]; + struct yaffs_buffer temp_buffer[YAFFS_N_TEMP_BUFFERS]; int max_temp; int temp_in_use; int unmanaged_buffer_allocs; @@ -741,7 +729,7 @@ struct yaffs_dev { int refresh_skip; /* A skip down counter. Refresh happens when this gets to zero. */ /* Dirty directory handling */ - struct ylist_head dirty_dirs; /* List of dirty directories */ + struct list_head dirty_dirs; /* List of dirty directories */ /* Statistcs */ @@ -769,21 +757,10 @@ struct yaffs_dev { }; -/* The static layout of block usage etc is stored in the super block header */ -typedef struct { - int StructType; - int version; - int checkpt_start_block; - int checkpt_end_block; - int start_block; - int end_block; - int rfu[100]; -} yaffs_sb_header; - /* The CheckpointDevice structure holds the device information that changes at runtime and * must be preserved over unmount/mount cycles. */ -typedef struct { +struct yaffs_checkpt_dev{ int struct_type; int n_erased_blocks; int alloc_block; /* Current block being allocated off */ @@ -797,32 +774,32 @@ typedef struct { /* yaffs2 runtime stuff */ unsigned seq_number; /* Sequence number of currently allocating block */ -} yaffs_checkpt_dev_t; +}; -typedef struct { +struct yaffs_checkpt_validity{ int struct_type; u32 magic; u32 version; u32 head; -} yaffs_checkpt_validty_t; +}; -struct yaffs_shadow_fixer_s { +struct yaffs_shadow_fixer { int obj_id; int shadowed_id; - struct yaffs_shadow_fixer_s *next; + struct yaffs_shadow_fixer *next; }; /* Structure for doing xattr modifications */ -typedef struct { +struct yaffs_xattr_mod{ int set; /* If 0 then this is a deletion */ const YCHAR *name; const void *data; int size; int flags; int result; -}yaffs_xattr_mod; +}; /*----------------------- YAFFS Functions -----------------------*/ @@ -844,9 +821,6 @@ int yaffs_get_obj_inode(struct yaffs_obj *obj); unsigned yaffs_get_obj_type(struct yaffs_obj *obj); int yaffs_get_obj_link_count(struct yaffs_obj *obj); -int yaffs_set_attribs(struct yaffs_obj *obj, struct iattr *attr); -int yaffs_get_attribs(struct yaffs_obj *obj, struct iattr *attr); - /* File operations */ int yaffs_file_rd(struct yaffs_obj *obj, u8 *buffer, loff_t offset, int n_bytes); @@ -897,11 +871,6 @@ int yaffs_remove_xattrib(struct yaffs_obj *obj, const YCHAR *name); struct yaffs_obj *yaffs_root(struct yaffs_dev *dev); struct yaffs_obj *yaffs_lost_n_found(struct yaffs_dev *dev); -#ifdef CONFIG_YAFFS_WINCE -/* CONFIG_YAFFS_WINCE special stuff */ -void yfsd_win_file_time_now(u32 target[2]); -#endif - void yaffs_handle_defered_free(struct yaffs_obj *obj); void yaffs_update_dirty_dirs(struct yaffs_dev *dev); @@ -916,7 +885,7 @@ void yaffs_guts_test(struct yaffs_dev *dev); /* A few useful functions to be used within the core files*/ void yaffs_chunk_del(struct yaffs_dev *dev, int chunk_id, int mark_flash, int lyn); int yaffs_check_ff(u8 *buffer, int n_bytes); -void yaffs_handle_chunk_error(struct yaffs_dev *dev, yaffs_block_info_t *bi); +void yaffs_handle_chunk_error(struct yaffs_dev *dev, struct yaffs_block_info *bi); u8 *yaffs_get_temp_buffer(struct yaffs_dev *dev, int line_no); void yaffs_release_temp_buffer(struct yaffs_dev *dev, u8 *buffer, int line_no); @@ -936,15 +905,15 @@ void yaffs_link_fixup(struct yaffs_dev *dev, struct yaffs_obj *hard_list); void yaffs_block_became_dirty(struct yaffs_dev *dev, int block_no); int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, int is_shrink, int shadows, - yaffs_xattr_mod *xop); + struct yaffs_xattr_mod *xop); void yaffs_handle_shadowed_obj(struct yaffs_dev *dev, int obj_id, int backward_scanning); int yaffs_check_alloc_available(struct yaffs_dev *dev, int n_chunks); -yaffs_tnode_t *yaffs_get_tnode(struct yaffs_dev *dev); -yaffs_tnode_t *yaffs_add_find_tnode_0(struct yaffs_dev *dev, - yaffs_file_s *file_struct, +struct yaffs_tnode *yaffs_get_tnode(struct yaffs_dev *dev); +struct yaffs_tnode *yaffs_add_find_tnode_0(struct yaffs_dev *dev, + struct yaffs_file_var *file_struct, u32 chunk_id, - yaffs_tnode_t *passed_tn); + struct yaffs_tnode *passed_tn); int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset, int n_bytes, int write_trhrough); @@ -953,10 +922,10 @@ void yaffs_skip_rest_of_block(struct yaffs_dev *dev); int yaffs_count_free_chunks(struct yaffs_dev *dev); -yaffs_tnode_t *yaffs_find_tnode_0(struct yaffs_dev *dev, - yaffs_file_s *file_struct, +struct yaffs_tnode *yaffs_find_tnode_0(struct yaffs_dev *dev, + struct yaffs_file_var *file_struct, u32 chunk_id); -u32 yaffs_get_group_base(struct yaffs_dev *dev, yaffs_tnode_t *tn, unsigned pos); +u32 yaffs_get_group_base(struct yaffs_dev *dev, struct yaffs_tnode *tn, unsigned pos); #endif