For a file-based storage backend, the implementation needs to be
unnecessarily complicated because it's unknown in the open() callback
whether the stack is going to read or write the file.
The only standard stdio file modes that supports both reading and writing
are "r+", "w+" and "a+". Of these, "w+" always truncates the file, deleting
the parameters when the stack wants to read them; "a+" only allows
appending, so existing stored parameters will not get updated. Only "r+"
technically works, but leaves garbage at the end of the file when writing
if the new data is shorter than the current file, so if it works or not
depends on the data format the stack uses internally.
Pass a new argument to the open() callback to let the implementation know
what the stack is going to do with the file.
The most trivial implementation could now be something like this:
For a file-based storage backend, the implementation needs to be unnecessarily complicated because it's unknown in the open() callback whether the stack is going to read or write the file.
The only standard stdio file modes that supports both reading and writing are "r+", "w+" and "a+". Of these, "w+" always truncates the file, deleting the parameters when the stack wants to read them; "a+" only allows appending, so existing stored parameters will not get updated. Only "r+" technically works, but leaves garbage at the end of the file when writing if the new data is shorter than the current file, so if it works or not depends on the data format the stack uses internally.
Pass a new argument to the open() callback to let the implementation know what the stack is going to do with the file.
The most trivial implementation could now be something like this:
Signed-off-by: Andreas Fritiofson andreas.fritiofson@unjo.com Change-Id: I3c1c6e3fa62c17cf672243bddd037e4ba42b4290