diff -u -r -N hw/xfree86/common.orig/Makefile.am hw/xfree86/common/Makefile.am --- hw/xfree86/common.orig/Makefile.am 2006-08-06 18:01:51.000000000 +0200 +++ hw/xfree86/common/Makefile.am 2006-08-06 18:03:28.000000000 +0200 @@ -31,7 +31,7 @@ BUILT_SOURCES = xf86DefModeSet.c AM_LDFLAGS = -r -libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \ +libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \ xf86Cursor.c xf86cvt.c xf86DGA.c xf86DPMS.c \ xf86DoProbe.c xf86DoScanPci.c xf86Events.c \ xf86Globals.c xf86Io.c xf86AutoConfig.c \ diff -u -r -N hw/xfree86/common.orig/xf86.h hw/xfree86/common/xf86.h --- hw/xfree86/common.orig/xf86.h 2006-08-06 18:01:51.000000000 +0200 +++ hw/xfree86/common/xf86.h 2006-08-06 18:05:18.000000000 +0200 @@ -48,6 +48,7 @@ /* General parameters */ extern int xf86DoConfigure; +extern int xf86DoShowOptions; extern Bool xf86DoConfigurePass1; extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */ extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */ diff -u -r -N hw/xfree86/common.orig/xf86Globals.c hw/xfree86/common/xf86Globals.c --- hw/xfree86/common.orig/xf86Globals.c 2006-08-06 18:01:51.000000000 +0200 +++ hw/xfree86/common/xf86Globals.c 2006-08-06 18:05:49.000000000 +0200 @@ -188,6 +188,7 @@ Bool xf86ProbeFailed = FALSE; Bool xf86DoProbe = FALSE; Bool xf86DoConfigure = FALSE; +Bool xf86DoShowOptions = FALSE; DriverPtr *xf86DriverList = NULL; int xf86NumDrivers = 0; InputDriverPtr *xf86InputDriverList = NULL; diff -u -r -N hw/xfree86/common.orig/xf86Init.c hw/xfree86/common/xf86Init.c --- hw/xfree86/common.orig/xf86Init.c 2006-08-06 18:01:51.000000000 +0200 +++ hw/xfree86/common/xf86Init.c 2006-08-06 18:07:55.000000000 +0200 @@ -309,7 +309,7 @@ } /* Read and parse the config file */ - if (!xf86DoProbe && !xf86DoConfigure) { + if (!xf86DoProbe && !xf86DoConfigure && !xf86DoShowOptions) { switch (xf86HandleConfigFile(FALSE)) { case CONFIG_OK: break; @@ -367,7 +367,10 @@ /* Force load mandatory base modules */ if (!xf86LoadModules(baseModules, NULL)) FatalError("Unable to load required base modules, Exiting...\n"); - + + if (xf86DoShowOptions) + DoShowOptions(); + xf86OpenConsole(); /* Do a general bus probe. This will be a PCI probe for x86 platforms */ @@ -1657,6 +1660,15 @@ xf86AllowMouseOpenFail = TRUE; return 1; } + if (!strcmp(argv[i], "-showopts")) + { + if (getuid() != 0 && geteuid() == 0) { + ErrorF("The '-showopts' option can only be used by root.\n"); + exit(1); + } + xf86DoShowOptions = TRUE; + return 1; + } if (!strcmp(argv[i], "-isolateDevice")) { int bus, device, func; @@ -1699,6 +1711,7 @@ ErrorF("-modulepath paths specify the module search path\n"); ErrorF("-logfile file specify a log file name\n"); ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n"); + ErrorF("-showopts print available options for all installed drivers\n"); } ErrorF("-config file specify a configuration file, relative to the\n"); ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n"); diff -u -r -N hw/xfree86/common.orig/xf86Priv.h hw/xfree86/common/xf86Priv.h --- hw/xfree86/common.orig/xf86Priv.h 2006-08-06 18:01:51.000000000 +0200 +++ hw/xfree86/common/xf86Priv.h 2006-08-06 18:02:03.000000000 +0200 @@ -169,6 +169,7 @@ /* xf86DoProbe.c */ void DoProbe(void); void DoConfigure(void); +void DoShowOptions(void); /* xf86Events.c */ diff -u -r -N hw/xfree86/common.orig/xf86ShowOpts.c hw/xfree86/common/xf86ShowOpts.c --- hw/xfree86/common.orig/xf86ShowOpts.c 1970-01-01 01:00:00.000000000 +0100 +++ hw/xfree86/common/xf86ShowOpts.c 2006-08-06 18:02:03.000000000 +0200 @@ -0,0 +1,129 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86ShopwOpts.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */ +/* + * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Marcus Schaefer, ms@suse.de + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "os.h" +#ifdef XFree86LOADER +#include "loaderProcs.h" +#endif +#include "xf86.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xf86Priv.h" +#include "xf86PciData.h" +#define IN_XSERVER +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include "vbe.h" +#include "xf86DDC.h" +#if defined(__sparc__) && !defined(__OpenBSD__) +#include "xf86Bus.h" +#include "xf86Sbus.h" +#endif +#include "globals.h" + +static const char* +optionTypeToSting(OptionValueType type) +{ + switch (type) { + case OPTV_NONE: + return ""; + case OPTV_INTEGER: + return ""; + case OPTV_STRING: + return ""; + case OPTV_ANYSTR: + return ""; + case OPTV_REAL: + return ""; + case OPTV_BOOLEAN: + return ""; + case OPTV_FREQ: + return ""; + default: + return ""; + } +} + +void DoShowOptions (void) { + int i = 0; + char **vlist = 0; + char *pSymbol = 0; + XF86ModuleData *initData = 0; + if (! (vlist = xf86DriverlistFromCompile())) { + ErrorF("Missing output drivers\n"); + goto bail; + } + xf86LoadModules (vlist,0); + xfree (vlist); + for (i = 0; i < xf86NumDrivers; i++) { + if (xf86DriverList[i]->AvailableOptions) { + OptionInfoPtr pOption = (OptionInfoPtr)(*xf86DriverList[i]->AvailableOptions)(0,0); + if (! pOption) { + ErrorF ("(EE) Couldn't read option table for %s driver\n", + xf86DriverList[i]->driverName + ); + continue; + } + pSymbol = xalloc ( + strlen(xf86DriverList[i]->driverName) + strlen("ModuleData") + 1 + ); + strcpy (pSymbol, xf86DriverList[i]->driverName); + strcat (pSymbol, "ModuleData"); + initData = LoaderSymbol (pSymbol); + if (initData) { + XF86ModuleVersionInfo *vers = initData->vers; + ErrorF ("Driver[%d]:%s[%s] {\n", + i,xf86DriverList[i]->driverName,vers->vendor + ); + OptionInfoPtr p; + for (p = pOption; p->name != NULL; p++) { + const char *opttype = optionTypeToSting(p->type); + char *optname = xalloc(strlen(p->name) + 2 + 1); + if (!optname) { + continue; + } + sprintf(optname, "%s", p->name); + ErrorF ("\t%s:%s\n", optname,opttype); + } + ErrorF ("}\n"); + } + } + } + bail: + OsCleanup (TRUE); + AbortDDX (); + fflush (stderr); + exit (0); +}