Methods for updating, reading, and personalizing smart card cyclic log files; computer devices and computer-readable storage media.
By setting an actual existing record identifier and a logical first record identifier in the smart card cyclic record file, the cross-sector problem during the cyclic record file update and reading process is solved, improving transaction performance and reading speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-13
- Publication Date
- 2026-03-13
AI Technical Summary
Existing technologies suffer from cross-sector write issues during the cyclic recording of file updates and reads in smart cards, leading to increased transaction time and impacting transaction performance.
In each physical record of the circular record file, an actual existing record identifier and a logical first record identifier are set. By judging these identifiers, the operable physical record is determined, thereby performing update and read operations and avoiding cross-sector operations.
By reducing cross-sector operations, the transaction performance and read speed of smart cards are improved.
Smart Images

Figure CN116383162B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart card operating system technology, specifically to a method for updating, reading, and personalizing a smart card cyclic record file, a computer device, and a computer-readable storage medium. Background Technology
[0002] A smart card is a general term for a plastic card with an embedded integrated circuit chip. Based on the type of chip embedded, smart cards can be divided into three categories: memory cards, logic encryption cards, and CPU cards, but only CPU cards are considered true smart cards. The integrated circuit within a smart card (CPU card) includes a central processing unit (CPU), non-volatile memory (usually EEPROM or FLASH), random access memory (RAM), and an internal operating system (COS) stored in read-only memory (ROM). EEPROM storage media has small capacity and is expensive, operates at the smallest byte level, and does not require erasing during writing. FLASH storage media has large capacity and is inexpensive, operates at the smallest sector block level, and requires erasing the entire sector during writing.
[0003] The chip operating system (COS) of a smart card is the core technology of the smart card at the software level. Its architecture consists of four parts: communication management module, security management module, application processing module, and file management module.
[0004] The file management module is responsible for managing the data and records that the smart card needs to store. The ISO / IEC 7816 protocol specifies the logical structure of the file system, which is a tree structure supporting arbitrary structures, mainly composed of MF files, DF files, and EF files. The MF file is the root directory of the file system, and there is only one MF file in the file system; the DF file, also called the directory file, is used to create subdirectories; the EF file is the lowest-level file in the file system, used to store application data units or records. Files are selected using Short File Identifier (SFI) and File Identifier (FID), and the SFIs are different within the same directory. According to the logical structure of the EF file, it can be divided into four types: transparent file, fixed-length record file, variable-length record file, and circular record file. In a circular record file, the number of records and the length of each record are fixed; the record following the last record is the first record, thus forming a circular storage space. When a new record is added, the new record occupies the space of the previously added record.
[0005] A circular log file consists of a header and a body. Typically, during smart card personalization, a circular log file is created based on the required number of records and the length of each record specified in the personalization data. Physical storage space is then allocated for the header and body. See also... Figure 1 In the header information of the loop record file, the "Actual Number of Existing Records" field records the number of valid records in the file body. The "Physical Record Number Corresponding to the Current Record" field records the physical record number corresponding to the current record in the file body. When the loop record file ends and no transaction is executed, the file body is empty. At this time, the "Actual Number of Existing Records" field has a value of 0, and the "Physical Record Number Corresponding to the Logical First Record" field has a value of 0. After the first transaction is executed, the "Actual Number of Records" field in the file header is set to 1, and the "Physical Record Number Corresponding to the Current Record" field is set to 1. The log file generated during the transaction is written to "Physical Record 1". Similarly, after the nth transaction (where n is the maximum number of records in the loop record file) is executed, the "Actual Number of Records" field in the file header is set to n (the maximum value of this field is n), and the "Physical Record Number Corresponding to the Current Record" field is set to n. The log file generated during the transaction is written to "Physical Record n". After the (n+1)th transaction is executed, the "Actual Number of Records" field in the file header is set to n, and the "Physical Record Number Corresponding to the Current Record" field is set to 1. The log file generated during the transaction is written to "Physical Record 1". This method is used to update the loop record file.
[0006] Smart cards are used in various industries, such as social security, finance, transportation, citizen cards, and telecommunications SIM cards. During transactions, records need to be added to a circular log file to record the current transaction log. This record, along with key information such as the transaction amount, must be written to memory within the same transaction (in the event of a power outage, either all data is written to memory or none is written at all). Transaction performance is a crucial technical indicator for smart cards; reducing the number of writes to memory within a transaction can reduce transaction time and improve performance. For smart cards using FLASH storage, since FLASH storage uses sectors as the smallest write unit, reducing the number of sectors involved when adding records to the circular log file can improve transaction performance. If the circular log file is updated in the above way, in a single transaction, information must be written to the file header ("the actual number of existing records"), the physical record number corresponding to the current record, and a specific physical record in the file body. Typically, a sector of a FLASH storage medium is 128 or 256 bytes, while a record in a circular record file is 30 to 60 bytes. The number of records is usually greater than or equal to 10. Even if the records in the file body are physically arranged sequentially, the file header and file body may not be in the same sector. This leads to cross-sector writes when adding records to the circular record file during a transaction, which in turn increases transaction time. Summary of the Invention
[0007] The primary objective of this invention is to provide a method for updating smart card cyclic log files to improve transaction performance.
[0008] A second objective of this invention is to provide a method for reading smart card cyclic log files to improve transaction performance.
[0009] A third objective of this invention is to provide a personalized method for cyclically recording files on a smart card.
[0010] A fourth objective of this invention is to provide a computer device for implementing the above-described methods for updating, reading, and personalizing smart card cyclic recording files.
[0011] The fifth objective of this invention is to provide a computer-readable storage medium that implements the above-described methods for updating, reading, and personalizing smart card cyclic recording files.
[0012] To achieve the aforementioned first objective, the present invention provides a method for updating a smart card cyclic log file, comprising the following steps: obtaining a target log; traversing the actual existence record identifier and logical first record identifier in the file body of the cyclic log file according to a preset writing order until the first actual existence record identifier of the first current physical record is in a first original state, determining the first current physical record as the first target physical record, or, until the first actual existence record identifier of the first current physical record is in a first changed state and the first logical first record identifier is in a second changed state, determining the next second current physical record of the first current physical record according to the preset writing order as the first target physical record; wherein, the file body of the cyclic log file has multiple physical records preset, each physical record being provided with an actual existence record identifier and a logical first record identifier; writing the target log into the first target physical record, setting the target actual existence record identifier of the first target physical record to the first changed state, and setting the first target logical first record identifier of the first target physical record to the second changed state; if the first target physical record is the second current physical record, setting the first logical first record identifier of the first current physical record to the second original state.
[0013] As can be seen from the above scheme, the present invention determines the first operable target physical record by judging the actual existence record identifier and the logical first record identifier of each physical record, thereby updating the target log to the operable physical record. Since the actual existence record identifier and the logical first record identifier are set on the file body of the circular record file, there is no need to operate on the file header of the circular record file body, reducing cross-sector operations, reducing transaction time, and improving the transaction performance of smart cards.
[0014] A further approach is to determine whether the following conditions are met after determining that the second current physical record is the first target physical record: the second current physical record is the actual first physical record of the file body of the circular record file, and the first current physical record is the actual last physical record of the file body of the circular record file. If these conditions are not met, the target actual existence record identifier of the first target physical record is set to the first changed state, the first target logical first record identifier is set to the second changed state, and the first logical first record identifier of the first current physical record is set to the second original state through a single write operation.
[0015] Therefore, it can be seen that the target file can be successfully written in a single write operation.
[0016] To achieve the second objective mentioned above, the present invention provides a method for reading a smart card cyclic record file, wherein: a record reading instruction is obtained, the record reading instruction including a logical record ordinal number; a second target physical record containing the logically first record is determined according to the logical first record identifier of the file body of the cyclic record file; a third target physical record corresponding to the logical record ordinal number is obtained in the reverse order of the preset writing order; and the content of the third target physical record is returned.
[0017] As can be seen from the above scheme, the present invention determines the logical first record by judging the actual existence record identifier and the logical first record identifier of each physical record, and then determines the physical location of the record to be read in the circular record file, so as to perform the reading. The reading operation is also completed in the file body of the circular record file, thereby improving the reading speed.
[0018] A further approach is to determine the second target physical record by traversing the physical records in the file body of the loop record file according to a preset writing order until the third actual existing record of the third current physical record is identified as the first change state and the third logical first record of the third current physical record is identified as the second change state.
[0019] To achieve the third objective mentioned above, the present invention provides a method for personalizing a smart card cyclic recording file, wherein: a personalization instruction is obtained, the personalization instruction including the maximum number of physical records and the length of the physical record in the file body of the cyclic recording file; the file body of the cyclic recording file is created according to the personalization instruction, the file body including multiple physical records, each physical record being set with an actual existing record identifier and a logical first record identifier.
[0020] As can be seen from the above scheme, in the personalization stage of the smart card, the present invention sets the actual existence record identifier and the logical first record identifier in the file body of the cyclic record file through personalization instructions, so that in the subsequent file body update and reading, the corresponding operation is performed by judging the status of the actual existence record identifier and the logical first record identifier.
[0021] To achieve the fourth objective mentioned above, the present invention provides a computer device comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, it implements the above-mentioned method for updating a smart card cyclic record file, or implements the above-mentioned method for updating a smart card cyclic record file, or implements the above-mentioned method for personalizing a smart card cyclic record file.
[0022] To achieve the fifth objective described above, the present invention provides a computer-readable storage medium storing a computer program thereon, wherein: when the computer program runs, it implements the above-described method for updating a smart card cyclic log file, or implements the above-described method for updating a smart card cyclic log file, or implements the above-described method for personalizing a smart card cyclic log file. Attached Figure Description
[0023] Figure 1 This is a schematic diagram of the file structure of a circular record file in the existing technology.
[0024] Figure 2 This is a flowchart of an embodiment of the personalized method for cyclically recording files according to the present invention.
[0025] Figure 3 This is a schematic diagram of the file structure of the cyclic recording file in an embodiment of the present invention.
[0026] Figure 4 This is a flowchart of an embodiment of the method for updating a cyclically recorded file according to the present invention.
[0027] Figure 5 This is a flowchart illustrating the process of determining the first target physical record in an embodiment of the method for updating a cyclically recorded file according to the present invention.
[0028] Figure 6 This is a schematic diagram of the cyclic record file update format in an embodiment of the cyclic record file update method of the present invention.
[0029] Figure 7 This is a schematic diagram of another update format of the cyclic record file in an embodiment of the update method for the cyclic record file of the present invention.
[0030] Figure 8 This is a schematic diagram of another update format for the cyclic record file in an embodiment of the update method for the cyclic record file of the present invention.
[0031] Figure 9 This is a flowchart of an embodiment of the method for reading cyclically recorded files according to the present invention.
[0032] The present invention will be further described below with reference to the accompanying drawings and embodiments. Detailed Implementation
[0033] This invention sets an actual existence record identifier and a logical first record identifier in each physical record of the file body of the circular record file, thereby realizing the updating and reading of the circular record file through the actual existence record identifier and the logical first record identifier, avoiding cross-sector operations on the circular record file.
[0034] Example of a personalized method for cyclically recording files on a smart card:
[0035] During the personalization phase of a smart card, a circular record file needs to be created within the smart card. Compared to existing technologies, this invention adds an actual existing record identifier and a logical first record identifier to each physical record in the file body of the circular record file when creating the circular record file.
[0036] See Figure 2 In this embodiment, the method for personalizing the circular log file is implemented by the smart card's processor executing a computer program. Specifically, step S11 is executed first to obtain a personalization instruction. The personalization instruction includes the maximum number of physical records and the physical record length of the circular log file's body. The maximum number of physical records refers to the maximum number of log entries generated by transactions that the circular log file's body can record; each physical record can store one log entry. The physical record length refers to the physical space occupied by one physical record on the FLASH storage medium. Thus, physical space can be allocated to the file body according to the personalization instruction.
[0037] Then, step S12 is executed to create the file body of the circular log file according to the personalized instructions. See also Figure 3 In this embodiment, for each physical record in the file body of the circular record file (the actual nth physical record represents one physical record, and "actual nth" indicates the position of the physical record in the circular record file), in addition to the physical space for storing the logs generated by the transaction, a physical space of two bytes is also provided, which is used to record the actual existence record identifier and the logical first record identifier of the physical record, respectively.
[0038] After the smart card is successfully personalized, a circular log file is created. At this time, for each physical record, the actual existence record identifier is in the first original state, that is, the value of the actual existence record identifier is 0. This means that the physical space in the physical record corresponding to the actual existence record identifier that is used to store logs generated by transactions is empty, and no logs have been written to this physical record. When the actual existence record identifier is set to the first changed state in the subsequent update process, that is, the value of the actual existence record identifier is 1, this means that the physical space in the physical record corresponding to the actual existence record identifier that is used to store logs generated by transactions is not empty, and logs have been written to this physical record.
[0039] After the smart card is successfully personalized, a circular record file is created. At this time, for each physical record, the logical first record identifier is in the second original state, that is, the logical first record identifier is 0. This means that the physical record corresponding to the logical first record identifier is not the logical first record. When the logical first record identifier is set to the second changed state in the subsequent update process, that is, the logical first record identifier is 1, this means that the physical record corresponding to the logical first record identifier is the logical first record.
[0040] Example of a method for updating smart card cyclic log files:
[0041] This embodiment is implemented by executing a computer program through the processor on the smart card. The circular record file on the smart card in this embodiment is the circular record file obtained in the above embodiment of the personalized method of the circular record file of the smart card. In each physical record of the file body of the circular record file, the space used for recording logs is empty, and the actual record identifier and the logical first record identifier are both 0.
[0042] For the method of updating the smart card cyclic recording file in this embodiment, please refer to [link / reference]. Figure 4 First, execute step S21 to obtain the target log. The target log is the log generated by the current transaction. At this point, the target log needs to be written to one of the physical records in the file body of the circular record file.
[0043] Then, step S22 is executed, which involves traversing the actual record identifiers and logical first record identifiers in the file body of the circular record file according to the preset writing order to determine the first target physical record. In this embodiment, the preset writing order is the order from the first actual physical record to the last actual physical record, and after the last actual physical record is written, the process returns to the first actual physical record. For example, in this embodiment, the maximum number of physical records in the body of the circular record file is 10, and the length of each physical record is 64 (i.e., 0x40 in hexadecimal). Therefore, the physical memory space allocated to the body of the circular record file is 10 * 64 = 640 bytes. The starting address of the file body in memory is 0x10000000. Then, 0x10000000 to 0x1000003F is the first physical record, 0x10000040 to 0x1000007F is the second physical record, and so on. From 0x10000240 to 0x1000027F, this is the tenth physical record, which is the last physical record.
[0044] Specifically, when executing step S22, see [link to relevant documentation]. Figure 5 First, execute step S211 to set variable i, with the initial value of variable i being i = 1.
[0045] Continue executing step S222 to obtain the actual existence record identifier and logical first record identifier of the actual i-th physical record.
[0046] Then, step S223 is executed to determine whether the actual existence record identifier of the actual i-th physical record is 0. If so, it means that the physical space corresponding to the actual i-th physical record for storing the log generated by the transaction is empty, and no log has been written to this physical record. At this time, the actual i-th physical record can be used to write the target log. Thus, step S224 is continued to be executed, and the actual i-th physical record is recorded as the first target physical record. And step S230 is executed to set the variable j, and the initial value of the variable j is j = 0. j = 0 indicates that the file body of the cyclic record file has not been filled yet, and there are still physical records with empty physical spaces for storing the log generated by the transaction.
[0047] If it is determined that the actual existence record identifier of the actual i-th physical record is not 0, that is, the actual existence record identifier of the actual i-th physical record is 1, it means that the physical space corresponding to the actual i-th physical record for storing the log generated by the transaction is not empty, and further judgment is needed. At this time, step S226 is executed to determine whether the logical first record identifier of the actual i-th physical record is 1. If not, step S225 is executed, and the variable i is incremented by 1, that is, i = i + 1, and then it returns to step S222.
[0048] If it is determined that the logical first record identifier of the actual i-th physical record is 1, it means that the actual i-th physical record is the first record logically, and the actual (i + 1)-th physical record can be used as the first target physical record. At this time, step S227 needs to be executed to determine whether i + 1 < n + 1 holds. n represents the maximum number of physical records, which is 10 in this embodiment. If i + 1 < n + 1, step S228 is executed, and the actual (i + 1)-th physical record is recorded as the first target physical record. If i + 1 < n + 1 does not hold, it means that the actual i-th physical record is the actual 10th physical record, that is, the actual last physical record. At this time, step S229 is executed, and the actual 1st physical record is recorded as the first target physical record. Then step S231 is executed, and the variable j is assigned 1. j = 1 indicates that the file body of the cyclic record file has been filled, and there are no physical records with empty physical spaces for storing the log generated by the transaction.
[0049] It should be noted that when traversing the actual record identifiers and logical first record identifiers in the file body of the loop record file according to the preset writing order, the first current physical record is the physical record read at this moment, and the second current physical record is the physical record read after the first current physical record according to the preset writing order. For example, if the first current physical record is the first actual physical record, the second current physical record is the second actual physical record; if the first current physical record is the second actual physical record, the second current physical record is the third actual physical record. The first actual record identifier is the actual record identifier of the first current physical record, and the first logical first record identifier is the logical first record identifier of the first current physical record. The second actual record identifier is the actual record identifier of the second current physical record, and the second logical first record identifier is the logical first record identifier of the second current physical record. Furthermore, the logical first record refers to the most recently written physical record.
[0050] Finally, step S23 is executed to complete the writing of the target log based on the first target physical record. As can be seen from step S22, the first target physical record may be one of the following three cases: the first physical record (j=0), one of the second to tenth physical records, or the first physical record (j=1).
[0051] In all three scenarios above, the target log is written to the space designated for logging within the first target physical record. However, the handling of the actual record identifier and the logical first record identifier differs. For the first target physical record being the first physical record (j=0), see [link to relevant documentation]. Figure 6 When the first target physical record is the first actual physical record and j=0, it indicates that the file body of the circular record file has not been filled and this is the first update. The target log is written to the first actual physical record, the target's actual record identifier is set to 1, and the target's logical first identifier is set to 1. For the first target physical record being one of the 2nd to 10th actual physical records, see [link to relevant documentation]. Figure 7 In addition to setting the target's actual existence record identifier to 1 and the target's logical first identifier to 1, the actual existence record identifier of the previous actual physical record of the first target physical record, written in a preset order, also needs to be set to 1, and the logical first identifier of the previous record needs to be set to 0. Because the addresses are contiguous, the target's actual existence record identifier, target's logical first identifier, previous record's actual existence record identifier, previous record's logical first identifier, and target log can be written all at once. For the first target physical record being the first actual physical record (j=1), refer to... Figure 8In addition to setting the target actual existence record identifier of the first physical record to 1 and the target logical first identifier to 1, and writing the target log into the physical space of the first physical record to accommodate the log, it is also necessary to set the actual existence record identifier of the tenth physical record to 1 and the target logical first identifier to 0. Due to the non-contiguous addresses, the above writing process needs to be done in two parts.
[0052] Example of a method for reading files in a loop from a smart card:
[0053] This embodiment is also implemented by executing a computer program through the processor on the smart card, and the circular record file on the smart card in this embodiment is the updated circular record file in the above embodiment of the method for updating the circular record file of the smart card.
[0054] For details, see Figure 9 To execute the smart card cyclic record file reading method of this embodiment, first, step S41 is executed to obtain a record reading instruction. In this embodiment, reading is performed through the Read record command. This instruction includes the logical record number P1 to be read and the end file identifier SFI. In this embodiment, the logical record number is described as 9, that is, the log of the logically 9th record needs to be read.
[0055] Continuing with step S42, the second target physical record where the logically first record resides is determined based on the logical first record identifier of the file body of the circular record file. By determining the second target physical record where the logically first record resides, the third target physical record where the logically third record resides can be determined. Specifically, from the first physical record to the tenth physical record, each physical record is sequentially checked to determine whether the third physical record of the current third physical record has an identifier of 1 and a logical first record identifier of 1. Since there is only one physical record in the circular record file with a logical first record identifier of 1, it can be determined that the physical record is the sequence number in the actual physical space. In this embodiment, the second target physical record is determined to be the third physical record.
[0056] Then, step S43 is executed to obtain the third target physical record corresponding to the logical record sequence number in the reverse order of the preset write order. Specifically, let the sequence number of the second target physical record be K. If K - P1 + 1 ≥ 1, the actual physical record K - P1 + 1 is the third target physical record; if K - P1 + 1 < 1, the actual physical record K - P1 + n + 1 is the third target physical record, where n is the maximum number of physical records. In this implementation, it can be calculated that the actual physical record 5 is the third target physical record.
[0057] Then, proceed to step S44 to determine if the actual existence record identifier of the third target physical record is 1. If yes, it means that there is a log that needs to be read, and continue to step S45. If no, proceed to step S46 and return a read failure.
[0058] Finally, step S45 is executed, returning the contents of the third target physical record. This completes the reading of the log from the third target physical record.
[0059] Computer device embodiment:
[0060] The computer device in this embodiment includes a processor and a memory. The memory stores a computer program, and when the processor executes the computer program, it implements the above-mentioned method for updating, reading, and personalizing the smart card cyclic recording file.
[0061] A computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that a computer device may include more or fewer components, or a combination of certain components, or different components; for example, a computer device may also include input / output devices, network access devices, buses, etc.
[0062] For example, a processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microcontroller or any conventional processor. The processor is the control center of a computer device, connecting all parts of the computer device through various interfaces and lines.
[0063] The memory can be used to store computer programs and / or modules. The controller implements various functions of the computer device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. For example, the memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (e.g., sound receiving function, sound-to-text function, etc.), etc.; the data storage area may store data created based on the use of the mobile phone (e.g., audio data, text data, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0064] Examples of computer-readable storage media:
[0065] If the modules integrated into the computer device in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes of the smart card cyclic recording file update method embodiment, reading method embodiment, and personalization method embodiment can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a controller, it can implement the steps of the above-mentioned smart card cyclic recording file update method embodiment, reading method embodiment, and personalization method embodiment. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The storage medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content contained in computer-readable media may be appropriately added to or subtracted from the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, computer-readable media may not include electrical carrier signals and telecommunication signals, in accordance with legislation and patent practice.
[0066] In summary, the personalized smart card cyclic log file method of the present invention sets an actual existence record identifier and a logical first record identifier on each physical record when creating the cyclic log file. The smart card cyclic log file update method of the present invention determines operable physical records by judging the actual existence record identifier and the logical first record identifier of each physical record, thereby updating the target log to the operable physical records. The smart card cyclic log file reading method of the present invention determines the logical first record by judging the actual existence record identifier and the logical first record identifier of each physical record, thereby determining the position of the record to be read in the cyclic log file, and then performing the reading. The above-described smart card cyclic log file update and reading methods, because they do not require manipulation of the file header of the smart card cyclic log file during the update and reading processes, can reduce cross-sector read / write operations, thereby improving smart card transaction performance.
Claims
1. A method for updating a smart card cyclic recording file, characterized in that, Includes the following steps: Obtain the target log; The actual existing record identifier and logical first record identifier in the file body of the circular record file are traversed according to a preset writing order until the first actual existing record identifier of the first current physical record is in the first original state. At this point, the first current physical record is determined to be the first target physical record. Alternatively, the next second current physical record of the first current physical record according to the preset writing order is determined to be the first target physical record until the first actual existing record identifier of the first current physical record is in the first changed state and the first logical first record identifier is in the second changed state. The file body of the circular record file has multiple physical records, and each physical record is provided with the actual existing record identifier and the logical first record identifier. Write the target log to the first target physical record, set the target actual existence record identifier of the first target physical record to a first changed state, and set the first target logical first record identifier of the first target physical record to a second changed state; if the first target physical record is the second current physical record, set the first logical first record identifier of the first current physical record to a second original state.
2. The method for updating a smart card cyclic recording file as described in claim 1, characterized in that: After determining that the second current physical record is the first target physical record, determine whether the following conditions are met: the second current physical record is the actual first physical record of the file body of the circular record file, and the first current physical record is the actual last physical record of the file body of the circular record file. If not, through a single write operation, set the target actual existence record identifier of the first target physical record to the first changed state, set the first target logical first record identifier to the second changed state, and set the first logical first record identifier of the first current physical record to the second original state.
3. A method for reading a smart card's cyclically recorded file, characterized in that: Obtain a record read instruction, wherein the record read instruction includes a logical record ordinal number; The second target physical record containing the logically first record is determined based on the logical first record identifier of the file body of the circular record file; Obtain the third target physical record corresponding to the logical record ordinal number in the reverse order of the preset writing order; Return the contents of the third target physical record. The cyclic record file is updated according to the smart card cyclic record file update method as described in claim 1 or 2.
4. The method for reading a smart card cyclic recording file as described in claim 3, characterized in that: When determining the second target physical record, the physical records in the file body of the loop record file are traversed according to the preset writing order until the third actual existing record of the third current physical record is identified as the first change state and the third logical first record of the third current physical record is identified as the second change state. Then, the third current physical record is determined as the second target physical record.
5. A method for personalizing smart card cyclic recording files, characterized in that: Obtain personalized instructions, which include the maximum number of physical records and the physical record length of the file body in a loop; The file body of the circular record file is created according to the personalized instructions. The file body includes multiple physical records. Each physical record is set with an actual existing record identifier and a logical first record identifier. The cyclic record file is updated according to the smart card cyclic record file update method as described in claim 1 or 2.
6. A computer device, comprising a processor and a memory, characterized in that: The memory stores a computer program, which, when executed by the processor, implements the method for updating the smart card cyclic recording file as described in claim 1 or 2, or the method for reading the smart card cyclic recording file as described in claim 3 or 4, or the method for personalizing the smart card cyclic recording file as described in claim 5.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program, when running, implements the method for updating the smart card cyclic recording file as described in claim 1 or 2, or the method for reading the smart card cyclic recording file as described in claim 3 or 4, or the method for personalizing the smart card cyclic recording file as described in claim 5.
Citation Information
Patent Citations
Method for operating data file by card operating system and smart card thereof
CN101140548A
Data updating method, data updating system and memory
CN102855162A