]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add mnt_reset_table()
authorKarel Zak <kzak@redhat.com>
Tue, 26 Apr 2011 14:34:16 +0000 (16:34 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 26 Apr 2011 14:34:16 +0000 (16:34 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/libmount.h.in
shlibs/mount/src/libmount.sym
shlibs/mount/src/tab.c

index 7d02ddcf0f4907b1cb0b951529ab36a5a95042d7..746555d484087bdba32fd44688d2ac52ee79d015 100644 (file)
@@ -276,6 +276,7 @@ extern int mnt_table_set_parser_errcb(struct libmnt_table *tb,
 /* 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);
index af6f7bf48a0496ffa36037e1ea369a9fd449b8c4..3e4d5cf7be9a0eb1249e0703a8831b6454a3f10b 100644 (file)
@@ -153,6 +153,7 @@ global:
        mnt_reset_context;
        mnt_reset_fs;
        mnt_reset_iter;
+       mnt_reset_table;
        mnt_resolve_path;
        mnt_resolve_spec;
        mnt_resolve_tag;
index fff56b7e06c1d7aae366a3839c2f54c26fc2e680..5c3c7994b39d70cbe37c7ab78b4ed3b16be46f1c 100644 (file)
@@ -82,17 +82,19 @@ struct libmnt_table *mnt_new_table(void)
 }
 
 /**
- * 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,
@@ -100,6 +102,23 @@ void mnt_free_table(struct libmnt_table *tb)
                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);
 }