Index: cpukit/libfs/src/jffs2/include/asm/bug.h
===================================================================
--- cpukit/libfs/src/jffs2/include/asm/bug.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/asm/bug.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,5 +2,9 @@
 #define __ASM_BUG_H__
 
-#define BUG() do { diag_printf("BUG() at %s %d\n", __FILE__, __LINE__); *(int *)0=0; } while (0)
+#include <assert.h>
+
+#define BUG() assert(0)
+
+#define WARN_ON(condition) do { } while (0)
 
 #endif /* __ASM_BUG_H__ */
Index: cpukit/libfs/src/jffs2/include/asm/page.h
===================================================================
--- cpukit/libfs/src/jffs2/include/asm/page.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/asm/page.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,10 +2,5 @@
 #define __ASM_PAGE_H__
 
-#include <pkgconf/linux_compat.h>
-
-/* These aren't used by much yet. If that changes, you might want
-   to make them actually correct :) */
-#define PAGE_SIZE  (0x1 << PAGE_SHIFT)
-
+#include <sys/param.h>
 
 #endif /* __ASM_PAGE_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/compiler.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/compiler.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/compiler.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -4,4 +4,5 @@
 #define likely(x) (x)
 #define unlikely(x) (x)
+#define uninitialized_var(x) x = x
 
 #endif /* __LINUX_COMPILER_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/crc32.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/crc32.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/crc32.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,6 +2,8 @@
 #define CRC32_H
 
+#include <zlib.h>
 #include <cyg/crc/crc.h>
 
+#undef crc32
 #define crc32(val, s, len) cyg_crc32_accumulate(val, (unsigned char *)s, len)
 
Index: cpukit/libfs/src/jffs2/include/linux/fs.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/fs.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/fs.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -3,11 +3,30 @@
 
 #include <linux/stat.h>
-/*
- * File types
- */
+#include <sys/types.h>
+#include <sys/time.h>
+
 #define DT_UNKNOWN	0
 #define DT_DIR		4
 #define DT_REG		8
+#define DT_LNK		10
 
+#define ATTR_MODE	(1U << 0)
+#define ATTR_UID	(1U << 1)
+#define ATTR_GID	(1U << 2)
+#define ATTR_SIZE	(1U << 3)
+#define ATTR_ATIME	(1U << 4)
+#define ATTR_MTIME	(1U << 5)
+#define ATTR_CTIME	(1U << 6)
+
+struct iattr {
+	unsigned int	ia_valid;
+	mode_t		ia_mode;
+	uid_t		ia_uid;
+	gid_t		ia_gid;
+	off_t		ia_size;
+	time_t		ia_atime;
+	time_t		ia_mtime;
+	time_t		ia_ctime;
+};
 
 #endif /* __LINUX_FS_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/kernel-rtems.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/kernel-rtems.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
+++ cpukit/libfs/src/jffs2/include/linux/kernel-rtems.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef __LINUX_RTEMS_IMPL_H__
+#define __LINUX_RTEMS_IMPL_H__
+
+static inline char *do_kmemdup(const char *s, size_t n)
+{
+	char *dup = malloc(n + 1);
+
+	if (dup != 0) {
+		dup[n] = '\0';
+		dup = memcpy(dup, s, n);
+	}
+
+	return dup;
+}
+
+#endif /* __LINUX_RTEMS_IMPL_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/kernel.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/kernel.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/kernel.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,21 +2,66 @@
 #define __LINUX_KERNEL_H__
 
-#define jiffies ((unsigned long)cyg_current_time())
+#include <rtems.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "kernel-rtems.h"
+
+#define jiffies ((unsigned long)rtems_clock_get_ticks_since_boot())
 
 #define ERR_PTR(err) ((void*)(err))
 #define PTR_ERR(err) ((unsigned long)(err))
 #define IS_ERR(err) ((unsigned long)err > (unsigned long)-1000L)
+static inline void *ERR_CAST(const void *ptr)
+{
+	return (void *) (uintptr_t) ptr;
+}
 
 #define CURRENT_TIME cyg_timestamp()
 
