Index: linux-2.4.21-chaos/include/linux/list.h =================================================================== --- linux-2.4.21-chaos.orig/include/linux/list.h 2003-12-05 16:54:33.000000000 +0300 +++ linux-2.4.21-chaos/include/linux/list.h 2003-12-12 16:08:20.000000000 +0300 @@ -241,6 +241,21 @@ pos = list_entry(pos->member.next, typeof(*pos), member), \ prefetch(pos->member.next)) +#ifndef list_for_each_entry_safe +/** + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry + * @pos: the type * to use as a loop counter. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(*n), member)) +#endif + #define list_first(head) (((head)->next != (head)) ? (head)->next: (struct list_head *) 0) #endif /* __KERNEL__ || _LVM_H_INCLUDE */