Re: [Mesa-dev] [PATCH 1/2] xmlconfig: read more config files from drirc.d/
OK, I'll move /etc/drirc to /usr/share/drirc.d. For /etc/drirc and /etc/drirc.d, I agree to keep /etc/drirc for keeping user convention of the previously usage of this file. As newly added /etc/drirc.d, just for admin's flexibility, I can drop it if no clear needs for now. Regards, Qiang From: mesa-dev on behalf of Michel Dänzer Sent: Thursday, August 2, 2018 9:54:51 PM To: Eric Engestrom Cc: mesa-dev@lists.freedesktop.org Subject: Re: [Mesa-dev] [PATCH 1/2] xmlconfig: read more config files from drirc.d/ On 2018-08-02 02:50 PM, Eric Engestrom wrote: > On Thursday, 2018-08-02 11:33:05 +0200, Michel Dänzer wrote: >> On 2018-08-01 01:10 PM, Qiang Yu wrote: >>> Add two places for hosting drirc config files: >>> /usr/share/drirc.d/ /etc/drirc.d/ >>> >>> Driver and application can put their drirc files in >>> these places with name xxx.conf. Config files will be >>> read and applied in file name alphabete order. >>> >>> So there are four places for drirc listed in order: >>> 1. /usr/share/drirc.d/ >>> 2. /etc/drirc.d/ >>> 3. /etc/drirc >>> 4. ~/.drirc >>> >>> Signed-off-by: Qiang Yu >> >> Mesa's own drirc should also be moved to >> $(datadir)/drirc.d/00-mesa-defaults.conf, either in this patch or a >> follow-up one. > > Agreed, which means there won't be a /etc/drirc anymore. > > If we do keep it though, I would expect /etc/drirc.d/10-foo.conf to > override /etc/drirc; in other words, I would swap 2 & 3 in that list > (and in the code). Hmm, based on experience with Xorg, I'd rather keep /etc/drirc and not add /etc/drirc.d/ than the other way around. Is there a use case for an administrator using multiple snippets in /etc/drirc.d/ ? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] xmlconfig: read more config files from drirc.d/
On 2018-08-02 02:50 PM, Eric Engestrom wrote: > On Thursday, 2018-08-02 11:33:05 +0200, Michel Dänzer wrote: >> On 2018-08-01 01:10 PM, Qiang Yu wrote: >>> Add two places for hosting drirc config files: >>> /usr/share/drirc.d/ /etc/drirc.d/ >>> >>> Driver and application can put their drirc files in >>> these places with name xxx.conf. Config files will be >>> read and applied in file name alphabete order. >>> >>> So there are four places for drirc listed in order: >>> 1. /usr/share/drirc.d/ >>> 2. /etc/drirc.d/ >>> 3. /etc/drirc >>> 4. ~/.drirc >>> >>> Signed-off-by: Qiang Yu >> >> Mesa's own drirc should also be moved to >> $(datadir)/drirc.d/00-mesa-defaults.conf, either in this patch or a >> follow-up one. > > Agreed, which means there won't be a /etc/drirc anymore. > > If we do keep it though, I would expect /etc/drirc.d/10-foo.conf to > override /etc/drirc; in other words, I would swap 2 & 3 in that list > (and in the code). Hmm, based on experience with Xorg, I'd rather keep /etc/drirc and not add /etc/drirc.d/ than the other way around. Is there a use case for an administrator using multiple snippets in /etc/drirc.d/ ? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] xmlconfig: read more config files from drirc.d/
On Thursday, 2018-08-02 11:33:05 +0200, Michel Dänzer wrote: > On 2018-08-01 01:10 PM, Qiang Yu wrote: > > Add two places for hosting drirc config files: > > /usr/share/drirc.d/ /etc/drirc.d/ > > > > Driver and application can put their drirc files in > > these places with name xxx.conf. Config files will be > > read and applied in file name alphabete order. > > > > So there are four places for drirc listed in order: > > 1. /usr/share/drirc.d/ > > 2. /etc/drirc.d/ > > 3. /etc/drirc > > 4. ~/.drirc > > > > Signed-off-by: Qiang Yu > > Mesa's own drirc should also be moved to > $(datadir)/drirc.d/00-mesa-defaults.conf, either in this patch or a > follow-up one. Agreed, which means there won't be a /etc/drirc anymore. If we do keep it though, I would expect /etc/drirc.d/10-foo.conf to override /etc/drirc; in other words, I would swap 2 & 3 in that list (and in the code). With that, the patch itself is: Reviewed-by: Eric Engestrom ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] xmlconfig: read more config files from drirc.d/
On 2018-08-01 01:10 PM, Qiang Yu wrote: > Add two places for hosting drirc config files: > /usr/share/drirc.d/ /etc/drirc.d/ > > Driver and application can put their drirc files in > these places with name xxx.conf. Config files will be > read and applied in file name alphabete order. > > So there are four places for drirc listed in order: > 1. /usr/share/drirc.d/ > 2. /etc/drirc.d/ > 3. /etc/drirc > 4. ~/.drirc > > Signed-off-by: Qiang Yu Mesa's own drirc should also be moved to $(datadir)/drirc.d/00-mesa-defaults.conf, either in this patch or a follow-up one. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] xmlconfig: read more config files from drirc.d/
Add two places for hosting drirc config files: /usr/share/drirc.d/ /etc/drirc.d/ Driver and application can put their drirc files in these places with name xxx.conf. Config files will be read and applied in file name alphabete order. So there are four places for drirc listed in order: 1. /usr/share/drirc.d/ 2. /etc/drirc.d/ 3. /etc/drirc 4. ~/.drirc Signed-off-by: Qiang Yu --- docs/autoconf.html | 11 +- src/util/Makefile.am | 1 + src/util/meson.build | 4 +- src/util/xmlconfig.c | 104 ++- 4 files changed, 83 insertions(+), 37 deletions(-) diff --git a/docs/autoconf.html b/docs/autoconf.html index df243c2..5f1a006 100644 --- a/docs/autoconf.html +++ b/docs/autoconf.html @@ -90,8 +90,15 @@ tree. --sysconfdir=DIR This option specifies the directory where the configuration files will be installed. The default is ${prefix}/etc. -Currently there's only one config file provided when dri drivers are -enabled - it's drirc. +Currently when dri drivers are enabled, drirc drirc.d/ +are in this place. + + +--datadir=DIR +This option specifies the directory where the data files will +be installed. The default is ${prefix}/share. +Currently when dri drivers are enabled, drirc.d/ is at +this place. --enable-static, --disable-shared diff --git a/src/util/Makefile.am b/src/util/Makefile.am index bafb574..8d8c156 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -67,6 +67,7 @@ libxmlconfig_la_CFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DDATADIR=\"$(datadir)\" \ $(VISIBILITY_CFLAGS) \ $(EXPAT_CFLAGS) libxmlconfig_la_LIBADD = $(EXPAT_LIBS) -lm diff --git a/src/util/meson.build b/src/util/meson.build index 8c91be8..108524b 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -121,7 +121,9 @@ libxmlconfig = static_library( c_args : [ c_msvc_compat_args, c_vis_args, '-DSYSCONFDIR="@0@"'.format( - join_paths(get_option('prefix'), get_option('sysconfdir')) + join_paths(get_option('prefix'), get_option('sysconfdir')), +'-DDATADIR="@0@"'.format( + join_paths(get_option('prefix'), get_option('datadir')) ), ], build_by_default : false, diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c index d384791..a3869ac 100644 --- a/src/util/xmlconfig.c +++ b/src/util/xmlconfig.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include "xmlconfig.h" #include "process.h" @@ -866,9 +868,8 @@ initOptionCache(driOptionCache *cache, const driOptionCache *info) } } -/** \brief Parse the named configuration file */ static void -parseOneConfigFile(XML_Parser p) +_parseOneConfigFile(XML_Parser p) { #define BUF_SIZE 0x1000 struct OptConfData *data = (struct OptConfData *)XML_GetUserData (p); @@ -907,17 +908,75 @@ parseOneConfigFile(XML_Parser p) #undef BUF_SIZE } +/** \brief Parse the named configuration file */ +static void +parseOneConfigFile(struct OptConfData *data, const char *filename) +{ +XML_Parser p; + +p = XML_ParserCreate (NULL); /* use encoding specified by file */ +XML_SetElementHandler (p, optConfStartElem, optConfEndElem); +XML_SetUserData (p, data); +data->parser = p; +data->name = filename; +data->ignoringDevice = 0; +data->ignoringApp = 0; +data->inDriConf = 0; +data->inDevice = 0; +data->inApp = 0; +data->inOption = 0; + +_parseOneConfigFile (p); +XML_ParserFree (p); +} + +static int +scandir_filter(const struct dirent *ent) +{ +if (ent->d_type != DT_REG && ent->d_type != DT_LNK) + return 0; + +if (fnmatch("*.conf", ent->d_name, 0)) + return 0; + +return 1; +} + +/** \brief Parse configuration files in a directory */ +static void +parseConfigDir(struct OptConfData *data, const char *dirname) +{ +int i, count; +struct dirent **entries = NULL; + +count = scandir(dirname, &entries, scandir_filter, alphasort); +if (count < 0) +return; + +for (i = 0; i < count; i++) { +char filename[PATH_MAX]; + +snprintf(filename, PATH_MAX, "%s/%s", dirname, entries[i]->d_name); +parseOneConfigFile(data, filename); +} + +if (entries) +free(entries); +} + #ifndef SYSCONFDIR #define SYSCONFDIR "/etc" #endif +#ifndef DATADIR +#define DATADIR "/usr/share" +#endif + void driParseConfigFiles(driOptionCache *cache, const driOptionCache *info, int screenNum, const char *driverName) { -char *filenames[2] = { SYSCONFDIR "/drirc", NULL}; char *home; -uint32_t i; struct OptConfData userData; initOptionCache (cache, info); @@ -927,39 +986,16 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info, userData.driverName = driverName; userData.execName = util_get_process_name(); +parseConfigDir(&userData, DATADIR "/drirc.d"); +parseConfigDir(&userD