A kind of smartcard file management system based on registration table and management method thereof
Technical field
The present invention relates to technical field of intelligent card, particularly based on smartcard file management system and the management method thereof of registration table.
Background technology
In prior art, the management method of smartcard file is: select blank out memory block directory information, fileinfo and file body all to be stored together.Profit in this way, can realize smartcard file and create, the operation such as to search.But because full detail is put together by this method, and the length of often kind of information is different, causes reducing compared with the search efficiency of deep layer file.Owing to requiring in application of IC cards occasion that the time of locating file is short as far as possible, so prior art has obviously been not suitable for the demand applied.
Summary of the invention
For above-mentioned the deficiencies in the prior art, the object of this invention is to provide a kind of smartcard file management system based on registration table and management method thereof.Catalogue and fileinfo are placed in different registration tablies and manage by it, effectively reduce the locating file time used.
In order to reach foregoing invention object, technical scheme of the present invention realizes as follows:
Based on a smartcard file management system for registration table, it comprises catalogue registry hive, file registration table unit and file body unit.It is characterized in that; Described catalogue registry hive stores the bibliography information that all catalogues comprise root directory and sub-directory, and each catalogue file header that catalogue registry hive stores comprises the logical address of the file registration table unit of described catalogue.Described file registration table unit is responsible for the file index information storing All Files under assigned catalogue, and the index information that file registration table unit stores comprises the logical address of file body unit.Described file body unit stores fileinfo and the data of concrete file.
In above-mentioned smartcard file management system, the system registry cellular logic address that the described File header information of catalogue registry hive storage directory, the set membership of catalogue and each catalogue are corresponding.Bibliography information each catalogue in catalogue registry hive occupies fixing size.
In above-mentioned smartcard file management system, the set membership of described catalogue adopts in bibliography information, to store call number in catalogue registry hive of the call number of parent directory in catalogue registry hive, first sub-directory and the call number of fraternal catalogue in catalogue registry hive realizes.
In above-mentioned smartcard file management system, described file index information comprises the logical address of the short file identifier of information, file name and file body unit required for file to be found.File index information each file in file registration table unit occupies fixing size.
As mentioned above based on the management method of the smartcard file management system of registration table, it uses and comprises catalogue registry hive, file registration table unit and file body unit, and its method step is:
1) file search method:
When 1. receiving selection catalogue instruction, in catalogue registry hive, carry out directory name comparison search, file finds its system registry cellular logic address of rear preservation.
When 2. receiving file read-write instruction, according to current file registry hive logical address, documents index information in file registration table unit, obtains the file body logical address of match index information, carries out the access of file data according to file body logical address.
2) the file erase management method of catalogue:
1. the system registry cellular logic address of catalogue is obtained.
2. according to the system registry cellular logic address of catalogue, the logical address and the logical space that obtain All Files body under this catalogue take, and carry out space reclamation one by one.
3. delete the file registration table unit of this catalogue, reclaim registration table space.
The present invention adopts said structure and method, catalogue and fileinfo is managed in the mode of registration table.Wherein, catalogue registry hive is responsible for the bibliography information storing all catalogues, and file registration table unit is responsible for the file index information storing All Files under assigned catalogue, and file body unit stores fileinfo and the data of concrete file.The length of each file index information in registration table is fixed, and can directly use file index number to find the offset address of respective file information.The present invention effectively can reduce the locating file time used, and search efficiency is high.
Below in conjunction with the drawings and specific embodiments, the invention will be further described.
Accompanying drawing explanation
Fig. 1 is management system structural representation of the present invention;
Fig. 2 is the smart card indices structural representation in the embodiment of the present invention;
Fig. 3 is the smart card indices storage organization schematic diagram in the embodiment of the present invention.
Embodiment
Referring to Fig. 1, smartcard file management system of the present invention, it comprises catalogue registry hive A, system registry unit B and file body unit C.Catalogue registry hive A stores the bibliography information that all catalogues comprise root directory and sub-directory, and each catalogue file header that catalogue registry hive A stores comprises the logical address of the system registry unit B of described catalogue.System registry unit B is responsible for the file index information storing All Files under assigned catalogue, and the index information that system registry unit B stores comprises the logical address of file body unit C.File body unit C stores fileinfo and the data of concrete file.The system registry cellular logic address that the File header information of catalogue registry hive A storage directory, the set membership of catalogue and each catalogue are corresponding; Bibliography information each catalogue in catalogue registry hive A occupies fixing size.The set membership of catalogue adopts in bibliography information, to store call number in catalogue registry hive A of the call number of parent directory in catalogue registry hive A, first sub-directory and the call number of fraternal catalogue in catalogue registry hive A realizes.File index information comprises the logical address of the short file identifier of information, file name and file body unit C required for file to be found, and file index information each file in system registry unit B occupies fixing size.
The management method of smartcard file management system of the present invention, its method step is:
1) file search method:
When 1. receiving selection catalogue instruction, in catalogue registry hive A, carry out directory name comparison search, file finds its system registry unit B logical address of rear preservation.
When 2. receiving file read-write instruction, according to current file registry hive logical address, documents index information in system registry unit B, obtains the file body logical address of match index information, carries out the access of file data according to file body logical address.
2) the file erase management method of catalogue:
1. the system registry cellular logic address of catalogue is obtained.
2. according to the system registry cellular logic address of catalogue, the logical address and the logical space that obtain All Files body under this catalogue take, and carry out space reclamation one by one.
3. delete the system registry unit B of this catalogue, reclaim registration table space.
In the present invention, a corresponding multiple system registry unit B of catalogue registry hive A, a corresponding multiple file body unit C of system registry unit B.The information that in system registry unit B, each file is corresponding comprises file type, file name, the short file identifier of file and file body cellular logic position.Each file needs at least to comprise in above-mentioned three index informations.The information that each file body unit C is corresponding comprises the data content of file operation authority, file body size and file.
Catalogue registry hive A in the present invention or system registry unit B can be multiple, and each catalogue registry hive A or system registry unit B are got up by logical address link.Now for a catalogue registry hive A or system registry unit B, implementing procedure is described:
Create first catalogue (root directory) front, need the registry hive A that first creaties directory, content is set to sky.When creating first catalogue (root directory), directory information is inserted the reference position of catalogue registry hive A, his father, son, number equal set of fraternal directory index are invalid.When creating other catalogue, the parent directory call number in this directory information is set, revises the fraternal directory index number of sub-directory call number in its parent directory or its adjacent brother.
See Fig. 2, for four catalogue process of establishing, catalogue 0 is root directory, and catalogue 1 and 2 is sub-directories of catalogue 0, and catalogue 3 is sub-directories of catalogue 1.
See Fig. 3, when setting up, the sub-directory call number of catalogue 0 is set to 1, and father and fraternal directory index number are invalid; The parent directory call number of catalogue 1 is set to 0, and sub-directory call number is set to 3, and fraternal directory index number is set to 2; The parent directory call number of catalogue 2 is set to 0, and brother and sub-directory call number are invalid; The parent directory call number of catalogue 3 is set to 1, and brother and sub-directory call number are invalid.
Before creating first file of each catalogue, need first to create system registry unit B, content is set to sky.When often creating a file, file index information is inserted the corresponding blank position of system registry unit B, and distribute its file body unit C, file out of Memory and file data content are inserted file body unit C.
When searching or operate the file content under catalogue, first in catalogue registry hive A, coupling is identical with the information of searching and meet the catalogue of current path, judge whether the authority of this catalogue meets according to the information in catalogue registry hive A, if met, by system registry unit B logical address, find respective file registry hive B.The file that coupling is identical with the information of searching from system registry unit B, by file body unit C logical address, finds respective file body unit C.Judge whether the authority of this file meets according to the information in file body unit C, if met, read or writing in files body content.