/* Compile with: gcc -o test-libmount test-libmount.c -g -Wall -lmount */
#include <libmount/libmount.h>
#include <stdio.h>

int main(int argc, char **argv)
{
  struct libmnt_table *table = NULL;
  struct libmnt_context *ctxt = NULL;
  struct libmnt_iter* iter = NULL;
  struct libmnt_fs *fs = NULL;

  ctxt = mnt_new_context ();
  mnt_context_get_mtab (ctxt, &table);
  if (!table)
    goto out;

  iter = mnt_new_iter (MNT_ITER_FORWARD);
  while (mnt_table_next_fs (table, iter, &fs) == 0)
    {
      printf ("%s %s %d\n",
              mnt_fs_get_source (fs),
              mnt_fs_get_target (fs),
              mnt_table_is_fs_mounted (table, fs));
    }
  mnt_free_iter (iter);

 out:
  mnt_free_context (ctxt);

  return 0;
}
