list the filesystems on linux.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 28 Jul 2009 22:44:50 +0000 (22:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 28 Jul 2009 22:44:50 +0000 (22:44 +0000)
source/blender/editors/space_file/fsmenu.c

index 12a3c38ab0946603eae5fcadbc5e526e6b917701..41d97e1e0ae1700b21b1922dad6f84aaf18898ac 100644 (file)
 #include "BKE_utildefines.h"
 #endif
 
+#ifdef __linux__
+#include <mntent.h>
+#endif
+
 #include "fsmenu.h"  /* include ourselves */
 
 
@@ -303,7 +307,7 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
                char dir[FILE_MAXDIR];
                char *home= BLI_gethome();
 
-               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0);
+               // fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0);
 
                if(home) {
                        BLI_snprintf(dir, FILE_MAXDIR, "%s/", home);
@@ -311,6 +315,33 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
                        BLI_snprintf(dir, FILE_MAXDIR, "%s/Desktop/", home);
                        fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, dir, 1, 0);
                }
+
+               {
+                       /* loop over mount points */
+                       struct mntent *mnt;
+                       FILE *fp;
+                       fp = setmntent (MOUNTED, "r");
+                       if (fp == NULL) {
+                               fprintf(stderr, "could not get a list of mounted filesystemts\n");
+                       }
+                       else {
+                               while ((mnt = getmntent (fp))) {
+                                       /* printf("%s %s %s %s %s %s\n", mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, mnt->mnt_opts, mnt->mnt_freq, mnt->mnt_passno); */
+
+                                       /* probably need to add more here */
+                                       if(     (strcmp (mnt->mnt_fsname, "none")==0) ||        /* /sys, /dev/pts */
+                                               (strcmp (mnt->mnt_type, "ramfs")==0)            /* /dev */
+                                       ) {
+                                               continue;
+                                       }
+
+                                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0);
+                               }
+                               if (endmntent (fp) == 0) {
+                                       fprintf(stderr, "could not close the list of mounted filesystemts\n");
+                               }
+                       }
+               }
        }
 #endif
 #endif