Background technology
Common file system has file allocation table (File Allocation Table, FAT) file system and New Technology File System (New Technology File System, NTFS) etc., what be stored wherein that card commonly uses is the FAT file system of being set up by Microsoft, comprises FAT12, FAT16 and FAT32 file system.
The FAT file system is comprised of Main Boot Record and some FAT subregions usually, usually only has a FAT subregion on storage card, and wherein, this FAT subregion is comprised of boot sector (BPB), FAT table, root directory area (FDT) and data field.
Boot sector (BPB) is first sector of FAT subregion, it is logic sector 0, be mainly used in recording in whole FAT file system relevant parameter setting, for example: the sector number of every sector byte number, every bunch of sector number, each FAT, sector sum, root directory item number etc. parameter.
The FAT table record membership credentials in the file system, particularly important, so two FAT tables are arranged, FAT1 table and FAT2 table, but its content is in full accord, this shows the chained list index structure that each list item has recorded storage elementary cell bunch jointly, i.e. each bunch of the starting cluster of each file and successive links thereof number; And show which is the sky bunch of available (FREE).Wherein, bunch be the minimum memory unit of FAT subregion File data, if one bunch of file size less than also will take the space of bunch; If more than one bunch of length by by chained list guided bunch number, stores file data in the data field the space of a plurality of bunches.
Root directory area (FDT) has recorded the content of file system root directory, comprises the substance such as title, size, reference position, creation-time, modification time of each file and file.Each file in file system is on the books in catalogue listing.Catalogue and file all show as a file item, and are distinguished by the attribute byte of file item.
The data field, the zone of actual file data and catalogue and the storage of sub-directory data takies most of storage space, and the data field is organized by the chained list of file take bunch as storage cell, and the read-write of data is all passive.The FAT system is take bunch as base unit storing documents data, and each bunch has N sector, and each file has M bunch, and the sector number N of every bunch is relevant with the total volume size of disk, and how much relevant with file size bunch M that file takies is.
The file system that just format is good; copied files inside; bunch take the order be to deposit with the TOC level of source file; namely in the data field; catalogue data and file data are entrained in together to be deposited; as shown in Fig. 1 and 2, this storage mode is divided into a lot of fragments with the data field, calculation of complex when protected file.
The content of file may be with different levels, file and file is arranged below file, if be entrained in together when depositing these data; will divide a lot of fragments to process; as described in Figure 2, mix with catalogue data and be in the same place in the file data district, and the fragment that is divided into is more; the data field is divided into six fragments in Fig. 2; in storer, the protection of data is as foundation, in the case take address realm; six fragments form six protection domains, calculation complex when protected file.
Summary of the invention
The object of the present invention is to provide a kind of management method of file system data; be intended to solve in the system file that prior art provides; depositing of catalogue data and file data is irregular without level, and the data field is divided into a lot of fragments, is unfavorable for the problem of protected file.
The present invention is achieved in that a kind of management method of file system data, and described method comprises the steps:
The recursively enumerate source folder calculates All Files folder and the catalogue of file and the sector sum that the sub-directory data need in source folder;
According to the sector sum of the catalogue of All Files folder in source folder and file and sub-directory data needs, the data field of target disk is divided into catalogue data district and file data district;
Obtain the sector start offset address information in file data district;
All catalogues in source folder and sub-directory data are write catalogue data district in the target disk data field, All Files data in source folder are write file data district in the target disk data field;
According to the writing address of catalogue and sub-directory data and file data, two file allocation table of updating file system.
Another purpose of the embodiment of the present invention is to provide a kind of management system of file system data, and described system comprises:
Sector sum computing module is used for the recursively enumerate source folder, calculates All Files folder and the catalogue of file and the sector sum that the sub-directory data need in source folder;
Module is divided in the data field, is used for according to the sector sum of the catalogue of source folder All Files folder and file and sub-directory data needs, the data field of target disk being divided into catalogue data district and file data district;
Sector start offset address acquisition of information module is for the sector start offset address information of obtaining the file data district;
Writing module is used for all catalogues of source folder and sub-directory data are write catalogue data district in the target disk data field, and All Files data in source folder are write file data district in the target disk data field; And
Update module is used for the writing address according to catalogue and sub-directory data and file data, two file allocation table of updating file system.
In embodiments of the present invention, the recursively enumerate source folder calculates the catalogue of All Files folder and file and the sector sum that the sub-directory data need; According to the sector sum of the catalogue data needs of All Files folder and file, the data field of target disk is divided into catalogue data district and file data district, and obtains the sector start offset address information in file data district; All catalogues and sub-directory data are write catalogue data district in the target disk data field, the All Files data are write file data district in the target disk data field; According to the writing address of catalogue data and file data, two file allocation table of updating file system, thus realize file data and separately storage of catalogue data are effectively simplified and processed calculation procedure.
Embodiment
In order to make purpose of the present invention, technical scheme and beneficial effect clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, is not intended to limit the present invention.
In embodiments of the present invention, the recursively enumerate source folder calculates the catalogue of All Files folder and file and the sector sum that the sub-directory data need; According to the sector sum of the catalogue data needs of All Files folder and file, the data field of target disk is divided into catalogue data district and file data district, and obtains the sector start offset address information in file data district; All catalogues and sub-directory data are write catalogue data district in the target disk data field, the All Files data are write file data district in the target disk data field; According to the writing address of catalogue data and file data, two file allocation table of updating file system, thus realize file data and separately storage of catalogue data are effectively simplified and processed calculation procedure.
The purpose of the embodiment of the present invention is to provide a kind of management method of file system data, it is characterized in that, described method comprises the steps:
The recursively enumerate source folder calculates the catalogue of All Files folder and file and the sector sum that the sub-directory data need;
According to the sector sum of the catalogue data needs of All Files folder and file, the data field of target disk is divided into catalogue data district and file data district, and obtains the sector start offset address information in file data district;
All catalogues and sub-directory data are write catalogue data district in the target disk data field, the All Files data are write file data district in the target disk data field;
According to the writing address of catalogue data and file data, two file allocation table of updating file system.
Further, the space in described catalogue data district is total more than or equal to the sector that the catalogue data of All Files folder and file needs.
Further, write the address of the deposit data in catalogue data district and file data district in the target disk data field continuous.
Another purpose of the embodiment of the present invention is to provide a kind of management system of file system data, it is characterized in that, described system comprises:
Sector sum computing module is used for the recursively enumerate source folder, calculates the catalogue of All Files folder and file and the sector sum that the sub-directory data need;
Module is divided in the data field, and the sector sum that is used for the catalogue data needs of the All Files folder that calculates according to described sector sum computing module and file is divided into catalogue data district and file data district with the data field of target disk;
Sector start offset address acquisition of information module is for the sector start offset address information of obtaining the file data district;
Writing module is used for dividing module to the division of data field according to described data field, and all catalogues and sub-directory data are write catalogue data district in the target disk data field, and the All Files data are write file data district in the target disk data field; And
Update module is used for the writing address according to catalogue data and file data, two file allocation table of updating file system.
Further, the space in described catalogue data district is total more than or equal to the sector that the catalogue data of All Files folder and file needs.
Further, write the address of the deposit data in catalogue data district and file data district in the target disk data field continuous.
Fig. 3 shows the realization flow of the management method of the file system data that the embodiment of the present invention provides, and its concrete step is as described below:
In step S101, the recursively enumerate source folder calculates the catalogue of All Files folder and file and the sector sum that the sub-directory data need.
In step S102, according to the sector sum of the catalogue data needs of All Files folder and file, the data field of target disk is divided into catalogue data district and file data district, and obtains the sector start offset address information in file data district.
In embodiments of the present invention, this to the division of data field according to being: the space in catalogue data district is total more than or equal to the sector that the catalogue data of All Files folder and file needs.Be that the catalogue data district wants to store all catalogue datas.
In embodiments of the present invention, the address of the data storage in the catalogue data district that obtains after dividing and file data district is continuous, wherein, in order to save the space of target disk data field, make the data field can deposit more catalogue data and file data, the address that all catalogues and sub-directory are deposited in the catalogue data district is continuous, and the address that all file datas are deposited in the file data district is continuous.
In the case, catalogue data district and file data district respectively only have a fragment, namely only form two protection domains; middle catalogue data and file data are entrained in together and deposit compared to existing technology; form a plurality of fragments, a plurality of protection domains calculate simpler when protected file.
In step S103, all catalogues and sub-directory data are write catalogue data district in the target disk data field, the All Files data are write file data district in the target disk data field.
In embodiments of the present invention, the data field is being carried out after division operation completes, with the storage of classifying of the data in original data field, be about to catalogue data and write the catalogue data district, with file data writing in files data field, completing the operation of classification storage.
In step S104, according to the writing address of catalogue data and file data, two file allocation table of updating file system.
File allocation table is a chained list, is used for the order of depositing of identification document data, and when writing catalogue data and file data, which bunches are the data that need record to write are, need to fill in bunch chained list of correspondence complete during the updating file allocation table.As: in FAT16, a file has taken two bunches, and bunches 3, bunches 4, will fill out in bunch 3 positions 4 and indicate that next bunch is bunches 4 in file allocation table, the ending that 0xffff0xff indicates this chained list is filled out in bunch 4 positions.
Fig. 4 shows the realization flow of the management method of the file system data that second embodiment of the invention provides, and its concrete step is as described below:
In step S201, the recursively enumerate source folder calculates the catalogue of All Files folder and file and the sector sum that the sub-directory data need.
In step S202, according to the sector sum of the catalogue data needs of All Files folder and file, the data field of target disk is divided into catalogue data district and file data district, and obtains the sector start offset address information in file data district.
In step S203, calculate the sector sum that the All Files data need.
In step S204, the sector sum that the All Files data are needed compares with the sector sum in file data district, judging sector sum that the All Files data need whether greater than the sector sum in file data district, is execution in step S205, otherwise execution in step S206.
In step S205, send warning message, prompting source folder capacity is excessive, and the target disk capacity is stored source file not.
In step S206, all catalogues and sub-directory data are write catalogue data district in the target disk data field, the All Files data are write file data district in the target disk data field.
In step S207, according to the writing address of catalogue data and file data, two file allocation table of updating file system.
Above-mentioned is only one embodiment of the present of invention, do not repeat them here, but not in order to limit the present invention.
As a specific embodiment of the present invention, as illustrated in Figures 5 and 6, form a sharp contrast with above-mentioned Fig. 1 and Fig. 2 respectively:
In Fig. 1, do not carry out the data field that the zone is divided, catalogue and sub-directory data and file data are being deposited in doping, and depositing that it is concrete can be with reference to shown in Figure 2, and namely catalogue data and file data storing have no rule, deposit at random;
In Fig. 5, pass through embodiment of the present invention, the data field of target disk is divided into catalogue data district and file data district, and the Data classification of data field will be original shown in Figure 1 stores catalogue data district and file data district after division into, data have been carried out classified and stored, convenient management, it specifically can be with reference to schematic diagram shown in Figure 6, file data and catalogue data be storage separately, is convenient to management.
Fig. 7 shows the structured flowchart of the management system of the file system data that the embodiment of the present invention provides, for convenience of explanation, only provided the part relevant to the embodiment of the present invention in figure, the management system of this document system data can be built in software unit or the hardware cell of the hardware devices such as storer.
Sector sum computing module 11 recursively enumerate source folders calculate the catalogue of All Files folder and file and the sector sum that the sub-directory data need; The sector sum that the catalogue data needs of All Files folder that module 12 calculates according to described sector sum computing module 11 and file are divided in the data field is divided into catalogue data district and file data district with the data field of target disk; Sector start offset address acquisition of information module 13 is obtained the sector start offset address information in file data district; Divide the division of 12 pairs of data fields of module according to described data field, writing module 14 writes catalogue data district in the target disk data field with all catalogues and sub-directory data, and the All Files data are write file data district in the target disk data field; Update module 15 is according to the writing address of catalogue data and file data, two file allocation table of updating file system.
As one embodiment of the present of invention, the total computing module 16 in file data sector calculates the sector sum that the All Files data need; The sector sum that the All Files data that comparing module 17 calculates described file data sector sum computing module need compares with the sector sum in file data district, judge that sector sum that the All Files data need is whether total greater than the sector in file data district; If the sector sum that the All Files data need is greater than the sector sum in file data district, reminding module 18 sends warning message, and prompting source folder capacity is excessive, and the target disk capacity is stored source file not; If the sector sum that the All Files data need is less than or equal to the sector sum in file data district, carry out said write module 14 all catalogues and sub-directory data are write catalogue data district in the target disk data field, the All Files data are write the step in the file data district in the target disk data field.
Wherein, the concrete enforcement of above-mentioned each module as described in above-mentioned embodiment of the method, does not repeat them here, but not in order to limit the present invention.
In embodiments of the present invention, the recursively enumerate source folder calculates the catalogue of All Files folder and file and the sector sum that the sub-directory data need; According to the sector sum of the catalogue data needs of All Files folder and file, the data field of target disk is divided into catalogue data district and file data district, and obtains the sector start offset address information in file data district; All catalogues and sub-directory data are write catalogue data district in the target disk data field, the All Files data are write file data district in the target disk data field; According to the writing address of catalogue data and file data, two file allocation table of updating file system, thus realize file data and separately storage of catalogue data are effectively simplified and processed calculation procedure.
The above is only preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., within all should being included in protection scope of the present invention.