-#define	KERN_EMERG              "<0>" // system is unusable
-#define	KERN_ALERT              "<1>" // action must be taken immediately
-#define	KERN_CRIT               "<2>" // critical conditions
-#define	KERN_ERR                "<3>" // error conditions
-#define	KERN_WARNING            "<4>" // warning conditions
-#define	KERN_NOTICE             "<5>" // normal but significant condition
-#define	KERN_INFO               "<6>" // informational
-#define	KERN_DEBUG              "<7>" // debug-level messages
-#define printk diag_printf
+#define	KERN_EMERG              "<0>"
+#define	KERN_ALERT              "<1>"
+#define	KERN_CRIT               "<2>"
+#define	KERN_ERR                "<3>"
+#define	KERN_WARNING            "<4>"
+#define	KERN_NOTICE             "<5>"
+#define	KERN_INFO               "<6>"
+#define	KERN_DEBUG              "<7>"
+#define KERN_CONT		""
+
+#ifndef pr_fmt
+#define pr_fmt(fmt) fmt
+#endif
+
+#define pr_emerg(fmt, ...) \
+	printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...) \
+	printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...) \
+	printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...) \
+	printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning(fmt, ...) \
+	printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn pr_warning
+#define pr_notice(fmt, ...) \
+	printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...) \
+	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_cont(fmt, ...) \
+	printk(KERN_CONT fmt, ##__VA_ARGS__)
+
+#ifdef DEBUG
+#define pr_debug(fmt, ...) \
+	printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+static inline int no_printk(const char *fmt, ...)
+{
+	(void) fmt;
+	return 0;
+}
+#define pr_debug(fmt, ...) \
+	no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#endif
 
 #define min(x,y) (x<y?x:y)
@@ -24,4 +69,15 @@
 #define min_t(t, x,y) ((t)x<(t)y?(t)x:(t)y)
 
+#define capable(x) 0
+
+#define kmemdup(x, y, z) do_kmemdup(x, y)
+
+#define from_kuid(x, y) (y)
+#define from_kgid(x, y) (y)
+#define i_uid_read(x) ((x)->i_uid)
+#define i_gid_read(x) ((x)->i_gid)
+#define i_uid_write(x, y) do { (x)->i_uid = (y); } while (0)
+#define i_gid_write(x, y) do { (x)->i_gid = (y); } while (0)
+#define truncate_setsize(x, y) do { (x)->i_size = (y); } while (0)
 
 #endif /* __LINUX_KERNEL_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/list.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/list.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/list.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -104,4 +104,18 @@
 } /* list_del() */
 
+static __inline__ void
+list_move( struct list_head *list, struct list_head *head )
+{
+    list_del( list );
+    list_add( list, head );
+}
+
+static __inline__ void
+list_move_tail( struct list_head *list, struct list_head *head )
+{
+    list_del( list );
+    list_add_tail( list, head );
+}
+
 /* Is this list empty? */
 static __inline__ int
Index: cpukit/libfs/src/jffs2/include/linux/magic.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/magic.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
+++ cpukit/libfs/src/jffs2/include/linux/magic.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -0,0 +1,6 @@
+#ifndef _LINUX_MAGIC_H
+#define _LINUX_MAGIC_H
+
+#define JFFS2_SUPER_MAGIC 0x72b6
+
+#endif /* _LINUX_MAGIC_H */
Index: cpukit/libfs/src/jffs2/include/linux/mtd/mtd.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/mtd/mtd.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/mtd/mtd.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,4 +2,22 @@
 #define __LINUX_MTD_MTD_H__
 
+#include <linux/slab.h>
+#include <errno.h>
+
+#define MTD_FAIL_ADDR_UNKNOWN -1LL
+
+static inline int do_mtd_point(size_t *retlen, void **ebuf)
+{
+	*retlen = 0;
+	*ebuf = NULL;
+
+	return -EOPNOTSUPP;
+}
+
+#define mtd_point(a, b, c, d, e, f) do_mtd_point(d, e)
+
+#define mtd_unpoint(a, b, c) do { } while (0)
+
+#define mtd_kmalloc_up_to(a, b) kmalloc(*(b), GFP_KERNEL)
 
 #endif /* __LINUX_MTD_MTD_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/mutex.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/mutex.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
+++ cpukit/libfs/src/jffs2/include/linux/mutex.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -0,0 +1,29 @@
+#ifndef __LINUX_MUTEX_H
+#define __LINUX_MUTEX_H
+
+struct mutex { };
+
+#define DEFINE_MUTEX(m) struct mutex m
+
+static inline void mutex_init(struct mutex *m)
+{
+	(void) m;
+}
+
+static inline void mutex_lock(struct mutex *m)
+{
+	(void) m;
+}
+
+static inline int mutex_lock_interruptible(struct mutex *m)
+{
+	(void) m;
+	return 0;
+}
+
+static inline void mutex_unlock(struct mutex *m)
+{
+	(void) m;
+}
+
+#endif
Index: cpukit/libfs/src/jffs2/include/linux/posix_acl.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/posix_acl.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
+++ cpukit/libfs/src/jffs2/include/linux/posix_acl.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -0,0 +1,3 @@
+#ifndef __LINUX_POSIX_ACL_H
+#define __LINUX_POSIX_ACL_H
+#endif
Index: cpukit/libfs/src/jffs2/include/linux/rbtree.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/rbtree.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/rbtree.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,19 +2,19 @@
 #define	_LINUX_RBTREE_H
 
+#include <stddef.h>
 
 struct rb_node {
-	struct rb_node *rb_left;	/* left element */
-	struct rb_node *rb_right;	/* right element */
-	struct rb_node *rb_parent;	/* parent element */
-	int rb_color;			/* node color */
+	struct rb_node *rb_left;
+	struct rb_node *rb_right;
+	struct rb_node *rb_parent;
+	int rb_color;
 };
 
 struct rb_root {
-	struct rb_node *rb_node; /* root of the tree */
+	struct rb_node *rb_node;
 };
-#define NULL ((void *)0)
-#define RB_ROOT ((struct rb_root){NULL})
+#define RB_ROOT ((struct rb_root){0})
 #define rb_entry(p, container, field)		\
-	((container *) ((char *)p - ((char *)&(((container *)0)->field))))
+	((container *) ((char *)p - offsetof(container, field)))
 
 #define RB_BLACK	0
@@ -25,10 +25,9 @@
 extern void rb_erase(struct rb_node *, struct rb_root *);
 
-/* Find logical next and previous nodes in a tree */
 extern struct rb_node *rb_next(struct rb_node *);
 extern struct rb_node *rb_prev(struct rb_node *);
 extern struct rb_node *rb_first(struct rb_root *);
+extern struct rb_node *rb_last(struct rb_root *);
 
-/* Fast replacement of a single node without remove/rebalance/add/rebalance */
 extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, 
 			    struct rb_root *root);
@@ -44,3 +43,8 @@
 }
 
+static inline struct rb_node *rb_parent(struct rb_node * node)
+{
+	return node->rb_parent;
+}
+
 #endif	/* _LINUX_RBTREE_H */
Index: cpukit/libfs/src/jffs2/include/linux/rwsem.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/rwsem.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/rwsem.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,19 +2,5 @@
 #define __LINUX_RWSEM_H__
 
-// eCos does not have the concept of a read/write semaphore. So just
-// map them onto normal semaphores and hope we don't deadlock
-// somewhere.
-
-#include <asm/semaphore.h>
-
 struct rw_semaphore;
 
-#define down_read(sem) cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem)
-#define down_read_trylock(sem) cyg_drv_mutex_trylock((cyg_drv_mutex_t *)sem)
-#define down_write(sem) cyg_drv_mutex_lock((cyg_drv_mutex_t *)sem)
-#define down_write_trylock(sem) cyg_drv_mutex_trylock((cyg_drv_mutex_t *)sem)
-#define up_read(sem) cyg_drv_mutex_unlock((cyg_drv_mutex_t *)sem)
-#define up_write(sem) cyg_drv_mutex_unlock((cyg_drv_mutex_t *)sem)
-#define downgrade_write(sem) 
-
-#endif // __LINUX_RWSEM_H__ 
+#endif /* __LINUX_RWSEM_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/sched.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/sched.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/sched.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,6 +2,8 @@
 #define __LINUX_SCHED_H__
 
+#define schedule() do { } while(0)
 #define cond_resched() do { } while(0)
 #define signal_pending(x) (0)
+#define set_current_state(x) do { } while (0)
 
 #endif /* __LINUX_SCHED_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/slab.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/slab.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/slab.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 
-#include <asm/page.h> /* Don't ask. Linux headers are a mess. */
+#include <asm/page.h>
 
+#define kzalloc(x, y) calloc(1, x)
 #define kmalloc(x, y) malloc(x)
 #define kfree(x) free(x)
Index: cpukit/libfs/src/jffs2/include/linux/timer.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/timer.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/timer.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,9 +2,5 @@
 #define __LINUX_TIMER_H__
 
-/* Not yet */
-
 struct timer_list { } ;
 
-
 #endif /* __LINUX_TIMER_H__ */
-
Index: cpukit/libfs/src/jffs2/include/linux/types.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/types.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/types.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,18 +2,24 @@
 #define __LINUX_TYPES_H__
 
