Previous Table of Contents Next


The File System API

A central application for smart cards defined by the ISO/IEC 7816-4 standard is a file system. The file system is actually applied to the nonvolatile memory on the smart card; generally EEPROM. The file system defined is a relatively straightforward hierarchical structure comprising three basic elements:

  A master file (MF) component
  A dedicated file (DF) component
  An elementary file (EF) component

The MF component is the root of the file hierarchy; there is only one MF on a smart card. An MF may contain, as elements, a DF, or even many DFs, and it may contain zero to many EFs. The DF component is essentially a container for EF components; a DF may contain zero to many EFs. An EF component may contain only records. This simple hierarchical structure is illustrated in Figure 4.8.


Figure 4.8.  The smart card file system architecture.

Several characteristics of the smart card file system are significantly different from typical (that is, disk based) file systems. These differences are almost exclusively due to the physical characteristics of the EEPROM memory system, specifically the facts that EEPROM memory can be subjected to only a modest number of erase and write cycles and that it is significantly faster to write to EEPROM memory in a cumulative fashion than in a pure erase and then write fashion. The first of these characteristics resulted in the definition of a rather unique file structure called a cyclic file. The second characteristic resulted in rather unique definitions of the various file write commands.

The cyclic file is actually a ring buffer of physical records that are addressed and accessed as a single record. On successive write operations, the next physical record (in the ring of physical records) is accessed. The net result is that erase and write operations can be spread across a wider selection of EEPROM memory locations. This mitigates somewhat the limit (generally on the order of 100,000 cycles) on the number of times that a specific EEPROM memory location can be erased and rewritten.

EEPROM memory has the additional interesting characteristic that it is significantly faster to set additional bits in a byte-sized memory location than it is to erase all the currently set bits and then rewrite them. This fact becomes doubly useful in certain operations (for example, manipulating a purse value on a smart card) where it is required that operations on a file be performed in such a fashion that the values stored in the file are well understood at any point in time, even if power is removed from the smart card in the middle of a write operation. To facilitate the exploitation of these characteristics, the write operations to a smart card file are typically bit set operations while the update operations are actually erase and rewrite operations that we generally associate with file-writing operations. These characteristics will be examined in more detail in the following sections.

Master File Characteristics

Each smart card file system has exactly one master file. The MF serves as the root of the hierarchical file structure. In the parlance of general file systems, the MF is a container or a directory; it may contain other dedicated (or directory) files or it may contain elementary files.

Any file can be identified by a 2-byte file identifier. The file identifier 3F00 is reserved for the MF; that is, there is only one file on the card with a file identifier of 3F00, and the file with that identifier is the MF.

Dedicated File Characteristics

A DF is also a container or a directory file in the same vein as the MF. A DF forms a subdirectory within the file hierarchy rooted in the MF. A DF can also be identified by a file identifier. A DF must be given a unique file identifier within the DF (or MF) that contains it. This allows for the creation of a unique path designation for a file; that is, a path is simply the concatenation of the file identifiers of the file in question and of all the DFs between the file in question and its containing DF or MF.

On some smart cards, a DF can also be referenced by a name which may be from 1 to 16 bytes long. The naming conventions for the DF name are found in the ISO/IEC 7816-5 specification.


Previous Table of Contents Next