CN100444166C - Position-based interface access method and device for FAT file system - Google Patents
Position-based interface access method and device for FAT file system Download PDFInfo
- Publication number
- CN100444166C CN100444166C CNB2005101306458A CN200510130645A CN100444166C CN 100444166 C CN100444166 C CN 100444166C CN B2005101306458 A CNB2005101306458 A CN B2005101306458A CN 200510130645 A CN200510130645 A CN 200510130645A CN 100444166 C CN100444166 C CN 100444166C
- Authority
- CN
- China
- Prior art keywords
- file
- directory
- location information
- address location
- sub
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 22
- 230000005540 biological transmission Effects 0.000 claims description 6
- 238000004321 preservation Methods 0.000 claims description 4
- 238000004891 communication Methods 0.000 claims description 2
- 230000006870 function Effects 0.000 description 9
- 238000012545 processing Methods 0.000 description 5
- 238000007726 management method Methods 0.000 description 4
- 238000012360 testing method Methods 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 230000018109 developmental process Effects 0.000 description 3
- 230000002950 deficient Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000008520 organization Effects 0.000 description 2
- 241001269238 Data Species 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000033772 system development Effects 0.000 description 1
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention relates to the technical field of computer principles and provides a position-based interface access method in an FAT file system. First, the file is provided with a structure body for storing the address information of the file. Then, the file is provided with a module for parsing the address. All the operations of the file system on the file pass through the module, which ensures using the file address information to operate on the file directly. When used, the present invention can save a large amount of searching time, greatly raises file browsing efficiency, and is especially suitable for developing an embedded system.
Description
Technical field
The present invention relates to the Computer Organization Principles field, be specifically related to location-based interface access method in the FAT file system, and make device in this way.
Background technology
Existing FAT file system all is based on " filename ", so before all operations, file system must find its memory location and corresponding bunch of chained list according to the name of file on access interface.The flow process that reads file content by filename can be described as:
(1) directory search successively, for example search "/testfolder/mp3/hello.mp3 ", the FAT file system can be searched corresponding list item (entry) structure according to subdirectory name " testfolder " in the FAT table, search successfully back memory location according to list item structural orientation testfolder catalogue, then under its catalogue, search corresponding list item structure according to subdirectory name " mp3 ", under the mp3 catalogue, search " hello.mp3 " corresponding list item structure at last, so far obtained the list item structure of file correspondence.
(2) from the list item structure, obtain first bunch of (cluster) value of file.
(3) from FAT table, obtain bunch chained list of file data storage, bunch chained list with 0xfff (FAT12) or 0xffff (FAT16) or 0xffffffff (FAT32) as end mark.
(4) read file content according to a bunch chained list.
The FAT file allocation table is duplicate, and it is arranged in several sectors of back, logical zero sector (being boot sector), is used for representing the assignment information of disk space.It does not represent the information of boot section, file directory, yet inreal storage file content.
Owing in the continuous zone leaving disk in that the data of a file might not be complete, and tend to be divided into plurality of sections, deposit as a chain.This storage mode is called the chain type storage of file.In order to realize the chain type storage of file, which bunch of hard disk recording taken by file, the next one that bunch indicates the follow-up content of storage that is necessary for also that each has taken bunch bunch number, to the last cluster of a file, then to indicate no follow-up bunch of this bunch.These are all preserved by FAT (file allocation table), and a lot of list items are arranged in the table, every information that writes down one bunch.
List item (entry) is a basic structure in the FAT file system, and it is used to represent file, catalogue, and in fact the storage organization of file, catalogue is the same, and only attribute is different.Main include file name, attribute, creation-time, access time, file size, first bunch of information such as (cluster) value in the Entry structure.These entry structures are stored in " root directory area " and " file storage area " of FAT file structure, and during ff, system finds corresponding Entry structure earlier, then carries out other respective handling.
A most frequently used interface of FAT file system is exactly a browsing file, and it is first thing that will do of all application layers that All Files information on the disk is shown, because before browsing disk, application layer is not also known data message on the disk.Conventional FAT file system can provide two interface findfirst () and findnext () to be used for by catalogue, by the whole magnetic disk of browsing of file, and then the backspace file directory information is presented at application layer.
Subsequent operation is all based on the disk browse operation first time, for example, application layer is browsed disk and is known that a catalogue " test " and a file " fat.h " are arranged under the root directory, application layer wants to continue to browse catalogue " test " so, must be according to browsing generation pass "/test " as a result last time, call the findfirst function, then with the findnext function one by one catalogue one by one file browse catalogue " test ", other browse operation is in like manner.
There are two tangible weak points in this access method based on filename in embedded development:
(1) restriction of sub-directory progression, file name length.Carry out file access, corresponding
The parameter transmission is essential, if sub-directory progression strengthens or filename character number lengthening,
Certainly will consume more memory headrooms.Therefore, in the prior art, various file system antithetical phrases
The progression of level catalogue all has clear and definite restriction.
(2) the search file time is long.Because file system adopts successively catalogue to resolve and seeks literary composition
Part, therefore consuming time must the lengthening.
Above defective has become the obstacle of embedded development.
Summary of the invention
The objective of the invention is to overcome the defective of present prior art, propose a kind of fast, effectively, can be applicable to embedded system development, in the FAT file system location-based interface access method.
The present invention proposes that location-based interface access method may further comprise the steps in a kind of FAT file system: define a kind of structure, this structure is used for memory address locations information; The visit disk is browsed root directory, and with the application layer that turns back to of the address location information in the described structure of sub-directory under the root directory and file; Described application layer by interface with these address location information stores in register; When needs are opened sub-directory or file, from register, read the address location information of file, carry out the location resolution operation according to the parameter of the structure of described preservation address location information.
Location-based interface access method in the above-mentioned FAT file system, a kind of preferred scheme is that the address information of defined structure comprises: the list item value in the first bunch of value at file or sub-directory place, the starting cluster value of file, current sector value, termination sector value, the sector.
Location-based interface access method in the above-mentioned FAT file system, a kind of preferred scheme are to use a plurality of register-stored to turn back to the file location information of application layer.
Location-based interface access method in the above-mentioned FAT file system, a kind of preferred scheme is, use 2 register-stored fileinfos, one of them register is used to store the address location information of sub-directories at different levels, and another is used to store the fileinfo under the current directory.
The present invention also proposes a kind of device, the FAT file system mistake disposal route that this device has used the present invention to propose, this device comprises CPU and storer, wherein, comprise a FAT file system in the storer, file data in this document system also comprises a kind of structure, and this structure is used for the address location information of storage file; This document system also comprises a location resolution module, and this module is used for when system visits the disk root directory for the first time, and the address location information of sub-directory in the root directory and file is turned back to application layer; When needing again to open sub-directory or file, carry out the location resolution operation by the location resolution module according to the parameter of the structure of described preservation address location information, directly read the address location information of file, open file.
Above-mentioned device, a kind of preferred scheme are that described location resolution module is arranged in file system, are application programming interfaces.
Above-mentioned device, a kind of preferred scheme are also to comprise 2 registers, and one of them is used to store the address location information of the sub-directories at different levels that system returns when browsing root directory first, and another is used to store the fileinfo under the current directory.
Above-mentioned device, a kind of preferred scheme is also to comprise the USB module, is used for this device is linked to each other with computing machine.
Above-mentioned device, a kind of preferred scheme are that CPU, the communication between the storer of device adopts dma mode to carry out data transmission.
Adopt in the FAT file system of the present invention interface access method and device thereof based on the address, because the address information that file itself has been stored this document, therefore during search file, no longer need to search for step by step, save a large amount of search times, improve browsing file efficient greatly, be highly suitable for embedded system.
Description of drawings
Fig. 1 is the structure synoptic diagram of the address location information of file;
Fig. 2 is the module map of embodiments of the invention.
Embodiment
The location-based interface access method in the FAT file system that the present invention proposes, and make in this way device, be described as follows in conjunction with the accompanying drawings and embodiments.Following embodiment only is used to illustrate the present invention; and be not limitation of the present invention; the those of ordinary skill in relevant technologies field; under the situation that does not break away from the spirit and scope of the present invention; can also make various variations and modification; therefore all technical schemes that are equal to also belong to category of the present invention, and scope of patent protection of the present invention should be limited by every claim.
With reference to Fig. 2, in the present embodiment, whole FAT file system is placed in a slice Audio Processing chip, and this Audio Processing chip comprises CPU and memory portion, and wherein the data transmission between CPU and the storer adopts DMA (direct memory access (DMA)) transmission mode commonly used in the prior art.Specifically saying, in the storer of this sheet audio chip, be provided with a FAT file system.Because this FAT file system, therefore can finish management to exterior storage medium by it, for example read outside SD, MMC, the data in the NandFlash memory card by it.Thisly undertaken the management of exterior storage medium is belonged to prior art, be similar to and on multi-purpose computer, finish the management of USB storage equally, do not give unnecessary details at this by operating system by a file system.
In this microprogram control unit MCU system 1, adopt 51C type CPU as central processing unit, communicate by letter by between dma mode and the storer.This device adopts audio processing modules commonly used in the prior art, supports the music playback function of midi, mp3, many kinds of forms of wave, also supports the broadcast of midi+wave, midi+mp3.These music datas can pass through the audio mixing module, output to EQ (intelligence) module, 3D module then, output to loudspeaker 2 then.
Also comprise the USB module in this MCU system, this Audio Processing chip can be by carrying out data transmission between this module and the multi-purpose computer (PC).
For the file system in being stored in storer, the positional structure of defined file (POS) information in file system, can describe with a structure:
typedef?struct{
Unsigned long cluster; First bunch of value of/* */
Unsigned long sector; The current sector value * of/*/
Unsigned long sectorend; / * end sector value */
Unsigned long pos; List item value * in the/* sector/
Unsigned long parentclus; First bunch of value * of/* file or file catalogue of living in/
}F_POS;
Information in this structure comprises entry (list item) value in the first bunch of value at file or sub-directory place, the starting cluster value of file, current sector value, last sector value, the sector.POS has specified a file or the position of sub-directory in disk, as shown in Figure 1.
In the present embodiment, POS information is positioned at the end of file, accounts for 20 bytes.Since in the FAT file system to the regulation that stores of file, according to these regulations, all can there be remaining space at the end of file usually and these spaces are can be not shared by other file, and the shared data space of 20 bytes is especially little, therefore, each file is increased POS and can not bring burden the space hold of disk.
On the other hand, the location resolution module is set in the FAT file system.This module is finished being connected between application layer and the FAT file system, is responsible for calling of POS information.Concrete implementation method is to use an API (application programming interfaces) interface as this location resolution module, realization calling POS.This API has used parameter F _ POS, the structure POS that contains positional information promptly defined above.After being provided with like this, to the reading and writing of All Files, all operations such as browsing all must be by the location resolution module.Because the F_POS parameter has comprised all information of locating file deposit position, so the location resolution module finds file according to these information.Step is: (1) finds first bunch according to bunch parameter of F_POS structure, and directly locating file is residing bunch; (2) searching of entry one by one under first bunch promptly obtained each filename; (3) with the residing sector of the filename that is obtained and address location information and known parameters relatively,, then return success, otherwise repeating step (2) finishes up to whole bunch of search, also do not find and just return failure if identical.
For example, when browsing root directory, All Files and sub-directory under employing and the similar findfirst of prior art () and findnext () the function search root directory according to the present invention, need add parameter F _ POS conduct variable wherein in these two functions.For example, findfirst () can describe like this:
unsigned?char?f_qfindfirst(F_POS?pos,char?flag,F_FINDDATA*finddat)
Like this, system can return POS in the lump when the search root directory returns related data, and these POS information will be stored in the application layer.In browsing backward, just do not need to search for step by step sub-directory, open required catalogue but directly call the POS information that is stored in the application layer, call the used function interface of POS information and can describe like this:
UINT8?f_findpath(F_NAME*fsname,F_POS*pos)
As seen, follow-up when needing to open file again after browsing root directory first and obtaining POS information,,, that is to say that direct address information with file just can point to file as long as directly call the file POS information that application layer is stored by above-mentioned steps (1)-(3).The operation of this fastopen can realize in order to minor function:
unsigned?char?f_qopen(F_POS?pos,const?char*mode)
Similarly, the function interface of creating new file and entry thereof can be described as:
UINT8?f_addentry(F_NAME*fsname,F_POS*pos,F_DIRENTRY**pde)
unsigned?char?f_qcreate(F_POS?pos,char?flag,const?char*name,const?char*uname)
Wherein, when creating file, also created the POS information of file, this information accounts for 20 bytes, is positioned at the end of file, has stored the address information of file.When file was moved, this information also can be upgraded accordingly.
These functions constitute a cover API, this API has realized the location resolution module, therefore the FAT file system can obtain the POS information of All Files under this catalogue when browsing root directory, this POS information is stored in application layer, convenient later direct use realizes location-based interface access method in the FAT file system thus.
In addition, 2 buffer (register) have been adopted in the present embodiment, register just can be realized for existing general register commonly used, one of them register is used to store the address location information of the sub-directories at different levels that system returns when browsing root directory first, and another is used to store the fileinfo under the current directory.Use the scheme of 2 registers to solve the problem of management of POS information stores simultaneously, and enter sub-directory and the switching problem when returning higher level's catalogue.
As seen, adopt in the FAT file system of the present invention interface access method based on the address, because the address information that file itself has been stored this document, therefore during search file, no longer need to search for step by step, only need be when browsing root directory the address information of backspace file, follow-up operation just can be directly opens file according to the address information of file, save a large amount of search times, improved browsing file efficient greatly.The raising of this browsing file efficient, the effect in embedded system is especially obvious.
This FAT file system that has adopted the location-based interface access method of FAT file system kind of the present invention's proposition, those skilled in the art can apply it in other occasions, for example is applied in multi-purpose computer or other embedded developments.Present embodiment only is used to support the present invention, and protection scope of the present invention should be defined by the claims.
Claims (9)
1, location-based interface access method in a kind of FAT file system, it is characterized in that may further comprise the steps: define a kind of structure, described structure is stored in the inside of file, and is used to store the address location information of this document; The visit disk is browsed root directory, and with the application layer that turns back to of the address location information in the described structure of sub-directory under the root directory and file; Described application layer by interface with these address location information stores in register; When needs are opened sub-directory or file, from register, read the address location information of file, carry out the location resolution operation according to the parameter of the structure of described preservation address location information.
2, location-based interface access method in the FAT file system as claimed in claim 1 is characterized in that defined structure comprises following data: the list item value in the first bunch of value at file or sub-directory place, the starting cluster value of file, current sector value, last sector value, the sector.
3, location-based interface access method in the FAT file system as claimed in claim 1, the address location information of the file that it is characterized in that using a plurality of register-stored to turn back to application layer.
4, location-based interface access method in the FAT file system as claimed in claim 3, it is characterized in that using 2 register-stored fileinfos, one of them register is used to store the address location information of sub-directories at different levels, and another is used to store the fileinfo under the current directory.
5, a kind of device that uses the method for claim 1, comprise CPU and storer, it is characterized in that comprising in the storer FAT file system, the file data in this document system also comprises a kind of structure, and this structure is used for the address location information of storage file; This document system also comprises a location resolution module, and this module is used for when system visits the disk root directory for the first time, and the address location information of sub-directory in the root directory and file is turned back to application layer; When needing again to open sub-directory or file, carry out the location resolution operation by the location resolution module according to the parameter of the structure of described preservation address location information, directly read the address location information of file, open file.
6, device as claimed in claim 5 is characterized in that described location resolution module is arranged in file system, is application programming interfaces.
7, device as claimed in claim 5 is characterized in that also comprising 2 registers, and one of them is used to store the address location information of the sub-directories at different levels that system returns when browsing root directory first, and another is used to store the fileinfo under the current directory.
8, device as claimed in claim 5 is characterized in that also comprising the USB module, is used for this device is linked to each other with computing machine.
9, device as claimed in claim 5 is characterized in that CPU, the communication between the storer of device adopts dma mode to carry out data transmission.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2005101306458A CN100444166C (en) | 2005-12-16 | 2005-12-16 | Position-based interface access method and device for FAT file system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2005101306458A CN100444166C (en) | 2005-12-16 | 2005-12-16 | Position-based interface access method and device for FAT file system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1776686A CN1776686A (en) | 2006-05-24 |
CN100444166C true CN100444166C (en) | 2008-12-17 |
Family
ID=36766178
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2005101306458A Expired - Fee Related CN100444166C (en) | 2005-12-16 | 2005-12-16 | Position-based interface access method and device for FAT file system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100444166C (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102402543B (en) * | 2010-09-14 | 2016-02-03 | 无锡中感微电子股份有限公司 | A kind of method of search file and device |
CN102289451A (en) * | 2011-06-17 | 2011-12-21 | 奇智软件(北京)有限公司 | Method and device for searching files or folders |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1517906A (en) * | 2003-01-14 | 2004-08-04 | 联想(北京)有限公司 | Document system and document management method |
CN1547137A (en) * | 2003-12-02 | 2004-11-17 | 中国科学院计算技术研究所 | Mass file management system and method based on database |
WO2005057343A2 (en) * | 2003-12-02 | 2005-06-23 | Interactive Content Engines, Llc | Virtual file system |
-
2005
- 2005-12-16 CN CNB2005101306458A patent/CN100444166C/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1517906A (en) * | 2003-01-14 | 2004-08-04 | 联想(北京)有限公司 | Document system and document management method |
CN1547137A (en) * | 2003-12-02 | 2004-11-17 | 中国科学院计算技术研究所 | Mass file management system and method based on database |
WO2005057343A2 (en) * | 2003-12-02 | 2005-06-23 | Interactive Content Engines, Llc | Virtual file system |
Also Published As
Publication number | Publication date |
---|---|
CN1776686A (en) | 2006-05-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7165156B1 (en) | Read-write snapshots | |
US8180956B2 (en) | Method for controlling memory card and method for controlling nonvolatile semiconductor memory | |
US8230160B2 (en) | Flash memory storage system and flash memory controller and data processing method thereof | |
US8650379B2 (en) | Data processing method for nonvolatile memory system | |
CN107391774B (en) | The rubbish recovering method of log file system based on data de-duplication | |
CN101983376B (en) | Access device, information recording device, information recording system, file management method, and program | |
US9384201B2 (en) | Method of managing data of file system using database management system | |
CN101727395A (en) | Flash memory device and management system and method thereof | |
KR20120093608A (en) | Method for managing file system in host and devices using the method | |
CN110908927A (en) | Data storage device and method for deleting name space thereof | |
CN109284252B (en) | Lightweight file system management method in communication equipment | |
CN100458736C (en) | NAND flash information extraction method and NAND flash automatic identification method | |
US20240330175A1 (en) | Storage device for classifying data based on stream class number, storage system, and operating method thereof | |
CN105528425A (en) | Method of implementing asynchronous data storage based on files in cloud computing environment | |
US8595426B2 (en) | Handling commands within a write-once read-many storage device configuration | |
CN100444166C (en) | Position-based interface access method and device for FAT file system | |
TWI715408B (en) | Flash memory controller, memory device and method for accessing flash memory module | |
CN1260546A (en) | Method and apparatus for storing and searching data in hand-held device | |
US20080033948A1 (en) | Storage apparatus and method therefor | |
CN100419760C (en) | File segmenting method and device for FAT file system | |
WO2023235040A1 (en) | File system improvements for zoned storage device operations | |
JP2008084184A (en) | Memory controller | |
CN100397399C (en) | Method and device for supporting multi-languages in FAT file system | |
CN100405330C (en) | Method and device for getting residual space for FAT file system | |
KR100479170B1 (en) | Access control device for memory and method thereof |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C17 | Cessation of patent right | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20081217 Termination date: 20111216 |