diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-07-27 09:53:14 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-07-27 09:53:14 +0000 |
commit | 8ef3e7052e8e1db869411e9f6fc88491e3f05474 (patch) | |
tree | 2c39c0514122143f69dad0c5d98c5e26d9babc5b /hw/xwin/InitOutput.c | |
parent | a12a678bc9af8df1a3078f574b0c910e3e6983f8 (diff) |
Merge latest changes from CYGWIN branch
Use find | xargs combination instead of simple shell globbing to prevent
commandline argument overflow
Diffstat (limited to 'hw/xwin/InitOutput.c')
-rw-r--r-- | hw/xwin/InitOutput.c | 93 |
1 files changed, 91 insertions, 2 deletions
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index c8f92d25a..673a0aa98 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -35,6 +35,7 @@ from The Open Group. #endif #include "winprefs.h" #include "X11/Xlocale.h" +#include <mntent.h> /* @@ -45,7 +46,7 @@ extern int g_iNumScreens; extern winScreenInfo g_ScreenInfo[]; extern int g_iLastScreen; extern char * g_pszCommandLine; -extern Bool g_fUseMsg; +extern Bool g_fSilentFatalError; extern char * g_pszLogFile; extern int g_iLogVerbose; @@ -72,6 +73,7 @@ extern FARPROC g_fpDirectDrawCreateClipper; extern HMODULE g_hmodCommonControls; extern FARPROC g_fpTrackMouseEvent; extern Bool g_fNoHelpMessageBox; +extern Bool g_fSilentDupError; /* @@ -267,6 +269,89 @@ AbortDDX (void) ddxGiveUp (); } +/* hasmntopt is currently not implemented for cygwin */ +const char *winCheckMntOpt(const struct mntent *mnt, const char *opt) +{ + const char *s; + size_t len; + if (mnt == NULL) + return NULL; + if (opt == NULL) + return NULL; + if (mnt->mnt_opts == NULL) + return NULL; + + len = strlen(opt); + s = strstr(mnt->mnt_opts, opt); + if (s == NULL) + return NULL; + if ((s == mnt->mnt_opts || *(s-1) == ',') && (s[len] == 0 || s[len] == ',')) + return (char *)opt; + return NULL; +} + +void +winCheckMount(void) +{ + FILE *mnt; + struct mntent *ent; + + enum { none = 0, sys_root, user_root, sys_tmp, user_tmp } + level = none, curlevel; + BOOL binary = TRUE; + + mnt = setmntent("/etc/mtab", "r"); + if (mnt == NULL) + { + ErrorF("setmntent failed"); + return; + } + + while ((ent = getmntent(mnt)) != NULL) + { + BOOL system = (strcmp(ent->mnt_type, "system") == 0); + BOOL root = (strcmp(ent->mnt_dir, "/") == 0); + BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0); + + if (system) + { + if (root) + curlevel = sys_root; + else if (tmp) + curlevel = sys_tmp; + else + continue; + } + else + { + if (root) + curlevel = user_root; + else if (tmp) + curlevel = user_tmp; + else + continue; + } + + if (curlevel <= level) + continue; + level = curlevel; + + if (winCheckMntOpt(ent, "binmode") == NULL) + binary = 0; + else + binary = 1; + } + + if (endmntent(mnt) != 1) + { + ErrorF("endmntent failed"); + return; + } + + if (!binary) + winMsg(X_WARNING, "/tmp mounted int textmode\n"); +} + void OsVendorInit (void) @@ -296,6 +381,8 @@ OsVendorInit (void) if (serverGeneration == 1) winLogVersionInfo (); + winCheckMount(); + /* Add a default screen if no screens were specified */ if (g_iNumScreens == 0) { @@ -472,7 +559,7 @@ void ddxUseMsg(void) { /* Set a flag so that FatalError won't give duplicate warning message */ - g_fUseMsg = TRUE; + g_fSilentFatalError = TRUE; winUseMsg(); @@ -534,6 +621,8 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[]) /* Check for duplicate invocation on same display number.*/ if (serverGeneration == 1 && !winCheckDisplayNumber ()) { + if (g_fSilentDupError) + g_fSilentFatalError = TRUE; FatalError ("InitOutput - Duplicate invocation on display " "number: %s. Exiting.\n", display); } |