All Products
Search
Document Center

Object Storage Service:Object and directory recognition of ossfs 2.0

Last Updated:Jun 13, 2025

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

Important

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 a.

Object

A name that does contain the / character is treated as an object.

The bucket contains only a/.

Directory

A name ending with / is identified as a virtual directory.

The bucket contains a/b, but neither a nor a/ exists.

Directory

"a" is treated as a virtual directory based on the object path a/b.

The bucket contains both a and a/.

Command ls: Object

Object naming in the bucket does not comply with file system rules.

Command stat: Directory

The bucket contains both a and a/b, but no a/.

Command ls: Object

Object naming in the bucket does not comply with file system rules.

Command stat: Directory