/* tab.c */
extern struct libmnt_table *mnt_new_table(void);
extern void mnt_free_table(struct libmnt_table *tb);
+extern int mnt_reset_table(struct libmnt_table *tb);
extern int mnt_table_get_nents(struct libmnt_table *tb);
extern int mnt_table_set_cache(struct libmnt_table *tb, struct libmnt_cache *mpc);
extern struct libmnt_cache *mnt_table_get_cache(struct libmnt_table *tb);
}
/**
- * mnt_free_table:
+ * mnt_reset_table:
* @tb: tab pointer
*
- * Deallocates tab struct and all entries.
+ * Dealocates all entries (filesystems) from the table
+ *
+ * Returns: 0 on success or negative number in case of error.
*/
-void mnt_free_table(struct libmnt_table *tb)
+int mnt_reset_table(struct libmnt_table *tb)
{
if (!tb)
- return;
+ return -EINVAL;
- DBG(TAB, mnt_debug_h(tb, "free"));
+ DBG(TAB, mnt_debug_h(tb, "reset"));
while (!list_empty(&tb->ents)) {
struct libmnt_fs *fs = list_entry(tb->ents.next,
mnt_free_fs(fs);
}
+ return 0;
+}
+
+/**
+ * mnt_free_table:
+ * @tb: tab pointer
+ *
+ * Deallocates tab struct and all entries.
+ */
+void mnt_free_table(struct libmnt_table *tb)
+{
+ if (!tb)
+ return;
+
+ mnt_reset_table(tb);
+
+ DBG(TAB, mnt_debug_h(tb, "free"));
free(tb);
}