[Toybox] [TOY] lspci - no *alloc

Felix Janda felix.janda at posteo.de
Fri Jul 26 03:56:48 PDT 2013


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.)

> > 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.)

Felix

 1374836208.0


More information about the Toybox mailing list