Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 323889

Summary: app-portage/portage-utils: qfile does not work on *BSD
Product: Portage Development Reporter: Naohiro Aota <naota>
Component: ToolsAssignee: Portage Utils Team <portage-utils>
Status: RESOLVED FIXED    
Severity: normal CC: tom.gl
Priority: High    
Version: unspecified   
Hardware: All   
OS: FreeBSD   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: patch to fix qfile.c wrong dirname_len calculation
patch to use local "basename" function.

Description Naohiro Aota gentoo-dev 2010-06-14 04:32:26 UTC
"qfile /bin/bash" doesn't output anything on Gentoo/FreeBSD. 

qfile.c assume basename(path) always return a pointer to some part of path. But this is not always true. We get wrong "dirname_len" and so qfile failed to find the package.


Reproducible: Always

Steps to Reproduce:
1. emerge portage-utils on Gentoo/FreeBSD
2. qfile /bin/bash


Actual Results:  
no output

Expected Results:  
qfile should print "app-shells/bash (/bin/bash)"
Comment 1 Naohiro Aota gentoo-dev 2010-06-14 04:35:09 UTC
Created attachment 235227 [details, diff]
patch to fix qfile.c wrong dirname_len calculation

With applying this patch, "qfile /bin/bash" output adequate result.
Comment 2 solar (RETIRED) gentoo-dev 2010-06-28 21:04:56 UTC
TGL, 
I think he is commenting on some code of yours. Would you mind reviewing this and suggesting what should be done. Thanks in advance.


Naohiro,
When you file a bug, it's best to include the exact versions you are talking about. I'll assume you tested with current ~arch.

Comment 3 SpanKY gentoo-dev 2010-07-09 22:38:42 UTC
the code was specifically written to avoid the overhead of string calls.  i cant see why bsd would operate differently since i cant see how it would be better for performance, and because the spec specifically allows the behavior.

perhaps we simply implement our own local basename to avoid this moronic C library behavior.  the glibc specific one looks nice:

char *basename (const char *filename)
{
  char *p = strrchr (filename, '/');
  return p ? p + 1 : (char *) filename;
}
Comment 4 Naohiro Aota gentoo-dev 2010-07-16 00:34:50 UTC
Created attachment 238967 [details, diff]
patch to use local "basename" function.

SpanKY
I agree. Implementing our own one would be better if we can.

I've wrote this patch and this worked for both Linux and FreeBSD.
(checked by "FEATURES=test emerge portage-utils" on Linux, and run "qfile /bin/bash" on FreeBSD)
Comment 5 SpanKY gentoo-dev 2010-07-19 00:24:27 UTC
i dont want to go that way as people will often not notice "mybasename" and will continue to use "basename".  as such, ive created a local basename() and constified all the callers in the tree.  cvs should work now.