diff options
author | Dan Nicholson <dbn.lists@gmail.com> | 2009-12-21 01:13:44 -0800 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2009-12-22 23:20:52 -0800 |
commit | 592b20c517461d32daf44a940386ffcc11c434f8 (patch) | |
tree | d20c89e68fe9fb9b7a55d013b327535c3dd2cebe /hw/xfree86/common/xf86Config.c | |
parent | efa5269f23c2237eb5368bf5245ffbbf35714153 (diff) |
xfree86: Allow config directory to be specified on command line
Add a new command line parameter, -configdir, to specify the config
directory to be used. Rules are the same as -config for root vs. user
privileges.
Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Diffstat (limited to 'hw/xfree86/common/xf86Config.c')
-rw-r--r-- | hw/xfree86/common/xf86Config.c | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index ffb964386..e4f0d2388 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -95,12 +95,22 @@ extern DeviceAssocRec mouse_assoc; "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ "%P/lib/X11/%X" #endif -#ifndef CONFIGDIRPATH -#define CONFIGDIRPATH "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ - "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ - "%P/etc/X11/%X," \ - "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ - "%P/lib/X11/%X" +#ifndef ROOT_CONFIGDIRPATH +#define ROOT_CONFIGDIRPATH "%A," "%R," \ + "/etc/X11/%R," "%P/etc/X11/%R," \ + "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" +#endif +#ifndef USER_CONFIGDIRPATH +#define USER_CONFIGDIRPATH "/etc/X11/%S," "%P/etc/X11/%S," \ + "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ + "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ + "%P/etc/X11/%X," \ + "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ + "%P/lib/X11/%X" #endif #ifndef PROJECTROOT #define PROJECTROOT "/usr/X11R6" @@ -2397,35 +2407,48 @@ ConfigStatus xf86HandleConfigFile(Bool autoconfig) { const char *filename, *dirname; - char *searchpath; - MessageType from = X_DEFAULT; + char *filesearch, *dirsearch; + MessageType filefrom = X_DEFAULT; + MessageType dirfrom = X_DEFAULT; char *scanptr; Bool singlecard = 0; Bool implicit_layout = FALSE; if (!autoconfig) { - if (getuid() == 0) - searchpath = ROOT_CONFIGPATH; - else - searchpath = USER_CONFIGPATH; + if (getuid() == 0) { + filesearch = ROOT_CONFIGPATH; + dirsearch = ROOT_CONFIGDIRPATH; + } else { + filesearch = USER_CONFIGPATH; + dirsearch = USER_CONFIGDIRPATH; + } if (xf86ConfigFile) - from = X_CMDLINE; + filefrom = X_CMDLINE; + if (xf86ConfigDir) + dirfrom = X_CMDLINE; xf86initConfigFiles(); - filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT); - dirname = xf86openConfigDirFiles(CONFIGDIRPATH, NULL, PROJECTROOT); + filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT); + dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT); if (filename) { - xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename); + xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename); xf86ConfigFile = xnfstrdup(filename); } else { if (xf86ConfigFile) xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n", xf86ConfigFile); } - if (dirname) - xf86MsgVerb(X_DEFAULT, 0, "Using config directory: \"%s\"\n", + if (dirname) { + xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n", dirname); + xf86ConfigDir = xnfstrdup(dirname); + } else { + if (xf86ConfigDir) + xf86Msg(X_ERROR, + "Unable to locate/open config directory: \"%s\"\n", + xf86ConfigDir); + } if (!filename && !dirname) return CONFIG_NOFILE; } |