diff options
author | Karel Zak | 2013-08-20 14:35:13 +0200 |
---|---|---|
committer | Karel Zak | 2013-08-20 14:35:13 +0200 |
commit | a2f17bb24ee7c3dd25639f78d5fd123161392e0c (patch) | |
tree | 1698c88363d887155b5054b8bfd1076dee3fe7c0 /sys-utils/swapon.c | |
parent | pylibmount: coding style changes, don't touch Context() status (diff) | |
download | kernel-qcow2-util-linux-a2f17bb24ee7c3dd25639f78d5fd123161392e0c.tar.gz kernel-qcow2-util-linux-a2f17bb24ee7c3dd25639f78d5fd123161392e0c.tar.xz kernel-qcow2-util-linux-a2f17bb24ee7c3dd25639f78d5fd123161392e0c.zip |
libmount: add mnt_table_is_empty(), improve table list usage
Currently you have to use mnt_table_remove_fs() + mnt_free_fs() to
destroy the list in the table. This is complicated in same situations.
This patch allows to use mnt_free_fs() only.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/swapon.c')
-rw-r--r-- | sys-utils/swapon.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c index f1e243375..4b4b7160c 100644 --- a/sys-utils/swapon.c +++ b/sys-utils/swapon.c @@ -188,12 +188,14 @@ static int display_summary(void) if (!st) return -1; + if (mnt_table_is_empty(st)) + return 0; + itr = mnt_new_iter(MNT_ITER_FORWARD); if (!itr) err(EXIT_FAILURE, _("failed to initialize libmount iterator")); - if (mnt_table_get_nents(st) > 0) - printf(_("%s\t\t\t\tType\t\tSize\tUsed\tPriority\n"), _("Filename")); + printf(_("%s\t\t\t\tType\t\tSize\tUsed\tPriority\n"), _("Filename")); while (mnt_table_next_fs(st, itr, &fs) == 0) { printf("%-39s\t%s\t%jd\t%jd\t%d\n", |