Hi Roman,
Then, I execute the following commands on the interactive shell:
> echo "1st-cfg" > /tmp/test.config` # "1st-cfg" is logged > mv /tmp/test.config /tmp/test.backup` # nothing is logged > echo "2nd-cfg" > /tmp/test.config` # nothing is logged > echo "3rd-cfg" > /tmp/test.backup` # "3rd-cfg" is logged
Is it the intended behavior that `fs_rom` "follows" the file or should it always provide the ROM content of the file with the specified name instead?
the behavior is the result of a combination of two things:
- The fs_rom component keeps the file handle for the watched file open during the whole lifetime of the ROM session.
- The <ram> VFS plugin implements the rename operation by modifying the meta data (the naming) but the physical object remains the same. The resolution of the physical object from its name is done only once when the file is opened. The file handle then keeps a reference to the underlying object. Hence, any open file descriptor will "follow" the rename operation.
I think that both points are quite reasonable. Or the other way around, I wonder what would be a sensible alternative?
You can avoid this situation be replacing the 'mv' by 'cp', which will keep the relationship of the original file and its original name intact for open file handles that refer to the file. You can also 'rm' the original file, which will result in an empty ROM, as expected.
Cheers Norman