This topic describes how ossfs 2.0 accurately detects objects and directories in an Object Storage Service (OSS) bucket.
Core differences between OSS and traditional file systems
OSS uses a flat storage structure to store data, while traditional file systems use a hierarchical structure to store data. OSS has the following core differences from traditional file systems:
No hierarchy: OSS organizes data as flat objects within buckets, bypassing hierarchical file and directory structures.
Naming rules:
Traditional file systems: Files with names that differ only by a trailing forward slash cannot exist in the same folder at the same time. For example, a file named "a" and a folder named "a/" cannot coexist in the same folder.
OSS: Objects with names that differ only by a trailing forward slash can exist at the same time. For example, "a" and "a/"" have no logical association and are two independent objects that can coexist.
File system stimulation of ossfs 2.0
When you mount an OSS bucket by using ossfs 2.0, the system stimulates a file system by using the following rules:
Directory tree construction: uses the forward slash (
/) in object names as the path separator to stimulate a directory structure.Detection logic: infers the object type (object or directory) by analyzing the / separator in the object name and the hierarchical relationships between sub-objects.
Object detection logic
When using tools like ossfs 1.0 or ossfs 2.0, or services like Cloud Storage Gateway (CSG), to mount an OSS bucket, adhere to file system naming rules and avoid creating objects with names that differ only by a trailing forward slash (for example, 'a' and 'a/').
Case | Recognition result | Logic description |
The bucket contains only | Object | A name that does contain the |
The bucket contains only | Directory | A name ending with |
The bucket contains | Directory | " |
The bucket contains both | Command ls: Object | Object naming in the bucket does not comply with file system rules. |
Command stat: Directory | ||
The bucket contains both | Command ls: Object | Object naming in the bucket does not comply with file system rules. |
Command stat: Directory |