Virtual file system--A better File abstraction layer

Source: Internet
Author: User
Tags abstract apache php new set
virtual File System--A better file abstraction layer

Any software design challenge can be solved by adding an abstraction layer
--Preface

In our system development, often encountered some difficult things, for example, a Linux server, from the source installed a set of Apache+php+mysql, and then another administrator found that one of the PHP project PHP version is not enough, compiled and installed a new set of PHP, Then the Apache PHP configuration chain comes up. But the PHP configuration to modify, it is very troublesome.

Also, like Linux compiled installation software, if installed, the project deleted, and then want to remove the installed files is very difficult.

There is no very good way to make the software does not produce junk files, the reason is probably the operating system of the file system management is not very advanced, we designed a set of virtual file system to solve many problems in the operating system. overall design of virtual file system

The virtual file system is relative to the real file system, the virtual file system is not the disk file organization format, but the abstract file tree collection. For example, under Windows, the real file system might be:

C: \
C:\program files\
C:\windows\
C:\users\
...

But the virtual file system, more like the concept of a library in Windows, is a collection of folders, and you can dynamically add or remove the corresponding directory to it through the API.
The directory structure of the virtual file system is modeled after Linux, and is differentiated by function, not by physical structure.
For example:

/os/                    # corresponds to C:\windows
/software/              # corresponding to C:\program files\, D:\program files\/software/office/10/    # corresponding C:\program Files\office10

Such a structure, on various systems, can exist the same abstract structure, so that we develop cross-platform programs, no longer need to consider the problem of file system structure. the benefits of this design

First, the software is easy to move, in the case of the real directory structure, the software may be referenced by other software, then want to move the software, it is very difficult, but in the virtual file system, because of a layer of mapping, can be very convenient to modify the mapping path. If your C drive is full, simply copy a portion of the file to D, re-specify the path mapping, and no further action is required.

The second is the ability to integrate environment variables.
Environment variables under Linux are not very critical because, under the filesystem, almost every software has a fixed installation location, so it is sometimes possible to reduce the environment variable designation. And through the virtual file system, for each software allocation of independent path rules can be, without the use of environment variables can easily find the corresponding software. Cross-platform design

The virtual file system, which encapsulates the underlying file system, can actually be designed across platforms, abstracting a common set of cross-platform file path patterns and providing a common interface for underlying file processing.

Including path conversion work, under different platforms, should be converted to a different path format.

The design idea can refer to Qt's cross-platform file system design. file directory mapping settings

Provides a virtual directory browser for viewing,
Provides an interface for editing, you can add any real directory, real files to any virtual directory. You can also move some of the content from a directory.
You can also traverse the entire virtual directory and automatically remove the nonexistent real directories and files.

Under the Virtual directory Viewer, you can also view the real directory and automatically modify the link to the virtual directory when you move the real directory. compatibility of virtual directories and real directory patterns

After adding the virtual directory, a series of problems occurred, first, the software works to access the file directory is the real directory, or virtual directory.
The answer is to see which interface you use, software access to the file system, must be through the programming interface, if you use the system's underlying programming interface, then it is natural to use the real directory, if you use the new dynamic library for file system access, then access to the virtual directory.
In general, we recommend the use of virtual path access, so that even if the software is moved, then the virtual directory can still be redirected.

The second problem is the current directory and the console, the current directory of our software work can be a virtual directory.
I think the answer is no, there is no need, the current directory is generally the role of some tool software, in order to determine the location of the current work path, so as to facilitate the search for the file to be operated. And the role of the virtual directory is often to allow the software to know the location of other software in the system, in order to be able to use the virtual directory under the console, then we need a virtual directory console, but I personally do not think this design is meaningful, because the console is the same, no need to run in the virtual directory. virtual file system and Registry

In fact, the Windows Registry has a subset of the virtual directory features, placement profiles, set path parameters, and so on, almost a Windows program configuration file collection.
But I personally hate the design of the registry, because he has a key problem is that the user is difficult to manually browse and configure the relevant system information, that is, his level of abstraction is too low, and the design of the registry, more like a large configuration file library, who can put, and delete the relevant configuration information, and difficult, If the registry has a table entry residue, it is likely to cause a software installation failure.

I do not want the virtual file system to have configuration parameters, I just want it as an abstract file system, to provide users with access control, rights Management, directory Mapping, directory movement, automatic Invalid directory deletion and other operations. Requirements of its robust, simple, so that users can easily control through the GUI. Multi-User Switching of virtual files

Although we now a computer is often only one user, but after all, the concept of user group is very important to the computer, after all, a software for different users to provide different configurations, is really very convenient. Now, these are put in the user's folder, not good management, uninstall and difficult to delete. If you enable the virtual file system, it is convenient, we can set up two parts of the virtual file configuration, part of the system global path configuration for all users are valid, part of the user's unique configuration, only valid for the current user, then when the user switches, we can switch the corresponding virtual file configuration. The virtual file path for different users has not changed, but the content has changed. Summary

The design of virtual file system is based on the difficulty of configuration and software management in the current operating system, which is equivalent to adding a part of abstraction layer to the traditional file system. Since there is little desktop software that does not rely on file systems, it is difficult to promote this virtual file system. However, I hope that by establishing a package manager that conforms to this design, and then promoting this package format, we will gradually let you know the advantages of the virtual file system, and gradually reduce the misuse of the traditional file system, thus eventually forming, only the specific root software can read and write the entire path, and the presence of any path written by the root user, other default path reads are accessed through a flexible virtual path.

This article is purely an individual design view of the operating system, there may be many local considerations, if there are other suggestions, welcome criticism and discussion.

This article belongs to the West Wind getaway original, reproduced please indicate the source: West Wind World http://blog.csdn.net/xfxyy_sxfancy

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.