#include <stdio.h>
#include <err.h>
#include <string.h>
#include <libmount.h>

int
main()
{
    int r;
    const char *version;

    r = mnt_get_library_version(&version);
    if (r < 0)
        errx(1, "failed to get lib versino: %s", strerror (-r));
    printf("libmount version: %s\n", version);

    struct libmnt_table *table = mnt_new_table();
    r = mnt_table_parse_mtab (table, NULL);
    if (r < 0)
        errx(1, "failed to parse mtab: %s", strerror (-r));

    struct libmnt_fs *fs;
    r = mnt_table_first_fs(table, &fs);
    if (r < 0)
        errx(1, "failed to find first fs: %s", strerror (-r));
    printf("first fs type: %s source: %s target: %s\n", mnt_fs_get_fstype(fs), mnt_fs_get_source(fs), mnt_fs_get_target(fs));
    mnt_free_fs(fs);

    mnt_free_table(table);
    return 0;
}
