[libvirt] virFileHasSuffix case sensitivity

Hi all, virFileHasSuffix fails on esx IDE fileName VMX entries that aren't lower case, e.g. '.ISO'. Unless there's a good reason, can the comparison be done with STRCASEEQ instead of STREQ? Kind regards, Paul

On 04/28/2010 09:24 PM, Paul Dorman wrote:
Hi all,
virFileHasSuffix fails on esx IDE fileName VMX entries that aren't lower case, e.g. '.ISO'. Unless there's a good reason, can the comparison be done with STRCASEEQ instead of STREQ?
Seems reasonable to me. It would help if you could write a patch for that, but if not, I can probably get around to figuring out the appropriate patch based on your description. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Hi Eric, sure. Here you go. Please let me know if there's anything else I need to do. diff --git a/src/util/util.c b/src/util/util.c index a7bb67c..3209185 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1153,7 +1153,7 @@ int virFileHasSuffix(const char *str, if (len < suffixlen) return 0; - return STREQ(str + len - suffixlen, suffix); + return STRCASEEQ(str + len - suffixlen, suffix); } # define SAME_INODE(Stat_buf_1, Stat_buf_2) \ Regards, Paul On Thu, Apr 29, 2010 at 3:43 PM, Eric Blake <eblake@redhat.com> wrote:
On 04/28/2010 09:24 PM, Paul Dorman wrote:
Hi all,
virFileHasSuffix fails on esx IDE fileName VMX entries that aren't lower case, e.g. '.ISO'. Unless there's a good reason, can the comparison be done with STRCASEEQ instead of STREQ?
Seems reasonable to me. It would help if you could write a patch for that, but if not, I can probably get around to figuring out the appropriate patch based on your description.
-- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Thu, Apr 29, 2010 at 04:04:25PM +1200, Paul Dorman wrote:
Hi Eric,
sure. Here you go. Please let me know if there's anything else I need to do.
diff --git a/src/util/util.c b/src/util/util.c index a7bb67c..3209185 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1153,7 +1153,7 @@ int virFileHasSuffix(const char *str, if (len < suffixlen) return 0;
- return STREQ(str + len - suffixlen, suffix); + return STRCASEEQ(str + len - suffixlen, suffix); }
# define SAME_INODE(Stat_buf_1, Stat_buf_2) \
Ah, you came up with the same patch, pushed but I'm sorry I forgot to attribute it to you ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wed, Apr 28, 2010 at 09:43:53PM -0600, Eric Blake wrote:
On 04/28/2010 09:24 PM, Paul Dorman wrote:
Hi all,
virFileHasSuffix fails on esx IDE fileName VMX entries that aren't lower case, e.g. '.ISO'. Unless there's a good reason, can the comparison be done with STRCASEEQ instead of STREQ?
Seems reasonable to me.
I wanted to make sure, so I dug a little bit, and most uses look okay, even for more complex kinds like FileTypeInfo storage file type detection ".ISO" or ".Dmg" should be fine. By definition using file suffixes is some kind of heuristic, at least in the cases we used (there is also '-64' but that's not case sensitive). So based on existing use and principle this sounds fine to me
It would help if you could write a patch for that, but if not, I can probably get around to figuring out the appropriate patch based on your description.
I suggest the trivial patch below, I assume that's what the reporter had in mind Daniel diff --git a/src/util/util.c b/src/util/util.c index a7bb67c..3209185 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1153,7 +1153,7 @@ int virFileHasSuffix(const char *str, if (len < suffixlen) return 0; - return STREQ(str + len - suffixlen, suffix); + return STRCASEEQ(str + len - suffixlen, suffix); } # define SAME_INODE(Stat_buf_1, Stat_buf_2) \ -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel Veillard
-
Eric Blake
-
Paul Dorman