Skip to content

Instantly share code, notes, and snippets.

@sahib
Created January 23, 2015 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sahib/cd4dd145eccd2cf84ce0 to your computer and use it in GitHub Desktop.
Save sahib/cd4dd145eccd2cf84ce0 to your computer and use it in GitHub Desktop.
#include <gio/gunixmounts.h>
#include <glib.h>
/* Compile with:
gcc list-disks.c $(pkg-config --libs --cflags gio-unix-2.0) -std=c11 -ggdb3 -W -Wall
*/
int main(void) {
g_printerr("MOUNTS:\n");
GList *mounts = g_unix_mounts_get(NULL);
for(GList *iter = mounts; iter; iter = iter->next) {
GUnixMountEntry *entry = iter->data;
char *guessed_name = g_unix_mount_guess_name(entry);
g_printerr(
" %s%s dev=%s mount=%s fs_type=%s name=%s\n",
g_unix_mount_is_system_internal(entry) ? " " : "*",
g_unix_mount_guess_should_display(entry) ? "^" : " ",
g_unix_mount_get_device_path(entry),
g_unix_mount_get_mount_path(entry),
g_unix_mount_get_fs_type(entry),
guessed_name
);
g_free(guessed_name);
}
g_list_free_full(mounts, (GDestroyNotify)g_unix_mount_free);
g_printerr("\nMOUNTPOINTS:\n");
GList *points = g_unix_mount_points_get(NULL);
for(GList *iter = points; iter; iter = iter->next) {
GUnixMountPoint *point = iter->data;
char *guessed_name = g_unix_mount_point_guess_name(point);
g_printerr(
" dev=%s mount=%s fs_type=%s name=%s\n",
g_unix_mount_point_get_device_path(point),
g_unix_mount_point_get_mount_path(point),
g_unix_mount_point_get_fs_type(point),
guessed_name
);
g_free(guessed_name);
}
g_list_free_full(points, (GDestroyNotify)g_unix_mount_point_free);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment