2
* Copyright (C) 2009 Karel Zak <kzak@redhat.com>
4
* This file may be redistributed under the terms of the
5
* GNU Lesser General Public License.
11
* @short_description: unified iterator
13
* The iterator keeps direction and last position for access to the internal
14
* library tables/lists.
24
* @direction: MNT_INTER_{FOR,BACK}WARD direction
26
* Returns: newly allocated generic libmount iterator.
28
struct libmnt_iter *mnt_new_iter(int direction)
30
struct libmnt_iter *itr = calloc(1, sizeof(*itr));
33
itr->direction = direction;
39
* @itr: iterator pointer
41
* Deallocates iterator.
43
void mnt_free_iter(struct libmnt_iter *itr)
50
* @itr: iterator pointer
51
* @direction: MNT_INTER_{FOR,BACK}WARD or -1 to keep the derection unchanged
55
void mnt_reset_iter(struct libmnt_iter *itr, int direction)
60
direction = itr->direction;
63
memset(itr, 0, sizeof(*itr));
64
itr->direction = direction;
69
* mnt_iter_get_direction:
70
* @itr: iterator pointer
72
* Returns: MNT_INTER_{FOR,BACK}WARD or negative number in case of error.
74
int mnt_iter_get_direction(struct libmnt_iter *itr)
77
return itr ? itr->direction : -EINVAL;