Only do 'drive' discovery on X11

As it turns out older versions of the Android NDK have mntent.h but not
a complete implementation. If it did work it would most likely give the
wrong results on Android anyway.

This commit enables the UNIX drive discovery only for X11

We also missed '/run/media' (default for gnome desktops) in the list of
places to look for 'drives' on Linux. Add that to the list also.

This fixes #11270
This commit is contained in:
Hein-Pieter van Braam 2017-09-14 21:43:17 +02:00
parent 5636ac526e
commit 65af96eab0

View file

@ -183,17 +183,18 @@ void DirAccessUnix::list_dir_end() {
_cisdir = false;
}
#ifdef HAVE_MNTENT
#if defined(HAVE_MNTENT) && defined(X11_ENABLED)
static bool _filter_drive(struct mntent *mnt) {
// Ignore devices that don't point to /dev
if (strncmp(mnt->mnt_fsname, "/dev", 4) != 0) {
return false;
}
// Accept devices mounted at /media, /mnt or /home
// Accept devices mounted at common locations
if (strncmp(mnt->mnt_dir, "/media", 6) == 0 ||
strncmp(mnt->mnt_dir, "/mnt", 4) == 0 ||
strncmp(mnt->mnt_dir, "/home", 5) == 0) {
strncmp(mnt->mnt_dir, "/home", 5) == 0 ||
strncmp(mnt->mnt_dir, "/run/media", 10) == 0) {
return true;
}
@ -204,7 +205,7 @@ static bool _filter_drive(struct mntent *mnt) {
static void _get_drives(List<String> *list) {
#ifdef HAVE_MNTENT
#if defined(HAVE_MNTENT) && defined(X11_ENABLED)
// Check /etc/mtab for the list of mounted partitions
FILE *mtab = setmntent("/etc/mtab", "r");
if (mtab) {