/* Thisisallweneedtokeepin-coreforeachrawnodeduringnormal operation.Asandwhenwedoread_inodeonaparticularinode,wecan scanthenodeswhicharelistedforitandbuildupapropermapof whichnodesarecurrentlyvalid.JFFSv1alwaysusedtokeepthatwhole mapincoreforeachinode.
*/ struct jffs2_raw_node_ref
{ struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref forthisobject.Ifthis_is_thelast,itpointstotheinode_cache, xattr_reforxattr_datuminstead.Thecommonpartofthosestructures
has NULL in the first word. See jffs2_raw_ref_to_ic() below */
uint32_t flash_offset; #undef TEST_TOTLEN #ifdef TEST_TOTLEN
uint32_t __totlen; /* This may die; use ref_totlen(c, jeb, ) below */ #endif
};
/* Link to another block of refs */ if (ref->flash_offset == REF_LINK_NODE) {
ref = ref->next_in_ino; if (!ref) return ref;
}
/* End of chain */ if (ref->flash_offset == REF_EMPTY_NODE) return NULL;
return ref;
}
staticinlinestruct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
{ while(raw->next_in_ino)
raw = raw->next_in_ino;
/* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and
not actually a jffs2_inode_cache. Check ->class */ return ((struct jffs2_inode_cache *)raw);
}
/* flash_offset & 3 always has to be zero, because nodes are alwaysalignedat4bytes.Sowehaveacoupleofextrabits
to play with, which indicate the node's status; see below: */ #define REF_UNCHECKED 0/* We haven't yet checked the CRC or built its inode */ #define REF_OBSOLETE 1/* Obsolete, can be completely ignored */ #define REF_PRISTINE 2/* Completely clean. GC without looking */ #define REF_NORMAL 3/* Possibly overlapped. Read the page and write again on GC */ #define ref_flags(ref) ((ref)->flash_offset & 3) #define ref_offset(ref) ((ref)->flash_offset & ~3) #define ref_obsolete(ref) (((ref)->flash_offset & 3) == REF_OBSOLETE) #define mark_ref_normal(ref) do { (ref)->flash_offset = ref_offset(ref) | REF_NORMAL; } while(0)
/* Dirent nodes should be REF_PRISTINE only if they are not a deletion dirent.DeletiondirentsshouldbeREF_NORMALsothatGCgetsto
throw them away when appropriate */ #define dirent_node_state(rd) ( (je32_to_cpu((rd)->ino)?REF_PRISTINE:REF_NORMAL) )
/* NB: REF_PRISTINE for an inode-less node (ref->next_in_ino == NULL) indicates itisanunknownnodeoftypeJFFS2_NODETYPE_RWCOMPAT_COPY,soit'llget copied.IfyouneedtodoanythingdifferenttoGCinode-lessnodes,then
you need to modify gc.c accordingly. */
/* For each inode in the filesystem, we need to keep a record of nlink,becauseitwouldbeaPITAtoscanthewholedirectorytree atread_inode()timetocalculateit,andtokeepsufficientinformation intheraw_node_ref(basicallybothparentandchildinodenumberfor direntnodes)wouldtakemorespacethanthisdoes.Wealsokeep apointertothefirstphysicalnodewhichispartofthisinode,too.
*/ struct jffs2_inode_cache { /* First part of structure is shared with other objects which canterminatetherawnoderefs'next_in_inolist--which
currently struct jffs2_xattr_datum and struct jffs2_xattr_ref. */
struct jffs2_full_dirent *scan_dents; /* Used during scan to hold temporarylistsofdirents,andlatermustbesetto NULLtomarktheendoftheraw_node_ref->next_in_ino
chain. */ struct jffs2_raw_node_ref *nodes;
uint8_t class; /* It's used for identification */
/* Inode states for 'state' above. We need the 'GC' state to prevent someonefromdoingaread_inode()whilewe'removinga'REF_PRISTINE'
node without going through all the iget() nonsense */ #define INO_STATE_UNCHECKED 0/* CRC checks not yet done */ #define INO_STATE_CHECKING 1/* CRC checks in progress */ #define INO_STATE_PRESENT 2/* In core */ #define INO_STATE_CHECKEDABSENT 3/* Checked, cleared again */ #define INO_STATE_GC 4/* GCing a 'pristine' node */ #define INO_STATE_READING 5/* In read_inode() */ #define INO_STATE_CLEARING 6/* In clear_inode() */
#define INO_FLAGS_XATTR_CHECKED 0x01 /* has no duplicate xattr_ref */ #define INO_FLAGS_IS_DIR 0x02 /* is a directory */
struct jffs2_full_dnode
{ struct jffs2_raw_node_ref *raw;
uint32_t ofs; /* The offset to which the data of this node belongs */
uint32_t size;
uint32_t frags; /* Number of fragments which currently refer tothisnode.Whenthisreacheszero,
the node is obsolete. */
};
/* Temporary data structure used during readinode. */ struct jffs2_readinode_info
{ struct rb_root tn_root; struct jffs2_tmp_dnode_info *mdata_tn;
uint32_t highest_version;
uint32_t latest_mctime;
uint32_t mctime_ver; struct jffs2_full_dirent *fds; struct jffs2_raw_node_ref *latest_ref;
};
struct jffs2_full_dirent
{ union { struct jffs2_raw_node_ref *raw; struct jffs2_inode_cache *ic; /* Just during part of build */
}; struct jffs2_full_dirent *next;
uint32_t version;
uint32_t ino; /* == zero for unlink */ unsignedint nhash; unsignedchar type; unsignedchar name[];
};
/* Fragments-usedtobuildamapofwhichrawnodetoobtain datafromforeachpartoftheino
*/ struct jffs2_node_frag
{ struct rb_node rb; struct jffs2_full_dnode *node; /* NULL for holes */
uint32_t size;
uint32_t ofs; /* The offset to which this fragment belongs */
};
struct jffs2_eraseblock
{ struct list_head list; int bad_count;
uint32_t offset; /* of this block in the MTD */
uint32_t unchecked_size;
uint32_t used_size;
uint32_t dirty_size;
uint32_t wasted_size;
uint32_t free_size; /* Note that sector_size - free_size
is the address of the first free space */
uint32_t allocated_refs; struct jffs2_raw_node_ref *first_node; struct jffs2_raw_node_ref *last_node;
struct jffs2_raw_node_ref *gc_node; /* Next node to be garbage collected */
};
#define ref_totlen(a, b, c) __jffs2_ref_totlen((a), (b), (c))
#define ALLOC_NORMAL 0/* Normal allocation */ #define ALLOC_DELETION 1/* Deletion node. Best to allow it */ #define ALLOC_GC 2/* Space requested for GC. Give it or die */ #define ALLOC_NORETRY 3/* For jffs2_write_dnode: On failure, return -EAGAIN instead of retrying */
/* How much dirty space before it goes on the very_dirty_list */ #define VERYDIRTY(c, size) ((size) >= ((c)->sector_size / 2))
/* check if dirty space is more than 255 Byte */ #define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.