laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37917?usp=email )
Change subject: filesystem: add command to delete all contents from a BER-TLV EF ......................................................................
filesystem: add command to delete all contents from a BER-TLV EF
When working with BER-TLF files, we can only delete one tag at a time. There is no way to delete all tags at once. This may make working with BER-TLV files difficult, in particular when scripting is used and the script needs to start with an empty file. Also export has problems, since it does not reset the file before setting the new values there may be unexpected results in case there still tags in the file that are not set during import. To fill the gap, let's add a commandd that deletes all tags in a BER-TLV EF at once.
Related: OS#6531 Change-Id: I5d6bcfe865df7cb8fa6dd0052cab3b364d929f94 --- M pySim/filesystem.py 1 file changed, 7 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
diff --git a/pySim/filesystem.py b/pySim/filesystem.py index 35af140..d5e99a4 100644 --- a/pySim/filesystem.py +++ b/pySim/filesystem.py @@ -1338,6 +1338,12 @@ if data: self._cmd.poutput(data)
+ def do_delete_all(self, opts): + """Delete all data from a BER-TLV EF""" + tags = self._cmd.lchan.retrieve_tags() + for tag in tags: + self._cmd.lchan.set_data(tag, None) + def __init__(self, fid: str, sfid: str = None, name: str = None, desc: str = None, parent: CardDF = None, size: Size = (1, None), **kwargs): """ @@ -1374,6 +1380,7 @@ if tags == []: export_str += "# empty file, no tags" else: + export_str += "delete_all\n" for t in tags: result = lchan.retrieve_data(t) (tag, l, val, remainer) = bertlv_parse_one(h2b(result[0]))