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

Srinivas KANDAGATLA srinivas.kandagatla at st.com
Thu Apr 11 16:52:40 EST 2013


On 11/04/13 02:44, David Gibson wrote:
> 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.
Thanks for the comment, I will try to fix fdtput with fdt_open_into.
>
>
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss



More information about the devicetree-discuss mailing list