summaryrefslogtreecommitdiff
path: root/fs/jffs2/nodelist.c
diff options
context:
space:
mode:
authorArtem B. Bityutskiy <dedekind@infradead.org>2005-07-31 09:20:48 +0100
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 18:11:59 +0100
commit1e900979a7e6c2abbfd1b86bffd226d2d6115f66 (patch)
tree700fd63d312704da8ab58d9de842420bc192f013 /fs/jffs2/nodelist.c
parent737b7661e059680a68afb3df0a088fd976f666b7 (diff)
[JFFS2] Move another fragtree-related function to nodelist.c
Signed-off-by: Artem B. Bityutskiy <dedekind@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2/nodelist.c')
-rw-r--r--fs/jffs2/nodelist.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 7997f526c94b..0cf5e6f11989 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -7,7 +7,7 @@
*
* For licensing information, see the file 'LICENCE' in this directory.
*
- * $Id: nodelist.c,v 1.102 2005/07/28 12:45:10 dedekind Exp $
+ * $Id: nodelist.c,v 1.103 2005/07/31 08:20:44 dedekind Exp $
*
*/
@@ -51,6 +51,30 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new
*prev = new;
}
+void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint32_t size)
+{
+ struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size);
+
+ JFFS2_DBG_FRAGTREE("truncating fragtree to 0x%08x bytes\n", size);
+
+ /* We know frag->ofs <= size. That's what lookup does for us */
+ if (frag && frag->ofs != size) {
+ if (frag->ofs+frag->size >= size) {
+ JFFS2_DBG_FRAGTREE2("truncating frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size);
+ frag->size = size - frag->ofs;
+ }
+ frag = frag_next(frag);
+ }
+ while (frag && frag->ofs >= size) {
+ struct jffs2_node_frag *next = frag_next(frag);
+
+ JFFS2_DBG_FRAGTREE("removing frag 0x%08x-0x%08x\n", frag->ofs, frag->ofs+frag->size);
+ frag_erase(frag, list);
+ jffs2_obsolete_node_frag(c, frag);
+ frag = next;
+ }
+}
+
void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *this)
{
if (this->node) {