/** * mnt_tabdiff_next_change: * @df: tabdiff pointer * @itr: iterator * @old_fs: returns the old entry or NULL if new entry added * @new_fs: returns the new entry or NULL if old entry removed * @oper: MNT_TABDIFF_{MOVE,UMOUNT,REMOUNT,MOUNT} flags * * The options @old_fs, @new_fs and @oper are optional. * * Returns: 0 on success, negative number in case of error or 1 at the end of list. */ int mnt_tabdiff_next_change(struct libmnt_tabdiff *df, struct libmnt_iter *itr, struct libmnt_fs **old_fs, struct libmnt_fs **new_fs, int *oper) { int rc = 1; struct tabdiff_entry *de = NULL; if (!df || !itr) return -EINVAL; if (!itr->head) MNT_ITER_INIT(itr, &df->changes); if (itr->p != itr->head) { MNT_ITER_ITERATE(itr, de, struct tabdiff_entry, changes); rc = 0; } if (old_fs) *old_fs = de ? de->old_fs : NULL; if (new_fs) *new_fs = de ? de->new_fs : NULL; if (oper) *oper = de ? de->oper : 0; return rc; }
/** * mnt_table_next_fs: * @tb: tab pointer * @itr: iterator * @fs: returns the next tab entry * * Returns: 0 on success, negative number in case of error or 1 at the end of list. * * Example: * <informalexample> * <programlisting> * while(mnt_table_next_fs(tb, itr, &fs) == 0) { * const char *dir = mnt_fs_get_target(fs); * printf("mount point: %s\n", dir); * } * </programlisting> * </informalexample> * * lists all mountpoints from fstab in reverse order. */ int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, struct libmnt_fs **fs) { int rc = 1; if (!tb || !itr || !fs) return -EINVAL; *fs = NULL; if (!itr->head) MNT_ITER_INIT(itr, &tb->ents); if (itr->p != itr->head) { MNT_ITER_ITERATE(itr, *fs, struct libmnt_fs, ents); rc = 0; }