diff options
author | Karel Zak | 2010-01-05 14:58:16 +0100 |
---|---|---|
committer | Karel Zak | 2010-06-03 15:20:10 +0200 |
commit | efab4b61572516f4c7579e345165e0094c1a2450 (patch) | |
tree | db65d4cf4892fcef156681040f3448e696994f85 /shlibs/mount/src/mountP.h | |
parent | libmount: add mnt_optstr_* functions (diff) | |
download | kernel-qcow2-util-linux-efab4b61572516f4c7579e345165e0094c1a2450.tar.gz kernel-qcow2-util-linux-efab4b61572516f4c7579e345165e0094c1a2450.tar.xz kernel-qcow2-util-linux-efab4b61572516f4c7579e345165e0094c1a2450.zip |
libmount: add list routines and generic iterator
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/mountP.h')
-rw-r--r-- | shlibs/mount/src/mountP.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/shlibs/mount/src/mountP.h b/shlibs/mount/src/mountP.h index 74db25568..ef3c1a661 100644 --- a/shlibs/mount/src/mountP.h +++ b/shlibs/mount/src/mountP.h @@ -11,7 +11,9 @@ #define _LIBMOUNT_PRIVATE_H #include <sys/types.h> + #include "mount.h" +#include "list.h" /* features */ #define CONFIG_CDROM_NOMEDIUM_RETRIES 5 @@ -69,4 +71,31 @@ extern char *strnchr(const char *s, size_t maxlen, int c); extern char *mnt_get_username(const uid_t uid); extern char *mnt_strconcat3(char *s, const char *t, const char *u); + +/* + * Generic iterator + */ +struct _mnt_iter { + struct list_head *p; /* current position */ + struct list_head *head; /* start position */ + int direction; /* MNT_ITER_{FOR,BACK}WARD */ +}; + +#define IS_ITER_FORWARD(_i) ((_i)->direction == MNT_ITER_FORWARD) +#define IS_ITER_BACKWARD(_i) ((_i)->direction == MNT_ITER_BACKWARD) + +#define MNT_ITER_INIT(itr, list) \ + do { \ + (itr)->p = IS_ITER_FORWARD(itr) ? \ + (list)->next : (list)->prev; \ + (itr)->head = (list); \ + } while(0) + +#define MNT_ITER_ITERATE(itr, res, restype, member) \ + do { \ + res = list_entry((itr)->p, restype, member); \ + (itr)->p = IS_ITER_FORWARD(itr) ? \ + (itr)->p->next : (itr)->p->prev; \ + } while(0) + #endif |