Understanding the file system architecture in Windows CE. net

Source: Internet
Author: User
Tags driver manager
Release date: 7/19/2004 | update date: 7/19/2004

Mike hall
Microsoft Corporation

Steve Maillet
Entelechy Consulting

Abstract:In this month's article, we will introduce the Windows CE. Net file system and its components and how to expand the file system.

If you regularly read Microsoft newsgroups for Microsoft Windows CE. net, you will find a group of duplicate issues related to file systems, especially those related to the Configuration unit-based registry. (If you are not a regular reader of this newsgroup, you will miss a lot of useful information !) In this month's article, we will discuss in depth the details of different parts of the system involved in implementing these features. We will first introduce the file system architecture in Windows CE. net, because it is the basis of the other functions we discuss. In the subsequent articles, we will examine the OSS and how the system registry works.

Windows CE. Net file system is a flexible modular design that allows you to customize file systems, filters, and a variety of block device types. The file system and all file-related APIs are managed through the filesys.exe process. This module implements the Object Storage and Storage Manager (we will discuss the object storage), and unify all file systems into a single system under the root. In Windows CE. net, all files and file systems are stored in a single namespace starting with "/" as the root. All files are identified by a unique path starting from the root in the hierarchy tree. This is similar to Windows on a desktop computer, but it does not have a drive letter. In Windows CE, the drive is loaded under the root as a folder. Therefore, the new memory card added to the system is mounted to the root of the tree, and its path is similar to "/storage card ".

Filesys.exe consists of the following components:

  • Rom File System

  • Storage Manager

  • Object Storage Service

OSS is a memory heap controlled by filesys.exe. OSS includes the ram system registry, ram file system, and attribute database. They are all optional components of the filesys.exe module. The ram file system and attribute database are completely optional and may not exist in some systems at all. For each Windows CE device, a registry that exists in some form is required. Until Windows CE version 4.0, it always resides in Oss. Windows CE. Net can be used as a file in a file system (such as a disk) mounted externally. Later, we will learn how the registry and the file system are connected.

A ram-based file system is usually connected to the root of the Unified File System presented to the application. That is to say, the file "/myfile.txt" is located in the root of the unified system and the root of the ram file system. The ROM file system is connected to the "/Windows" folder in the Unified File System. This means that All Files can be accessed as read-only files in the/Windows folder.

Storage Manager is a new function of Windows CE. net. As shown in the name, it manages the storage devices in the system and the file systems used to access them. The Storage Manager processes four main projects:

  • Storage driver.They are device drivers for physical storage media. They are sometimes called block drivers because they provide access to random addressing blocks for data storage.

  • Partition driver.They manage multiple partitions on a single storage device. Windows CE. Net allows a physical disk to contain multiple partitions, and each partition can be formatted as a different file system. The partition driver is actually a converter that stores the driver. It exposes the same interface as the storage driver and converts the block address of the partition into the real address of the storage device block. It then passes the call to the storage driver.

  • File System driver.These drivers organize the data on the storage device into files and folders. Windows CE. Net comes with several different systems, including udfs for CD and DVD, and fatfs (including FAT32 support ). In version 4.2, there is a new system called transaction security FAT file system (tfat ). (We may discuss it in future articles. Similarly, if you are interested in it, please let us know .)

  • File System filter.The file system filter is used to process calls to the file system. After that, the file system can obtain these calls. This allows special processing of file access for data encryption, compression, and monitoring using statistical data.

As the saying goes, the relationship between various components of the file system is illustrated.

Figure 1. Windows CE File System Overview

One important thing to note about this structure is that the file system filter works under the Storage Manager and cannot be applied to the ROM file system or RAM File System in Oss. Microsoft does not provide a mechanism to filter access to these systems. Therefore, in this article, we will focus on the content on the right. To make it clearer, You can enlarge the area.

Figure 2. Storage Manager and related components

We can see that not all file system drivers use physical devices. Even if they are used, partition drivers may not be used. This provides great flexibility. For example, the Network redirector responsible for providing shared network access uses WinSock to communicate with remote servers over the network, and it does not have a physical disk on a Windows CE device.

Now that we can see what most projects are and how they are associated, we will discuss how the system loads all items. When the operating system starts, nk.exe will directly load filesys.exe from the ROM file system. Then, filesys.exe initializes the registry from the default registry in the ROM file system. (Here, when using the Configuration unit registry, there is a problem like "first chicken or first egg", because the Registry is in a file on the disk, and the file system has not been mounted yet. In subsequent articles, we will introduce how the operating system solves this problem when introducing the Configuration unit registry .)

Then, filesys.exe reads the registry key to start various applications. First, an application listed in the registry is usually device.exe, that is, the Device Manager. The Device Manager loads the driver from the HKEY_LOCAL_MACHINE/driver/builtin entry. Under normal circumstances, any built-in disk devices (such as hard disks) are listed under this item, so the block driver will be loaded. The block driver advertises a specific device Class Identifier block_driver_guid {A4E7EDDA-E575-4252-9D6B-4195D48BB865 }.

The Storage Manager built in filesys.exe notifies the Device Manager of system registration to receive notifications about loading and uninstalling block drivers. Then, the storage manager opens the block driver and queries it for the name of the configuration file. Each block device type has a configuration file related to it. Profile is a registry key used to specify the partition driver and default file system for a specific type of devices. (We will give a brief introduction to the details of the registry key in the configuration file .)

The Storage Manager reads information about the device's partition driver and loads the appropriate driver. (Microsoft provides a partition driver called "mspar" for standard hard disk partitioning through the partition table in the disk's primary Boot Record. Of course, if you need it, you can create your own partition or not use it at all .)

Once the partition driver has been loaded, the storage manager will request the partition driver to enumerate the partitions on the disk and identify the file system on each partition. The partition driver reads information about the partition and file system from the master startup record (MBR) and provides information to the storage manager. Then, the Storage Manager uses this information to load the file system driver for each partition and load the file system to the root of the Unified File System. Although this seems to have many steps, it allows flexible support for network redirector fatfs and DVD Rom in the same framework.

After learning how filesys.exe loads various components, we will introduce the role of the file system driver and file system driver Manager (fsdmgr) in more detail. Fsdmgr is part of the Storage Manager (which is part of the Device Manager in earlier versions of the operating system) and is responsible for providing services to the file system driver. Because the file system does not need to know whether the data is from the partition on the disk or directly from the disk, fsdmgr encapsulates the file system driver, to provide interfaces for high-end or low-end drivers. Describes how this works.

Figure 3. Storage Manager

The storage manager calls the file system driver (FSD), while FSD uses the fsdmgr _ API to retrieve data from the device. If it is Cd (no partition), the device communicates with the block driver through fsdmgr. If it is a hard disk with multiple partitions, it uses the fsdmgr _ API in the same way. However, after that, fsdmgr will forward the work to the appropriate partition driver.

We have discussed how the Storage Manager, fsdmgr, FSD, partition drivers, and block drivers interact and interoperate. Let's go back and discuss in detail how they are loaded and examine the configuration file details in the registry. As mentioned above, the configuration file is only a set of registry values used to define information about Block devices and how they should be used in the system. The configuration file is located under the following items: HKEY_LOCAL_MACHINE/system/storagemanager/profiles

Each configuration file is located under the basic configuration file and identified by the configuration file name. For example, if a hard disk exists on a Windows CE. Net device and does use a hard disk configuration file, the configuration file is located in

HKEY_LOCAL_MACHINE/system/storagemanager/profiles/hard disk. All configuration file information is included in the name values under the configuration file. The following table lists the values and their objectives.

Table 1.Configuration File registry key

Value

Type

Description

Folder

REG_SZ

The folder name displayed to the user in Windows Resource Manager. An integer is automatically appended to multiple instances. (Such as storage card and storage card2 .)

Filesystem

REG_SZ

Used as the name of the default file system of the disk. (If a partition driver is used, it is usually not used .)

Partitiondriver

REG_SZ

List the partition drivers to be used when the default driver is not appropriate. If this string is null, no partition driver is loaded. If this value does not appear, use the default partition driver.

AutoFormat

REG_DWORD

If the disk is not formatted, the disk is automatically formatted.

Autopart

REG_DWORD

