GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing livinginharmony.substack.com — HarmonyOS Distributed File System Development Guide HarmonyOS Distributed File System Development GuideOverview of distributed file systemsThe HarmonyOS Distributed File System (hmdfs) provides cross-device file access and is suitable for the following scenarios: ● Two devices are networked, users can use the editing software on one device to edit documents on the other device. Living In Harmony is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber. Based on the dynamic networking of distributed soft bus, HMDFS provides a global and consistent access view for each device node on the network, and supports developers to read and write through the basic file system interface, which has the advantages of high performance and low latency. Distributed file system architecture● distributedfile_daemon: Mainly responsible for device online monitoring, establishing links through soft buses, and implementing different data flow policies according to the distributed device security level. ● HMDFS: Implement the network file system in the kernel, including cache management, file access, metadata management, and conflict management. ○ Cache management ■ hmdfs ensures the consistency of Close-to-Open, that is, after one end writes closes, the other end can read the latest data, and does not ensure the real-time consistency of file content. ■ If the data is written to the remote end but is not flashed back in time due to network reasons, the file system will flash back to the local area the next time the network is connected, but if the remote end has been modified, it cannot be flashed back. ○ File access ■ The file access interface is the same as that of the local one (ohos.file.fs). ■ If the file is local, stack access to the local file system. ■ If the file is on another device, the network will be synchronized to access the file of the remote device. illustrate symlink: Not supported. ○ Metadata management ○ Conflict handling ■ Local and remote conflicts, the remote file is renamed, the file with the same name is the local file with the same name, and the remote file is renamed. ■ If multiple devices conflict at the remote end, files with the same name with small device IDs will be displayed in the order of accessing the device ID, and other files will be renamed in turn. ■ If there is already a remote file in the directory tree, create a file with the same name to indicate that the file already exists. ■ The ID is added after the _conflict_dev of the conflicting file is displayed, and the ID is automatically incremented from 1. ■ There is no conflict between directories with the same name, files and remote directories have the same name, and the suffix of the remote directory is _remote_directory. Set the distributed file data levelThe security capabilities of different devices vary greatly, and the security capabilities of some small embedded devices are much weaker than those of device types such as tablets. Different files and applications have different security requirements, such as personal health information and bank card information, which are not expected to be read by weak devices. Therefore, HarmonyOS provides a complete set of data classification and device classification standards, and formulates different data transfer policies for different devices. API descriptionFor more information about the API, see ohos.file.securityLabel. Table 1 Setting the file data level The name of the interfacefunctionInterface typeSynchronization is supportedAsynchronous support is supportedsetSecurityLabelSet up file security labelsmethod√√getSecurityLabelGet a file security labelmethod√√ note
Development examplesObtain the common file sandbox path and set the data level label. For details about how to obtain the context in this example, see Obtaining the Context of UIAbility. Cross-device file accessWhen installing the same application on multiple devices, developers can read and write files under the distributed file path (/data/storage/el2/distributedfiles/) of other devices through the basic file interface. For example, in the scenario of multi-device data transfer, after the device is networked and interconnected, the application on device A can access the files under the distributed path of device B and the application. Development steps
On device A, create a test file in the distributed path and write the content. For details on how to obtain the context in this example, see UIAbility. The test file is read under a distributed path on device B. In order to allow you to better learn Harmony OS development technology, here is a special compilation of the "Harmony OS Development Study Manual" (a total of 890 pages), I hope it will be helpful to you: Harmony OS Development WorkbookA must-see for getting started:
HarmonyOS Concept:
How to get started quickly:
Development Basics:
Based on ArkTS:
Living In Harmony is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |