Commit 6c152520 authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Include config.h to reenable reading /etc/fstab on platforms that

support it. Implemented a black list of mount directories, which should not be mapped. Ensure that the user's home directory is mapped.
parent 3b26f513
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* *
*/ */
#include "config.h"
#include <wine/debug.h> #include <wine/debug.h>
#include <wine/library.h> #include <wine/library.h>
...@@ -52,6 +54,11 @@ static char *ignored_fstypes[] = { ...@@ -52,6 +54,11 @@ static char *ignored_fstypes[] = {
NULL NULL
}; };
static char *ignored_mnt_dirs[] = {
"/boot",
NULL
};
static BOOL should_ignore_fstype(char *type) static BOOL should_ignore_fstype(char *type)
{ {
char **s; char **s;
...@@ -62,6 +69,16 @@ static BOOL should_ignore_fstype(char *type) ...@@ -62,6 +69,16 @@ static BOOL should_ignore_fstype(char *type)
return FALSE; return FALSE;
} }
static BOOL should_ignore_mnt_dir(char *dir)
{
char **s;
for (s = ignored_mnt_dirs; *s; s++)
if (!strcmp(*s, dir)) return TRUE;
return FALSE;
}
static BOOL is_drive_defined(char *path) static BOOL is_drive_defined(char *path)
{ {
int i; int i;
...@@ -88,6 +105,7 @@ static char allocate_letter() ...@@ -88,6 +105,7 @@ static char allocate_letter()
#define NO_MORE_LETTERS 2 #define NO_MORE_LETTERS 2
#define NO_ROOT 3 #define NO_ROOT 3
#define NO_DRIVE_C 4 #define NO_DRIVE_C 4
#define NO_HOME 5
static void report_error(int code) static void report_error(int code)
{ {
...@@ -108,13 +126,13 @@ static void report_error(int code) ...@@ -108,13 +126,13 @@ static void report_error(int code)
} }
else else
{ {
fprintf(stderr, "winecfg: could not open fstab: %s", strerror(errno)); fprintf(stderr, "winecfg: could not open fstab: %s\n", strerror(errno));
} }
break; break;
case NO_MORE_LETTERS: case NO_MORE_LETTERS:
if (gui_mode) MessageBox(NULL, "No more letters are available to auto-detect available drives with.", "", MB_OK | MB_ICONEXCLAMATION); if (gui_mode) MessageBox(NULL, "No more letters are available to auto-detect available drives with.", "", MB_OK | MB_ICONEXCLAMATION);
fprintf(stderr, "winecfg: no more available letters while scanning /etc/fstab"); fprintf(stderr, "winecfg: no more available letters while scanning /etc/fstab\n");
break; break;
case NO_ROOT: case NO_ROOT:
...@@ -132,8 +150,17 @@ static void report_error(int code) ...@@ -132,8 +150,17 @@ static void report_error(int code)
MessageBox(NULL, "No virtual drive C mapped\n\nTry running wineprefixcreate", "", MB_OK | MB_ICONEXCLAMATION); MessageBox(NULL, "No virtual drive C mapped\n\nTry running wineprefixcreate", "", MB_OK | MB_ICONEXCLAMATION);
else else
fprintf(stderr, "winecfg: no drive_c directory\n"); fprintf(stderr, "winecfg: no drive_c directory\n");
case NO_HOME:
if (gui_mode)
MessageBox(NULL, "Could not ensure that your home directory was mapped.\n\n"
"This can happen if you run out of drive letters. "
"Try unmapping a drive letter then try again.", "",
MB_OK | MB_ICONEXCLAMATION);
else
fprintf(stderr, "winecfg: unable to map home drive\n");
break;
} }
} }
static void ensure_root_is_mapped() static void ensure_root_is_mapped()
...@@ -163,6 +190,34 @@ static void ensure_root_is_mapped() ...@@ -163,6 +190,34 @@ static void ensure_root_is_mapped()
} }
} }
static void ensure_home_is_mapped()
{
int i;
BOOL mapped = FALSE;
char *home = getenv("HOME");
if (!home) return;
for (i = 0; i < 26; i++)
if (drives[i].in_use && !strcmp(drives[i].unixpath, home)) mapped = TRUE;
if (!mapped)
{
char letter;
for (letter = 'H'; letter <= 'Z'; letter++)
{
if (!drives[letter - 'A'].in_use)
{
add_drive(letter, home, "Home", "0", DRIVE_FIXED);
WINE_TRACE("allocated drive %c as the user's home directory\n", letter);
break;
}
}
if (letter == ('Z' + 1)) report_error(NO_HOME);
}
}
static void ensure_drive_c_is_mapped() static void ensure_drive_c_is_mapped()
{ {
struct stat buf; struct stat buf;
...@@ -222,6 +277,7 @@ int autodetect_drives() ...@@ -222,6 +277,7 @@ int autodetect_drives()
WINE_TRACE("ent->mnt_dir=%s\n", ent->mnt_dir); WINE_TRACE("ent->mnt_dir=%s\n", ent->mnt_dir);
if (should_ignore_fstype(ent->mnt_type)) continue; if (should_ignore_fstype(ent->mnt_type)) continue;
if (should_ignore_mnt_dir(ent->mnt_dir)) continue;
if (is_drive_defined(ent->mnt_dir)) continue; if (is_drive_defined(ent->mnt_dir)) continue;
/* allocate a drive for it */ /* allocate a drive for it */
...@@ -249,7 +305,8 @@ int autodetect_drives() ...@@ -249,7 +305,8 @@ int autodetect_drives()
add_drive(letter, ent->mnt_dir, label, "0", type); add_drive(letter, ent->mnt_dir, label, "0", type);
working_mask |= DRIVE_MASK_BIT(letter); /* working_mask is a map of the drive letters still available. */
working_mask &= ~DRIVE_MASK_BIT(letter);
} }
fclose(fstab); fclose(fstab);
...@@ -259,5 +316,7 @@ int autodetect_drives() ...@@ -259,5 +316,7 @@ int autodetect_drives()
ensure_drive_c_is_mapped(); ensure_drive_c_is_mapped();
ensure_home_is_mapped();
return TRUE; return TRUE;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment