Hi, In article <slrnp80aau.nkj.a...@xcp-mailnews.gently.org.uk>, Andy Hawkins<a...@gently.org.uk> wrote: > In inotify.c, around line 236 is the following code block: > > /* ignore emacs backups and dotfiles */ > if (in->len == 0 || > in->name[in->len - 1] == '~' || > (in->name[0] == '#' && in->name[in->len - 1] == '#') || > in->name[0] == '.') > continue; > > However, if I create a file called 'fred~' in the directory I've specified > using dhcp-hostsdir I still get an event in syslog that shows this file is > being processed: > > Feb 11 11:14:34 xcp-gateway dnsmasq[1039]: inotify, new or changed file > /etc/dnsmasq/dhcp-hosts.d/fred~
Ok, I've done some debugging. I added the following lines: my_syslog(LOG_INFO, "ADH: len: %d", in->len); my_syslog(LOG_INFO, "ADH: name: %s", in->name); my_syslog(LOG_INFO, "ADH: last char: %c", in->name[in->len - 1]); And I get the following output: dnsmasq: ADH: len: 16 dnsmasq: ADH: name: fred4~ dnsmasq: ADH: last char: So, it appears that the length in in->len is being interpreted correctly. According to the inotify man page: The len field counts all of the bytes in name, including the null bytes; the length of each inotify_event structure is thus sizeof(struct inotify_event)+len. So in fact, 'len' seems to be a fixed length, irrespective of the length of the file name in the 'name' field. It looks like the check should actually be something like: /* ignore emacs backups and dotfiles */ if (in->len == 0 || in->name[strlen(in->name) - 1] == '~' || (in->name[0] == '#' && in->name[strlen(in->name) - 1] == '#') || in->name[0] == '.') I guess you may need to check that there's a null in the name somewhere before using strlen, otherwise you might end up running off the end of the string. I don't know inotify well enough to know if there's guaranteed to be a null in there somewhere. The manpage does say that the name field is null terminated, but I don't know if that's guaranteed or not. I could have a look at submitting a patch, but my editor is showing some very strange indentation of the source, so I suspect I have my tab settings incorrect. What is the standard setting for tabs on the dnasmasq source files? Thanks Andy _______________________________________________ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss