[S] Change in pysim[master]: esim.saip: let a GenericFileManagement PE create the MF
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/43982?usp=email ) Change subject: esim.saip: let a GenericFileManagement PE create the MF ...................................................................... esim.saip: let a GenericFileManagement PE create the MF A profile without PE-MF creates the MF as the first file of a PE-GenericFileManagement. ProfileElementGFM.add_file() resolved every file's parent through the sequence's MF, which does not exist yet at that point, so decoding such a profile failed with "AttributeError: 'NoneType' object has no attribute 'lookup_by_fidpath'". While the sequence has no MF, the DF with FID 3F00 becomes the MF root (sequence.mf and cur_df), as FsProfileElement.add_file() does for a PE-MF, and any other file is registered by path. A rootless ProfileElementSequence.cd() selects nothing instead of dereferencing the missing MF. The folder osmocom-pysim-saip-gfm-mf-creation of hampushellsberg-dev/PySIM-upstream-patches on GitHub has the analysis and a repro. Change-Id: Iceb910070e359c3830871f9048e448d6b115acae --- M pySim/esim/saip/__init__.py 1 file changed, 21 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified dexter: Looks good to me, but someone else must approve diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 55811a8..11f549d 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -830,6 +830,23 @@ def add_file(self, file: File, path: Path): logger.debug("%s.add_file(path=%s, %s)" % (self.__class__.__name__, path, repr(file))) if hasattr(self.pe_sequence, 'mf'): + if self.pe_sequence.mf is None and file.fid == 0x3f00 and file.file_type == 'DF': + # TCA SAIP §8.1: without a PE-MF, the MF is created as the first file of a + # PE-GenericFileManagement; PE-MF is not allowed in an IoT Minimal Profile (§7.5). + if file.pe_name in self.files: + raise KeyError('Cannot add file: %s already exists' % file.pe_name) + file.node = FsNodeMF(file) + self.pe_sequence.mf = file.node + self.pe_sequence.cur_df = file.node + self.files[file.pe_name] = file + return + if self.pe_sequence.mf is None: + # no MF yet: keep the file reachable by path, as for a PE decoded without a sequence + path_str = str(path) if isinstance(path, Path) else self.path_str(path) + if path_str in self.files: + raise KeyError('Cannot add file: %s already exists' % path_str) + self.files[path_str] = file + return if isinstance(path, Path): parent = self.pe_sequence.mf.lookup_by_path(Path(path[:-1])) else: @@ -2066,6 +2083,10 @@ # remove the leading MF, in case it's specified explicitly while len(path) and path[0] == 0x3f00: path.pop(0) + if self.mf is None: + # no MF yet (a GFM creating the file system from scratch): nothing to select + self.cur_df = None + return df = self.mf for p in path: if not p in df.children: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43982?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Iceb910070e359c3830871f9048e448d6b115acae Gerrit-Change-Number: 43982 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge@osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: jolly <andreas@eversberg.eu> Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> Gerrit-CC: hampushellsberg <hampushellsberg@gmail.com>
participants (1)
-
laforge