[RFC 0/2] Add node and property realloc functions.

David Gibson dwg at au1.ibm.com
Thu Apr 11 11:44:39 EST 2013


On Wed, Apr 10, 2013 at 03:31:18PM +0100, Srinivas KANDAGATLA wrote:
> If you try to insert a new node or extend a property with large value, 
> using fdtput you will notice that it always fails.
> 
> example:
> fdtput -v -p -ts ./tst.dtb "/node-1" "property-1" "str10"
> Error at 'node-1': FDT_ERR_NOSPACE
> 
> or
> 
> fdtput -v -c ./tst.dtb "/node-1"
> Error at 'node-1': FDT_ERR_NOSPACE
> 
> 
> fdtput -v  -ts ./tst.dtb "/node" "property" "very big value"
> Decoding value:
> 	string: 'very big value'
> Value size 15
> Error at 'property': FDT_ERR_NOSPACE
> 
> All these error are returned from libfdt, as the size of the fdt passed
> has not space to accomdate these new properties.
> 
> However,
> libfdt has code to add new property or node or extend a property to an
> arbitary value, however it cannot be used because all the library
> functions take preallocated fdt pointer limted to a size.
> 
> Adding realloc function into libfdt can help tools like fdtput to insert
> nodes or properties or extend a property.

Nack.

libfdt deliberately does not use an allocator, to permit embedding in
weird and limited environments such as bootloaders.

I've thought about adding an optional layer of allocator aware
functions, but it's not quite as straightforward as you'd think
because you need to be clear about what the assumptions are on the
allocation of the given blob - there's no place to put extra context
to indicate whether it is malloc()ed or part of a larger structure,
for example.  At the very lease allocating functions would need to
move to a separate source file from the existing functions.

I think the correct fix in this case is to make fdtput handle the
FDT_ERR_NOSPACE by reallocating itself, using fdt_open_into() and
retrying.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/devicetree-discuss/attachments/20130411/c6010aa2/attachment.sig>


More information about the devicetree-discuss mailing list