Change in pysim[master]: filesystem: add new command add_ef

dexter gerrit-no-reply at
Mon Mar 29 19:07:39 UTC 2021

dexter has uploaded this change for review. ( )

Change subject: filesystem: add new command add_ef

filesystem: add new command add_ef

Some cards may have additional propritary EF files which pySim-shell
does not support. If the user knows the exact FID, the command add_ef
can be used to manually add a new EF at runtime. The newly created file
will then work like any other EF.

Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Related: OS#4963
M pySim/
1 file changed, 31 insertions(+), 0 deletions(-)

  git pull ssh:// refs/changes/33/23533/1

diff --git a/pySim/ b/pySim/
index 04fa250..2c1fe8b 100644
--- a/pySim/
+++ b/pySim/
@@ -130,12 +130,43 @@
 class CardDF(CardFile):
     """DF (Dedicated File) in the smart card filesystem.  Those are basically sub-directories."""
+    @with_default_category('DF/ADF Commands')
+    class ShellCommands(CommandSet):
+        def __init__(self):
+            super().__init__()
+        add_ef_parser = argparse.ArgumentParser()
+        add_ef_parser.add_argument('fid', type=str, default=None, help='file identifier (hexadecimal)')
+        add_ef_parser.add_argument('--name', type=str, default=None, help='human readable name')
+        add_ef_parser.add_argument('--desc', type=str, default=None, help='human readable description')
+        add_ef_parser.add_argument('--struct', type=str, default="TransparentEF", help='file structure (TransparentEF|LinFixedEF)')
+        @cmd2.with_argparser(add_ef_parser)
+        def do_add_ef(self, opts):
+            """Add an EF representation at the current position in the file system"""
+            selected_file =
+            if not
+       = "EF." + opts.fid
+            if not opts.desc:
+                opts.desc = "manually added at runtime"
+            if opts.struct == "TransparentEF":
+                ef = TransparentEF(fid=opts.fid, sfid=None,, desc=opts.desc)
+            elif opts.struct == "LinFixedEF":
+                ef = LinFixedEF(fid=opts.fid, sfid=None,, desc=opts.desc)
+            else:
+                self._cmd.poutput("add_ef: error: invalid file type specified")
+            selected_file.add_files([ef])
     def __init__(self, **kwargs):
         if not isinstance(self, CardADF):
             if not 'fid' in kwargs:
                 raise TypeError('fid is mandatory for all DF')
         self.children = dict()
+        self.shell_commands = [self.ShellCommands()]
     def __str__(self):
         return "DF(%s)" % (super().__str__())

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iafff97443130f8bb8c5bc68f51d2fe1d93fff07c
Gerrit-Change-Number: 23533
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list