If the disk is not partitioned, it is automatically partitioned, and one of the partitions occupies the maximum available disk space.

Automount

REG_DWORD

When the driver of the storage device is loaded, the file system is automatically loaded.

Name

REG_SZ

The name of the configuration file displayed in the control panel UI.

Mountflags

REG_DWORD

The identifier used to determine how to mount the file system. (For more information, see the following table .)

Pay special attention to the mountflags value. It is the bitmask of values in the following table.

Table 2. mountflagsRegistry entry flag

Flag

Description

1

Hide the file system.

2

It can contain the Configuration unit registry.

4

Load as the root ("/") of the file system.

8

Hide the ROM file system. (Used only with [4 .)

Marking the file system as hidden can prevent it from being discovered by any standard file and folder enumeration. (For exampleFindfirstfileAnd so on .) The Storage Manager completes this operation independently so that device drivers and applications can detect whether a specific system is using the Storage Manager. (Because older versions of the operating system do not have it, some drivers may need to be compatible with the old loadfsd (Ex) mechanism to load the file system .) Though not availableFindfirstfileTo enumerate any hidden system, but if you know the name of the file system, you can use it wherever the file path is used. The following example shows how to check whether the Storage Manager is using a system.

BOOL IsStorageManagerRunning(){    DWORD attr = GetFileAttributes( _T("//StoreMgr") );    if( (attr != -1) && (attr & FILE_ATTRIBUTE_TEMPORARY) )        return TRUE;    return FALSE;}

The next position of mountflags indicates whether the file system can contain a Configuration unit-based registry. This enables filesys.exe to manage the previously mentioned "first chicken or first egg" problem. (Because the registry is required to load components that may be used to access the Registry on the disk to configure a single-element file ......) We will introduce how to use this bit in subsequent articles on the Configuration unit registry.

The last two are related. You need to use the external file system as the root of the Unified File System. We can recall that the root of a unified system is a ram file system. This is effective for battery-powered handheld devices, but does not work for devices that sometimes turn off the AC power, because Ram content is lost every time it is turned off. As the root flag, the mount file system allows you to avoid this problem by using external storage as the root, because in this way, the file/mydatafile. TXT will reside in the root of the external storage device. Hiding the ROM file system hides the ROM file system data files (but does not execute the appropriate EXE and DLL) so that you can update all files in the Rom. This allows you to use very small operating system images in flash memory, and place most executable files on disks and load them only when needed. (It is very similar to a desktop computer system .)

If no value exists in the specified configuration file, the Storage Manager uses the default value in the HKEY_LOCAL_MACHINE/system/storagemanager/profiles item. The default value that can be rewritten is located in common. Reg. You should use your platform. Reg or project. Reg for rewriting. (Remember, do not change common. Reg !) The following table shows the default values in common. Reg.

Value

Default Value

Folder

Loc_store_default_folder (the identifier of a string in the. Str file of the device; it is usually "storage card" in the English internal version ".)

Filesystem

Fatfs

Partitiondriver

Mspart. dll

AutoFormat

0

Autopart

0

Automount

1

Mountflags

0

Summary

The Windows CE file system architecture is flexible and scalable and supports:

  • Multiple Block devices.

  • Each block device supports multiple partitions.

  • Each partition supports different file systems.

  • Mount the file system of the external device as the root system.

The Registry is the key to making the process of loading and running the file system correct (or expected) behavior. The Configuration unit-based registry does help us. To prevent you from having fear of "loading", we will use some real examples in subsequent articles to examine the Configuration unit registry in detail. But now, we will end this month's discussion.

Understanding EmbeddedPerson

Mike hallIs the product manager of Microsoft Embedded and appliance platform group (EAPG. Mike has been working on Windows CE since 1996. He has participated in Developer support, embedded system engineering, and embedded product groups. In addition to work, Mike enjoys spending time with his family, playing with gadgets, or riding on the Honda st1100 for a ride.

Steve MailletHe is the founder and senior consultant of entelechy consulting. Since the advent of CE in 1997, Steve has been providing training and developing Windows CE solutions for customers. Steve is an enthusiastic participant in the Microsoft Windows CE Development News group. Steve liked nearby skydiving when he was not playing with the computer.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.