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 uses always is the FAT file system of being set up by Microsoft, comprises FAT12, FAT16 and FAT32 file system.
The FAT file system is made up of Main Boot Record and some FAT subregions usually, has only a FAT subregion on the storage card usually, and wherein, this FAT subregion is made up 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 relevant parameter setting in the whole FAT file system of record, for example: the sector number of every sector byte number, every bunch of sector number, each FAT, sector sum, root directory item number or the like 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 has shown each the list item co-registered chained list index structure of storage elementary cell bunch, 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 file data in the FAT subregion, file size is if one bunch of less than also will take one bunch space; If more than one bunch of length,, store file data in the data field a plurality of bunches space then by by chained list guided bunch number.
Root directory area (FDT) has write down 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 the file system is all 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 actual file data and the zone of catalogue and sub-directory data storage take most of storage space, and the data field is organized by the chained list of file bunch to be storage cell, and data write all is passive.The FAT system is bunch to be that base unit is deposited file data, and each bunch has N sector, and each file has M bunch, and every bunch sector number N 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 format just is good; copied files inside; bunch take the order be to deposit with the TOC level of source file; promptly in the data field; catalogue data and file data are entrained in together to be deposited; 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 the file, if be entrained in together when depositing these data; will divide a lot of fragments to handle; 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, Data Protection is to be foundation with the address realm, in the case; six fragments then form six protection domains, calculate complicated 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; catalogue data and file data deposit irregular no level, the data field is divided into a lot of fragments, be 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 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 address that writes of catalogue data and file data, two file allocation table of updating file system.
Another purpose of the embodiment of the 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 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 information acquisition module is used to obtain the sector start offset address information in file data district;
Writing module is used for dividing the division of module to the 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 address that writes according to catalogue 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 address that writes of catalogue data and file data, two file allocation table of updating file system, thus realize file data and catalogue data separate storage, effectively simplify and handle calculation procedure.
Embodiment
In order to make purpose of the present invention, technical scheme and beneficial effect clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification 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 address that writes of catalogue data and file data, two file allocation table of updating file system, thus realize file data and catalogue data separate storage, effectively simplify and handle calculation procedure.
The purpose of the embodiment of the 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 address that writes of catalogue data and file data, two file allocation table of updating file system.
Further, the space in described catalogue data district is more than or equal to the sector sum of the catalogue data needs of All Files folder and file.
Further, it is continuous to write in the target disk data field data storage addresses in catalogue data district and file data district.
Another purpose of the embodiment of the 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 information acquisition module is used to obtain the sector start offset address information in file data district;
Writing module is used for dividing the division of module to the 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 address that writes according to catalogue data and file data, two file allocation table of updating file system.
Further, the space in described catalogue data district is more than or equal to the sector sum of the catalogue data needs of All Files folder and file.
Further, it is continuous to write in the target disk data field data storage addresses in catalogue data district and file data district.
Fig. 3 shows the realization flow of the management method of the file system data that the embodiment of the 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 division foundation to the data field is: the space in catalogue data district is more than or equal to the sector sum of the catalogue data needs of All Files folder and file.Be that the catalogue data district wants to store all catalogue datas.
In embodiments of the present invention, the address of the catalogue data district that obtains after dividing and the data storage in 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, all catalogues and sub-directory are continuous in catalogue data district storage addresses, and all file datas are continuous in file data district storage addresses.
In the case, catalogue data district and file data district respectively have only a fragment, promptly only form two protection domains; middle compared to existing technology catalogue data and file data are entrained in together to be deposited; 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,, be about to catalogue data and write the catalogue data district, file data is write the file data district, finish the operation of classification and storage the data field being carried out the data in original data field are carried out classification and storage after division operation finishes.
In step S104, according to the address that writes 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 fill in bunch chained list of correspondence complete during the updating file allocation table.As: a file has taken two bunches among the FAT16, and bunches 3, bunches 4, in file allocation table, will fill out 4 in bunch 3 positions and indicate that next bunch is bunches 4, 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 total sector sum with the file data district in sector that the All Files data are needed compares, judging sector sum that the All Files data need whether greater than the sector sum in file data district, is execution in step S205 then, 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 inadequately.
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 address that writes of catalogue data and file data, two file allocation table of updating file system.
Above-mentioned is one embodiment of the present of invention only, do not repeat them here, but not in order to restriction 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 of area dividing, to mix and depositing catalogue and sub-directory data and file data, depositing that it is concrete can be with reference to shown in Figure 2, and promptly 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 qualification of data field will be original shown in Figure 1 stores catalogue data district and file data district after the division into, data have been carried out classified and stored, convenient management, it specifically can be with reference to synoptic diagram shown in Figure 6, file data and catalogue data separate storage are convenient to management.
Fig. 7 shows the structured flowchart of the management system of the file system data that the embodiment of the invention provides, for convenience of explanation, only provided the part relevant with the embodiment of the invention among the figure, the management system of this document system data can be built in the software unit or the hardware cell of 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 information acquisition module 13 obtains the sector start offset address information in file data district; According to the division that 12 pairs of data fields of module are divided in 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 address that writes of catalogue data and file data, two file allocation table of updating file system.
As one embodiment of the present of invention, file data sector sum computing module 16 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 the All Files data need the sector sum whether greater than the sector sum 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 inadequately; If the sector sum that the All Files data need is less than or equal to the sector sum in file data district, then 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 method embodiment, does not repeat them here, but not in order to restriction 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 address that writes of catalogue data and file data, two file allocation table of updating file system, thus realize file data and catalogue data separate storage, effectively simplify and handle calculation procedure.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.