-#include "cyg/infra/cyg_type.h"
-
-#define uint8_t cyg_uint8
-#define uint16_t cyg_uint16
-#define uint32_t cyg_uint32
-
-#define int8_t cyg_int8
-#define int16_t cyg_int16
-#define int32_t cyg_int32
+#include <sys/types.h>
+#include <stdint.h>
 
 #define loff_t off_t
 
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+
+typedef uint8_t __u8;
+typedef uint16_t __u16;
+typedef uint32_t __u32;
 
 #define kvec iovec
+
+struct qstr {
+	const char *name;
+	size_t len;
+};
+
 #endif /* __LINUX_TYPES_H__ */
 
Index: cpukit/libfs/src/jffs2/include/linux/uio.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/uio.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
+++ cpukit/libfs/src/jffs2/include/linux/uio.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -0,0 +1,4 @@
+#ifndef _LINUX_UIO_H
+#define _LINUX_UIO_H
+
+#endif /* _LINUX_UIO_H */
Index: cpukit/libfs/src/jffs2/include/linux/wait.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/wait.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/wait.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -10,6 +10,5 @@
 #define DECLARE_WAITQUEUE(wait,current) do{} while (0)
 
-static inline void wake_up(wait_queue_head_t *erase_wait)
-{ /* Only used for waking up threads blocks on erases. Not used in eCos */ }
+static inline void wake_up(wait_queue_head_t *erase_wait) { }
 
 #endif /* __LINUX_WAIT_H__ */
Index: cpukit/libfs/src/jffs2/include/linux/workqueue.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/workqueue.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/workqueue.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,5 +2,4 @@
 #define __LINUX_WORKQUEUE_H__
 
-/* We don't do this yet */
 struct work_struct { } ;
 
Index: cpukit/libfs/src/jffs2/include/linux/xattr.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/xattr.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
+++ cpukit/libfs/src/jffs2/include/linux/xattr.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -0,0 +1,7 @@
+#ifndef _LINUX_XATTR_H
+#define _LINUX_XATTR_H
+
+#include <asm/atomic.h>
+#include <linux/types.h>
+
+#endif /* _LINUX_XATTR_H */
Index: cpukit/libfs/src/jffs2/include/linux/zlib.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/zlib.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/zlib.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,5 +2,5 @@
 #define __LINUX_ZLIB_H__
 
-#include <cyg/compress/zlib.h>
+#include <zlib.h>
 
 #define zlib_deflateInit(x,y) deflateInit(x,y)
Index: cpukit/libfs/src/jffs2/include/linux/zutil.h
===================================================================
--- cpukit/libfs/src/jffs2/include/linux/zutil.h	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/include/linux/zutil.h	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -2,5 +2,5 @@
 #define __LINUX_ZUTIL_H__
 
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
+#define PRESET_DICT 0x20
 
 #endif /* __LINUX_ZUTIL_H__ */
Index: cpukit/libfs/src/jffs2/src/compat-rbtree.c
===================================================================
--- cpukit/libfs/src/jffs2/src/compat-rbtree.c	(revision 672038b174456ff89d46a5f16ecac90f43e364f3)
+++ cpukit/libfs/src/jffs2/src/compat-rbtree.c	(revision 78b85286f073092b53ec405b9d9eebd3f49b44f6)
@@ -120,6 +120,7 @@
 	RB_PARENT(elm) = (tmp);					\
 	RB_AUGMENT(tmp);					\
-	if ((RB_PARENT(tmp)))					\
+	if ((RB_PARENT(tmp))) {					\
 		RB_AUGMENT(RB_PARENT(tmp));			\
+	}							\
 } while (0)
 
@@ -140,6 +141,7 @@
 	RB_PARENT(elm) = (tmp);					\
 	RB_AUGMENT(tmp);					\
-	if ((RB_PARENT(tmp)))					\
+	if ((RB_PARENT(tmp))) {					\
 		RB_AUGMENT(RB_PARENT(tmp));			\
+	}							\
 } while(0)
 
@@ -385,4 +387,16 @@
 }
 
+struct rb_node *rb_last(struct rb_root *root)
+{
+	struct rb_node	*n;
+
+	n = root->rb_node;
+	if (!n)
+		return 0;
+	while (n->rb_right)
+		n = n->rb_right;
+	return n;
+}
+
 void rb_replace_node(struct rb_node *victim, struct rb_node *new,
                      struct rb_root *root)
