summaryrefslogtreecommitdiff
path: root/libmount/src/tab_diff.c
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2014-06-12 12:04:01 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2014-06-12 12:04:01 +0100
commitc5c1033c5c7deda8abe3448ec81bbb33c72219e0 (patch)
tree6e5cef29b85161eea8a7488a029f5a32f982c6ab /libmount/src/tab_diff.c
parent462008f79be9e195670b202cb43827b8aeb1e60b (diff)
parent2fb567c080e1762ec6a2147564f03068f55d4f14 (diff)
downloadutil-linux-baserock/morph.tar.gz
Merge branch 'baserock/richardmaw/yakshave/util-linux-blkid' into baserock/morphbaserock/morph
Reviewed-by: Lars Wirzenius Reviewed-by: Sam Thursfield
Diffstat (limited to 'libmount/src/tab_diff.c')
-rw-r--r--libmount/src/tab_diff.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/libmount/src/tab_diff.c b/libmount/src/tab_diff.c
index f01f889f8..052278233 100644
--- a/libmount/src/tab_diff.c
+++ b/libmount/src/tab_diff.c
@@ -25,7 +25,7 @@ struct libmnt_tabdiff {
int nchanges; /* number of changes */
struct list_head changes; /* list with modified entries */
- struct list_head unused; /* list with unuused entries */
+ struct list_head unused; /* list with unused entries */
};
/**
@@ -54,6 +54,8 @@ static void free_tabdiff_entry(struct tabdiff_entry *de)
if (!de)
return;
list_del(&de->changes);
+ mnt_unref_fs(de->new_fs);
+ mnt_unref_fs(de->old_fs);
free(de);
}
@@ -89,7 +91,7 @@ void mnt_free_tabdiff(struct libmnt_tabdiff *df)
*
* The options @old_fs, @new_fs and @oper are optional.
*
- * Returns: 0 on success, negative number in case of error or 1 at end of list.
+ * 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)
@@ -124,9 +126,9 @@ static int tabdiff_reset(struct libmnt_tabdiff *df)
{
assert(df);
- DBG(DIFF, mnt_debug_h(df, "reseting"));
+ DBG(DIFF, mnt_debug_h(df, "resetting"));
- /* zeroize all entries and move them to the list of unuused
+ /* zeroize all entries and move them to the list of unused
*/
while (!list_empty(&df->changes)) {
struct tabdiff_entry *de = list_entry(df->changes.next,
@@ -135,6 +137,9 @@ static int tabdiff_reset(struct libmnt_tabdiff *df)
list_del(&de->changes);
list_add_tail(&de->changes, &df->unused);
+ mnt_unref_fs(de->new_fs);
+ mnt_unref_fs(de->old_fs);
+
de->new_fs = de->old_fs = NULL;
de->oper = 0;
}
@@ -164,6 +169,12 @@ static int tabdiff_add_entry(struct libmnt_tabdiff *df, struct libmnt_fs *old,
INIT_LIST_HEAD(&de->changes);
+ mnt_ref_fs(new);
+ mnt_ref_fs(old);
+
+ mnt_unref_fs(de->new_fs);
+ mnt_unref_fs(de->old_fs);
+
de->old_fs = old;
de->new_fs = new;
de->oper = oper;
@@ -280,6 +291,8 @@ int mnt_diff_tables(struct libmnt_tabdiff *df, struct libmnt_table *old_tab,
de = tabdiff_get_mount(df, src, mnt_fs_get_id(fs));
if (de) {
+ mnt_ref_fs(fs);
+ mnt_unref_fs(de->old_fs);
de->oper = MNT_TABDIFF_MOVE;
de->old_fs = fs;
} else
@@ -342,8 +355,8 @@ int test_diff(struct libmnt_test *ts, int argc, char *argv[])
rc = 0;
done:
- mnt_free_table(tb_old);
- mnt_free_table(tb_new);
+ mnt_unref_table(tb_old);
+ mnt_unref_table(tb_new);
mnt_free_tabdiff(diff);
mnt_free_iter(itr);
return rc;