[Toybox] [TOY] lspci - no *alloc

Isaac idunham at lavabit.com
Fri Jul 26 08:50:45 PDT 2013


On Fri, Jul 26, 2013 at 12:56:48PM +0200, Felix Janda wrote:
> Isaac wrote:
> > On Thu, Jul 25, 2013 at 10:31:47AM +0200, Felix Janda wrote:
> > > Isaac wrote:
> [...]
> > > > By the way, there are requests for more features (-v/-vv and text output) 
> > > > that would mean slightly different approaches to getting data; (p)readat_name 
> > > > would work in many of these cases, but text output means reading to toybuf
> > > > (which would clobber this), and I would also need to add more fields of varying sizes.
> > > 
> > > Yeah, I guess I did some premature optimizations. But still the data read from the
> > > /sys files is of relatively small fixed size?
> > 
> > If by "small" you mean "Probably smaller than toybuf" (see resource and config).
> 
> Something one feels comfortable to put on the stack. If it fits into toybuf,
> that's also good.
> 
> Just for the record: resource is 399 and config 256 bytes. (Extended config for pci
> express devices is 4096 bytes.)
> 

Here resource is 4096 bytes.

> > > Instead of to toybuf one could also put the buffers on the stack freeing up toybuf
> > > for other purposes.
> > > 
> > > For the text output the structure of the toy would change a lot if we want to
> > > avoid reparsing the pci id database for each device.
> > I honestly had not thought about that, but really, it is needed if we do that.
> >
> > Would it work if we save it to a linked list of structs and print at the end? 
> > Would llist* work with that?
> > (I'm thinking about putting a pointer in GLOBALS.)
> 
> That should work.
> 
> > The structs would need char clname[128], devname[128].
> > Fortunately /usr/share/misc/pci.ids is sorted.
> 
> Are the names in the pci database required to be less than 128 bytes long? (The longest
> name I found in my local database is 92 bytes.)

No hard requirement, but I'd think that a 2-line name should be 
truncated somewhere.

Isaac Dunham


 1374853845.0


More information about the Toybox mailing list