summaryrefslogtreecommitdiff
path: root/jffsX-utils
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2024-02-02 10:22:53 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-09-25 15:03:08 +0200
commita3b803747b363b0ececd329583e0412672e7f30b (patch)
treea2b48674f2e28235f89d787c16e0917f7236ed7b /jffsX-utils
parent6ff8739a6bf5fce30e9d99ee4b35322313300dcb (diff)
mtd-utils: Extract list implementation to common lib and add list_sort support
Current list implementation code is put under jffs utils, extract it into common lib, and add more list operations(eg. list_move, list_splice, etc.). Besides, add list sorting support in new source file lib/list_sort.c. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'jffsX-utils')
-rw-r--r--jffsX-utils/Makemodule.am3
-rw-r--r--jffsX-utils/compr.c49
-rw-r--r--jffsX-utils/compr.h5
3 files changed, 3 insertions, 54 deletions
diff --git a/jffsX-utils/Makemodule.am b/jffsX-utils/Makemodule.am
index 266c12e..2374b85 100644
--- a/jffsX-utils/Makemodule.am
+++ b/jffsX-utils/Makemodule.am
@@ -9,7 +9,8 @@ mkfs_jffs2_SOURCES = \
jffsX-utils/rbtree.h \
jffsX-utils/summary.h \
include/linux/jffs2.h \
- include/mtd/jffs2-user.h
+ include/mtd/jffs2-user.h \
+ include/list.h
mkfs_jffs2_LDADD = libmtd.a $(ZLIB_LIBS) $(LZO_LIBS)
mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS)
diff --git a/jffsX-utils/compr.c b/jffsX-utils/compr.c
index 01176eb..d408ef8 100644
--- a/jffsX-utils/compr.c
+++ b/jffsX-utils/compr.c
@@ -17,55 +17,6 @@
extern int page_size;
-/* LIST IMPLEMENTATION (from linux/list.h) */
-
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
-
-static inline void __list_add(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
-{
- next->prev = new;
- new->next = next;
- new->prev = prev;
- prev->next = new;
-}
-
-static inline void list_add(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head, head->next);
-}
-
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
-{
- __list_add(new, head->prev, head);
-}
-
-static inline void __list_del(struct list_head *prev, struct list_head *next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-static inline void list_del(struct list_head *entry)
-{
- __list_del(entry->prev, entry->next);
- entry->next = (void *) 0;
- entry->prev = (void *) 0;
-}
-
-#define list_entry(ptr, type, member) \
- ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
-
-#define list_for_each_entry(pos, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-
/* Available compressors are on this list */
static LIST_HEAD(jffs2_compressor_list);
diff --git a/jffsX-utils/compr.h b/jffsX-utils/compr.h
index f1f5975..6969952 100644
--- a/jffsX-utils/compr.h
+++ b/jffsX-utils/compr.h
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <stdint.h>
#include "linux/jffs2.h"
+#include "list.h"
#define CONFIG_JFFS2_RTIME
@@ -49,10 +50,6 @@
#define KERN_INFO
#define KERN_DEBUG
-struct list_head {
- struct list_head *next, *prev;
-};
-
void jffs2_set_compression_mode(int mode);
int jffs2_get_compression_mode(void);
int jffs2_set_compression_mode_name(const char *mode_name);