misc: use libmnt_table reference counter

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2013-08-21 16:07:51 +02:00
parent c9f1585e67
commit 50fccba1ab
9 changed files with 23 additions and 20 deletions

View File

@ -1577,7 +1577,7 @@ int main(int argc, char *argv[])
status |= wait_many(FLAG_WAIT_ALL);
free(fsck_path);
mnt_unref_cache(mntcache);
mnt_free_table(fstab);
mnt_free_table(mtab);
mnt_unref_table(fstab);
mnt_unref_table(mtab);
return status;
}

View File

@ -806,7 +806,7 @@ static struct libmnt_table *parse_tabfiles(char **files,
break;
}
if (rc) {
mnt_free_table(tb);
mnt_unref_table(tb);
warn(_("can't read %s"), path);
return NULL;
}
@ -1087,7 +1087,7 @@ static int poll_table(struct libmnt_table *tb, const char *tabfile,
rc = 0;
done:
mnt_free_table(tb_new);
mnt_unref_table(tb_new);
mnt_free_tabdiff(diff);
mnt_free_iter(itr);
if (f)
@ -1496,8 +1496,9 @@ int main(int argc, char *argv[])
leave:
tt_free_table(tt);
mnt_free_table(tb);
mnt_unref_table(tb);
mnt_unref_cache(cache);
free(tabfiles);
#ifdef HAVE_LIBUDEV
udev_unref(udev);

View File

@ -1604,8 +1604,9 @@ int main(int argc, char *argv[])
leave:
tt_free_table(lsblk->tt);
mnt_free_table(mtab);
mnt_free_table(swaps);
mnt_unref_table(mtab);
mnt_unref_table(swaps);
mnt_unref_cache(mntcache);
#ifdef HAVE_LIBUDEV
udev_unref(udev);

View File

@ -592,6 +592,6 @@ int main(int argc, char *argv[])
if (!rc && !list_empty(&locks))
rc = show_locks(&locks, tt_flags);
mnt_free_table(tab);
mnt_unref_table(tab);
return rc;
}

View File

@ -106,7 +106,6 @@ static long int c_arg;
static long int x_arg;
struct libmnt_table *mtab;
struct libmnt_cache *cache;
static void vinfo(const char *fmt, va_list va)
{
@ -725,13 +724,15 @@ static int device_get_mountpoint(char **devname, char **mnt)
*mnt = NULL;
if (!mtab) {
struct libmnt_cache *cache;
mtab = mnt_new_table();
if (!mtab)
err(EXIT_FAILURE, _("failed to initialize libmount table"));
if (!cache)
cache = mnt_new_cache();
cache = mnt_new_cache();
mnt_table_set_cache(mtab, cache);
mnt_unref_cache(cache);
if (p_option)
rc = mnt_table_parse_file(mtab, _PATH_PROC_MOUNTINFO);
@ -1147,8 +1148,7 @@ int main(int argc, char **argv)
free(device);
free(mountpoint);
mnt_free_table(mtab);
mnt_unref_cache(cache);
mnt_unref_table(mtab);
return EXIT_SUCCESS;
}

View File

@ -641,6 +641,8 @@ static struct libmnt_table *append_fstab(struct libmnt_context *cxt,
mnt_table_set_parser_errcb(fstab, table_parser_errcb);
mnt_context_set_fstab(cxt, fstab);
mnt_unref_table(fstab); /* reference is handled by @cxt now */
}
if (mnt_table_parse_fstab(fstab, path))
@ -1078,7 +1080,6 @@ int main(int argc, char **argv)
success_message(cxt);
done:
mnt_free_context(cxt);
mnt_free_table(fstab);
return rc;
}

View File

@ -91,7 +91,7 @@ static int dir_to_device(const char *spec, dev_t *dev)
rc = 0;
}
mnt_free_table(tb);
mnt_unref_table(tb);
return rc;
}

View File

@ -41,8 +41,8 @@ struct libmnt_table *get_swaps(void)
void free_tables(void)
{
mnt_free_table(swaps);
mnt_free_table(fstab);
mnt_unref_table(swaps);
mnt_unref_table(fstab);
}
int match_swap(struct libmnt_fs *fs, void *data __attribute__((unused)))

View File

@ -317,7 +317,7 @@ static struct libmnt_table *new_mountinfo(struct libmnt_context *cxt)
if (mnt_table_parse_file(tb, _PATH_PROC_MOUNTINFO)) {
warn(_("failed to parse %s"), _PATH_PROC_MOUNTINFO);
mnt_free_table(tb);
mnt_unref_table(tb);
tb = NULL;
}
@ -400,7 +400,7 @@ static int umount_recursive(struct libmnt_context *cxt, const char *spec)
_("%s: not found"), spec);
}
mnt_free_table(tb);
mnt_unref_table(tb);
return rc;
}
@ -459,7 +459,7 @@ static int umount_alltargets(struct libmnt_context *cxt, const char *spec, int r
}
mnt_free_iter(itr);
mnt_free_table(tb);
mnt_unref_table(tb);
return rc;
}