From: Karel Zak Date: Tue, 26 Apr 2011 14:34:16 +0000 (+0200) Subject: libmount: add mnt_reset_table() X-Git-Tag: v2.20-rc1~320 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18486fbbbe323c3fe99f4601544cf731fbe3cc4d;p=thirdparty%2Futil-linux.git libmount: add mnt_reset_table() Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/libmount.h.in b/shlibs/mount/src/libmount.h.in index 7d02ddcf0f..746555d484 100644 --- a/shlibs/mount/src/libmount.h.in +++ b/shlibs/mount/src/libmount.h.in @@ -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); diff --git a/shlibs/mount/src/libmount.sym b/shlibs/mount/src/libmount.sym index af6f7bf48a..3e4d5cf7be 100644 --- a/shlibs/mount/src/libmount.sym +++ b/shlibs/mount/src/libmount.sym @@ -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; diff --git a/shlibs/mount/src/tab.c b/shlibs/mount/src/tab.c index fff56b7e06..5c3c7994b3 100644 --- a/shlibs/mount/src/tab.c +++ b/shlibs/mount/src/tab.c @@ -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); }