From e7462a881930a41ec84bf0661ff19f8fd1dfe7be Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 5 Mar 2010 10:52:59 +0100 Subject: [PATCH] libblkid: add mnt_iter_get_direction() Signed-off-by: Karel Zak --- shlibs/mount/src/iter.c | 17 ++++++++++++++++- shlibs/mount/src/mount.h.in | 1 + shlibs/mount/src/mount.sym | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/shlibs/mount/src/iter.c b/shlibs/mount/src/iter.c index d64f2d40..4baa7ffb 100644 --- a/shlibs/mount/src/iter.c +++ b/shlibs/mount/src/iter.c @@ -39,7 +39,7 @@ void mnt_free_iter(mnt_iter *itr) /** * mnt_reset_iter: * @itr: iterator pointer - * @direction: MNT_INTER_{FOR,BACK}WARD iterator direction + * @direction: MNT_INTER_{FOR,BACK}WARD or -1 to keep the derection unchanged * * Resets iterator. */ @@ -47,8 +47,23 @@ void mnt_reset_iter(mnt_iter *itr, int direction) { assert(itr); + if (direction == -1) + direction = itr->direction; + if (itr) { memset(itr, 0, sizeof(struct _mnt_iter)); itr->direction = direction; } } + +/** + * mnt_iter_get_direction: + * @itr: iterator pointer + * + * Returns: MNT_INTER_{FOR,BACK}WARD or -1 in case of error. + */ +int mnt_iter_get_direction(mnt_iter *itr) +{ + assert(itr); + return itr ? itr->direction : -1; +} diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in index 8e71213a..585b9fca 100644 --- a/shlibs/mount/src/mount.h.in +++ b/shlibs/mount/src/mount.h.in @@ -147,6 +147,7 @@ enum { extern mnt_iter *mnt_new_iter(int direction); extern void mnt_free_iter(mnt_iter *mi); extern void mnt_reset_iter(mnt_iter *mi, int direction); +extern int mnt_iter_get_direction(mnt_iter *itr); /* optmap.c */ enum { diff --git a/shlibs/mount/src/mount.sym b/shlibs/mount/src/mount.sym index 3bc32ecd..6740bbcd 100644 --- a/shlibs/mount/src/mount.sym +++ b/shlibs/mount/src/mount.sym @@ -46,6 +46,7 @@ global: mnt_fstype_is_pseudofs; mnt_get_builtin_optmap; mnt_get_library_version; + mnt_iter_get_direction; mnt_lock_file; mnt_lock_get_linkfile; mnt_lock_get_lockfile; -- 2.39.5