JP2020135656A - File management system - Google Patents
File management system Download PDFInfo
- Publication number
- JP2020135656A JP2020135656A JP2019030888A JP2019030888A JP2020135656A JP 2020135656 A JP2020135656 A JP 2020135656A JP 2019030888 A JP2019030888 A JP 2019030888A JP 2019030888 A JP2019030888 A JP 2019030888A JP 2020135656 A JP2020135656 A JP 2020135656A
- Authority
- JP
- Japan
- Prior art keywords
- data
- file
- management
- sector
- area
- 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.)
- Pending
Links
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本開示はデータ処理技術に関し、特にファイル管理システムに関する。 The present disclosure relates to data processing techniques, especially file management systems.
様々な機器が通信ネットワークに接続されるIoT(Internet of Things)が進展している。通信ネットワークに接続される家電製品やセンサ装置等に組み込まれるコンピュータシステム(組み込みシステムとも呼ばれる)では、マイクロコントローラ(ワンチップマイコンとも呼ばれる)が使用されることがある。 The IoT (Internet of Things), in which various devices are connected to communication networks, is progressing. A microcontroller (also called a one-chip microcomputer) may be used in a computer system (also called an embedded system) incorporated in a home appliance or a sensor device connected to a communication network.
PC等と同様に、組み込みシステムにおいても、ファイルシステムが利用できることのメリットは大きい。しかし、マイクロコントローラのメモリサイズは、大きくても数MBである。そのため、組み込みシステムにおいて従来のファイルシステムを利用することは困難であった。 As with PCs, the advantage of being able to use a file system is great in embedded systems. However, the memory size of the microcontroller is at most several MB. Therefore, it has been difficult to use a conventional file system in an embedded system.
本開示はこうした状況に鑑みてなされたものであり、1つの目的は、メモリサイズが小さいシステムに好適なファイルシステムを実現することにある。 The present disclosure has been made in view of these circumstances, and one object is to realize a file system suitable for a system having a small memory size.
上記課題を解決するために、本発明のある態様のファイル管理システムは、ファイルデータが格納されるメモリ空間であるデータ領域と、ファイルデータに関する属性情報が格納されるメモリ空間である管理領域と、を備える。データ領域は、複数のセクタに分割されており、1つのファイルデータは、連続するセクタに格納され、1つのファイルデータがデータ領域に格納される場合、管理領域には、1つのファイルデータの識別名称と、連続するセクタの先頭位置とを示す1つの属性情報が格納される。 In order to solve the above problems, the file management system of a certain aspect of the present invention includes a data area which is a memory space in which file data is stored, a management area which is a memory space in which attribute information related to file data is stored, and the like. To be equipped. The data area is divided into a plurality of sectors, one file data is stored in consecutive sectors, and when one file data is stored in the data area, the management area identifies one file data. One attribute information indicating the name and the start position of consecutive sectors is stored.
なお、以上の構成要素の任意の組合せ、本開示の表現を、装置、方法、コンピュータプログラム、コンピュータプログラムを記録した記録媒体などの間で変換したものもまた、本開示の態様として有効である。 It should be noted that any combination of the above components and the expression of the present disclosure converted between an apparatus, a method, a computer program, a recording medium on which a computer program is recorded, and the like are also effective as aspects of the present disclosure.
本開示によれば、メモリサイズが小さいシステムに好適なファイルシステムを実現することができる。 According to the present disclosure, it is possible to realize a file system suitable for a system having a small memory size.
本開示における装置または方法の主体は、コンピュータを備えている。このコンピュータがプログラムを実行することによって、本開示における装置または方法の主体の機能が実現される。コンピュータは、プログラムにしたがって動作するプロセッサを主なハードウェア構成として備える。プロセッサは、プログラムを実行することによって機能を実現することができれば、その種類は問わない。プロセッサは、半導体集積回路(IC)、またはLSI(large scale integration)を含む1つまたは複数の電子回路で構成される。ここではICやLSIと呼んでいるが、集積の度合いによって呼び方が変わり、システムLSI、VLSI(very large scale integration)もしくはUSLI(ultra large scale integration)と呼ばれるものであってもよい。LSIの製造後にプログラムされる、フィールド・プログラマブル・ゲート・アレイ(FPGA)、又はLSI内部の接合関係の再構成又はLSI内部の回路区画のセットアップができる再構成可能な論理デバイスも同じ目的で使うことができる。複数の電子回路は、1つのチップに集積されてもよいし、複数のチップに設けられてもよい。複数のチップは1つの装置に集約されていてもよいし、複数の装置に備えられていてもよい。プログラムは、コンピュータが読み取り可能なROM、光ディスク、ハードディスクドライブなどの非一時的記録媒体に記録される。プログラムは、記録媒体に予め格納されていてもよいし、インターネット等を含む広域通信網を介して記録媒体に供給されてもよい。 The subject of the device or method in the present disclosure comprises a computer. By executing the program by this computer, the function of the subject of the device or method in the present disclosure is realized. A computer has a processor that operates according to a program as a main hardware configuration. The type of processor does not matter as long as the function can be realized by executing the program. A processor is composed of one or more electronic circuits including a semiconductor integrated circuit (IC) or an LSI (large scale integration). Although they are called ICs and LSIs here, they may be called system LSIs, VLSIs (very large scale integrations) or USLIs (ultra large scale integrations), depending on the degree of integration. Field programmable gate arrays (FPGAs), which are programmed after the LSI is manufactured, or reconfigurable logic devices that can reconfigure the junction relationships inside the LSI or set up circuit partitions inside the LSI should also be used for the same purpose. Can be done. The plurality of electronic circuits may be integrated on one chip or may be provided on a plurality of chips. A plurality of chips may be integrated in one device, or may be provided in a plurality of devices. The program is recorded on a non-temporary recording medium such as a computer-readable ROM, optical disc, or hard disk drive. The program may be stored in the recording medium in advance, or may be supplied to the recording medium via a wide area communication network including the Internet or the like.
実施例の概要を説明する。組み込みシステムで使用されるCPUやSoC(System-On-a-Chip)(実施例ではマイクロコントローラ)は、ROM(Read Only Memory)およびRAM(Random Access Memory)のサイズが非常に小さい。例えば、OSにLinux(登録商標)を搭載する組み込みシステムでは、ROMおよびRAMの最低サイズがそれぞれ64MB程度となるが、マイクロコントローラにおけるROMおよびRAMのサイズは大きくても2MB程度である。 The outline of the embodiment will be described. The CPU and SoC (System-On-a-Chip) (microcontroller in the embodiment) used in the embedded system have very small ROM (Read Only Memory) and RAM (Random Access Memory) sizes. For example, in an embedded system in which Linux (registered trademark) is installed in an OS, the minimum size of ROM and RAM is about 64 MB, respectively, but the size of ROM and RAM in a microcontroller is about 2 MB at the maximum.
PC等においてROMやRAMのデータを活用する場合、ファイルシステムを使用して、ファイル単位でデータを管理することが一般的である。組み込みシステムにおいても、OSがファイルシステムの機能を提供する場合(組み込みLinux等)、ファイル単位でデータを管理することができる。しかし、リアルタイムOS等、ファイルシステムを前提としない軽量なOSを使用する場合、PC等で使用されているファイルシステムを移植するか、もしくは、ファイルシステムを使用せずにROMのデータを直に管理する必要がある。 When utilizing ROM or RAM data in a PC or the like, it is common to use a file system to manage the data in file units. Even in an embedded system, when the OS provides a file system function (embedded Linux, etc.), data can be managed in file units. However, when using a lightweight OS such as a real-time OS that does not assume a file system, either port the file system used in a PC or the like, or manage the ROM data directly without using the file system. There is a need to.
ファイルシステムの従来例としてFATファイルシステムがある。FATファイルシステムでは、種々の管理用データをユーザデータと同様にROMに配置し、また、「File Allocation Table(FAT)」と呼ばれる参照テーブルを設ける。FATは、ROMやハードディスク上で断片化したデータを1つのファイルとして管理するためのテーブルであるが、ROMの容量に応じて一定のメモリ領域を占有する。また、FATファイルシステムでは、ファイルの他にディレクトリ(フォルダとも呼ばれる)の概念もあり、フォルダもファイルと同様に管理され、一定のメモリ領域を占有する。 There is a FAT file system as a conventional example of a file system. In the FAT file system, various management data are arranged in the ROM in the same manner as the user data, and a reference table called "File Allocation Table (FAT)" is provided. The FAT is a table for managing fragmented data on the ROM or the hard disk as one file, and occupies a certain memory area according to the capacity of the ROM. Further, in the FAT file system, there is a concept of a directory (also called a folder) in addition to a file, and the folder is managed in the same manner as a file and occupies a certain memory area.
ファイルシステムの別の従来例としてJFFS2(Journaling Flash File System, version 2)がある。JFFS2は、組み込みシステムに搭載されるLinuxで使用されるファイルシステムであり、フラッシュROM等の不揮発性メモリの使用を前提に作られている。フラッシュROMは、複数のセクタにより構成され、各セクタは、フラッシュROMのデータを消去する際の消去単位である。JFFS2では、1つのセクタに複数のノード(データの塊)が記録され、1つのファイルは複数のノードにより構成される。 Another conventional example of a file system is JFFS2 (Journaling Flash File System, version 2). JFFS2 is a file system used in Linux installed in an embedded system, and is made on the assumption that a non-volatile memory such as a flash ROM is used. The flash ROM is composed of a plurality of sectors, and each sector is an erasing unit when erasing data in the flash ROM. In JFFS2, a plurality of nodes (data chunks) are recorded in one sector, and one file is composed of a plurality of nodes.
ROMおよびRAMのサイズが小さい組み込みシステムにおいてもファイルシステムが利用できることのメリットは大きい。ファイルシステムを使用することで、例えば、複数のプログラムで共通のAPI(Application Programming Interface)を利用してファイルを管理でき、また、データの追加や削除も容易になる。一方、従来のファイルシステム(上記のFATファイルシステムやJFFS2等)は、ファイルやディレクトリの管理情報によりROM領域を大量に使用するため、ROMおよびRAMのサイズが小さい組み込みシステムでは使用が困難であった。 The advantage of being able to use the file system is great even in embedded systems with small ROM and RAM sizes. By using a file system, for example, files can be managed using a common API (Application Programming Interface) in a plurality of programs, and data can be easily added or deleted. On the other hand, conventional file systems (FAT file system, JFFS2, etc.) use a large amount of ROM area due to file and directory management information, so it is difficult to use in embedded systems with small ROM and RAM sizes. ..
ROMおよびRAMのサイズが小さい組み込みシステムでは、記憶すべきデータのサイズは、大きくても数百KBと想定される。また、組み込みシステムでは、基本的には最初(例えば工場出荷時)にROMに書かれたデータがそのまま使い続けられ、データの追加や削除は稀である。また、組み込みシステムではファイルの種類も少ないため、ディレクトリや拡張子でファイルを分類する必要はない。これらを考慮し、実施例では、ROMおよびRAMのサイズが小さい組み込みシステムに好適なファイルシステムを提案する。 In embedded systems with small ROM and RAM sizes, the size of data to be stored is assumed to be at most several hundred KB. Further, in an embedded system, basically, the data written in the ROM at the beginning (for example, at the time of shipment from the factory) is continuously used as it is, and the addition or deletion of the data is rare. Also, since there are few types of files in embedded systems, there is no need to classify files by directory or extension. In consideration of these, in the embodiment, a file system suitable for an embedded system having a small size of ROM and RAM is proposed.
図1は、実施例のマイクロコントローラ10のハードウェア構成を示す。マイクロコントローラ10は、CPUコア12、ROM14、RAM16、入出力装置18を備える。CPUコア12は、各種データ処理を実行する。ROM14およびRAM16は、CPUコア12によるデータ処理において参照され、または更新されるデータを記憶する。実施例のROM14は、書き換え可能なフラッシュROMである。また、実施例のRAM16は、SDRAM(Synchronous Dynamic RAM)である。入出力装置18は、外部機器とデータを送受信する。
FIG. 1 shows the hardware configuration of the
図2は、実施例のファイル管理システム20の機能ブロックを示すブロック図である。実施例のファイル管理システム20は、図1のマイクロコントローラ10に導入され、マイクロコントローラ10においてファイル単位でデータを管理するためのファイルシステムを実現する。
FIG. 2 is a block diagram showing a functional block of the file management system 20 of the embodiment. The file management system 20 of the embodiment is introduced into the
ファイル管理システム20は、ROM14内にデータ領域22と管理領域24とを備える。データ領域22は、ファイルとして管理すべきデータであるファイルデータが格納されるメモリ空間である。データ領域22は、複数の固定長のセクタに分割されており、1つのファイルデータは、原則として連続するセクタに格納される。実施例では、各セクタのサイズは、512バイトとする。
The file management system 20 includes a
図2では、データ領域22に、5つのファイルデータ(ファイルf1〜ファイルf5)が格納されている。ROM14では、ファイルデータはセクタ単位で配置される。例えば、ファイルf1は、セクタs0の先頭アドレスからセクタs2に亘り配置される。セクタs0およびセクタs1の全領域はファイルf1のデータで埋められ、ファイルf1の残りのデータが、セクタs2の一部または全領域に配置される
In FIG. 2, five file data (files f1 to f5) are stored in the
管理領域24は、ファイルデータに関する属性情報が格納されるメモリ空間である。1つのファイルデータがデータ領域(典型的には連続する1つ以上のセクタ)に格納される場合、管理領域24には、1つの属性情報(実施例では「管理ブロック」とも呼ぶ)が格納される。以下、1つのセクタまたは複数のセクタを総称して「セクタ群」とも呼ぶ。例外として、1つのファイルデータが非連続のセクタ群に分散して格納される場合、管理領域24には、非連続のセクタ群ごとに1つの管理ブロックが格納される。
The
1つのファイルデータに対応する管理ブロックには、上記1つのファイルデータの識別名称(典型的にはファイル名)と、上記1つのファイルデータが格納された連続するセクタの先頭位置とが記録される。管理領域24には、データ領域22に格納された複数のファイルデータに対応する複数の管理ブロックを含む管理情報が格納される。
In the management block corresponding to one file data, the identification name (typically the file name) of the one file data and the start position of consecutive sectors in which the one file data is stored are recorded. .. The
図2の管理領域24には、管理ブロック26a、管理ブロック26b、管理ブロック26c(これらを総称する場合「管理ブロック26」と呼ぶ)が格納されている。管理ブロック26aは、ファイルf1に対応し、開始セクタとしてセクタs0が記録される。管理ブロック26bは、ファイルf2に対応し、開始セクタとしてセクタs3が記録される。管理ブロック26cは、ファイルf3に対応し、開始セクタとしてセクタs5が記録される。
The
図3は、管理領域24に格納される管理情報の構成を示す。管理情報は、管理ヘッダ(16バイト)と、管理されるファイル数分の管理ブロック(1つの管理ブロックのサイズは16バイト)を含む。管理ブロックにおけるデータ種別「start sector」には、ファイルデータが格納される先頭位置、実施例では、ファイルデータが格納される先頭のセクタ番号が記録される。変形例として、「start sector」には、ファイルデータが格納されるセクタの先頭位置のアドレスが記録されてもよい。
FIG. 3 shows the configuration of management information stored in the
管理ブロックにおけるデータ種別「status」には、ファイルデータの記憶に関する状態が記録され、例えば、使用中、空き、削除状態のいずれかが記録される。後述するが、「使用中」は、非連続のセクタ群に分割して格納されるファイルデータのどの部分に対応するかを示すよう細分化されてもよい。例えば、使用中(先頭)、使用中(中間)、使用中(末尾)のいずれかが記録されてもよい。 In the data type "status" in the management block, the status related to the storage of file data is recorded, and for example, one of the busy, free, and deleted status is recorded. As will be described later, "in use" may be subdivided to indicate which part of the file data is divided and stored in discontinuous sector groups. For example, one of in use (beginning), in use (intermediate), and in use (end) may be recorded.
管理ブロックにおけるデータ種別「ext info」には、ファイルデータが連続するセクタ群に格納される場合(すなわち分割なし)、または、ファイルデータが非連続のセクタ群に分散して格納され(すなわち分割あり)かつファイルデータの先頭部分である場合、ファイルデータ(の先頭部分)が格納された連続するセクタ群のセクタ数が記録される。一方、ファイルデータが非連続のセクタに分散して格納され(すなわち分割あり)かつファイルデータの先頭以外の部分である場合、「ext info」には、ファイルデータの分割態様に応じた通し番号(すなわち複数の管理ブロックの何番目に該当するかを示す番号)が記録される。 In the data type "ext info" in the management block, when the file data is stored in consecutive sector groups (that is, without division), or when the file data is distributed and stored in non-continuous sector groups (that is, with division). ) And the first part of the file data, the number of sectors of the continuous sector group in which the file data (the first part) is stored is recorded. On the other hand, when the file data is distributed and stored in non-contiguous sectors (that is, with division) and is a part other than the beginning of the file data, "ext info" contains a serial number (that is, a serial number according to the division mode of the file data). The number indicating which number of multiple management blocks corresponds to) is recorded.
管理ブロックにおけるデータ種別「size」には、ファイルデータが連続するセクタ群に格納される場合(すなわち分割なし)、または、ファイルデータが非連続のセクタ群に分散して格納され(すなわち分割あり)かつファイルデータの先頭部分である場合、ファイルデータの全体サイズが記録される。一方、ファイルデータが非連続のセクタ群に分散して格納され(すなわち分割あり)かつファイルデータの先頭以外の部分である場合、当該管理ブロックに対応するセクタ群に格納されたファイルデータのサイズが記録される。 In the data type "size" in the management block, when the file data is stored in consecutive sector groups (that is, without division), or when the file data is distributed and stored in non-continuous sector groups (that is, with division). If it is the first part of the file data, the entire size of the file data is recorded. On the other hand, when the file data is distributed and stored in non-contiguous sector groups (that is, there is division) and is a part other than the beginning of the file data, the size of the file data stored in the sector group corresponding to the management block is large. Recorded.
実施例のファイル管理システム20では、原則として、1つのファイルデータは連続するセクタ群に格納され、1つのファイルデータを管理するために必要な最低限の属性を含む1つの管理ブロックが管理領域24に格納される。これにより、ROM14およびRAM16のサイズが小さいマイクロコントローラ10であっても、ROM14のデータをファイル単位で管理可能なファイルシステムであって、かつ、ROM14およびRAM16の消費量や処理量が小さいファイルシステムを実現できる。
In the file management system 20 of the embodiment, as a general rule, one file data is stored in a continuous sector group, and one management block including the minimum attributes necessary for managing one file data is a
例えば、実施例のファイル管理システム20では、管理領域24のサイズが4KBである場合、(4096/16)−1 = 255個のファイルデータを管理可能である。
For example, in the file management system 20 of the embodiment, when the size of the
図2に戻り、ファイル管理システム20は、RAM16内にセクタマップ28を備える。セクタマップ28は、データ領域22へのファイルデータの書き込み可否を判断するためのデータであって、かつ、データ領域22の各セクタの使用状態を示すデータである。各セクタの使用状態は、使用中、空き、削除状態を含む。
Returning to FIG. 2, the file management system 20 includes a
ファイル管理システム20は、制御部30を備える。制御部30は、起動処理部31、読出部32、書込部33、管理領域更新部34、削除部35を含む。これら複数の機能ブロックに対応する複数のモジュールを含むコンピュータプログラムが記録媒体に格納され、その記録媒体を介して上記コンピュータプログラムがROM14にインストールされてもよい。または、外部装置がマイクロコントローラ10へ上記コンピュータプログラムを送信して、上記コンピュータプログラムがROM14にインストールされてもよい。マイクロコントローラ10のCPUコア12は、上記コンピュータプログラムをRAM16に読み出して実行することにより、各機能ブロックの機能を発揮してもよい。
The file management system 20 includes a
また、読出部32、書込部33、管理領域更新部34、削除部35は、ファイル管理システム20が提供するファイルシステムを利用するアプリケーションプログラムに動的または静的にリンクされるライブラリプログラムとして実装されてもよい。
Further, the
起動処理部31は、ファイル管理システム20の起動時の処理を実行する。起動処理部31は、管理領域24に格納された管理情報(すなわち複数の管理ブロックの情報)を読み出してRAM16に格納する。また、起動処理部31は、管理領域24に格納された管理情報をもとに、データ領域22の各セクタの使用状態を示すセクタマップ28をRAM16内に生成する。RAM16(実施例ではSDRAM)へのアクセス速度は、ROM14(実施例ではフラッシュROM)へのアクセス速度より高速であるため、管理領域24の管理情報と、セクタマップ28をRAM16に配置することで、ファイルデータの読み書きに要する時間を短縮することができる。
The
読出部32は、データ領域22に格納されたファイルデータの読み出しが要求された場合、ファイルデータの読み出し処理を実行する。書込部33は、データ領域22へのファイルデータの書き込みが要求された場合、ファイルデータの書き込み処理を実行する。削除部35は、データ領域22に格納されたファイルデータの削除が要求された場合、ファイルデータの削除処理を実行する。読み出し、書き込み、および削除の要求元は、典型的にはCPUコア12で実行中のアプリケーションプログラムとなる。
When the
なお、削除部35は、データ領域22に格納されたファイルデータを削除すべき場合、データ領域22に格納された当該ファイルデータを消去せず残し、すなわち、削除すべきファイルデータが格納されたセクタをイレースしない。一方、削除部35は、削除すべきファイルデータに対応する管理ブロックに、ファイルデータを削除したことを記録する。具体的には、削除部35は、削除すべきファイルデータの名称が記録された管理ブロックのstatusに「削除状態」を記録する。後述するが、書込部33は、データ領域22に新たなファイルデータを格納すべき場合、削除状態が記録された管理ブロックが示すセクタに新たなファイルデータを格納する。
When the file data stored in the
管理領域更新部34は、RAM16に格納された管理情報が更新された場合、更新前の管理情報が格納されたROM14の領域とは異なるROM14の領域に、更新後の管理情報を格納する。ROM14(実施例ではフラッシュROM)には書き換え限度回数が存在するが、管理情報の書き込み領域を分散させること(すなわちウェアレベリング)により、ROM14の使用寿命を延ばすことができる。
When the management information stored in the
図4は、管理情報のウェアレベリングを模式的に示す。管理領域更新部34は、RAM16に読み出された管理情報が更新される都度、更新された管理情報を、第1管理領域24a(セクタN)、第2管理領域24b(セクタN+1)、第3管理領域24c(セクタN+2)、第4管理領域24d(セクタN+3)の順にサイクリックに格納する。なお、管理領域更新部34は、更新後の管理情報を或るセクタ(例えばセクタN+1)に格納する際、更新前の管理情報が格納されたセクタ(例えばセクタN)をイレースする。
FIG. 4 schematically shows wear leveling of management information. Each time the management information read into the
以上の構成によるファイル管理システム20の動作を説明する。
まず、ファイル管理システム20の起動時の動作を説明する。図5は、ファイル管理システム20の起動時の動作を示すフローチャートである。起動処理部31は、複数の管理領域24の中で管理情報が格納された管理領域24から管理情報を読み出し、読み出した管理情報をRAM16に格納する(S10)。起動処理部31は、RAM16に読み出した管理情報(管理領域24の管理情報でもよい)をもとにセクタマップ28を生成してRAM16に格納する(S12)。
The operation of the file management system 20 with the above configuration will be described.
First, the operation at the time of starting the file management system 20 will be described. FIG. 5 is a flowchart showing the operation at the time of starting the file management system 20. The
次に、ファイルデータ読み込み時の動作を説明する。読出部32は、CPUコア12で実行中のコンピュータプログラムのプロセスから、ファイルデータの読み出し要求を受け付ける。このコンピュータプログラムは、ファイル管理システム20が提供するファイルシステムを利用してROM14のファイルデータを読み出す処理が実装されたコンピュータプログラムである。読み出し要求では、読み出しの対象となるファイル名が指定される。
Next, the operation at the time of reading the file data will be described. The
読出部32は、RAM16に読み出された管理情報を参照して、読み出し要求で指定されたファイル名が記録された管理ブロック26を特定し、その管理ブロック26に記録された開始セクタとサイズを特定する。読出部32は、特定したデータ領域22の開始セクタから、特定したサイズ分のファイルデータを読み出し、読み出したファイルデータを要求元のプログラムへ出力する。
The
次に、ファイルデータ書き込み時の動作を説明する。図6は、ファイルデータ書き込み時の動作を示すフローチャートである。書込部33は、CPUコア12で実行中のコンピュータプログラムのプロセスから、ファイルデータの書き込み要求を受け付ける。このコンピュータプログラムは、ファイル管理システム20が提供するファイルシステムを利用してROM14へファイルデータを書き込む処理が実装されたコンピュータプログラムである。書き込み要求では、ROM14への書き込み対象となるファイルデータについて、RAM16上でのアドレスとファイル名とが指定される。
Next, the operation at the time of writing the file data will be described. FIG. 6 is a flowchart showing an operation at the time of writing file data. The
書き込み要求を受け付けた書込部33は、RAM16に読み込まれた管理情報を参照して、今回書き込むファイルデータ用の管理ブロック(典型的には新たな管理ブロック)を格納する空きが管理領域24にあるか否かを確認する。また、書込部33は、セクタマップ28を参照して、ファイルデータを書き込み可能な空きセクタ(後述するように削除状態のセクタを含む)があるか否かを確認する。管理領域24に空きがあり(S20のY)、かつ、データ領域22に空きセクタがあれば(S22のY)、書込部33は、書き込み対象となるファイルデータを、RAM16内に設けられたセクタキャッシュに書き込む(S24)。
The
セクタキャッシュは、セクタ単位でデータを書き込むために設けられた、1つのセクタと同じサイズ(実施例では512バイト)の記憶領域である。セクタキャッシュは、ファイルデータの中の512バイト分のデータを一時的に記憶する。管理領域24に空きがなく(S20のN)、または、データ領域22に空きセクタがなければ(S22のN)、書込部33は、要求元のプログラムへエラーを返し、書き込み処理を終了する(S26)。
The sector cache is a storage area of the same size as one sector (512 bytes in the embodiment) provided for writing data in sector units. The sector cache temporarily stores 512 bytes of data in the file data. If there is no free space in the management area 24 (N in S20) or there is no free sector in the data area 22 (N in S22), the
ファイルデータにおける最後のデータまでの書き込みが未完了であり(S28のN)、セクタキャッシュに対する1セクタ分のデータの書き込みも未完了であれば(S30のN)、S24に戻り、セクタキャッシュへのファイルデータの書き込みを続ける。セクタキャッシュに対する1セクタ分のデータの書き込みが完了すると(S30のY)、書込部33は、セクタキャッシュに格納された1セクタ分のデータをデータ領域22の空きセクタに書き込む(S32)。書込部33は、ファイルデータを書き込んだ空きセクタに対応するセクタマップ28の領域に「使用中」を記録し(S34)、S24に戻る。すなわち、書込部33は、セクタキャッシュに対してファイルデータの残りを書き込む。
If the writing to the last data in the file data is incomplete (N in S28) and the writing of data for one sector to the sector cache is also incomplete (N in S30), the process returns to S24 and is sent to the sector cache. Continue writing file data. When the writing of the data for one sector to the sector cache is completed (Y in S30), the
セクタキャッシュに対してファイルデータにおける最後のデータまで書き込みが完了すると(S28のY)、書込部33は、セクタキャッシュに格納された1セクタ分のデータをデータ領域22の空きセクタに書き込む(S36)。書込部33は、ファイルデータを書き込んだ空きセクタに対応するセクタマップ28の領域に「使用中」を記録する(S38)。ここでは、ファイルデータは、データ領域22における連続するセクタ群に格納されたこととする。書込部33は、書き込んだファイルデータに対応する管理ブロックであって、ファイル名や開始セクタ等を設定した管理ブロックを1つ生成し、RAM16に読み出された管理情報に当該管理ブロックを追加する(S40)。
When writing to the last data in the file data to the sector cache is completed (Y in S28), the
さらに書込部33は、RAM16に読み出された管理情報における管理ヘッダを更新する(S42)。例えば、書込部33は、管理ヘッダにおけるファイル数をインクリメントする。管理領域更新部34は、更新後の管理情報を、更新前の管理情報が格納された管理領域(例えば第1管理領域24a)とは異なる管理領域(例えば第2管理領域24b)に格納する(S44)。
Further, the
次に、ファイルデータ削除時の動作を説明する。図7は、ファイルデータ削除時の動作を示すフローチャートである。削除部35は、CPUコア12で実行中のコンピュータプログラムのプロセスから、ファイルデータの削除要求を受け付ける。このコンピュータプログラムは、ファイル管理システム20が提供するファイルシステムを利用してROM14からファイルデータを削除する処理が実装されたコンピュータプログラムである。削除要求では、削除対象となるファイルデータのファイル名が指定される。
Next, the operation at the time of deleting the file data will be described. FIG. 7 is a flowchart showing the operation when the file data is deleted. The
削除部35は、RAM16に読み出された管理情報を参照して、削除要求で指定されたファイル名が記録された管理ブロック(ここでは「対象管理ブロック」と呼ぶ)を特定する。削除部35は、対象管理ブロックに記録された開始セクタおよびサイズをもとに、削除対象のファイルデータが格納されたデータ領域22の1つ以上のセクタを特定する。削除部35は、削除対象のファイルデータが格納された1つ以上のセクタの情報を「削除状態」とするようセクタマップ28を更新する(S50)。
The
また、削除部35は、RAM16に読み出された管理情報における対象管理ブロックの「status」を削除状態に変更する(S52)また、削除部35は、RAM16に読み出された管理情報における管理ヘッダを更新し、例えば、管理ヘッダにおけるファイル数をデクリメントする(S54)。管理領域更新部34は、更新後の管理情報を、更新前の管理情報が格納された管理領域(例えば第1管理領域24a)とは異なる管理領域(例えば第2管理領域24b)に格納する(S56)。
Further, the
図8は、ファイルデータが削除された状態を模式的に示す。データ領域22のファイルf2を削除した場合、ファイルf2に対応する管理ブロック26bには「削除状態」が記録され、かつ、セクタs3およびセクタs4に対応するセクタマップ28の領域にも「削除状態」が記録される。ここで新たなファイルf6をデータ領域22に格納する場合、実施例では、削除状態のセクタを再利用することより優先して、空きセクタの先頭(例えばセクタs11)からファイルf6を格納する。
FIG. 8 schematically shows a state in which the file data is deleted. When the file f2 in the
すなわち、書込部33は、新たなファイルデータの格納先として、削除したことが記録された管理ブロック26が示すセクタよりも空き状態のセクタを優先して選択する。これにより、データ領域22の同じセクタに対する書き換え回数を低減し、データ領域22の使用寿命を伸ばすことができる。なお、書込部33は、削除したファイルf2に対応する管理ブロック26bを、新たに追加するファイルf6用に再利用してもよい。この場合、管理ブロック26bの「status」「ext info」「size」「name」をファイルf6にあわせて変更する一方、「start sector」は変更なしで使用することができる。
That is, the
ファイル管理システム20においてファイルデータの削除を繰り返すと、データ領域22には「使用中」の領域と「削除状態」の領域が混在するようになる。空きセクタにファイルデータを書き込めなくなった場合、書込部33は、削除状態のセクタを再利用する。例えば、書込部33は、非連続のセクタ群に対して1つのファイルデータを書き込む。削除状態のセクタを有効活用することで、より多くのファイルデータをファイル管理システム20で管理可能になる。
When the file data is repeatedly deleted in the file management system 20, the "in use" area and the "deleted state" area are mixed in the
図9(a)と図9(b)は、ファイルデータを非連続のセクタ群に書き込む例を示す。データ領域22のセクタs3、セクタs4、セクタs7は使用中である。一方、データ領域22のセクタs0〜セクタs2、セクタs5、セクタs6、セクタs8以降は、削除状態である。この例において、書き込むべきファイルf7は、8セクタを占有するサイズとする。
9 (a) and 9 (b) show an example of writing file data to a non-contiguous sector group. The sectors s3, s4, and s7 of the
図9(a)に示すように、書込部33は、セクタs0〜セクタs2にファイルf7の先頭部分を格納し、セクタs5とセクタs6にファイルf7の中間部分を格納し、セクタs8〜セクタs10にファイルf7の末尾部分を格納する。書き込み先のセクタが削除状態の場合、そのセクタには削除対象のデータが消去されず残っているため、書込部33は、そのセクタに対してイレース処理を実行後、そのセクタにデータを書き込む。
As shown in FIG. 9A, the
書込部33は、非連続のセクタ群に対してファイルデータを書き込む場合、連続するセクタセクタ群ごとに1つの管理ブロック26を割り当てる。図9(a)の例では、書込部33は、管理ブロック26aと、管理ブロック26bと、管理ブロック26cを管理領域24に格納する。管理ブロック26aは、ファイルf7の先頭部分(言い換えればセクタs0〜セクタs2)に対応し、その開始セクタにはセクタs0が記録される。管理ブロック26bは、ファイルf7の中間部分(言い換えればセクタs5およびセクタs6)に対応し、その開始セクタにはセクタs5が記録される。管理ブロック26cは、ファイルf7の末尾部分(言い換えればセクタs8〜セクタs10)に対応し、その開始セクタにはセクタs8が記録される。
When writing file data to a non-contiguous sector group, the
図9(b)は、各管理ブロックに記録されるデータを示している。管理ブロック26aでは、先頭部分であることを示すフラグである「使用中(先頭)」がstatusに記録され、先頭部分のセクタ数(図9の例では「3」)がext infoに記録される。また、管理ブロック26aのsizeには、ファイルデータ全体のサイズが記録される。
FIG. 9B shows the data recorded in each management block. In the
管理ブロック26bでは、中間部分であることを示すフラグである「使用中(中間)」がstatusに記録され、通し番号(図9の例では「1」)がext infoに記録される。また、管理ブロック26bのsizeには、中間部分のセクタ数(図9の例では「2」)が記録される。ファイルf7の中間部分が格納されるセクタはその全領域がファイルf7のデータになるため、中間部分のセクタ数は、中間部分のデータサイズと実質的に同義である。
In the
管理ブロック26cでは、末尾部分であることを示すフラグである「使用中(末尾)」がstatusに記録され、通し番号(図9の例では「2」)がext infoに記録される。また、管理ブロック26cのsizeには、使用サイズが記録される。最後のセクタ(図9の例ではセクタs10)は一部領域が未使用の可能性があるため、管理ブロック26cのsizeには、セクタ数でなく、末尾部分の実際のデータサイズが記録される。
In the
図9(a)(b)で示した断片化したファイルデータの読み出し処理を説明する。読出部32は、ファイル名「test.bin」を指定した読み出し要求を受け付けると、管理領域24の管理情報(実際にはRAM16に読み出された管理情報、以下同じ。)を参照して、ファイル名に「test.bin」が記録され、かつ、statusに「使用中(先頭)」が記録された管理ブロック26aを特定する。読出部32は、管理ブロック26aの開始セクタであるセクタs0から、ext infoに記録されたセクタ数分のデータを先頭部分のデータとして読み込む。
The process of reading the fragmented file data shown in FIGS. 9A and 9B will be described. When the
次に読出部32は、管理領域24の管理情報を参照して、ファイル名に「test.bin」が記録され、かつ、通し番号「1」が記録された管理ブロック26bを特定する。読出部32は、管理ブロック26bの開始セクタであるセクタs5から、sizeに記録されたセクタ数分のデータを中間部分のデータとして読み込む。
Next, the
次に読出部32は、管理領域24の管理情報を参照して、ファイル名に「test.bin」が記録され、かつ、通し番号「2」が記録された管理ブロック26cを特定する。読出部32は、管理ブロック26cの開始セクタであるセクタs8から、sizeに記録された長さのデータを末尾部分のデータとして読み込む。読出部32は、先頭部分のデータ、中間部分のデータ、および末尾部分のデータを合成することにより要求された「test.bin」のファイルデータを生成し、そのファイルデータを要求元のプログラムに返す。
Next, the
以上、本開示を実施例をもとに説明した。この実施例は例示であり、各構成要素あるいは各処理プロセスの組合せにいろいろな変形例が可能なこと、またそうした変形例も本開示の範囲にあることは当業者に理解されるところである。 The present disclosure has been described above based on the examples. This embodiment is an example, and it will be understood by those skilled in the art that various modifications are possible for each component or combination of each processing process, and that such modifications are also within the scope of the present disclosure.
上述した実施例および変形例の任意の組み合わせもまた本開示の実施の形態として有用である。組み合わせによって生じる新たな実施の形態は、組み合わされる実施例および変形例それぞれの効果をあわせもつ。また、請求項に記載の各構成要件が果たすべき機能は、実施例および変形例において示された各構成要素の単体もしくはそれらの連携によって実現されることも当業者には理解されるところである。 Any combination of the examples and modifications described above is also useful as an embodiment of the present disclosure. The new embodiments resulting from the combination have the effects of the combined examples and the modifications. It is also understood by those skilled in the art that the functions to be fulfilled by each of the constituent elements described in the claims are realized by a single component or a cooperation thereof shown in the examples and modifications.
実施例および変形例に記載の技術は、以下の項目によって特定されてもよい。
[項目1]
ファイルデータが格納されるメモリ空間であるデータ領域(22)と、ファイルデータに関する属性情報が格納されるメモリ空間である管理領域(24)と、を備え、
前記データ領域(22)は、複数のセクタに分割されており、1つのファイルデータは、連続するセクタに格納され、
前記1つのファイルデータが前記データ領域に格納される場合、前記管理領域には、前記1つのファイルデータの識別名称と、前記連続するセクタの先頭位置とを示す1つの属性情報が格納されることを特徴とするファイル管理システム(20)。
[項目2]
複数の管理領域(24)を書き換え可能なROM(14)に備え、
第1の管理領域(24a)に格納された属性情報がRAM(16)に読み出され、当該属性情報が更新された場合、前記第1の管理領域(24a)とは異なる第2の管理領域(24b)に更新後の属性情報を格納することを特徴とする項目1に記載のファイル管理システム(20)。
[項目3]
前記管理領域(24)はROM(14)に設けられ、
本ファイル管理システム(20)の起動時に、前記管理領域(24)に格納された属性情報をもとに、前記データ領域(22)へのファイルデータの書き込み可否を判断するためのデータであって、前記データ領域(22)の各セクタの使用状態を示すデータ(28)をRAM(16)に格納する生成部(31)をさらに備えることを特徴とする項目1または2に記載のファイル管理システム(20)。
[項目4]
前記データ領域(22)に格納されたファイルデータを削除すべき場合、前記データ領域(22)に格納されたファイルデータを消去せず残し、当該ファイルデータに対応する属性情報に削除したことを記録する削除部(35)と、
前記データ領域(22)に新たなファイルデータを格納すべき場合、削除したことが記録された属性情報が示すセクタに前記新たなファイルデータを格納する書込部(33)と、
をさらに備えることを特徴とする項目1から3のいずれかに記載のファイル管理システム(20)。
[項目5]
前記書込部(33)は、前記新たなファイルデータの格納先として、削除したことが記録された属性情報が示すセクタよりも空き状態のセクタを優先して選択することを特徴とする項目4に記載のファイル管理システム(20)。
The techniques described in the examples and modifications may be specified by the following items.
[Item 1]
A data area (22), which is a memory space for storing file data, and a management area (24), which is a memory space for storing attribute information related to file data, are provided.
The data area (22) is divided into a plurality of sectors, and one file data is stored in consecutive sectors.
When the one file data is stored in the data area, one attribute information indicating the identification name of the one file data and the head position of the continuous sector is stored in the management area. A file management system (20) characterized by.
[Item 2]
A plurality of management areas (24) are provided in a rewritable ROM (14).
When the attribute information stored in the first management area (24a) is read into the RAM (16) and the attribute information is updated, a second management area different from the first management area (24a) is used. The file management system (20) according to
[Item 3]
The management area (24) is provided in the ROM (14).
This data is used to determine whether or not file data can be written to the data area (22) based on the attribute information stored in the management area (24) when the file management system (20) is started. The file management system according to
[Item 4]
When the file data stored in the data area (22) should be deleted, the file data stored in the data area (22) is left unerased and the deletion is recorded in the attribute information corresponding to the file data. Delete part (35) and
When new file data should be stored in the data area (22), a writing unit (33) that stores the new file data in the sector indicated by the attribute information in which the deletion is recorded, and
The file management system (20) according to any one of
[Item 5]
10 マイクロコントローラ、 14 ROM、 16 RAM、 20 ファイル管理システム、 22 データ領域、 24 管理領域、 31 起動処理部、 33 書込部、 34 管理領域更新部、 35 削除部。 10 Microcontroller, 14 ROM, 16 RAM, 20 File management system, 22 Data area, 24 Management area, 31 Startup processing unit, 33 Writing unit, 34 Management area update unit, 35 Delete unit.
Claims (5)
前記データ領域は、複数のセクタに分割されており、1つのファイルデータは、連続するセクタに格納され、
前記1つのファイルデータが前記データ領域に格納される場合、前記管理領域には、前記1つのファイルデータの識別名称と、前記連続するセクタの先頭位置とを示す1つの属性情報が格納されることを特徴とするファイル管理システム。 It has a data area that is a memory space for storing file data and a management area that is a memory space for storing attribute information related to file data.
The data area is divided into a plurality of sectors, and one file data is stored in consecutive sectors.
When the one file data is stored in the data area, one attribute information indicating the identification name of the one file data and the head position of the continuous sector is stored in the management area. A file management system featuring.
第1の管理領域に格納された属性情報がRAMに読み出され、当該属性情報が更新された場合、前記第1の管理領域とは異なる第2の管理領域に更新後の属性情報を格納することを特徴とする請求項1に記載のファイル管理システム。 With a rewritable ROM for multiple management areas
When the attribute information stored in the first management area is read into the RAM and the attribute information is updated, the updated attribute information is stored in a second management area different from the first management area. The file management system according to claim 1, wherein the file management system is characterized in that.
本ファイル管理システムの起動時に、前記管理領域に格納された属性情報をもとに、前記データ領域へのファイルデータの書き込み可否を判断するためのデータであって、前記データ領域の各セクタの使用状態を示すデータをRAMに格納する生成部をさらに備えることを特徴とする請求項1または2に記載のファイル管理システム。 The management area is provided in ROM.
Data for determining whether or not file data can be written to the data area based on the attribute information stored in the management area when the file management system is started, and the use of each sector of the data area. The file management system according to claim 1 or 2, further comprising a generation unit that stores data indicating a state in a RAM.
前記データ領域に新たなファイルデータを格納すべき場合、削除したことが記録された属性情報が示すセクタに前記新たなファイルデータを格納する書込部と、
をさらに備えることを特徴とする請求項1から3のいずれかに記載のファイル管理システム。 When the file data stored in the data area should be deleted, a deletion unit that records that the file data stored in the data area is deleted without being deleted and deleted in the attribute information corresponding to the file data, and a deletion unit.
When new file data should be stored in the data area, a writing unit that stores the new file data in the sector indicated by the attribute information in which the deletion is recorded, and a writing unit.
The file management system according to any one of claims 1 to 3, further comprising.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019030888A JP2020135656A (en) | 2019-02-22 | 2019-02-22 | File management system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2019030888A JP2020135656A (en) | 2019-02-22 | 2019-02-22 | File management system |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2020135656A true JP2020135656A (en) | 2020-08-31 |
Family
ID=72263297
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2019030888A Pending JP2020135656A (en) | 2019-02-22 | 2019-02-22 | File management system |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2020135656A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115826884A (en) * | 2023-02-16 | 2023-03-21 | 湖南源科创新科技有限公司 | Lightweight high-speed file system facing embedded heterogeneous platform and processing method thereof |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2000076117A (en) * | 1998-08-31 | 2000-03-14 | Kano Densan Hongkong Yugenkoshi | Electronic device, control method therefor and storage medium |
JP2008251154A (en) * | 2008-04-11 | 2008-10-16 | Renesas Technology Corp | Nonvolatile semiconductor memory device |
JP2009037630A (en) * | 1991-11-28 | 2009-02-19 | Hitachi Ltd | Information apparatus equipped with flash memory |
JP2017097404A (en) * | 2015-11-18 | 2017-06-01 | 株式会社デンソー | Microcomputer |
-
2019
- 2019-02-22 JP JP2019030888A patent/JP2020135656A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009037630A (en) * | 1991-11-28 | 2009-02-19 | Hitachi Ltd | Information apparatus equipped with flash memory |
JP2000076117A (en) * | 1998-08-31 | 2000-03-14 | Kano Densan Hongkong Yugenkoshi | Electronic device, control method therefor and storage medium |
JP2008251154A (en) * | 2008-04-11 | 2008-10-16 | Renesas Technology Corp | Nonvolatile semiconductor memory device |
JP2017097404A (en) * | 2015-11-18 | 2017-06-01 | 株式会社デンソー | Microcomputer |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115826884A (en) * | 2023-02-16 | 2023-03-21 | 湖南源科创新科技有限公司 | Lightweight high-speed file system facing embedded heterogeneous platform and processing method thereof |
CN115826884B (en) * | 2023-02-16 | 2023-04-18 | 湖南源科创新科技有限公司 | Lightweight high-speed file system facing embedded heterogeneous platform and processing method thereof |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11573701B2 (en) | Memory device and host device | |
TWI661301B (en) | Memory system and control method for controlling non-volatile memory | |
CN110678836B (en) | Persistent memory for key value storage | |
CN109144887B (en) | Memory system and control method for controlling nonvolatile memory | |
US10635310B2 (en) | Storage device that compresses data received from a host before writing therein | |
CN111344683A (en) | Namespace allocation in non-volatile memory devices | |
KR100951107B1 (en) | Method for managing files for optimal performance | |
US9678676B2 (en) | Method for storage devices to achieve low write amplification with low over provision | |
KR100849221B1 (en) | Method for managing non-volatile memory, and memory-based apparatus including the non-volatile memory | |
WO2017000658A1 (en) | Storage system, storage management device, storage device, hybrid storage device, and storage management method | |
US20200012598A1 (en) | Garbage Collection Method for Storage Medium, Storage Medium, and Program Product | |
JP6403164B2 (en) | Memory system | |
CN108959119B (en) | Method and system for garbage collection in storage system | |
JP2018073040A (en) | Memory system | |
US10976946B2 (en) | Method and computer system for managing blocks | |
WO2016038765A1 (en) | Memory device and method for controlling memory device | |
JP2020135656A (en) | File management system | |
JP2010182160A (en) | Memory access device, nonvolatile storage device, nonvolatile storage system, memory access method, program and integrated circuit | |
JP6329185B2 (en) | Memory control circuit, memory control system, memory control method, and memory control program | |
JP6652605B2 (en) | Memory system control method | |
JP2010257250A (en) | Electronic device, storage area allocation method for file system, and storage area allocation program | |
US9904483B2 (en) | File management device, program and file management method | |
JP2011118953A (en) | Device, method and program for recording information | |
JP2010039676A (en) | Data management method | |
JP2012068853A (en) | Information processing apparatus and information processing method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20211214 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20221018 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20221122 |
|
A02 | Decision of refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A02 Effective date: 20230516 |