kernels/linux-2.4.0/fs/jffs/intrep.c
/* Remove redundant nodes from a file.  Mark the on-flash memory
   as dirty.  */
Remove redundant nodes from a file.  Mark the on-flash memory
as dirty.
Remove redundant nodes from a file . Mark the on - flash memory as dirty .
int
jffs_remove_redundant_nodes(struct jffs_file *f)
{
	struct jffs_node *newest_node;
	struct jffs_node *cur;
	struct jffs_node *prev;
	__u8 newest_type;
	__u8 mod_type;
	__u8 node_with_name_later = 0;
	if (!(newest_node = f->version_tail)) {
		return 0;
	}
	newest_type = jffs_classify_node(newest_node);
	node_with_name_later = newest_type & JFFS_MODIFY_NAME;
	D3(printk("jffs_remove_redundant_nodes(): ino: %u, name: \"%s\", "
		  "newest_type: %u\n", f->ino, (f->name ? f->name : ""),
		  newest_type));
	for (cur = newest_node->version_prev; cur; cur = prev) {
		prev = cur->version_prev;
		mod_type = jffs_classify_node(cur);
		if ((mod_type <= JFFS_MODIFY_INODE)
		    || ((newest_type & JFFS_MODIFY_NAME)
			&& (mod_type
			    <= (JFFS_MODIFY_INODE + JFFS_MODIFY_NAME)))
		    || (cur->data_size == 0 && cur->removed_size
			&& !cur->version_prev && node_with_name_later)) {
			D2(printk("jffs_remove_redundant_nodes(): "
				  "Removing node: ino: %u, version: %u, "
				  "mod_type: %u\n", cur->ino, cur->version,
				  mod_type));
			jffs_unlink_node_from_version_list(f, cur);
			jffs_fmfree(f->c->fmc, cur->fm, cur);
			kfree(cur);
			DJM(no_jffs_node--);
		}
		else {
			node_with_name_later |= (mod_type & JFFS_MODIFY_NAME);
		}
	}
	return 0;
}
int jffs_remove_redundant_nodes ( struct jffs_file * f ) { struct jffs_node * newest_node ; struct jffs_node * cur ; struct jffs_node * prev ; __u8 newest_type ; __u8 mod_type ; __u8 node_with_name_later = 0 ; if ( ! ( newest_node = f -> version_tail ) ) { return 0 ; } newest_type = jffs_classify_node ( newest_node ) ; node_with_name_later = newest_type & JFFS_MODIFY_NAME ; D3 ( printk ( " \" \" " " \n " , f -> ino , ( f -> name ? f -> name : " " ) , newest_type ) ) ; for ( cur = newest_node -> version_prev ; cur ; cur = prev ) { prev = cur -> version_prev ; mod_type = jffs_classify_node ( cur ) ; if ( ( mod_type <= JFFS_MODIFY_INODE ) || ( ( newest_type & JFFS_MODIFY_NAME ) && ( mod_type <= ( JFFS_MODIFY_INODE + JFFS_MODIFY_NAME ) ) ) || ( cur -> data_size == 0 && cur -> removed_size && ! cur -> version_prev && node_with_name_later ) ) { D2 ( printk ( " " " " " \n " , cur -> ino , cur -> version , mod_type ) ) ; jffs_unlink_node_from_version_list ( f , cur ) ; jffs_fmfree ( f -> c -> fmc , cur -> fm , cur ) ; kfree ( cur ) ; DJM ( no_jffs_node -- ) ; } else { node_with_name_later |= ( mod_type & JFFS_MODIFY_NAME ) ; } } return 0 ; }
Remove redundant nodes from a file.
Remove redundant nodes from a file .
/* What does the `newest_node' modify?  */ /* Traverse the file's nodes and determine which of them that are
	   superfluous.  Yeah, this might look very complex at first
	   glance but it is actually very simple.  */ /* Yes, this node is redundant. Remove it.  */