one last firmware(9) issue
Max Laier
max at love2party.net
Thu Feb 15 18:35:05 UTC 2007
On Thursday 15 February 2007 18:43, Luigi Rizzo wrote:
> I have committed the cleanup to firmware(9) discussed earlier
> on this list, see the commit log below. There is a remaining issue
> on which i would like some advice. From the commit log:
>
> Note also that there is a subtle issue with the implementation of
> firmware_register(): currently, as in the previous version, we just
> store a reference to the 'imagename' argument, but we should rather
> copy it because there is no guarantee that this is a static string.
>
> Now, what do you think is the best way to handle this ? The existing
> code tries not to allocate memory on a firmware_register(), not
> sure if it is on purpose (e.g. to avoid sleeping) or for other
> reasons. To preserve this, we should use static buffers for the
> image names, and pick a reasonable size for them (128 ? 256 ? 1025 ?).
>
> If on the other hand, we can afford a malloc in firmware_register(),
> i'd move the whole registry to a linked list, to avoid the hard limit
> of 30 slots in the firmware table.
>
> suggestions ?
I say, let the caller deal with it. After all the caller must ensure that
the firmware itself stays in memory until they call firmware_unregister,
why should we jump through all the hoops for the name?
The linked list is another thing. As I recall, the static array is only
there due to our lazyness. It's a lot easier to use a static array and I
don't forsee us using more than 30 firmware images at a time. OTOH, it
would of course be nice to have a more flexible system. I'm not 100%
certain what the locking constrains for firmware_register() are. Usually
it is called from the mod_event of a firmware module, which in turn is
called from the linker subsystem. There might be some locks involved
that would prevent you from sleeping, but that's just a wild guess.
Thanks for taking care of this, by the way. Much appreciated.
--
/"\ Best regards, | mlaier at freebsd.org
\ / Max Laier | ICQ #67774661
X http://pf4freebsd.love2party.net/ | mlaier at EFnet
/ \ ASCII Ribbon Campaign | Against HTML Mail and News
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20070215/818b7b42/attachment.pgp
More information about the freebsd-current
mailing list