// gcc -Wall -g gunixmounts.c `pkg-config --cflags --libs glib-2.0 gio-2.0 gio-unix-2.0` -o gunixmounts && ./gunixmounts

#include <glib.h>
#include <gio/gio.h>
#include <gio/gunixmounts.h>

void
on_mounts_changed (GUnixMountMonitor *monitor, gpointer user_data)
{
    GList *list, *l;
    guint64 time_read;

    list = g_unix_mounts_get (&time_read);
    g_print ("%"G_GUINT64_FORMAT": ", time_read);

    for (l = list; l != NULL; l = l->next)
    {
        g_print ("%s, ", g_unix_mount_get_mount_path ((GUnixMountEntry *)l->data));
    }
    g_print ("\n\n");
}

int
main (int argc, const char* argv[])
{
    GMainLoop *loop;
    GUnixMountMonitor *monitor;

    monitor = g_unix_mount_monitor_get ();
    on_mounts_changed (monitor, NULL);
    g_signal_connect (monitor, "mounts-changed", G_CALLBACK (on_mounts_changed), NULL);

    loop = g_main_loop_new (NULL, TRUE);
    g_main_loop_run (loop);
}
