CN1776686A - 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 PDF

Info

Publication number
CN1776686A
CN1776686A CN 200510130645 CN200510130645A CN1776686A CN 1776686 A CN1776686 A CN 1776686A CN 200510130645 CN200510130645 CN 200510130645 CN 200510130645 A CN200510130645 A CN 200510130645A CN 1776686 A CN1776686 A CN 1776686A
Authority
CN
China
Prior art keywords
file
directory
sub
location information
file system
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.)
Granted
Application number
CN 200510130645
Other languages
Chinese (zh)
Other versions
CN100444166C (en
Inventor
孙丰强
赵原
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vimicro Corp
Original Assignee
Vimicro Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Vimicro Corp filed Critical Vimicro Corp
Priority to CNB2005101306458A priority Critical patent/CN100444166C/en
Publication of CN1776686A publication Critical patent/CN1776686A/en
Application granted granted Critical
Publication of CN100444166C publication Critical patent/CN100444166C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

First, the method sets up a structure for file in use for storing address information of file. Then, a module for parsing address is setup. All operations of file system on a file are passing through the module in order to guarantee that using information of file address operates files directly. The method saves lot of searching time and raises efficiency for browsing file. The invention is suitable for developing embedded system especially.

Description

Location-based interface access method and device thereof in the FAT file system
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, the relevant parameters 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 all have clear and definite restriction to the progression of sub level catalogue.
(2) the search file time is long.Because file system adopts successively catalogue to resolve and seeks file, 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; Carry out location resolution operation, 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; These address location information stores are in register; When needs are opened sub-directory or file, from register, read the address location information of file.
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 fileinfo 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, directly read the address location information of file by the location resolution module, 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 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 be described 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, as long as directly call the file POS information of application layer storage, that is to say that direct address information with file just can point to file.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, adopted 2 buffer (register) in the present embodiment, 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, this structure is used for memory address locations information; Carry out location resolution operation, 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; These address location information stores are in register; When needs are opened sub-directory or file, from register, read the address location information of file.
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, directly read the address location information of file by the location resolution module, 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.
CNB2005101306458A 2005-12-16 2005-12-16 Position-based interface access method and device for FAT file system Expired - Fee Related CN100444166C (en)

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 true CN1776686A (en) 2006-05-24
CN100444166C 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102402543A (en) * 2010-09-14 2012-04-04 无锡中星微电子有限公司 File searching method and device
WO2012171434A1 (en) * 2011-06-17 2012-12-20 北京奇虎科技有限公司 Method and device for finding files or folders

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7644136B2 (en) * 2001-11-28 2010-01-05 Interactive Content Engines, Llc. Virtual file system
CN100504854C (en) * 2003-01-14 2009-06-24 联想(北京)有限公司 Document management method
CN100498766C (en) * 2003-12-02 2009-06-10 天津曙光计算机产业有限公司 Mass file management system and method based on database

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102402543A (en) * 2010-09-14 2012-04-04 无锡中星微电子有限公司 File searching method and device
CN102402543B (en) * 2010-09-14 2016-02-03 无锡中感微电子股份有限公司 A kind of method of search file and device
WO2012171434A1 (en) * 2011-06-17 2012-12-20 北京奇虎科技有限公司 Method and device for finding files or folders

Also Published As

Publication number Publication date
CN100444166C (en) 2008-12-17

Similar Documents

Publication Publication Date Title
CN108073363B (en) Data storage method, storage device and computer readable storage medium
CN109697016B (en) Method and apparatus for improving storage performance of containers
US8825942B2 (en) Apparatus and method of rearranging data and nonvolatile data storage apparatus
CN1313941C (en) Method for data exchange between data handling equipment and operating system
US10216418B2 (en) Storage apparatus and method for autonomous space compaction
US20140095556A1 (en) Computing system, host system and method for managing data
US11042328B2 (en) Storage apparatus and method for autonomous space compaction
KR101055324B1 (en) Enhanced Host Interface
US20240143219A1 (en) Software-hardware combination method for internal mapping address query of zoned namespace
CN101051317A (en) FAT file system and its processing method
US20170160940A1 (en) Data processing method and apparatus of solid state disk
CN1896960A (en) Fast photographic system and method
US20060036663A1 (en) Method and apparatus for effective data management of files
CN1687899A (en) Method, system and module for dynamic downloading of applied programe to user identification
CN101056338A (en) Method for providing personalized information lifecycle management service using policy-based autonomic data management
JP2008503818A (en) Method for improving the performance of a file system in a computer device
KR101123335B1 (en) Method and apparatus for configuring hash index, and apparatus for storing data having the said apparatus, and the recording media storing the program performing the said method
CN1908937A (en) FLASH document management method and system in FLASH memory
CN1889189A (en) Partition-supporting flash storing memory device
CN1260546A (en) Method and apparatus for storing and searching data in hand-held device
TWI715408B (en) Flash memory controller, memory device and method for accessing flash memory module
CN1776686A (en) Position-based interface access method and device for FAT file system
CN116414304B (en) Data storage device and storage control method based on log structured merging tree
CN111930684A (en) Small file processing method, device and equipment based on HDFS (Hadoop distributed File System) and storage medium
CN1975935A (en) External storing performance testing method and apparatus

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