[Dnsmasq-discuss] feature: dictionary order import of addn-hosts dirs?

Ed W lists at wildgooses.com
Tue Aug 10 23:25:24 UTC 2021

On 10/08/2021 23:12, Simon Kelley wrote:
> On 08/08/2021 14:02, Ed W wrote:
>> On 19/07/2021 18:52, Ed W wrote:
>>> Hi, around 2.82 someone posted a little patch to import the config files in dictionary order, which
>>> is very useful for situations where you have overlapping definitions. I'm using an addn-hosts stanza
>>> pointing to a directory and files currently import in a somewhat random order (suppose inode
>>> order?), which can lead to unexpected reverse host definitions in some cases
>>> Could we have a dictionary order import for add-hosts files please?
>>> Ed W
>> Hi, I have developed the attached patch without really being sure that this is the best approach. I
>> would be grateful for some feedback. I have used scandir without understanding if this is portable
>> across systems that we support with dnsmasq. Also I am trying to copy the existing coding style, but
>> surely I have failed.
> I'll look in more detail soon, but this certainly looks like the right
> way to go.
>> I'm also unclear that it still works as advertised in the case that I don't have inotify enabled?
>> Any help?
> Since the whole point of the inotify stuff is that individual files get
> read as they change, imposing or relying on a particular order doesn't
> make much sense. I'd therefore not make any changes to inotify.c.
> The man page then needs to note that --dhcp-hostsdir --dhcp-optsdir and
> --hostsdir DON'T offer any ordering of files read, but
> --dhcp-hostsfile --dhcp-optsfile and --addn-hosts with directory
> arguments DO.

Aha, then I might have gone off the rails here then...

It's the changes in inotify.c which affect my --addn-hosts directives? I left the top part of the
patch to option.c in there as it seemed like it probably affected (hostsdir?), and seemed useful yet
without any real cost?

Could it be that when inotify fires that it pulls in all files in --addn-hosts? In which case the
dictionary order functions, even though we have inotify?

Ed W

More information about the Dnsmasq-discuss mailing list