#include <glib.h> #include <mntent.h> #include <string.h> GList * g_get_drives_list(GList * g) { FILE *fstab = NULL; struct mntent *part = NULL; gchar *mntp = NULL; if ((fstab = setmntent( "/etc/fstab", "r" )) != NULL) { while ((part = getmntent(fstab)) != NULL) { if((strcmp(part->mnt_type, "proc")) != 0 && (strcmp(part->mnt_type, "devpts")) != 0 && (strcmp(part->mnt_type, "swap")) != 0) { mntp = g_strdup(part->mnt_dir); g=g_list_append(g, mntp); } } endmntent(fstab); } if ((fstab = setmntent( "/etc/mtab", "r")) != NULL) { while ((part = getmntent(fstab)) != NULL) { if (part->mnt_type != NULL) { if((strcmp(part->mnt_type, "proc")) != 0 && (strcmp(part->mnt_type, "devpts")) != 0 && (strcmp(part->mnt_type, "swap")) != 0 && (strcmp(part->mnt_type, "sysfs")) != 0 && (strcmp(part->mnt_type, "tmpfs")) != 0 && (strcmp(part->mnt_type, "fuseblk")) != 0 && (strcmp(part->mnt_type, "securityfs")) != 0) { if((g_list_find_custom(g, part->mnt_dir, (GCompareFunc)strcmp)) == 0) { mntp=g_strdup(part->mnt_dir); g=g_list_append(g, mntp); } } } } endmntent(fstab); } return g; }
You need to create an account or log in to post comments to this site.